From: Chris B. <buc...@us...> - 2010-12-23 20:39:56
|
Update of /cvsroot/sblim/sfcb In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv27546 Modified Files: mofpp.c ChangeLog NEWS Log Message: [ 3054618 ] mofpp is overaggressive when detecting comments Index: mofpp.c =================================================================== RCS file: /cvsroot/sblim/sfcb/mofpp.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mofpp.c 29 Nov 2010 20:15:54 -0000 1.8 +++ mofpp.c 23 Dec 2010 20:39:48 -0000 1.9 @@ -68,9 +68,19 @@ return 0; } +char* getLineEnding(char* s) { + char* e = NULL; + if ((e = strstr(s, "\r\n"))) { + e+=2; + } else if ((e = strstr(s, "\n"))) { + e+=1; + } + return e; +} + void processFile(char *fn, FILE *in, FILE *out) { - char *s,*e,rec[10000],*ifn=NULL; + char *s,*e,*es,rec[10000],*ifn=NULL; FILE *incFile; int comment=0; int nl=0; @@ -90,47 +100,57 @@ else { s = rec; - if (comment == 1) { - if ((e=strstr(s,"\r\n"))) { - strcpy(s,e+2); - comment=0; - } else if ((e=strstr(s,"\n"))) { - strcpy(s,e+1); - comment=0; - } - } else if (comment == 2) { - if ((e=strstr(s,"*/"))) { - strcpy(s,e+2); - comment=0; - } - else { - continue; - } + if (comment == 1) { /* check for single-line comment */ + e = getLineEnding(s); + if (e) { + strcpy(s, e); + comment = 0; + } + } else if (comment == 2) { /* check for block comment */ + if ((e = strstr(s, "*/"))) { + strcpy(s, getLineEnding(e)); + comment = 0; + } else { + continue; + } } - while ((s = strstr(s,"/"))) { - if (*(s+1) == '/') { - if ((e = strstr(s+2,"\r\n"))) { - strcpy(s,e+2); - } else if ((e = strstr(s+2,"\n"))) { - strcpy(s,e+1); - } else { - *s = 0; - comment = 1; - break; - } - } else if (*(s+1) == '*') { - if ((e = strstr(s+2,"*/"))) { - strcpy(s,e+2); - } else { - *s = 0; - comment = 2; - break; - } - } else { - s++; - } + /* skip whitespace */ + while ((*s == ' ') || (*s == '\t')) { + s++; } + es = s; + /* is this line a quoted string? */ + if (*s == '"') { + /* find end of the string */ + es++; + while ((s = strstr(es, "\""))) { + es = s+1; /* end of quoted string */ + } + } + + while ((s = strstr(es, "/"))) { + if (*(s + 1) == '/') { + e = getLineEnding(s); + if (e) { + strcpy(s, e); + } else { + *s = 0; + comment = 1; + break; + } + } else if (*(s + 1) == '*') { + if ((e = strstr(s + 2, "*/"))) { + strcpy(s, getLineEnding(e)); + } else { + *s = 0; + comment = 2; + break; + } + } else { + es++; + } + } fprintf(out,"%s",rec); } Index: NEWS =================================================================== RCS file: /cvsroot/sblim/sfcb/NEWS,v retrieving revision 1.567 retrieving revision 1.568 diff -u -d -r1.567 -r1.568 --- NEWS 21 Dec 2010 23:01:49 -0000 1.567 +++ NEWS 23 Dec 2010 20:39:48 -0000 1.568 @@ -4,6 +4,7 @@ Bugs fixed: - 3130727 CMPIPropertyMIFT.setProperty() missing objectpath keys +- 3054618 mofpp is overaggressive when detecting comments Changes in 1.3.10 ================= Index: ChangeLog =================================================================== RCS file: /cvsroot/sblim/sfcb/ChangeLog,v retrieving revision 1.640 retrieving revision 1.641 diff -u -d -r1.640 -r1.641 --- ChangeLog 21 Dec 2010 23:01:49 -0000 1.640 +++ ChangeLog 23 Dec 2010 20:39:48 -0000 1.641 @@ -1,3 +1,8 @@ +2010-12-23 Chris Buccella <buc...@li...> + + * mofpp.c: + [ 3054618 ] mofpp is overaggressive when detecting comments + 2010-12-21 Chris Buccella <buc...@li...> * cimXmlRequest.c: |