\subsection{Code to recognize [[noweb]] markup on input} We recognize the input using matching functions, which can find [[@begin]], [[@end]], and other useful information. <
>= extern int is_keyword(char *line, char *keyword); extern int is_begin(char *line, char *type); extern int is_end(char *line, char *type); extern int is_index(char *line, char *type); <<*>>= static char rcsid[] = "$Id: match.nw,v 1.21 2008/10/06 01:03:05 nr Exp nr $"; static char rcsname[] = "$Name: v2_12 $"; #include #include "match.h" static int matches(char *line, char *search) { (void)rcsid; /* avoid a warning */ (void)rcsname; /* avoid a warning */ return !strncmp(line,search,strlen(search)); } @ On 24 March 1996, I changed this to accept zero as a terminator because I strip newlines in the prettyprinter. Too bad if we just got worse at detecting bogus filters. <<*>>= int is_keyword(char *line, char *keyword) { char low_at_sign = '@'; return *line==low_at_sign && matches(line+1,keyword) && (line[strlen(keyword)+1]==' ' || line[strlen(keyword)+1]=='\n' || line[strlen(keyword)+1]=='\0'); } int is_begin(char *line, char *type) { return is_keyword(line,"begin") && matches(line+1+6,type); } int is_end(char *line, char *type) { return is_keyword(line,"end") && matches (line+1+4,type); } int is_index(char *line, char *type) { return is_keyword(line,"index") && matches(line+1+6,type); }