It throws a warning now and insert a \n
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@937
4a8a32a2-be11-0410-ad9d-
d568d2c75423
- while ((c = input()) != '*' && c)
- if ( c == '\n')
- yylineno++ ;
+ while ((c = input()) != '*' && c) {
+ if ( c == '\n') {
+ lineno=++yylineno;
+ }
+ }
if (c && (c1 = input()) != '/') {
unput(c1);
if (c && (c1 = input()) != '/') {
unput(c1);
- int i;
- for (i = 0; yytext[i] != '\0'; i++) {
- if (yytext[i] == '\n') {
- column = 0;
- lineno = ++yylineno ;
- }
- else
- if (yytext[i] == '\t')
- column += 8 - (column % 8);
- else
- column++;
- }
-
- /* ECHO; */
+ int i;
+ for (i = 0; yytext[i] != '\0'; i++) {
+ if (yytext[i] == '\n') {
+ column = 0;
+ lineno = ++yylineno ;
+ }
+ else
+ if (yytext[i] == '\t')
+ column += 8 - (column % 8);
+ else
+ column++;
+ }
+ /* ECHO; */
+char strLitBuff[2048]; // TODO: this is asking for the next bug :)
/*
* Change by JTV 2001-05-19 to not concantenate strings
/*
* Change by JTV 2001-05-19 to not concantenate strings
/* if it is a \ then escape char's are allowed */
if (ch == '\\') {
/* if it is a \ then escape char's are allowed */
if (ch == '\\') {
- *str++ = ch; /* backslash in place */
- *str++=input(); /* get the escape char, no check */
+ ch=input();
+ if (ch=='\r') {
+ // input() translates \n into \r\n
+ if ((ch=input())!='\n') {
+ unput (ch);
+ }
+ /* \<newline> is a continuator */
+ lineno=++yylineno;
+ continue;
+ }
+ *str++ = '\\'; /* backslash in place */
+ *str++ = ch; /* get the escape char, no further check */
continue; /* carry on */
}
continue; /* carry on */
}
- /* if new line we have a new line break */
- if (ch == '\n') {
- yylineno++;
+ /* if new line we have a new line break, which is illegal */
+ if (ch == '\r') {
+ // input() translates \n into \r\n
+ if ((ch=input())!='\n') {
+ unput (ch);
+ }
+ werror (W_NEWLINE_IN_STRING);
+ *str++ = '\n';
+ lineno=++yylineno;
/* if that is a double quote then carry on */
if (ch == '\"') {
*str++ = ch ; /* Pass end of this string or substring to evaluator */
/* if that is a double quote then carry on */
if (ch == '\"') {
*str++ = ch ; /* Pass end of this string or substring to evaluator */
while ((ch = input()) && (isspace(ch) || ch=='\\')) {
switch (ch) {
case '\\':
while ((ch = input()) && (isspace(ch) || ch=='\\')) {
switch (ch) {
case '\\':
- werror (W_STRAY_BACKSLASH, filename, yylineno);
+ //werror (W_STRAY_BACKSLASH)
break;
case '\n':
yylineno++;
break;
case '\n':
yylineno++;
"Option %s requires an argument." },
{ W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING,
"stray '\\' in program" },
"Option %s requires an argument." },
{ W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING,
"stray '\\' in program" },
+{ W_NEWLINE_IN_STRING, ERROR_LEVEL_WARNING,
+ "newline in string constant" },
#define W_EXESS_ARRAY_INITIALIZERS 147 /* too much initializers for array */
#define E_ARGUMENT_MISSING 148 /* Option requires an argument. */
#define W_STRAY_BACKSLASH 149
#define W_EXESS_ARRAY_INITIALIZERS 147 /* too much initializers for array */
#define E_ARGUMENT_MISSING 148 /* Option requires an argument. */
#define W_STRAY_BACKSLASH 149
+#define W_NEWLINE_IN_STRING 150
/** Describes the maximum error level that will be logged. Any level
* includes all of the levels listed after it.
/** Describes the maximum error level that will be logged. Any level
* includes all of the levels listed after it.