summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorGary Mills <gary_mills@fastmail.fm>2014-01-03 08:12:29 -0600
committerRichard Lowe <richlowe@richlowe.net>2014-01-05 16:00:17 -0500
commit7ab03f887ff62508a7f59fd9c235aaeb3e17866a (patch)
tree422ff6a5086d9a302659f961ada81e57ac45485e /usr/src/cmd
parent4cf73299b119968f5f0090a5f98b799fad68dfc5 (diff)
downloadillumos-joyent-7ab03f887ff62508a7f59fd9c235aaeb3e17866a.tar.gz
2926 lex ignores -Y
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com> Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/sgs/lex/common/main.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/usr/src/cmd/sgs/lex/common/main.c b/usr/src/cmd/sgs/lex/common/main.c
index 975827996a..17ba4808a4 100644
--- a/usr/src/cmd/sgs/lex/common/main.c
+++ b/usr/src/cmd/sgs/lex/common/main.c
@@ -19,6 +19,8 @@
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2014 Gary Mills
+ *
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,8 +30,6 @@
/* Copyright 1976, Bell Telephone Laboratories, Inc. */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <string.h>
#include "once.h"
#include "sgs.h"
@@ -51,7 +51,8 @@ main(int argc, char **argv)
{
int i;
int c;
- char *path = NULL;
+ char *apath = NULL;
+ char *ypath;
Boolean eoption = 0, woption = 0;
sargv = argv;
@@ -83,9 +84,13 @@ main(int argc, char **argv)
"lex: -Q should be followed by [y/n]");
break;
case 'Y':
- path = (char *)malloc(strlen(optarg) +
+ apath = (char *)malloc(strlen(optarg) +
sizeof ("/nceucform") + 1);
- path = strcpy(path, optarg);
+ if (apath == NULL)
+ error("No available memory "
+ "for directory name.");
+ else
+ apath = strcpy(apath, optarg);
break;
case 'c':
ratfor = FALSE;
@@ -113,7 +118,8 @@ main(int argc, char **argv)
break;
default:
(void) fprintf(stderr,
- "Usage: lex [-ewctvnVY] [-Q(y/n)] [file]\n");
+ "Usage: lex [-ewctvnV] [-Y directory] "
+ "[-Q(y/n)] [file]\n");
exit(1);
}
}
@@ -221,18 +227,21 @@ main(int argc, char **argv)
if (handleeuc) {
if (ratfor)
error("Ratfor is not supported by -w or -e option.");
- path = EUCNAME;
+ ypath = EUCNAME;
}
else
- path = ratfor ? RATNAME : CNAME;
+ ypath = ratfor ? RATNAME : CNAME;
- fother = fopen(path, "r");
+ if (apath != NULL)
+ ypath = strcat(apath, strrchr(ypath, '/'));
+ fother = fopen(ypath, "r");
if (fother == NULL)
- error("Lex driver missing, file %s", path);
+ error("Lex driver missing, file %s", ypath);
while ((i = getc(fother)) != EOF)
(void) putc((char)i, fout);
(void) fclose(fother);
(void) fclose(fout);
+ free(apath);
if (report == 1)
statistics();
(void) fclose(stdout);