Skip to content

Instantly share code, notes, and snippets.

@ap
Created February 10, 2009 04:57
Show Gist options
  • Save ap/61242 to your computer and use it in GitHub Desktop.
Save ap/61242 to your computer and use it in GitHub Desktop.
Answers to Tom Duff's stylistic conundrums presented in “Reading Code From Top to Bottom”, http://www.iq0.com/notes/deep.nesting.html
/* answers to Tom Duff's stylistic conundrums presented in
[Reading Code From Top to Bottom]
(http://www.iq0.com/notes/deep.nesting.html)
*/
char *skip(char *s, int c) {
char cc;
for(;;) {
if(!*s) break;
cc = *s++;
if(cc==c) break;
}
return s;
}
/* * * * * * * * * * * * * * * * * */
char *stopword = "/*%";
char *cursor = stopword;
while(*cursor){
c=getc(f);
if(c==EOF) { /* handle error */ }
if(c!=*cursor) cursor=stopword;
if(c==*cursor) ++cursor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment