]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(print_esc): Support \x, \u, \U even if POSIXLY_CORRECT,
authorJim Meyering <jim@meyering.net>
Tue, 15 Jun 2004 18:00:35 +0000 (18:00 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 15 Jun 2004 18:00:35 +0000 (18:00 +0000)
since POSIX says the behavior is unspecified here.
(main): Recognize --help, --version even if
POSIXLY_CORRECT.  POSIX does not specify any options, but it
does not prohibit options either, so "printf" is like "expr" here.

src/printf.c

index 0c709864b8e08552cde983aae027d88a470b2e7c..af2f31afab50b87eb3614d456cfd5eac253aee04 100644 (file)
@@ -241,7 +241,7 @@ print_esc (const char *escstart, bool octal_0)
   int esc_value = 0;           /* Value of \nnn escape. */
   int esc_length;              /* Length of \nnn escape. */
 
-  if (!posixly_correct && *p == 'x')
+  if (*p == 'x')
     {
       /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits.  */
       for (esc_length = 0, ++p;
@@ -265,7 +265,7 @@ print_esc (const char *escstart, bool octal_0)
     }
   else if (*p && strchr ("\"\\abcfnrtv", *p))
     print_esc_char (*p++);
-  else if (!posixly_correct && (*p == 'u' || *p == 'U'))
+  else if (*p == 'u' || *p == 'U')
     {
       char esc_char = *p;
       unsigned int uni_value;
@@ -557,11 +557,10 @@ main (int argc, char **argv)
 
   exit_status = 0;
 
-  /* Don't recognize --help or --version if POSIXLY_CORRECT is set.  */
   posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
-  if (!posixly_correct)
-    parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
-                       usage, AUTHORS, (char const *) NULL);
+
+  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
+                     usage, AUTHORS, (char const *) NULL);
 
   /* The above handles --help and --version.
      Since there is no other invocation of getopt, handle `--' here.  */