You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/14 08:03:56 UTC

svn commit: r814484 - in /commons/sandbox/runtime/trunk/src/main/native/os/win32: env.c wutil.c

Author: mturk
Date: Mon Sep 14 06:03:56 2009
New Revision: 814484

URL: http://svn.apache.org/viewvc?rev=814484&view=rev
Log:
Always use snwprintf. Later MSVC versions rquire len for swprintf anyhow

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c?rev=814484&r1=814483&r2=814484&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c Mon Sep 14 06:03:56 2009
@@ -265,11 +265,7 @@
     }
 
     /* Override the existing setting by forcibly defining the var */
-#if _MSC_VER >= 1300
-    swprintf(estr, elen, L"%s=%s", var, val);
-#else
-    swprintf(estr,       L"%s=%s", var, val);
-#endif
+    _snwprintf(estr, elen, L"%s=%s", var, val);
     if (_msvcrt_wputenv(estr)) {
         int se = errno;
         x_free(estr);
@@ -300,11 +296,7 @@
         return -1;
     }
     /* Override the existing setting by forcibly defining the var */
-#if _MSC_VER >= 1300
-    swprintf(estr, elen, L"%s=", var);
-#else
-    swprintf(estr,       L"%s=", var);
-#endif
+    _snwprintf(estr, elen, L"%s=", var);
     if (_msvcrt_wputenv(estr)) {
         int se = errno;
         x_free(estr);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=814484&r1=814483&r2=814484&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Mon Sep 14 06:03:56 2009
@@ -37,21 +37,11 @@
      * This requires SeCreateGlobalPrivilege which
      * we try to enable at startup.
      */
-#if _MSC_VER >= 1300
-    swprintf(rname, 32,
-#else
-    swprintf(rname,
-#endif
-            L"Global\\ac%02x-", (type & 0xFF));
+    _snwprintf(rname, 32, L"Global\\ac%02x-", (type & 0xFF));
     if (fname == NULL) {
         /* Use upper 24 bits for object name.
          */
-#if _MSC_VER >= 1300
-        swprintf(pname, sizeof(pname),
-#else
-        swprintf(pname,
-#endif
-                L"%08x", (type >> 8));
+        _snwprintf(pname, sizeof(pname), L"%08x", (type >> 8));
         rc = 1;
     }
     else if (*fname == L'\\' || *fname == '/' ||
@@ -78,14 +68,10 @@
         return res_name_from_filenamew((GetCurrentProcessId() << 8) |
                                        GetTickCount(), rname, NULL);
     }
-#if _MSC_VER >= 1300
-    swprintf(rname, 64,
-#else
-    swprintf(rname,
-#endif
-            L"Global\\uuid-%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-            d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
-            d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+    _snwprintf(rname, 64,
+               L"Global\\uuid-%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+               d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+               d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
 
     return rname;
 }
@@ -100,12 +86,8 @@
     wchar_t pname[64];
 
     wcscpy(rname, L"\\\\.\\pipe\\");
-#if _MSC_VER >= 1300
-    swprintf(pname, sizeof(pname),
-#else
-    swprintf(pname,
-#endif
-            L"apache-commons-pipe-%08x-%08x", pid, id);
+    _snwprintf(pname, sizeof(pname),
+               L"apache-commons-pipe-%08x-%08x", pid, id);
     ACR_MD5EncUuidW(pname, wcslen(pname), rname + 9);
     return rname;
 }