|
Re: printf \xNNN: msg#00095gnu.core-utils.bugs
> From: Jim Meyering > Date: Wed Nov 6 05:12:26 2002 > That looks like a bug. It is at least 10 years old, since that code > was there for my initial cvs import on Nov 1, 1992. I don't think it's a bug, since it's how printf behaves in the C language. For example, if I write this program: #include <stdio.h> int main (void) { return printf ("(\x00000040)\n"); } the output is "(@)". The GNU coreutils manual says that GNU printf is supposed to behave like the C printf function, so I'd say that the 1992 behavior was correct. Here is a proposed patch to revert the behavior, and fix some texinfo formatting bugs. You also need to remove tests/misc/printf-hex, but I didn't do this (sorry, I've gotta run....). 2003-03-24 Paul Eggert <eggert@xxxxxxxxxxx> * doc/coreutils.texi (printf invocation): \x can take any number of digits. * src/printf.c (print_esc): Implement this. This undoes the 2002-11-06 patch. --- doc/coreutils.texi 2003/03/13 13:15:50 4.5.11.0 +++ doc/coreutils.texi 2003/03/25 00:41:18 4.5.11.1 @@ -8454,12 +8454,14 @@ all of the given @var{argument}s. argument string with @samp{\} escapes interpreted in the same way as in the @var{format} string. -@kindex \0ooo -@kindex \xhh -@command{printf} interprets @samp{\0ooo} in @var{format} as an octal number -(if @var{ooo} is 0 to 3 octal digits) specifying a character to print, -and @samp{\xhh} as a hexadecimal number (if @var{hh} is 1 to 2 hex -digits) specifying a character to print. +@kindex \@var{ooo} +@kindex \x@var{hh} + +@command{printf} interprets @samp{\@var{ooo}} in @var{format} as an +octal number (if @var{ooo} is 1 to 3 octal digits) specifying a the +numeric code of a character to print, and @samp{\x@var{hh}} as a +hexadecimal number (if @var{hh} is 1 or more hexadecimal digits) +specifying the numeric code of a character to print. @kindex \uhhhh @kindex \Uhhhhhhhh --- src/printf.c 2003/03/25 00:17:55 4.5.11.4 +++ src/printf.c 2003/03/25 00:28:22 4.5.11.5 @@ -245,9 +245,8 @@ print_esc (const char *escstart) if (!posixly_correct && (*p == 'x')) { - /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */ for (esc_length = 0, ++p; - esc_length < 2 && ISXDIGIT (*p); + ISXDIGIT (*p); ++esc_length, ++p) esc_value = esc_value * 16 + hextobin (*p); if (esc_length == 0) |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: bug: printf overruns an argument: 00095, Paul Eggert |
|---|---|
| Next by Date: | Re: printf \xNNN: 00095, Jim Meyering |
| Previous by Thread: | bug: printf overruns an argumenti: 00095, TAKAI Kousuke |
| Next by Thread: | Re: printf \xNNN: 00095, Jim Meyering |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |