head 1.17; access; symbols Version_2_1:1.6 Version_2:1.5 C_Demo_1:1.4; locks; strict; comment @ * @; 1.17 date 92.04.09.17.59.12; author mer; state Exp; branches; next 1.16; 1.16 date 92.04.03.07.31.05; author mer; state Exp; branches; next 1.15; 1.15 date 92.03.16.04.49.24; author mer; state Exp; branches; next 1.14; 1.14 date 91.08.23.16.45.35; author kemnitz; state Exp; branches; next 1.13; 1.13 date 91.08.15.01.35.10; author kemnitz; state Exp; branches; next 1.12; 1.12 date 91.08.14.17.03.49; author kemnitz; state Exp; branches; next 1.11; 1.11 date 91.04.11.01.35.43; author kemnitz; state Exp; branches; next 1.10; 1.10 date 91.04.09.15.04.38; author choi; state Exp; branches; next 1.9; 1.9 date 91.04.04.18.26.50; author kemnitz; state Exp; branches; next 1.8; 1.8 date 91.03.28.13.33.30; author choi; state Exp; branches; next 1.7; 1.7 date 91.03.27.17.20.26; author choi; state Exp; branches; next 1.6; 1.6 date 90.09.25.22.23.26; author goh; state Exp; branches; next 1.5; 1.5 date 90.04.20.07.55.12; author goh; state Version_2; branches; next 1.4; 1.4 date 89.09.05.16.51.51; author mao; state C_Demo_1; branches; next 1.3; 1.3 date 89.03.07.01.20.59; author goh; state Stab; branches; next 1.2; 1.2 date 89.03.02.01.55.09; author goh; state Exp; branches; next 1.1; 1.1 date 89.02.22.16.13.06; author goh; state Exp; branches; next ; desc @@ 1.17 log @bug in scanning array constant, using a variable that was never set. @ text @static char *scanner_c = "$Header: /users/mer/pg/src/parser/RCS/scanner.c,v 1.16 1992/04/03 07:31:05 mer Exp mer $"; #include #define false 0 #define true !false /* * Support routines for the scanner. * Includes: comment, character constant, * and string constant scanning. */ /* * Scan PL/1 style comment. */ scancmnt() { register int c, trail; trail = 0; for (;;) { c = input(); switch (c) { case 0: serror("Unterminated comment."); return; case '/': if (trail == '*') return; } trail = c; } } char delimiter; /* * Scan a character constant into yytext. */ scanchar(buf) char *buf; { delimiter = '\''; scancon(buf, 1); } scanstr(buf, len) char *buf; int len; { delimiter = '\"'; scancon(buf, len); } scanspecial(buf, len) char *buf; int len; { delimiter = '`'; scancon(buf, len); } /* * Scan a string. The leading delimiter (", ') has already been * read. Be sure to gobble up the whole thing, including the * trailing delimiter. */ scancon(buf, len) char *buf; int len; { register char *cp = buf; register int c, dc, cspec; int entering = 1; cspec = 0; while ((c = input()) != delimiter) { if (cp - buf > len - 1) { serror("String/char constant too large"); cp = buf; } switch (c) { default: *cp++ = c; break; case '{': /* * Right curly brace indicates array constant. */ if (entering && delimiter == '\"') { scanarr(buf, len); cp += strlen(buf); cspec = cp - buf - 1; } else *cp++ = c; break; case 0: case '\n': serror("Unterminated char/string constant"); goto out; case '\\': c = input(); if (c == '\n') continue; /* *cp++ = '\\'; When _should_ this be done? XXX */ if (isdigit(c)) { dc = 0; while (dc++ < 3 && isdigit(c)) { *cp++ = c; c = input(); } unput(c); break; } if (c != 0) { switch (c) { case 't': c = '\t'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; default: break; } *cp++ = c; } break; } entering = 0; cspec++; } out: *cp = 0; return(cspec); } /* * Scan input for array_in. The leading delimiter ({) has already been * read. Be sure to gobble up the whole thing, including the * trailing delimiter. */ scanarr(buf, len) char *buf; int len; { register char *cp = buf; register int c, c2, dc, cspec, counter; /* counts matching '{' and '}'. */ /* stop scanning when unmatched '}' */ /* is encounterd. */ int in_string = false; cspec = 0; /* * counter counts {'s, so we can do nested arrays properly. * It starts from 1 (not zero) because the first thing we encountered * was a {. */ counter = 1; *cp++ = '{'; /* array funcs assume that there is a proper nesting */ while (counter != 0) { c = input(); if ( c == '{' && !in_string) counter++; if ( c == '}' && !in_string) counter--; if (cp - buf > len - 1) { serror("String/char constant too large"); cp = buf; } switch (c) { default: *cp++ = c; break; case 0: case '\n': serror("Unterminated array constant"); goto out; case '\\': c = input(); if (c == '\n') continue; /* *cp++ = '\\'; When _should_ this be done? XXX */ if (isdigit(c)) { dc = 0; while (dc++ < 3 && isdigit(c)) { *cp++ = c; c = input(); } unput(c); break; } if (c != 0) { switch (c) { case 't': c = '\t'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; default: *cp++ = '\\'; break; } *cp++ = c; } break; case '\"': in_string = !in_string; *cp++ = c; break; } cspec++; } out: *cp = 0; return(cspec); } @ 1.16 log @copy double quotes along, array input function needs them @ text @d1 1 a1 1 static char *scanner_c = "$Header: /users/mer/pg/src/parser/RCS/scanner.c,v 1.15 1992/03/16 04:49:24 mer Exp mer $"; d197 1 a197 1 while (dc++ < 3 && isdigit(c2)) { @ 1.15 log @fix scan of array constants @ text @d1 1 a1 1 static char *scanner_c = "$Header: /users/mer/pg/src/parser/RCS/scanner.c,v 1.14 1991/08/23 16:45:35 kemnitz Exp mer $"; d218 1 @ 1.14 log @got to compile under gcc (with -traditional set) @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.13 91/08/15 01:35:10 kemnitz Exp Locker: kemnitz $"; a80 14 /* * Right curly brace indicates array constant. */ if (entering && delimiter == '\"') { if (c == '{') { scanarr(buf, len); cp += strlen(buf); } entering = 0; } d85 1 d90 13 a102 1 d135 1 @ 1.13 log @oops - shouldn't change buffer pointer unless we actually call scanarr() @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.12 91/08/14 17:03:49 kemnitz Exp Locker: kemnitz $"; d174 2 a175 2 if ( c == '\{' && !in_string) counter++; if ( c == '\}' && !in_string) counter--; @ 1.12 log @arrays now look like "{ ... }" @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.11 91/04/11 01:35:43 kemnitz Exp Locker: kemnitz $"; d87 5 a91 2 if (c == '{') scanarr(buf, len); cp += strlen(buf); @ 1.11 log @fixes problem with array constants - arrays can have nested {}'s @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.10 91/04/09 15:04:38 choi Exp $"; a63 8 scanarray(buf, len) char *buf; int len; { delimiter = '\}'; scanarr(buf, len); } d76 1 d80 12 @ 1.10 log @now able to scan in nested array input. @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.9 91/04/04 18:26:50 kemnitz Exp Locker: choi $"; d5 3 d151 1 d154 5 a158 1 counter = 0; d160 8 a167 3 while (!(((c = input()) == delimiter) && (counter == 0))) { if ( c == '\{' ) counter++; if ( c == '\}' ) counter--; d179 1 a179 1 serror("Unterminated char/string constant"); d207 3 @ 1.9 log @handles special case of arrays now - array_in has to do some of the parsing so it can handle {"string","bad\"string"} @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.8 91/03/28 13:33:30 choi Exp Locker: kemnitz $"; d144 4 a147 1 register int c, c2, dc, cspec; d150 1 d152 3 a154 1 while ((c = input()) != delimiter) { @ 1.8 log @got rid of a stupid comment @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.7 91/03/27 17:20:26 choi Exp Locker: choi $"; d66 1 a66 1 scancon(buf, len); d74 1 d133 64 @ 1.7 log @added scanarray() @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.6 90/09/25 22:23:26 goh Exp Locker: choi $"; d60 1 a60 1 /* ron */ @ 1.6 log @bug fixes for various things ... uninitialized variables ... automatic variables set but not used ... etc ... that saber picked up on @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.5 90/04/20 07:55:12 goh Version_2 $"; d58 8 @ 1.5 log @added scanspecial (funky testing stuff) @ text @d1 1 a1 1 static char *scanner_c = "$Header: RCS/scanner.c,v 1.4 89/09/05 16:51:51 mao C_Demo_1 $"; d57 1 a57 1 delimiter = '\`'; @ 1.4 log @Working version of C-only demo @ text @d1 1 a1 1 static char *scanner_c = "$Header: /usr6/postgres/mao/postgres/src/parser/RCS/scanner.c,v 1.3 89/03/07 01:20:59 goh Stab $"; d51 7 @ 1.3 log @minor fix to get sequent compilation correct @ text @d1 1 a1 1 static char *scanner_c = "$Header: scanner.c,v 1.2 89/03/02 01:55:09 goh Exp $"; @ 1.2 log @*** empty log message *** @ text @d1 1 a1 1 static char *scanner_c = "$Header: scanner.c,v 1.1 89/02/22 16:13:06 goh Exp $"; d64 1 a64 1 register int c, dc, cc; d66 1 a66 1 cc = 0; d109 1 a109 1 cc++; d114 1 a114 1 return(cc); @ 1.1 log @Initial revision @ text @d1 1 a1 1 static char *scanner_c = "$Header: scanner.c,v 1.1 88/12/31 13:07:27 goh Locked $"; @