Print this page
2926 lex ignores -Y

*** 17,37 **** * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ /* Copyright 1976, Bell Telephone Laboratories, Inc. */ - #pragma ident "%Z%%M% %I% %E% SMI" - #include <string.h> #include "once.h" #include "sgs.h" #include <locale.h> #include <limits.h> --- 17,37 ---- * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* + * Copyright (c) 2014 Gary Mills + * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ /* Copyright 1976, Bell Telephone Laboratories, Inc. */ #include <string.h> #include "once.h" #include "sgs.h" #include <locale.h> #include <limits.h>
*** 49,59 **** int main(int argc, char **argv) { int i; int c; ! char *path = NULL; Boolean eoption = 0, woption = 0; sargv = argv; sargc = argc; (void) setlocale(LC_ALL, ""); --- 49,60 ---- int main(int argc, char **argv) { int i; int c; ! char *apath = NULL; ! char *ypath; Boolean eoption = 0, woption = 0; sargv = argv; sargc = argc; (void) setlocale(LC_ALL, "");
*** 81,93 **** if (*v_stmp != 'y' && *v_stmp != 'n') error( "lex: -Q should be followed by [y/n]"); break; case 'Y': ! path = (char *)malloc(strlen(optarg) + sizeof ("/nceucform") + 1); ! path = strcpy(path, optarg); break; case 'c': ratfor = FALSE; break; case 't': --- 82,98 ---- if (*v_stmp != 'y' && *v_stmp != 'n') error( "lex: -Q should be followed by [y/n]"); break; case 'Y': ! apath = (char *)malloc(strlen(optarg) + sizeof ("/nceucform") + 1); ! if (apath == NULL) ! error("No available memory " ! "for directory name."); ! else ! apath = strcpy(apath, optarg); break; case 'c': ratfor = FALSE; break; case 't':
*** 111,121 **** handleeuc = 1; widecio = 0; break; default: (void) fprintf(stderr, ! "Usage: lex [-ewctvnVY] [-Q(y/n)] [file]\n"); exit(1); } } if (woption && eoption) { error( --- 116,127 ---- handleeuc = 1; widecio = 0; break; default: (void) fprintf(stderr, ! "Usage: lex [-ewctvnV] [-Y directory] " ! "[-Q(y/n)] [file]\n"); exit(1); } } if (woption && eoption) { error(
*** 219,240 **** #endif if (handleeuc) { if (ratfor) error("Ratfor is not supported by -w or -e option."); ! path = EUCNAME; } else ! path = ratfor ? RATNAME : CNAME; ! fother = fopen(path, "r"); if (fother == NULL) ! error("Lex driver missing, file %s", path); while ((i = getc(fother)) != EOF) (void) putc((char)i, fout); (void) fclose(fother); (void) fclose(fout); if (report == 1) statistics(); (void) fclose(stdout); (void) fclose(stderr); return (0); /* success return code */ --- 225,249 ---- #endif if (handleeuc) { if (ratfor) error("Ratfor is not supported by -w or -e option."); ! ypath = EUCNAME; } else ! ypath = ratfor ? RATNAME : CNAME; ! if (apath != NULL) ! ypath = strcat(apath, strrchr(ypath, '/')); ! fother = fopen(ypath, "r"); if (fother == NULL) ! 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); (void) fclose(stderr); return (0); /* success return code */