7 only check when we are not in a quoted area
8 check current char for * or / if prev char is a / than we are in a comment
17 void advbuf(char buf
[], char mrk
[])
25 /* if buffer has comment string, continue comment by default */
26 /* similar to carrying in math :) */
31 char buf
[2], mrk
[2] = { '\0' };
33 /* mrk c = comment q = quote p = program */
35 char strtyp
= '\0'; /* store string type */
42 buf
[1] = getchar(); // load new char at start of buffer
43 if(buf
[1] == EOF
) { return 0; } /* exit when we get to end of input */
48 if(buf
[1] == '\'' || buf
[1] == '"') /* found one of the quotes */
54 /* if quote is in effect, keep quoting until we find corresponding quote */
55 if(strtyp
== '\'' || strtyp
== '"')
67 if(mrk
[1] == 'p' || mrk
[1] == 'c')
70 /* look for start of comment */
71 if(buf
[1] == '*' || buf
[1] == '/')
81 /* look for end of comment */
85 if(buf
[0] == '*' || buf
[0] == '/')
95 //printf("%c%c", buf[0], buf[1]);
96 //printf("->%c%c\n", mrk[0], mrk[1]);
98 /* based on current state print output */
99 if(mrk
[0] == 'p' || mrk
[0] == 'q') { putchar(buf
[0]); }
102 printf("This is a comment in a quote /* comment here */ just ignore it.\n");