- int ch;
- char *str = strLitBuff ;
-
- *str++ = '\"' ;
- /* put into the buffer till we hit the */
- /* first \" */
- while (1) {
-
- ch = input() ;
- if (!ch) break ; /* end of input */
- /* if it is a \ then everything allowed */
- if (ch == '\\') {
- *str++ = ch ; /* backslash in place */
- *str++ = input() ; /* following char in place */
- continue ; /* carry on */
- }
-
- /* if new line we have a new line break */
- if (ch == '\n') break ;
-
- /* if this is a quote then we have work to do */
- /* find the next non whitespace character */
- /* if that is a double quote then carry on */
- if (ch == '\"') {
-
- while ((ch = input()) && isspace(ch)) ;
- if (!ch) break ;
- if (ch != '\"') {
- unput(ch) ;
- break ;
- }
-
- continue ;
+#define STR_BUF_CHUNCK_LEN 1024
+ int ch;
+ static struct dbuf_s dbuf;
+ char buf[2];
+
+ if (dbuf.alloc == 0)
+ dbuf_init(&dbuf, STR_BUF_CHUNCK_LEN);
+ else
+ dbuf_set_size(&dbuf, 0);
+
+
+ dbuf_append(&dbuf, "\"", 1);
+ /* put into the buffer till we hit the first \" */
+
+ while ((ch = input()) != 0) {
+ switch (ch) {
+ case '\\':
+ /* if it is a \ then escape char's are allowed */
+ ch = input();
+ if (ch == '\n') {
+ /* \<newline> is a continuator */
+ lineno = ++yylineno;
+ column = 0;
+ }
+ else {
+ buf[0] = '\\';
+ buf[1] = ch;
+ dbuf_append(&dbuf, buf, 2); /* get the escape char, no further check */
+ }
+ break; /* carry on */
+
+ case '\n':
+ /* if new line we have a new line break, which is illegal */
+ werror(W_NEWLINE_IN_STRING);
+ dbuf_append(&dbuf, "\n", 1);
+ lineno = ++yylineno;
+ column = 0;
+ break;
+
+ case '"':
+ /* if this is a quote then we have work to do */
+ /* find the next non whitespace character */
+ /* if that is a double quote then carry on */
+ dbuf_append(&dbuf, "\"", 1); /* Pass end of this string or substring to evaluator */
+ while ((ch = input()) && (isspace(ch) || ch=='\\')) {
+ switch (ch) {
+ case '\\':
+ if ((ch = input()) != '\n') {
+ werror(W_STRAY_BACKSLASH, column);
+ unput(ch);
+ }
+ else {
+ lineno = ++yylineno;
+ column = 0;
+ }
+ break;
+
+ case '\n':
+ yylineno++;
+ break;