/[pspp]/pspp/src/lexer.c
ViewVC logotype

Diff of /pspp/src/lexer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by blp, Sat Mar 12 01:08:33 2005 UTC revision 1.15 by jmd, Wed Apr 13 10:09:59 2005 UTC
# Line 48  int token; Line 48  int token;
48  double tokval;  double tokval;
49    
50  /* T_ID: the identifier. */  /* T_ID: the identifier. */
51  char tokid[9];  char tokid[LONG_NAME_LEN + 1];
52    
53  /* T_ID, T_STRING: token string value.  /* T_ID, T_STRING: token string value.
54     For T_ID, this is not truncated to 8 characters as is tokid. */     For T_ID, this is not truncated to SHORT_NAME_LEN characters as is tokid. */
55  struct string tokstr;  struct string tokstr;
56    
57  /* Static variables. */  /* Static variables. */
# Line 116  restore_token (void) Line 116  restore_token (void)
116    assert (put_token != 0);    assert (put_token != 0);
117    token = put_token;    token = put_token;
118    ds_replace (&tokstr, ds_c_str (&put_tokstr));    ds_replace (&tokstr, ds_c_str (&put_tokstr));
119    strncpy (tokid, ds_c_str (&put_tokstr), 8);    strncpy (tokid, ds_c_str (&put_tokstr), SHORT_NAME_LEN);
120    tokid[8] = 0;    tokid[SHORT_NAME_LEN] = 0;
121    tokval = put_tokval;    tokval = put_tokval;
122    put_token = 0;    put_token = 0;
123  }  }
# Line 137  save_token (void) Line 137  save_token (void)
137  void  void
138  lex_get (void)  lex_get (void)
139  {  {
140      int i;
141    
142    /* If a token was pushed ahead, return it. */    /* If a token was pushed ahead, return it. */
143    if (put_token)    if (put_token)
144      {      {
# Line 354  lex_get (void) Line 356  lex_get (void)
356              }              }
357    
358            /* Copy id to tokstr. */            /* Copy id to tokstr. */
359            ds_putc (&tokstr, toupper ((unsigned char) *prog++));            ds_putc (&tokstr, *prog++);
360            while (CHAR_IS_IDN (*prog))            while (CHAR_IS_IDN (*prog))
361              ds_putc (&tokstr, toupper ((unsigned char) *prog++));              ds_putc (&tokstr, *prog++);
362    
363            /* Copy tokstr to tokid, truncating it to 8 characters. */            /* Copy tokstr to tokid, truncating it to LONG_NAME_LEN characters.*/
364            strncpy (tokid, ds_c_str (&tokstr), 8);            strncpy (tokid, ds_c_str (&tokstr), LONG_NAME_LEN);
365            tokid[8] = 0;            tokid[LONG_NAME_LEN] = 0;
366    
367              /* Convert to upper case */
368              for ( i = 0 ; i < ds_length(&tokstr) ; ++i )
369                      tokstr.string[i] = toupper(tokstr.string[i]);
370    
371            token = lex_id_to_token (ds_c_str (&tokstr), ds_length (&tokstr));            token = lex_id_to_token (ds_c_str (&tokstr), ds_length (&tokstr));
372            break;            break;
# Line 714  lex_put_back_id (const char *id) Line 720  lex_put_back_id (const char *id)
720    save_token ();    save_token ();
721    token = T_ID;    token = T_ID;
722    ds_replace (&tokstr, id);    ds_replace (&tokstr, id);
723    strncpy (tokid, ds_c_str (&tokstr), 8);    strncpy (tokid, ds_c_str (&tokstr), SHORT_NAME_LEN);
724    tokid[8] = 0;    tokid[SHORT_NAME_LEN] = 0;
725  }  }
726    
727  /* Weird line processing functions. */  /* Weird line processing functions. */

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26