about summary refs log tree commit diff
path: root/lib/libpm.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-02-15 03:57:12 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-02-15 03:57:12 +0000
commit96b3c930fe53eb1dbfc42cf5d0723df02bdda815 (patch)
tree6703205e8f269bcb7e655badf55cc488bf825b7b /lib/libpm.c
parentf04c9ab87ec721ba307fcbe9a70b2b25ac67474e (diff)
downloadnetpbm-mirror-96b3c930fe53eb1dbfc42cf5d0723df02bdda815.tar.gz
netpbm-mirror-96b3c930fe53eb1dbfc42cf5d0723df02bdda815.tar.xz
netpbm-mirror-96b3c930fe53eb1dbfc42cf5d0723df02bdda815.zip
Use _splitpath; _splitpath_s isn't really available
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1839 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpm.c')
-rw-r--r--lib/libpm.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/libpm.c b/lib/libpm.c
index 6bc8521c..61a47099 100644
--- a/lib/libpm.c
+++ b/lib/libpm.c
@@ -708,18 +708,6 @@ extractAfterLastSlash(const char * const fullPath,
 
 
 
-#if MSVCRT
-static void
-splitpath(const char * const fullPath,
-          char *       const retval,
-          size_t       const retvalSize) {
-
-    _splitpath_s(fullPath, 0, 0,  0, 0,  retval, retvalSize,  0, 0);
-}
-#endif
-
-
-
 char *
 pm_arg0toprogname(const char arg0[]) {
 /*----------------------------------------------------------------------------
@@ -736,14 +724,23 @@ pm_arg0toprogname(const char arg0[]) {
    The return value is in static storage within.  It is NUL-terminated,
    but truncated at 64 characters.
 -----------------------------------------------------------------------------*/
-    static char retval[64+1];
+#define MAX_RETVAL_SIZE 64
 #if MSVCRT
-    splitpath(arg0, retval, sizeof(retval));
+    /* Note that there exists _splitpath_s, which takes a size argument,
+       but it is only in "secure" extensions of MSVCRT that come only with
+       MSVC; but _splitpath() comes with Windows.  MinGW has a header file
+       for it.
+    */
+    static char retval[_MAX_FNAME];
+    _splitpath(fullPath, 0, 0,  retval, 0);
+    if (MAX_RETVAL_SIZE < _MAX_FNAME)
+        retval[MAX_RETVAL_SIZE] = '\0';
 #else
+    static char retval[MAX_RETVAL_SIZE+1];
     extractAfterLastSlash(arg0, retval, sizeof(retval));
 #endif
 
-    return(retval);
+    return retval;
 }