summaryrefslogtreecommitdiffstats
path: root/usr.bin/awk/main.c.diff
blob: 252cd5ac24217e10c61be24078047570387c0404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
$FreeBSD$

Index: main.c
===================================================================
RCS file: /home/ncvs/src/contrib/one-true-awk/main.c,v
retrieving revision 1.1.1.10
diff -u -p -r1.1.1.10 main.c
--- main.c	16 May 2005 19:11:31 -0000	1.1.1.10
+++ main.c	15 Sep 2006 13:21:30 -0000
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE
 THIS SOFTWARE.
 ****************************************************************/
 
-const char	*version = "version 20070501";
+const char	*version = "version 20070501 (FreeBSD)";
 
 #define DEBUG
 #include <stdio.h>
@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
 	const char *fs = NULL;
 
 	setlocale(LC_CTYPE, "");
+	setlocale(LC_COLLATE, "");
 	setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
 	cmdname = argv[0];
 	if (argc == 1) {
@@ -79,13 +80,18 @@ int main(int argc, char *argv[])
 				safe = 1;
 			break;
 		case 'f':	/* next argument is program filename */
-			argc--;
-			argv++;
-			if (argc <= 1)
-				FATAL("no program filename");
-			if (npfile >= MAX_PFILE - 1)
-				FATAL("too many -f options"); 
-			pfile[npfile++] = argv[1];
+			if (argv[1][2] != 0) {	/* arg is -fsomething */
+				if (npfile >= MAX_PFILE - 1)
+					FATAL("too many -f options"); 
+				pfile[npfile++] = &argv[1][2];
+			} else {		/* arg is -f something */
+				argc--; argv++;
+				if (argc <= 1)
+					FATAL("no program filename");
+				if (npfile >= MAX_PFILE - 1)
+					FATAL("too many -f options"); 
+				pfile[npfile++] = argv[1];
+			}
 			break;
 		case 'F':	/* set field separator */
 			if (argv[1][2] != 0) {	/* arg is -Fsomething */
@@ -104,8 +110,14 @@ int main(int argc, char *argv[])
 				WARNING("field separator FS is empty");
 			break;
 		case 'v':	/* -v a=1 to be done NOW.  one -v for each */
-			if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
-				setclvar(argv[1]);
+			if (argv[1][2] != 0) {	/* arg is -vsomething */
+				if (argv[1][2] != 0)
+					setclvar(&argv[1][2]);
+			} else {		/* arg is -v something */
+				argc--; argv++;
+				if (argc > 1 && isclvar(argv[1]))
+					setclvar(argv[1]);
+			}
 			break;
 		case 'm':	/* more memory: -mr=record, -mf=fields */
 				/* no longer supported */
OpenPOWER on IntegriCloud