bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ASCII-isms in od.c, printf.c, tr.c


From: Paul Eggert
Subject: ASCII-isms in od.c, printf.c, tr.c
Date: Wed, 12 May 2004 23:48:06 -0700

Here are patches for a few places where the coreutils source code
assumes ASCII, and will do the wrong thing on an EBCDIC host.  It's
now safe to use \a since we're assuming C89 or better these days.

There's another place in echo.c but I'll send a bigger patch about
that shortly.

2004-05-12  Paul Eggert  <address@hidden>

        * src/od.c (print_ascii, dump_strings): Use e.g. '\a' rather than
        '\007', for portability to EBCDIC hosts.
        * src/printf.c (print_esc_char): Likewise.
        * src/tr.c (unquote, make_printable_str): Likewise.

Index: src/od.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/od.c,v
retrieving revision 1.147
diff -p -u -r1.147 od.c
--- src/od.c    15 Apr 2004 09:12:01 -0000      1.147
+++ src/od.c    13 May 2004 04:28:11 -0000
@@ -559,7 +559,7 @@ print_ascii (size_t n_bytes, const char 
          s = " \\0";
          break;
 
-       case '\007':
+       case '\a':
          s = " \\a";
          break;
 
@@ -1539,7 +1539,7 @@ dump_strings (void)
        {
          switch (c)
            {
-           case '\007':
+           case '\a':
              fputs ("\\a", stdout);
              break;
 
Index: src/printf.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/printf.c,v
retrieving revision 1.87
diff -p -u -r1.87 printf.c
--- src/printf.c        21 Jan 2004 23:38:45 -0000      1.87
+++ src/printf.c        13 May 2004 04:27:36 -0000
@@ -199,28 +199,28 @@ print_esc_char (int c)
   switch (c)
     {
     case 'a':                  /* Alert. */
-      putchar (7);
+      putchar ('\a');
       break;
     case 'b':                  /* Backspace. */
-      putchar (8);
+      putchar ('\b');
       break;
     case 'c':                  /* Cancel the rest of the output. */
       exit (EXIT_SUCCESS);
       break;
     case 'f':                  /* Form feed. */
-      putchar (12);
+      putchar ('\f');
       break;
     case 'n':                  /* New line. */
-      putchar (10);
+      putchar ('\n');
       break;
     case 'r':                  /* Carriage return. */
-      putchar (13);
+      putchar ('\r');
       break;
     case 't':                  /* Horizontal tab. */
-      putchar (9);
+      putchar ('\t');
       break;
     case 'v':                  /* Vertical tab. */
-      putchar (11);
+      putchar ('\v');
       break;
     default:
       putchar (c);
Index: src/tr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tr.c,v
retrieving revision 1.127
diff -p -u -r1.127 tr.c
--- src/tr.c    9 May 2004 19:29:42 -0000       1.127
+++ src/tr.c    13 May 2004 04:28:39 -0000
@@ -494,7 +494,7 @@ unquote (const unsigned char *s, struct 
              c = '\\';
              break;
            case 'a':
-             c = '\007';
+             c = '\a';
              break;
            case 'b':
              c = '\b';
@@ -643,7 +643,7 @@ make_printable_str (const unsigned char 
        case '\\':
          tmp = "\\";
          break;
-       case '\007':
+       case '\a':
          tmp = "\\a";
          break;
        case '\b':




reply via email to

[Prev in Thread] Current Thread [Next in Thread]