summaryrefslogtreecommitdiff
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
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>
-rw-r--r--usr/src/cmd/sgs/lex/common/main.c29
-rw-r--r--usr/src/man/man1/lex.115
2 files changed, 32 insertions, 12 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);
diff --git a/usr/src/man/man1/lex.1 b/usr/src/man/man1/lex.1
index f12f22a3f8..b5caa7d5fb 100644
--- a/usr/src/man/man1/lex.1
+++ b/usr/src/man/man1/lex.1
@@ -1,4 +1,5 @@
'\" te
+.\" Copyright (c) 2014 Gary Mills
.\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
@@ -7,13 +8,13 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH LEX 1 "Aug 22, 1997"
+.TH LEX 1 "Jan 1, 2014"
.SH NAME
lex \- generate programs for lexical tasks
.SH SYNOPSIS
.LP
.nf
-\fBlex\fR [\fB-cntv\fR] [\fB-e\fR | \fB-w\fR] [\fB-V\fR \fB-Q\fR [y | n]] [\fIfile\fR]...
+\fBlex\fR [\fB-cntv\fR] [\fB-e\fR | \fB-w\fR] [\fB-V\fR \fB-Q\fR [y | n]] [\fB-Y\fR \fIdirectory\fR]] [\fIfile\fR]...
.fi
.SH DESCRIPTION
@@ -112,6 +113,16 @@ Prints out version information to output file \fBlex.yy.c\fR by using
the default.
.RE
+.sp
+.ne 2
+.na
+\fB\fB\fR\fB-Y\fR \fBdirectory\fR \fR
+.ad
+.RS 12n
+Designates an alternate directory that contains the driver files
+used by \fBlex\fR.
+.RE
+
.SH OPERANDS
.sp
.LP