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:
Y_Less 2018-06-30 17:00:46 +02:00
parent 62805cb400
commit 23485cfeda

View File

@ -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;
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 */ 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 */