about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--converter/pbm/pbmtonokia.c19
-rw-r--r--lib/libppmcolor.c18
-rw-r--r--lib/util/nstring.c17
-rw-r--r--lib/util/nstring.h4
4 files changed, 23 insertions, 35 deletions
diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c
index c94a80c5..47745288 100644
--- a/converter/pbm/pbmtonokia.c
+++ b/converter/pbm/pbmtonokia.c
@@ -59,23 +59,6 @@ uppercase(const char * const subject) {
 
 
 
-static bool
-ishexstring(const char * const subject) {
-
-    bool retval;
-    unsigned int i;
-
-    retval = TRUE;  /* initial assumption */
-
-    for (i = 0; i < strlen(subject); ++i)
-        if (!ISXDIGIT(subject[i]))
-            retval = FALSE;
-
-    return retval;
-}
-
-
-
 static void
 parseCommandLine(int argc, char ** argv,
                  struct cmdlineInfo * const cmdlineP) {
@@ -131,7 +114,7 @@ parseCommandLine(int argc, char ** argv,
         if (strlen(netOpt) != 6)
             pm_error("-net option must be 6 hex digits long.  "
                      "You specified %u characters", strlen(netOpt));
-        else if (!ishexstring(netOpt))
+        else if (!strishex(netOpt))
             pm_error("-net option must be hexadecimal.  You specified '%s'",
                      netOpt);
         else
diff --git a/lib/libppmcolor.c b/lib/libppmcolor.c
index d5323be3..a200ab2b 100644
--- a/lib/libppmcolor.c
+++ b/lib/libppmcolor.c
@@ -248,22 +248,6 @@ parseNewDecX11(char       const colorname[],
 
 
 
-static bool
-isHexString(char const string[],
-            int  const hexit[]) {
-
-    bool retval;
-    const char * p;
-
-    for (p = &string[0], retval = true; *p && retval == true; ++p) {
-        if (hexit[(unsigned int)*p] == -1)
-            retval = false;
-    }
-    return retval;
-}
-
-
-
 static void
 parseOldX11(char       const colorname[], 
             pixval     const maxval,
@@ -279,7 +263,7 @@ parseOldX11(char       const colorname[],
     
     computeHexTable(hexit);
 
-    if (!isHexString(&colorname[1], hexit))
+    if (!strishex(&colorname[1]))
         pm_error("Non-hexadecimal characters in #-type color specification");
 
     switch (strlen(colorname) - 1 /* (Number of hex digits) */) {
diff --git a/lib/util/nstring.c b/lib/util/nstring.c
index 749e9060..58500547 100644
--- a/lib/util/nstring.c
+++ b/lib/util/nstring.c
@@ -895,3 +895,20 @@ memmemN(const char * const haystack,
 
     return NULL;
 }
+
+
+
+bool
+strishex(const char * const subject) {
+
+    bool retval;
+    unsigned int i;
+
+    retval = TRUE;  /* initial assumption */
+
+    for (i = 0; i < strlen(subject); ++i)
+        if (!ISXDIGIT(subject[i]))
+            retval = FALSE;
+
+    return retval;
+}
diff --git a/lib/util/nstring.h b/lib/util/nstring.h
index d976e859..70a53f45 100644
--- a/lib/util/nstring.h
+++ b/lib/util/nstring.h
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <ctype.h>
 
+#include "pm_c_util.h"
 #include "pm.h"  /* For PM_GNU_PRINTF_ATTR, __inline__ */
 
 #ifdef __cplusplus
@@ -155,6 +156,9 @@ memmemN(const char * const haystack,
         const char * const needle,
         size_t       const needlelen);
 
+bool
+strishex(const char * const subject);
+
 #ifdef __cplusplus
 }
 #endif