OSDN Git Service

* smallprint.cc (__small_vsprintf): Add format specifier 'W' for
authorcorinna <corinna>
Wed, 1 Aug 2007 07:39:20 +0000 (07:39 +0000)
committercorinna <corinna>
Wed, 1 Aug 2007 07:39:20 +0000 (07:39 +0000)
PWCHAR arguments.  Move wide char handling after char handling.

winsup/cygwin/ChangeLog
winsup/cygwin/smallprint.cc

index 2cbcf39..c9e7b2f 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * smallprint.cc (__small_vsprintf): Add format specifier 'W' for
+       PWCHAR arguments.  Move wide char handling after char handling.
+
 2007-07-31  Corinna Vinschen  <corinna@vinschen.de>
 
        * ntdll.h (RtlFreeAnsiString): Declare.
index d06f558..bdf5028 100644 (file)
@@ -66,6 +66,8 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
   char tmp[CYG_MAX_PATH + 1];
   char *orig = dst;
   const char *s;
+  PWCHAR w;
+  UNICODE_STRING uw, *us;
 
   DWORD err = GetLastError ();
 
@@ -171,9 +173,27 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
                  else
                    s = tmp;
                  goto fillin;
+               case '.':
+                 n = strtol (fmt, (char **) &fmt, 10);
+                 if (*fmt++ != 's')
+                   goto endfor;
+               case 's':
+                 s = va_arg (ap, char *);
+                 if (s == NULL)
+                   s = "(null)";
+               fillin:
+                 for (i = 0; *s && i < n; i++)
+                   *dst++ = *s++;
+                 break;
+               case 'W':
+                 w = va_arg (ap, PWCHAR);
+                 RtlInitUnicodeString (&uw, w);
+                 us = &uw;
+                 goto wfillin;
                case 'S':
+                 us = va_arg (ap, PUNICODE_STRING);
+               wfillin:
                  {
-                   PUNICODE_STRING us = va_arg (ap, PUNICODE_STRING);
                    ANSI_STRING as = { 0, 0, NULL };
                    NTSTATUS status;
 
@@ -194,18 +214,6 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
                      RtlFreeOemString (&as);
                  }
                  break;
-               case '.':
-                 n = strtol (fmt, (char **) &fmt, 10);
-                 if (*fmt++ != 's')
-                   goto endfor;
-               case 's':
-                 s = va_arg (ap, char *);
-                 if (s == NULL)
-                   s = "(null)";
-               fillin:
-                 for (i = 0; *s && i < n; i++)
-                   *dst++ = *s++;
-                 break;
                default:
                  *dst++ = '?';
                  *dst++ = fmt[-1];