[BACK]Return to parse.y CVS log [TXT][DIR] Up to [local] / blind

Diff for /blind/parse.y between version 1.16 and 1.17

version 1.16, 2022/04/10 20:03:38 version 1.17, 2022/04/10 21:04:06
Line 25 
Line 25 
 #include "config.h"  #include "config.h"
 #include "log.h"  #include "log.h"
   
 static struct file {  #define START_EXPAND    1
         FILE                    *stream;  #define DONE_EXPAND     2
         char                    *name;  
         size_t                   ungetpos;  
         size_t                   ungetsize;  
         u_char                  *ungetbuf;  
         int                      eof_reached;  
         int                      lineno;  
 } *f;  
   
   static struct file *f;
   
 int             lookup(char *);  int             lookup(char *);
 int             igetc(void);  int             igetc(void);
 int             lgetc(int);  int             lgetc(int);
Line 50  int  yyerror(const char *, ...)
Line 45  int  yyerror(const char *, ...)
 int             config_load(struct blind *);  int             config_load(struct blind *);
 struct file    *config_push(const char *);  struct file    *config_push(const char *);
 int             config_close(void);  int             config_close(void);
 #define START_EXPAND    1  
 #define DONE_EXPAND     2  
 static int      expanding;  static int      expanding;
   static int      errors = 0;
   struct blind   *env = NULL;
   
 TAILQ_HEAD(symhead, sym)         symhead = TAILQ_HEAD_INITIALIZER(symhead);  TAILQ_HEAD(symhead, sym)         symhead = TAILQ_HEAD_INITIALIZER(symhead);
 struct sym {  struct sym {
Line 62  struct sym {
Line 58  struct sym {
         char                    *nam;          char                    *nam;
         char                    *val;          char                    *val;
 };  };
   
 char           *symget(const char *);  char           *symget(const char *);
   
 struct blind   *env = NULL;  
 static int      errors = 0;  
   
 typedef struct {  typedef struct {
         union {          union {
                 int64_t  number;                  int64_t  number;
Line 171  igetc(void)
Line 165  igetc(void)
         int     c;          int     c;
   
         while (1) {          while (1) {
                 if (f->ungetpos > 0)                  if (f->unpos > 0)
                         c = f->ungetbuf[--f->ungetpos];                          c = f->unbuf[--f->unpos];
                 else                  else
                         c = getc(f->stream);                          c = getc(f->stream);
   
Line 218  lgetc(int quotec)
Line 212  lgetc(int quotec)
                  * count right if last line in included file is syntactically                   * count right if last line in included file is syntactically
                  * invalid and has no newline.                   * invalid and has no newline.
                  */                   */
                 if (f->eof_reached == 0) {                  if (f->eof == 0) {
                         f->eof_reached = 1;                          f->eof = 1;
                         return ('\n');                          return ('\n');
                 }                  }
                 while (c == EOF) {                  while (c == EOF) {
Line 237  lungetc(int c)
Line 231  lungetc(int c)
         if (c == EOF)          if (c == EOF)
                 return;                  return;
   
         if (f->ungetpos >= f->ungetsize) {          if (f->unpos >= f->unsize) {
                 void *p = reallocarray(f->ungetbuf, f->ungetsize, 2);                  void *p = reallocarray(f->unbuf, f->unsize, 2);
                 if (p == NULL)                  if (p == NULL)
                         log_fatal("cannot reallocate memory");                          log_fatal("cannot reallocate memory");
                 f->ungetbuf = p;                  f->unbuf = p;
                 f->ungetsize *= 2;                  f->unsize *= 2;
         }          }
         f->ungetbuf[f->ungetpos++] = c;          f->unbuf[f->unpos++] = c;
 }  }
   
 int  int
Line 455  config_load(struct blind *temp)
Line 449  config_load(struct blind *temp)
                 return (-1);                  return (-1);
         }          }
         f->lineno = 1;          f->lineno = 1;
         f->ungetsize = 16;          f->unsize = 16;
         f->ungetbuf = malloc(f->ungetsize);          if ((f->unbuf = malloc(f->unsize)) == NULL) {
         if (f->ungetbuf == NULL) {  
                 log_debug("cannot allocate buffer");                  log_debug("cannot allocate buffer");
                 fclose(f->stream);                  fclose(f->stream);
                 free(f->name);                  free(f->name);
Line 479  config_close(void)
Line 472  config_close(void)
 {  {
         fclose(f->stream);          fclose(f->stream);
         free(f->name);          free(f->name);
         free(f->ungetbuf);          free(f->unbuf);
         free(f);          free(f);
   
         return (EOF);          return (EOF);

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

https://cvs.kroczynski.net