Blame SOURCES/coreutils-i18n-cut-old.patch

d3767b
diff --git a/src/cut.c b/src/cut.c
d3767b
index 7ab6be4..022d0ad 100644
d3767b
--- a/src/cut.c
d3767b
+++ b/src/cut.c
d3767b
@@ -28,6 +28,11 @@
d3767b
 #include <assert.h>
d3767b
 #include <getopt.h>
d3767b
 #include <sys/types.h>
d3767b
+
d3767b
+/* Get mbstate_t, mbrtowc().  */
d3767b
+#if HAVE_WCHAR_H
d3767b
+# include <wchar.h>
d3767b
+#endif
d3767b
 #include "system.h"
d3767b
 
d3767b
 #include "error.h"
d3767b
@@ -38,6 +43,18 @@
d3767b
 
d3767b
 #include "set-fields.h"
d3767b
 
d3767b
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
d3767b
+   installation; work around this configuration error.        */
d3767b
+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2
d3767b
+# undef MB_LEN_MAX
d3767b
+# define MB_LEN_MAX 16
d3767b
+#endif
d3767b
+
d3767b
+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t.  */
d3767b
+#if HAVE_MBRTOWC && defined mbstate_t
d3767b
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
d3767b
+#endif
d3767b
+
d3767b
 /* The official name of this program (e.g., no 'g' prefix).  */
d3767b
 #define PROGRAM_NAME "cut"
d3767b
 
d3767b
@@ -54,6 +71,52 @@
d3767b
     }									\
d3767b
   while (0)
d3767b
 
d3767b
+/* Refill the buffer BUF to get a multibyte character. */
d3767b
+#define REFILL_BUFFER(BUF, BUFPOS, BUFLEN, STREAM)                        \
d3767b
+  do                                                                        \
d3767b
+    {                                                                        \
d3767b
+      if (BUFLEN < MB_LEN_MAX && !feof (STREAM) && !ferror (STREAM))        \
d3767b
+        {                                                                \
d3767b
+          memmove (BUF, BUFPOS, BUFLEN);                                \
d3767b
+          BUFLEN += fread (BUF + BUFLEN, sizeof(char), BUFSIZ, STREAM); \
d3767b
+          BUFPOS = BUF;                                                        \
d3767b
+        }                                                                \
d3767b
+    }                                                                        \
d3767b
+  while (0)
d3767b
+
d3767b
+/* Get wide character on BUFPOS. BUFPOS is not included after that.
d3767b
+   If byte sequence is not valid as a character, CONVFAIL is true. Otherwise false. */
d3767b
+#define GET_NEXT_WC_FROM_BUFFER(WC, BUFPOS, BUFLEN, MBLENGTH, STATE, CONVFAIL) \
d3767b
+  do                                                                        \
d3767b
+    {                                                                        \
d3767b
+      mbstate_t state_bak;                                                \
d3767b
+                                                                        \
d3767b
+      if (BUFLEN < 1)                                                        \
d3767b
+        {                                                                \
d3767b
+          WC = WEOF;                                                        \
d3767b
+          break;                                                        \
d3767b
+        }                                                                \
d3767b
+                                                                        \
d3767b
+      /* Get a wide character. */                                        \
d3767b
+      CONVFAIL = false;                                                        \
d3767b
+      state_bak = STATE;                                                \
d3767b
+      MBLENGTH = mbrtowc ((wchar_t *)&WC, BUFPOS, BUFLEN, &STATE);        \
d3767b
+                                                                        \
d3767b
+      switch (MBLENGTH)                                                        \
d3767b
+        {                                                                \
d3767b
+        case (size_t)-1:                                                \
d3767b
+        case (size_t)-2:                                                \
d3767b
+          CONVFAIL = true;                                                        \
d3767b
+          STATE = state_bak;                                                \
d3767b
+          /* Fall througn. */                                                \
d3767b
+                                                                        \
d3767b
+        case 0:                                                                \
d3767b
+          MBLENGTH = 1;                                                        \
d3767b
+          break;                                                        \
d3767b
+        }                                                                \
d3767b
+    }                                                                        \
d3767b
+  while (0)
d3767b
+
d3767b
 
d3767b
 /* Pointer inside RP.  When checking if a byte or field is selected
d3767b
    by a finite range, we check if it is between CURRENT_RP.LO
d3767b
@@ -61,6 +124,9 @@
d3767b
    CURRENT_RP.HI then we make CURRENT_RP to point to the next range pair. */
d3767b
 static struct field_range_pair *current_rp;
d3767b
 
d3767b
+/* Length of the delimiter given as argument to -d.  */
d3767b
+size_t delimlen;
d3767b
+
d3767b
 /* This buffer is used to support the semantics of the -s option
d3767b
    (or lack of same) when the specified field list includes (does
d3767b
    not include) the first field.  In both of those cases, the entire
d3767b
@@ -77,15 +143,25 @@ enum operating_mode
d3767b
   {
d3767b
     undefined_mode,
d3767b
 
d3767b
-    /* Output characters that are in the given bytes. */
d3767b
+    /* Output bytes that are at the given positions. */
d3767b
     byte_mode,
d3767b
 
d3767b
+    /* Output characters that are at the given positions. */
d3767b
+    character_mode,
d3767b
+
d3767b
     /* Output the given delimiter-separated fields. */
d3767b
     field_mode
d3767b
   };
d3767b
 
d3767b
 static enum operating_mode operating_mode;
d3767b
 
d3767b
+/* If nonzero, when in byte mode, don't split multibyte characters.  */
d3767b
+static int byte_mode_character_aware;
d3767b
+
d3767b
+/* If nonzero, the function for single byte locale is work
d3767b
+   if this program runs on multibyte locale. */
d3767b
+static int force_singlebyte_mode;
d3767b
+
d3767b
 /* If true do not output lines containing no delimiter characters.
d3767b
    Otherwise, all such lines are printed.  This option is valid only
d3767b
    with field mode.  */
d3767b
@@ -97,6 +173,9 @@ static bool complement;
d3767b
 
d3767b
 /* The delimiter character for field mode. */
d3767b
 static unsigned char delim;
d3767b
+#if HAVE_WCHAR_H
d3767b
+static wchar_t wcdelim;
d3767b
+#endif
d3767b
 
d3767b
 /* The delimiter for each line/record. */
d3767b
 static unsigned char line_delim = '\n';
d3767b
@@ -164,7 +243,7 @@ Print selected parts of lines from each FILE to standard output.\n\
d3767b
   -f, --fields=LIST       select only these fields;  also print any line\n\
d3767b
                             that contains no delimiter character, unless\n\
d3767b
                             the -s option is specified\n\
d3767b
-  -n                      (ignored)\n\
d3767b
+  -n                      with -b: don't split multibyte characters\n\
d3767b
 "), stdout);
d3767b
       fputs (_("\
d3767b
       --complement        complement the set of selected bytes, characters\n\
d3767b
@@ -280,6 +359,82 @@ cut_bytes (FILE *stream)
d3767b
     }
d3767b
 }
d3767b
 
d3767b
+#if HAVE_MBRTOWC
d3767b
+/* This function is in use for the following case.
d3767b
+
d3767b
+   1. Read from the stream STREAM, printing to standard output any selected
d3767b
+   characters.
d3767b
+
d3767b
+   2. Read from stream STREAM, printing to standard output any selected bytes,
d3767b
+   without splitting multibyte characters.  */
d3767b
+
d3767b
+static void
d3767b
+cut_characters_or_cut_bytes_no_split (FILE *stream)
d3767b
+{
d3767b
+  uintmax_t idx;             /* number of bytes or characters in the line so far. */
d3767b
+  char buf[MB_LEN_MAX + BUFSIZ];  /* For spooling a read byte sequence. */
d3767b
+  char *bufpos;                /* Next read position of BUF. */
d3767b
+  size_t buflen;        /* The length of the byte sequence in buf. */
d3767b
+  wint_t wc;                /* A gotten wide character. */
d3767b
+  size_t mblength;        /* The byte size of a multibyte character which shows
d3767b
+                           as same character as WC. */
d3767b
+  mbstate_t state;        /* State of the stream. */
d3767b
+  bool convfail = false;  /* true, when conversion failed. Otherwise false. */
d3767b
+  /* Whether to begin printing delimiters between ranges for the current line.
d3767b
+     Set after we've begun printing data corresponding to the first range.  */
d3767b
+  bool print_delimiter = false;
d3767b
+
d3767b
+  idx = 0;
d3767b
+  buflen = 0;
d3767b
+  bufpos = buf;
d3767b
+  memset (&state, '\0', sizeof(mbstate_t));
d3767b
+
d3767b
+  current_rp = frp;
d3767b
+
d3767b
+  while (1)
d3767b
+    {
d3767b
+      REFILL_BUFFER (buf, bufpos, buflen, stream);
d3767b
+
d3767b
+      GET_NEXT_WC_FROM_BUFFER (wc, bufpos, buflen, mblength, state, convfail);
d3767b
+      (void) convfail;  /* ignore unused */
d3767b
+
d3767b
+      if (wc == WEOF)
d3767b
+        {
d3767b
+          if (idx > 0)
d3767b
+            putchar (line_delim);
d3767b
+          break;
d3767b
+        }
d3767b
+      else if (wc == line_delim)
d3767b
+        {
d3767b
+          putchar (line_delim);
d3767b
+          idx = 0;
d3767b
+          print_delimiter = false;
d3767b
+          current_rp = frp;
d3767b
+        }
d3767b
+      else
d3767b
+        {
d3767b
+          next_item (&idx);
d3767b
+          if (print_kth (idx))
d3767b
+            {
d3767b
+              if (output_delimiter_specified)
d3767b
+                {
d3767b
+                  if (print_delimiter && is_range_start_index (idx))
d3767b
+                    {
d3767b
+                      fwrite (output_delimiter_string, sizeof (char),
d3767b
+                              output_delimiter_length, stdout);
d3767b
+                    }
d3767b
+                  print_delimiter = true;
d3767b
+                }
d3767b
+              fwrite (bufpos, mblength, sizeof(char), stdout);
d3767b
+            }
d3767b
+        }
d3767b
+
d3767b
+      buflen -= mblength;
d3767b
+      bufpos += mblength;
d3767b
+    }
d3767b
+}
d3767b
+#endif
d3767b
+
d3767b
 /* Read from stream STREAM, printing to standard output any selected fields.  */
d3767b
 
d3767b
 static void
d3767b
@@ -425,13 +580,211 @@ cut_fields (FILE *stream)
d3767b
     }
d3767b
 }
d3767b
 
d3767b
+#if HAVE_MBRTOWC
d3767b
+static void
d3767b
+cut_fields_mb (FILE *stream)
d3767b
+{
d3767b
+  int c;
d3767b
+  uintmax_t field_idx;
d3767b
+  int found_any_selected_field;
d3767b
+  int buffer_first_field;
d3767b
+  int empty_input;
d3767b
+  char buf[MB_LEN_MAX + BUFSIZ];  /* For spooling a read byte sequence. */
d3767b
+  char *bufpos;                /* Next read position of BUF. */
d3767b
+  size_t buflen;        /* The length of the byte sequence in buf. */
d3767b
+  wint_t wc = 0;        /* A gotten wide character. */
d3767b
+  size_t mblength;        /* The byte size of a multibyte character which shows
d3767b
+                           as same character as WC. */
d3767b
+  mbstate_t state;        /* State of the stream. */
d3767b
+  bool convfail = false;  /* true, when conversion failed. Otherwise false. */
d3767b
+
d3767b
+  current_rp = frp;
d3767b
+
d3767b
+  found_any_selected_field = 0;
d3767b
+  field_idx = 1;
d3767b
+  bufpos = buf;
d3767b
+  buflen = 0;
d3767b
+  memset (&state, '\0', sizeof(mbstate_t));
d3767b
+
d3767b
+  c = getc (stream);
d3767b
+  empty_input = (c == EOF);
d3767b
+  if (c != EOF)
d3767b
+  {
d3767b
+    ungetc (c, stream);
d3767b
+    wc = 0;
d3767b
+  }
d3767b
+  else
d3767b
+    wc = WEOF;
d3767b
+
d3767b
+  /* To support the semantics of the -s flag, we may have to buffer
d3767b
+     all of the first field to determine whether it is `delimited.'
d3767b
+     But that is unnecessary if all non-delimited lines must be printed
d3767b
+     and the first field has been selected, or if non-delimited lines
d3767b
+     must be suppressed and the first field has *not* been selected.
d3767b
+     That is because a non-delimited line has exactly one field.  */
d3767b
+  buffer_first_field = (suppress_non_delimited ^ !print_kth (1));
d3767b
+
d3767b
+  while (1)
d3767b
+    {
d3767b
+      if (field_idx == 1 && buffer_first_field)
d3767b
+        {
d3767b
+          int len = 0;
d3767b
+
d3767b
+          while (1)
d3767b
+            {
d3767b
+              REFILL_BUFFER (buf, bufpos, buflen, stream);
d3767b
+
d3767b
+              GET_NEXT_WC_FROM_BUFFER
d3767b
+                (wc, bufpos, buflen, mblength, state, convfail);
d3767b
+
d3767b
+              if (wc == WEOF)
d3767b
+                break;
d3767b
+
d3767b
+              field_1_buffer = xrealloc (field_1_buffer, len + mblength);
d3767b
+              memcpy (field_1_buffer + len, bufpos, mblength);
d3767b
+              len += mblength;
d3767b
+              buflen -= mblength;
d3767b
+              bufpos += mblength;
d3767b
+
d3767b
+              if (!convfail && (wc == line_delim || wc == wcdelim))
d3767b
+                break;
d3767b
+            }
d3767b
+
d3767b
+          if (len <= 0 && wc == WEOF)
d3767b
+            break;
d3767b
+
d3767b
+          /* If the first field extends to the end of line (it is not
d3767b
+             delimited) and we are printing all non-delimited lines,
d3767b
+             print this one.  */
d3767b
+          if (convfail || (!convfail && wc != wcdelim))
d3767b
+            {
d3767b
+              if (suppress_non_delimited)
d3767b
+                {
d3767b
+                  /* Empty.        */
d3767b
+                }
d3767b
+              else
d3767b
+                {
d3767b
+                  fwrite (field_1_buffer, sizeof (char), len, stdout);
d3767b
+                  /* Make sure the output line is newline terminated.  */
d3767b
+                  if (convfail || (!convfail && wc != line_delim))
d3767b
+                    putchar (line_delim);
d3767b
+                }
d3767b
+              continue;
d3767b
+            }
d3767b
+
d3767b
+          if (print_kth (1))
d3767b
+            {
d3767b
+              /* Print the field, but not the trailing delimiter.  */
d3767b
+              fwrite (field_1_buffer, sizeof (char), len - 1, stdout);
d3767b
+              found_any_selected_field = 1;
d3767b
+            }
d3767b
+          next_item (&field_idx);
d3767b
+        }
d3767b
+
d3767b
+      if (wc != WEOF)
d3767b
+        {
d3767b
+          if (print_kth (field_idx))
d3767b
+            {
d3767b
+              if (found_any_selected_field)
d3767b
+                {
d3767b
+                  fwrite (output_delimiter_string, sizeof (char),
d3767b
+                          output_delimiter_length, stdout);
d3767b
+                }
d3767b
+              found_any_selected_field = 1;
d3767b
+            }
d3767b
+
d3767b
+          while (1)
d3767b
+            {
d3767b
+              REFILL_BUFFER (buf, bufpos, buflen, stream);
d3767b
+
d3767b
+              GET_NEXT_WC_FROM_BUFFER
d3767b
+                (wc, bufpos, buflen, mblength, state, convfail);
d3767b
+
d3767b
+              if (wc == WEOF)
d3767b
+                break;
d3767b
+              else if (!convfail && (wc == wcdelim || wc == line_delim))
d3767b
+                {
d3767b
+                  buflen -= mblength;
d3767b
+                  bufpos += mblength;
d3767b
+                  break;
d3767b
+                }
d3767b
+
d3767b
+              if (print_kth (field_idx))
d3767b
+                fwrite (bufpos, mblength, sizeof(char), stdout);
d3767b
+
d3767b
+              buflen -= mblength;
d3767b
+              bufpos += mblength;
d3767b
+            }
d3767b
+        }
d3767b
+
d3767b
+      if ((!convfail || wc == line_delim) && buflen < 1)
d3767b
+        wc = WEOF;
d3767b
+
d3767b
+      if (!convfail && wc == wcdelim)
d3767b
+        next_item (&field_idx);
d3767b
+      else if (wc == WEOF || (!convfail && wc == line_delim))
d3767b
+        {
d3767b
+          if (found_any_selected_field
d3767b
+              || (!empty_input && !(suppress_non_delimited && field_idx == 1)))
d3767b
+            putchar (line_delim);
d3767b
+          if (wc == WEOF)
d3767b
+            break;
d3767b
+          field_idx = 1;
d3767b
+          current_rp = frp;
d3767b
+          found_any_selected_field = 0;
d3767b
+        }
d3767b
+    }
d3767b
+}
d3767b
+#endif
d3767b
+
d3767b
 static void
d3767b
 cut_stream (FILE *stream)
d3767b
 {
d3767b
-  if (operating_mode == byte_mode)
d3767b
-    cut_bytes (stream);
d3767b
+#if HAVE_MBRTOWC
d3767b
+  if (MB_CUR_MAX > 1 && !force_singlebyte_mode)
d3767b
+    {
d3767b
+      switch (operating_mode)
d3767b
+        {
d3767b
+        case byte_mode:
d3767b
+          if (byte_mode_character_aware)
d3767b
+            cut_characters_or_cut_bytes_no_split (stream);
d3767b
+          else
d3767b
+            cut_bytes (stream);
d3767b
+          break;
d3767b
+
d3767b
+        case character_mode:
d3767b
+          cut_characters_or_cut_bytes_no_split (stream);
d3767b
+          break;
d3767b
+
d3767b
+        case field_mode:
d3767b
+          if (delimlen == 1)
d3767b
+            {
d3767b
+              /* Check if we have utf8 multibyte locale, so we can use this
d3767b
+                 optimization because of uniqueness of characters, which is
d3767b
+                 not true for e.g. SJIS */
d3767b
+              char * loc = setlocale(LC_CTYPE, NULL);
d3767b
+              if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8") ||
d3767b
+                  strstr (loc, "UTF8") || strstr (loc, "utf8")))
d3767b
+                {
d3767b
+                  cut_fields (stream);
d3767b
+                  break;
d3767b
+                }
d3767b
+            }
d3767b
+          cut_fields_mb (stream);
d3767b
+          break;
d3767b
+
d3767b
+        default:
d3767b
+          abort ();
d3767b
+        }
d3767b
+    }
d3767b
   else
d3767b
-    cut_fields (stream);
d3767b
+#endif
d3767b
+    {
d3767b
+      if (operating_mode == field_mode)
d3767b
+        cut_fields (stream);
d3767b
+      else
d3767b
+        cut_bytes (stream);
d3767b
+    }
d3767b
 }
d3767b
 
d3767b
 /* Process file FILE to standard output.
d3767b
@@ -483,6 +836,7 @@ main (int argc, char **argv)
d3767b
   bool ok;
d3767b
   bool delim_specified = false;
d3767b
   char *spec_list_string IF_LINT ( = NULL);
d3767b
+  char mbdelim[MB_LEN_MAX + 1];
d3767b
 
d3767b
   initialize_main (&argc, &argv);
d3767b
   set_program_name (argv[0]);
d3767b
@@ -505,7 +859,6 @@ main (int argc, char **argv)
d3767b
       switch (optc)
d3767b
         {
d3767b
         case 'b':
d3767b
-        case 'c':
d3767b
           /* Build the byte list. */
d3767b
           if (operating_mode != undefined_mode)
d3767b
             FATAL_ERROR (_("only one type of list may be specified"));
d3767b
@@ -513,6 +866,14 @@ main (int argc, char **argv)
d3767b
           spec_list_string = optarg;
d3767b
           break;
d3767b
 
d3767b
+        case 'c':
d3767b
+          /* Build the character list. */
d3767b
+          if (operating_mode != undefined_mode)
d3767b
+            FATAL_ERROR (_("only one type of list may be specified"));
d3767b
+          operating_mode = character_mode;
d3767b
+          spec_list_string = optarg;
d3767b
+          break;
d3767b
+
d3767b
         case 'f':
d3767b
           /* Build the field list. */
d3767b
           if (operating_mode != undefined_mode)
d3767b
@@ -524,10 +885,38 @@ main (int argc, char **argv)
d3767b
         case 'd':
d3767b
           /* New delimiter. */
d3767b
           /* Interpret -d '' to mean 'use the NUL byte as the delimiter.'  */
d3767b
-          if (optarg[0] != '\0' && optarg[1] != '\0')
d3767b
-            FATAL_ERROR (_("the delimiter must be a single character"));
d3767b
-          delim = optarg[0];
d3767b
-          delim_specified = true;
d3767b
+            {
d3767b
+#if HAVE_MBRTOWC
d3767b
+              if(MB_CUR_MAX > 1)
d3767b
+                {
d3767b
+                  mbstate_t state;
d3767b
+
d3767b
+                  memset (&state, '\0', sizeof(mbstate_t));
d3767b
+                  delimlen = mbrtowc (&wcdelim, optarg, strnlen(optarg, MB_LEN_MAX), &state);
d3767b
+
d3767b
+                  if (delimlen == (size_t)-1 || delimlen == (size_t)-2)
d3767b
+                    ++force_singlebyte_mode;
d3767b
+                  else
d3767b
+                    {
d3767b
+                      delimlen = (delimlen < 1) ? 1 : delimlen;
d3767b
+                      if (wcdelim != L'\0' && *(optarg + delimlen) != '\0')
d3767b
+                        FATAL_ERROR (_("the delimiter must be a single character"));
d3767b
+                      memcpy (mbdelim, optarg, delimlen);
d3767b
+                      mbdelim[delimlen] = '\0';
d3767b
+                      if (delimlen == 1)
d3767b
+                        delim = *optarg;
d3767b
+                    }
d3767b
+                }
d3767b
+
d3767b
+              if (MB_CUR_MAX <= 1 || force_singlebyte_mode)
d3767b
+#endif
d3767b
+                {
d3767b
+                  if (optarg[0] != '\0' && optarg[1] != '\0')
d3767b
+                    FATAL_ERROR (_("the delimiter must be a single character"));
d3767b
+                  delim = (unsigned char) optarg[0];
d3767b
+                }
d3767b
+            delim_specified = true;
d3767b
+          }
d3767b
           break;
d3767b
 
d3767b
         case OUTPUT_DELIMITER_OPTION:
d3767b
@@ -540,6 +929,7 @@ main (int argc, char **argv)
d3767b
           break;
d3767b
 
d3767b
         case 'n':
d3767b
+          byte_mode_character_aware = 1;
d3767b
           break;
d3767b
 
d3767b
         case 's':
d3767b
@@ -579,15 +969,34 @@ main (int argc, char **argv)
d3767b
               | (complement ? SETFLD_COMPLEMENT : 0) );
d3767b
 
d3767b
   if (!delim_specified)
d3767b
-    delim = '\t';
d3767b
+    {
d3767b
+      delim = '\t';
d3767b
+#ifdef HAVE_MBRTOWC
d3767b
+      wcdelim = L'\t';
d3767b
+      mbdelim[0] = '\t';
d3767b
+      mbdelim[1] = '\0';
d3767b
+      delimlen = 1;
d3767b
+#endif
d3767b
+    }
d3767b
 
d3767b
   if (output_delimiter_string == NULL)
d3767b
     {
d3767b
-      static char dummy[2];
d3767b
-      dummy[0] = delim;
d3767b
-      dummy[1] = '\0';
d3767b
-      output_delimiter_string = dummy;
d3767b
-      output_delimiter_length = 1;
d3767b
+#ifdef HAVE_MBRTOWC
d3767b
+      if (MB_CUR_MAX > 1 && !force_singlebyte_mode)
d3767b
+        {
d3767b
+          output_delimiter_string = xstrdup(mbdelim);
d3767b
+          output_delimiter_length = delimlen;
d3767b
+        }
d3767b
+
d3767b
+      if (MB_CUR_MAX <= 1 || force_singlebyte_mode)
d3767b
+#endif
d3767b
+        {
d3767b
+          static char dummy[2];
d3767b
+          dummy[0] = delim;
d3767b
+          dummy[1] = '\0';
d3767b
+          output_delimiter_string = dummy;
d3767b
+          output_delimiter_length = 1;
d3767b
+        }
d3767b
     }
d3767b
 
d3767b
   if (optind == argc)