Print this page
2926 lex ignores -Y

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/lex/common/main.c
          +++ new/usr/src/cmd/sgs/lex/common/main.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright (c) 2014 Gary Mills
       23 + *
  22   24   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   25   * Use is subject to license terms.
  24   26   */
  25   27  
  26   28  /* Copyright (c) 1988 AT&T */
  27   29  /* All Rights Reserved */
  28   30  
  29   31  /* Copyright 1976, Bell Telephone Laboratories, Inc. */
  30   32  
  31      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  32      -
  33   33  #include <string.h>
  34   34  #include "once.h"
  35   35  #include "sgs.h"
  36   36  #include <locale.h>
  37   37  #include <limits.h>
  38   38  
  39   39  static wchar_t  L_INITIAL[] = {'I', 'N', 'I', 'T', 'I', 'A', 'L', 0};
  40   40  static void get1core(void);
  41   41  static void free1core(void);
  42   42  static void get2core(void);
↓ open down ↓ 1 lines elided ↑ open up ↑
  44   44  static void get3core(void);
  45   45  #ifdef DEBUG
  46   46  static void free3core(void);
  47   47  #endif
  48   48  
  49   49  int
  50   50  main(int argc, char **argv)
  51   51  {
  52   52          int i;
  53   53          int c;
  54      -        char *path = NULL;
       54 +        char *apath = NULL;
       55 +        char *ypath;
  55   56          Boolean eoption = 0, woption = 0;
  56   57  
  57   58          sargv = argv;
  58   59          sargc = argc;
  59   60          (void) setlocale(LC_ALL, "");
  60   61  #ifdef DEBUG
  61   62          while ((c = getopt(argc, argv, "dyctvnewVQ:Y:")) != EOF) {
  62   63  #else
  63   64          while ((c = getopt(argc, argv, "ctvnewVQ:Y:")) != EOF) {
  64   65  #endif
↓ open down ↓ 11 lines elided ↑ open up ↑
  76   77                                      (const char *)SGU_PKG,
  77   78                                      (const char *)SGU_REL);
  78   79                                  break;
  79   80                          case 'Q':
  80   81                                  v_stmp = optarg;
  81   82                                  if (*v_stmp != 'y' && *v_stmp != 'n')
  82   83                                          error(
  83   84                                          "lex: -Q should be followed by [y/n]");
  84   85                                  break;
  85   86                          case 'Y':
  86      -                                path = (char *)malloc(strlen(optarg) +
       87 +                                apath = (char *)malloc(strlen(optarg) +
  87   88                                      sizeof ("/nceucform") + 1);
  88      -                                path = strcpy(path, optarg);
       89 +                                if (apath == NULL)
       90 +                                        error("No available memory "
       91 +                                            "for directory name.");
       92 +                                else
       93 +                                        apath = strcpy(apath, optarg);
  89   94                                  break;
  90   95                          case 'c':
  91   96                                  ratfor = FALSE;
  92   97                                  break;
  93   98                          case 't':
  94   99                                  fout = stdout;
  95  100                                  break;
  96  101                          case 'v':
  97  102                                  report = 1;
  98  103                                  break;
↓ open down ↓ 7 lines elided ↑ open up ↑
 106  111                                  widecio = 1;
 107  112                                  break;
 108  113                          case 'e':
 109  114                          case 'E':
 110  115                                  eoption = 1;
 111  116                                  handleeuc = 1;
 112  117                                  widecio = 0;
 113  118                                  break;
 114  119                          default:
 115  120                                  (void) fprintf(stderr,
 116      -                                "Usage: lex [-ewctvnVY] [-Q(y/n)] [file]\n");
      121 +                                "Usage: lex [-ewctvnV] [-Y directory] "
      122 +                                "[-Q(y/n)] [file]\n");
 117  123                                  exit(1);
 118  124                  }
 119  125          }
 120  126          if (woption && eoption) {
 121  127                  error(
 122  128                  "You may not specify both -w and -e simultaneously.");
 123  129          }
 124  130          no_input = argc - optind;
 125  131          if (no_input) {
 126  132                  /* XCU4: recognize "-" file operand for stdin */
↓ open down ↓ 87 lines elided ↑ open up ↑
 214  220           *              gotof, atable, ccpackflg, sfall
 215  221           */
 216  222  
 217  223  #ifdef DEBUG
 218  224          free3core();
 219  225  #endif
 220  226  
 221  227          if (handleeuc) {
 222  228                  if (ratfor)
 223  229                          error("Ratfor is not supported by -w or -e option.");
 224      -                path = EUCNAME;
      230 +                ypath = EUCNAME;
 225  231          }
 226  232          else
 227      -                path = ratfor ? RATNAME : CNAME;
      233 +                ypath = ratfor ? RATNAME : CNAME;
 228  234  
 229      -        fother = fopen(path, "r");
      235 +        if (apath != NULL)
      236 +                ypath = strcat(apath, strrchr(ypath, '/'));
      237 +        fother = fopen(ypath, "r");
 230  238          if (fother == NULL)
 231      -                error("Lex driver missing, file %s", path);
      239 +                error("Lex driver missing, file %s", ypath);
 232  240          while ((i = getc(fother)) != EOF)
 233  241                  (void) putc((char)i, fout);
 234  242          (void) fclose(fother);
 235  243          (void) fclose(fout);
      244 +        free(apath);
 236  245          if (report == 1)
 237  246                  statistics();
 238  247          (void) fclose(stdout);
 239  248          (void) fclose(stderr);
 240  249          return (0);     /* success return code */
 241  250  }
 242  251  
 243  252  static void
 244  253  get1core(void)
 245  254  {
↓ open down ↓ 126 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX