main.c (201989) | main.c (221381) |
---|---|
1/**************************************************************** 2Copyright (C) Lucent Technologies 1997 3All Rights Reserved 4 5Permission to use, copy, modify, and distribute this software and 6its documentation for any purpose and without fee is hereby 7granted, provided that the above copyright notice appear in all 8copies and that both that the copyright notice and this --- 9 unchanged lines hidden (view full) --- 18SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 22THIS SOFTWARE. 23****************************************************************/ 24 25#include <sys/cdefs.h> | 1/**************************************************************** 2Copyright (C) Lucent Technologies 1997 3All Rights Reserved 4 5Permission to use, copy, modify, and distribute this software and 6its documentation for any purpose and without fee is hereby 7granted, provided that the above copyright notice appear in all 8copies and that both that the copyright notice and this --- 9 unchanged lines hidden (view full) --- 18SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 20IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 21ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 22THIS SOFTWARE. 23****************************************************************/ 24 25#include <sys/cdefs.h> |
26__FBSDID("$FreeBSD: head/contrib/one-true-awk/main.c 201989 2010-01-10 08:02:07Z ru $"); | 26__FBSDID("$FreeBSD: head/contrib/one-true-awk/main.c 221381 2011-05-03 11:47:19Z ru $"); |
27 | 27 |
28const char *version = "version 20091126 (FreeBSD)"; | 28const char *version = "version 20110501 (FreeBSD)"; |
29 30#define DEBUG 31#include <stdio.h> 32#include <ctype.h> 33#include <locale.h> 34#include <stdlib.h> 35#include <string.h> 36#include <signal.h> 37#include "awk.h" 38#include "ytab.h" 39 40extern char **environ; 41extern int nfields; 42 43int dbg = 0; | 29 30#define DEBUG 31#include <stdio.h> 32#include <ctype.h> 33#include <locale.h> 34#include <stdlib.h> 35#include <string.h> 36#include <signal.h> 37#include "awk.h" 38#include "ytab.h" 39 40extern char **environ; 41extern int nfields; 42 43int dbg = 0; |
44Awkfloat srand_seed = 1; |
|
44char *cmdname; /* gets argv[0] for error messages */ 45extern FILE *yyin; /* lex input file */ 46char *lexprog; /* points to program argument if it exists */ 47extern int errorflag; /* non-zero if any syntax errors; set by yyerror */ 48int compile_time = 2; /* for error printing: */ 49 /* 2 = cmdline, 1 = compile, 0 = running */ 50 51#define MAX_PFILE 20 /* max number of -f's */ --- 14 unchanged lines hidden (view full) --- 66 cmdname = argv[0]; 67 if (argc == 1) { 68 fprintf(stderr, 69 "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", 70 cmdname); 71 exit(1); 72 } 73 signal(SIGFPE, fpecatch); | 45char *cmdname; /* gets argv[0] for error messages */ 46extern FILE *yyin; /* lex input file */ 47char *lexprog; /* points to program argument if it exists */ 48extern int errorflag; /* non-zero if any syntax errors; set by yyerror */ 49int compile_time = 2; /* for error printing: */ 50 /* 2 = cmdline, 1 = compile, 0 = running */ 51 52#define MAX_PFILE 20 /* max number of -f's */ --- 14 unchanged lines hidden (view full) --- 67 cmdname = argv[0]; 68 if (argc == 1) { 69 fprintf(stderr, 70 "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", 71 cmdname); 72 exit(1); 73 } 74 signal(SIGFPE, fpecatch); |
75 76 srand_seed = 1; 77 srand(srand_seed); 78 |
|
74 yyin = NULL; 75 symtab = makesymtab(NSYMTAB/NSYMTAB); 76 while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { 77 if (strcmp(argv[1],"-version") == 0 || strcmp(argv[1],"--version") == 0) { 78 printf("awk %s\n", version); 79 exit(0); 80 break; 81 } --- 33 unchanged lines hidden (view full) --- 115 fs = "\t"; 116 else if (argc > 1 && argv[1][0] != 0) 117 fs = &argv[1][0]; 118 } 119 if (fs == NULL || *fs == '\0') 120 WARNING("field separator FS is empty"); 121 break; 122 case 'v': /* -v a=1 to be done NOW. one -v for each */ | 79 yyin = NULL; 80 symtab = makesymtab(NSYMTAB/NSYMTAB); 81 while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { 82 if (strcmp(argv[1],"-version") == 0 || strcmp(argv[1],"--version") == 0) { 83 printf("awk %s\n", version); 84 exit(0); 85 break; 86 } --- 33 unchanged lines hidden (view full) --- 120 fs = "\t"; 121 else if (argc > 1 && argv[1][0] != 0) 122 fs = &argv[1][0]; 123 } 124 if (fs == NULL || *fs == '\0') 125 WARNING("field separator FS is empty"); 126 break; 127 case 'v': /* -v a=1 to be done NOW. one -v for each */ |
123 if (argv[1][2] != 0) { /* arg is -vsomething */ 124 if (argv[1][2] != 0) 125 setclvar(&argv[1][2]); 126 } else { /* arg is -v something */ 127 argc--; argv++; 128 if (argc > 1 && isclvar(argv[1])) 129 setclvar(argv[1]); 130 } | 128 if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1])) 129 setclvar(argv[1]); 130 else if (argv[1][2] != '\0') 131 setclvar(&argv[1][2]); |
131 break; 132 case 'd': 133 dbg = atoi(&argv[1][2]); 134 if (dbg == 0) 135 dbg = 1; 136 printf("awk %s\n", version); 137 break; 138 default: --- 69 unchanged lines hidden --- | 132 break; 133 case 'd': 134 dbg = atoi(&argv[1][2]); 135 if (dbg == 0) 136 dbg = 1; 137 printf("awk %s\n", version); 138 break; 139 default: --- 69 unchanged lines hidden --- |