|
|
1.1 ! root 1: # include <ingres.h> ! 2: # include "scanner.h" ! 3: # include <sccs.h> ! 4: # include <errors.h> ! 5: ! 6: SCCSID(@(#)s_string.c 8.2 2/8/85) ! 7: ! 8: /* ! 9: ** STRING ! 10: ** A string is defined as any sequence of MAXSTRING or fewer characters, ! 11: ** surrounded by string delimiters. New-line ;characters are purged ! 12: ** from strings unless preceeded by a '\'; QUOTE's must be similarly ! 13: ** prefixed in order to be correctly inserted within a string. Each ! 14: ** string is entered in the symbol table, indexed by 'yylval'. A ! 15: ** token or the error condition -1 is returned. ! 16: */ ! 17: string(op) ! 18: struct optab *op; ! 19: { ! 20: extern char Cmap[]; ! 21: extern char *yylval; ! 22: extern char *syment(); ! 23: register int esc; ! 24: register int save; ! 25: register char *ptr; ! 26: char buf[MAXSTRING + 1]; ! 27: ! 28: /* disable case conversion and fill in string */ ! 29: ptr = buf; ! 30: save = Lcase; ! 31: Lcase = 0; ! 32: do ! 33: { ! 34: /* get next character */ ! 35: if ((*ptr = get_scan(NORMAL)) <= 0) ! 36: { ! 37: Lcase = save; ! 38: /* non term string */ ! 39: par_error(STRTERM, FATAL, 0); ! 40: } ! 41: ! 42: /* handle escape characters */ ! 43: esc = (*ptr == '\\'); ! 44: if (*ptr == '\n') ! 45: { ! 46: if ((*ptr = get_scan(NORMAL)) <= 0) ! 47: { ! 48: Lcase = save; ! 49: *ptr = 0; ! 50: /* non term string */ ! 51: par_error(STRTERM, FATAL, 0); ! 52: } ! 53: } ! 54: if (esc == 1) ! 55: { ! 56: if ((*++ptr = get_scan(NORMAL)) <= 0) ! 57: { ! 58: Lcase = save; ! 59: *ptr = 0; ! 60: /* non term string */ ! 61: par_error(STRTERM, FATAL, 0); ! 62: } ! 63: if (*ptr == *(op->term)) ! 64: *--ptr = *(op->term); ! 65: } ! 66: ! 67: /* check length */ ! 68: if ((ptr - buf) > MAXSTRING - 1) ! 69: { ! 70: Lcase = save; ! 71: /* string too long */ ! 72: par_error(STRLONG, WARN, 0); ! 73: } ! 74: if (Cmap[*ptr] == CNTRL) ! 75: /* cntrl in string from equel */ ! 76: par_error(CNTRLCHR, WARN, 0); ! 77: } while (*ptr++ != *(op->term) || esc == 1); ! 78: ! 79: /* restore case conversion and return */ ! 80: *--ptr = '\0'; ! 81: Lcase = save; ! 82: # ifdef xSTR2 ! 83: tTfp(71, 8, "STRING: %s\n", buf); ! 84: # endif ! 85: yylval = syment(buf, (ptr - buf) + 1); ! 86: Lastok.tok = yylval; ! 87: Lastok.toktyp = Tokens.sconst; ! 88: return (Tokens.sconst); ! 89: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.