[BACK]Return to bc.y CVS log [TXT][DIR] Up to [local] / src / usr.bin / bc

Diff for /src/usr.bin/bc/bc.y between version 1.23 and 1.24

version 1.23, 2004/02/18 07:43:58 version 1.24, 2004/10/19 07:36:51
Line 62 
Line 62 
 int                     yyparse(void);  int                     yyparse(void);
 int                     yywrap(void);  int                     yywrap(void);
   
   int                     fileindex;
   int                     sargc;
   char                    **sargv;
   char                    *filename;
   char                    *cmdexpr;
   
 static void             grow(void);  static void             grow(void);
 static ssize_t          cs(const char *);  static ssize_t          cs(const char *);
 static ssize_t          as(const char *);  static ssize_t          as(const char *);
Line 94 
Line 100 
 static ssize_t          epilogue;  static ssize_t          epilogue;
 static bool             st_has_continue;  static bool             st_has_continue;
 static char             str_table[UCHAR_MAX][2];  static char             str_table[UCHAR_MAX][2];
 static int              fileindex;  
 static int              sargc;  
 static char             **sargv;  
 static char             *filename;  
 static bool             do_fork = true;  static bool             do_fork = true;
 static u_short          var_count;  static u_short          var_count;
   
Line 921 
Line 923 
         epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE);          epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE);
 }  }
   
 int  
 yywrap(void)  
 {  
         if (fileindex < sargc) {  
                 filename = sargv[fileindex++];  
                 yyin = fopen(filename, "r");  
                 lineno = 1;  
                 if (yyin == NULL)  
                         err(1, "cannot open %s", filename);  
                 return 0;  
         } else if (fileindex == sargc) {  
                 fileindex++;  
                 yyin = stdin;  
                 lineno = 1;  
                 filename = "stdin";  
                 return 0;  
         }  
         return 1;  
 }  
   
 void  void
 yyerror(char *s)  yyerror(char *s)
 {  {
Line 994 
Line 976 
 static __dead void  static __dead void
 usage(void)  usage(void)
 {  {
         fprintf(stderr, "%s: usage: [-cl] [file ...]\n", __progname);          fprintf(stderr, "%s: usage: [-cl] [-e expression] [file ...]\n",
               __progname);
         exit(1);          exit(1);
 }  }
   
Line 1058 
Line 1041 
 {  {
         int     i, ch, ret;          int     i, ch, ret;
         int     p[2];          int     p[2];
           char    *q;
   
         init();          init();
         setlinebuf(stdout);          setlinebuf(stdout);
Line 1066 
Line 1050 
         if (sargv == NULL)          if (sargv == NULL)
                 err(1, NULL);                  err(1, NULL);
   
         /* The d debug option is 4.4 BSD dc(1) compatible */          if ((cmdexpr = strdup("")) == NULL)
         while ((ch = getopt(argc, argv, "cdl")) != -1) {                  err(1, NULL);
           /* The d debug option is 4.4 BSD bc(1) compatible */
           while ((ch = getopt(argc, argv, "cde:l")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case 'c':                  case 'c':
                 case 'd':                  case 'd':
                         do_fork = false;                          do_fork = false;
                           break;
                   case 'e':
                           q = cmdexpr;
                           if (asprintf(&cmdexpr, "%s%s\n", cmdexpr, optarg) == -1)
                                   err(1, NULL);
                           free(q);
                         break;                          break;
                 case 'l':                  case 'l':
                         sargv[sargc++] = _PATH_LIBB;                          sargv[sargc++] = _PATH_LIBB;

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24