# 2.11BSD#431 - /usr/ingres/source/scanner/string.c

##### Functions

    string            X

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

#### Defined functions

string defined in line 13; used 1 times

- in /usr/ingres/source/scanner/operator.c line 67

Last modified: 1995-02-18 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 944 |