diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-10-30 12:02:30 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-10-30 12:02:30 +0300 |
commit | 460af5f9c0eeaf3e4147c6882430e4df024bfddb (patch) | |
tree | 71066b1129c8abaa3dde7ae1ed36cffcce17d5b4 /winsup | |
parent | dc3d6d9093d3cab0a412b7e5694d3a8fcd116d5c (diff) |
* smallprint.cc (hex_str): New const string.
(__rn): Drop str and use hex_str instead.
(__small_vsprintf): If 'l' modifier has been found, print subsequent
multibyte or wide char string using the s, S, or W options in extended
hex value layout.
* fhandler_disk_file.cc (fhandler_disk_file::readdir): Print WCHAR
and resulting multibyte filename in extended hex value layout in
debug output.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/smallprint.cc | 51 |
3 files changed, 54 insertions, 12 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8141ab754..5e1ef2d57 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2009-10-30 Corinna Vinschen <corinna@vinschen.de> + + * smallprint.cc (hex_str): New const string. + (__rn): Drop str and use hex_str instead. + (__small_vsprintf): If 'l' modifier has been found, print subsequent + multibyte or wide char string using the s, S, or W options in extended + hex value layout. + + * fhandler_disk_file.cc (fhandler_disk_file::readdir): Print WCHAR + and resulting multibyte filename in extended hex value layout in + debug output. + 2009-10-26 Charles Wilson <cygwin@cwilson.fastmail.fm> * lib/pseudo-reloc.c (__report_error) [CYGWIN]: Correct size bug diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index d65938ce2..3bf24b037 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -2053,7 +2053,8 @@ go_ahead: res = 0; } - syscall_printf ("%d = readdir (%p, %p) (%s)", res, dir, &de, res ? "***" : de->d_name); + syscall_printf ("%d = readdir (%p, %p) (L\"%lS\" > \"%ls\")", res, dir, &de, + res ? NULL : &fname, res ? "***" : de->d_name); return res; } diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc index bf6fd67eb..0688ef75d 100644 --- a/winsup/cygwin/smallprint.cc +++ b/winsup/cygwin/smallprint.cc @@ -21,13 +21,14 @@ details. */ #define rnarg(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, long), len, pad, LMASK) #define rnargLL(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, unsigned long long), len, pad, LLMASK) +static const char hex_str[] = "0123456789ABCDEF"; + static char __fastcall * __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned long long mask) { /* longest number is ULLONG_MAX, 18446744073709551615, 20 digits */ unsigned long long uval = 0; char res[20]; - static const char str[] = "0123456789ABCDEF"; int l = 0; if (dosign && val < 0) @@ -47,7 +48,7 @@ __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned do { - res[l++] = str[uval % base]; + res[l++] = hex_str[uval % base]; uval /= base; } while (uval); @@ -75,6 +76,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) while (*fmt) { int i, n = 0x7fff; + bool l_opt = false; if (*fmt != '%') *dst++ = *fmt++; else @@ -110,6 +112,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) len = len * 10 + (c - '0'); continue; case 'l': + l_opt = true; continue; case 'c': { @@ -184,7 +187,16 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) s = "(null)"; fillin: for (i = 0; *s && i < n; i++) - *dst++ = *s++; + if (l_opt && ((*(unsigned char *)s <= 0x1f && *s != '\n') + || *(unsigned char *)s >= 0x7f)) + { + *dst++ = '\\'; + *dst++ = 'x'; + *dst++ = hex_str[*(unsigned char *)s >> 4]; + *dst++ = hex_str[*(unsigned char *)s++ & 0xf]; + } + else + *dst++ = *s++; break; case 'W': w = va_arg (ap, PWCHAR); @@ -195,12 +207,30 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap) if (!us) RtlInitUnicodeString (us = &uw, L"(null)"); wfillin: - if (sys_wcstombs (tmp, NT_MAX_PATH, us->Buffer, - us->Length / sizeof (WCHAR))) - { - s = tmp; - goto fillin; - } + if (l_opt) + { + for (USHORT i = 0; i < us->Length / sizeof (WCHAR); ++i) + { + WCHAR w = us->Buffer[i]; + if ((w <= 0x1f && w != '\n') || w >= 0x7f) + { + *dst++ = '\\'; + *dst++ = 'x'; + *dst++ = hex_str[(w >> 12) & 0xf]; + *dst++ = hex_str[(w >> 8) & 0xf]; + *dst++ = hex_str[(w >> 4) & 0xf]; + *dst++ = hex_str[w & 0xf]; + } + else + *dst++ = w; + } + } + else if (sys_wcstombs (tmp, NT_MAX_PATH, us->Buffer, + us->Length / sizeof (WCHAR))) + { + s = tmp; + goto fillin; + } break; default: *dst++ = '?'; @@ -288,7 +318,6 @@ __wrn (PWCHAR dst, int base, int dosign, long long val, int len, int pad, unsign /* longest number is ULLONG_MAX, 18446744073709551615, 20 digits */ unsigned long long uval = 0; WCHAR res[20]; - static const WCHAR str[] = L"0123456789ABCDEF"; int l = 0; if (dosign && val < 0) @@ -308,7 +337,7 @@ __wrn (PWCHAR dst, int base, int dosign, long long val, int len, int pad, unsign do { - res[l++] = str[uval % base]; + res[l++] = hex_str[uval % base]; uval /= base; } while (uval); |