Allow line continuations in single-line comments only when they are followed by another comment:
It is quite annoying to get an error for commenting out a define using: // // #define LONG_MACRO\ // did span \ // multiple lines //
This commit is contained in:
parent
62805cb400
commit
23485cfeda
@ -448,6 +448,7 @@ static void readline(unsigned char *line)
|
|||||||
static void stripcomment(unsigned char *line)
|
static void stripcomment(unsigned char *line)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
char* continuation;
|
||||||
#if !defined SC_LIGHT
|
#if !defined SC_LIGHT
|
||||||
#define COMMENT_LIMIT 100
|
#define COMMENT_LIMIT 100
|
||||||
#define COMMENT_MARGIN 40 /* length of the longest word */
|
#define COMMENT_MARGIN 40 /* length of the longest word */
|
||||||
@ -519,8 +520,24 @@ static void stripcomment(unsigned char *line)
|
|||||||
if (icomment==2)
|
if (icomment==2)
|
||||||
*line++=' ';
|
*line++=' ';
|
||||||
} else if (*line=='/' && *(line+1)=='/'){ /* comment to end of line */
|
} else if (*line=='/' && *(line+1)=='/'){ /* comment to end of line */
|
||||||
if (strchr((char*)line,'\a')!=NULL)
|
continuation=line;
|
||||||
error(49); /* invalid line continuation */
|
while ((continuation=strchr(continuation,'\a'))!=NULL){
|
||||||
|
/* don't give the error if the next line is also commented out.
|
||||||
|
it is quite annoying to get an error for commenting out a define using:
|
||||||
|
|
||||||
|
//
|
||||||
|
// #define LONG_MACRO\
|
||||||
|
// did span \
|
||||||
|
// multiple lines
|
||||||
|
//
|
||||||
|
*/
|
||||||
|
while (*continuation<=' ' && *continuation!='\0')
|
||||||
|
continuation++; /* skip whitespace */
|
||||||
|
if (*continuation!='/' || *(continuation+1)!='/') {
|
||||||
|
error(49); /* invalid line continuation */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#if !defined SC_LIGHT
|
#if !defined SC_LIGHT
|
||||||
if (*(line+2)=='/' && *(line+3)<=' ') {
|
if (*(line+2)=='/' && *(line+3)<=' ') {
|
||||||
/* documentation comment */
|
/* documentation comment */
|
||||||
@ -2062,7 +2079,7 @@ static const unsigned char *packedstring(const unsigned char *lptr,int *flags)
|
|||||||
|
|
||||||
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' ||
|
if (*lptr==',' || *lptr==')' || *lptr=='}' || *lptr==';' ||
|
||||||
*lptr==':' || *lptr=='\n' || *lptr=='\r')
|
*lptr==':' || *lptr=='\n' || *lptr=='\r')
|
||||||
lptr=stringize; /* backtrack to end of last string for closing " */
|
lptr=stringize; /* backtrack to end of last string for closing " */
|
||||||
return lptr;
|
return lptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user