Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/libbb/process_escape_sequence.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 20  char FAST_FUNC bb_process_escape_sequenc Line 20  char FAST_FUNC bb_process_escape_sequenc
20  {  {
21   /* bash builtin "echo -e '\ec'" interprets \e as ESC,   /* bash builtin "echo -e '\ec'" interprets \e as ESC,
22   * but coreutils "/bin/echo -e '\ec'" does not.   * but coreutils "/bin/echo -e '\ec'" does not.
23   * manpages tend to support coreutils way. */   * manpages tend to support coreutils way.
24     * Update: coreutils added support for \e on 28 Oct 2009. */
25   static const char charmap[] ALIGN1 = {   static const char charmap[] ALIGN1 = {
26   'a',  'b', /*'e',*/ 'f',  'n',  'r',  't',  'v',  '\\', 0,   'a',  'b', 'e', 'f',  'n',  'r',  't',  'v',  '\\', 0,
27   '\a', '\b', /*27,*/ '\f', '\n', '\r', '\t', '\v', '\\', '\\' };   '\a', '\b', 27, '\f', '\n', '\r', '\t', '\v', '\\', '\\' };
28    
29   const char *p;   const char *p;
30   const char *q;   const char *q;
# Line 45  char FAST_FUNC bb_process_escape_sequenc Line 46  char FAST_FUNC bb_process_escape_sequenc
46   }   }
47  #endif  #endif
48    
49     /* bash requires leading 0 in octal escapes:
50     * \02 works, \2 does not (prints \ and 2).
51     * We treat \2 as a valid octal escape sequence. */
52   do {   do {
53   d = (unsigned char)(*q) - '0';   d = (unsigned char)(*q) - '0';
54  #ifdef WANT_HEX_ESCAPES  #ifdef WANT_HEX_ESCAPES
# Line 80  char FAST_FUNC bb_process_escape_sequenc Line 84  char FAST_FUNC bb_process_escape_sequenc
84   break;   break;
85   }   }
86   } while (*++p);   } while (*++p);
87   n = *(p + (sizeof(charmap)/2));   /* p points to found escape char or NUL,
88     * advance it and find what it translates to */
89     p += sizeof(charmap) / 2;
90     n = *p;
91   }   }
92    
93   *ptr = q;   *ptr = q;

Legend:
Removed from v.983  
changed lines
  Added in v.984