about summary refs log tree commit diff
path: root/lib/util
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-29 21:45:56 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-29 21:45:56 +0000
commit28ed9cda2a47c17130ee5b97588695ed3acb4e45 (patch)
tree8de89d205b94221a7941177f365f0e05c0fad039 /lib/util
parentc1b82fa06e7e88a68c877c501fc0422888920415 (diff)
downloadnetpbm-mirror-28ed9cda2a47c17130ee5b97588695ed3acb4e45.tar.gz
netpbm-mirror-28ed9cda2a47c17130ee5b97588695ed3acb4e45.tar.xz
netpbm-mirror-28ed9cda2a47c17130ee5b97588695ed3acb4e45.zip
Rename nstring.h functions with pm_ prefix
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1320 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/filename.c2
-rw-r--r--lib/util/io.c13
-rw-r--r--lib/util/nstring.c78
-rw-r--r--lib/util/nstring.h56
-rw-r--r--lib/util/shhopt.c10
-rw-r--r--lib/util/token.c9
-rw-r--r--lib/util/vasprintf.c8
7 files changed, 89 insertions, 87 deletions
diff --git a/lib/util/filename.c b/lib/util/filename.c
index e3a9a89f..18c12e3c 100644
--- a/lib/util/filename.c
+++ b/lib/util/filename.c
@@ -20,7 +20,7 @@ pm_basename(const char * const fileName) {
         if (fileName[i] == '/')
             basenameStart = i+1;
     }
-    asprintfN(&retval, "%s", &fileName[basenameStart]);
+    pm_asprintf(&retval, "%s", &fileName[basenameStart]);
 
     return retval;
 }
diff --git a/lib/util/io.c b/lib/util/io.c
index edec4a7c..5fe959a9 100644
--- a/lib/util/io.c
+++ b/lib/util/io.c
@@ -49,9 +49,9 @@ pm_freadline(FILE *        const fileP,
         }
 
         if (!buffer)
-            asprintfN(errorP,
-                      "Couldn't get memory for a %u-byte file read buffer.",
-                      (unsigned int)bufferSize);
+            pm_asprintf(errorP,
+                        "Couldn't get memory for a %u-byte file read buffer.",
+                        (unsigned int)bufferSize);
         else {
             int const rc = getc(fileP);
         
@@ -59,9 +59,10 @@ pm_freadline(FILE *        const fileP,
                 if (feof(fileP))
                     eof = true;
                 else
-                    asprintfN(errorP, "Failed to read a character from file.  "
-                              "Errno = %d (%s)",
-                              errno, strerror(errno));
+                    pm_asprintf(errorP,
+                                "Failed to read a character from file.  "
+                                "Errno = %d (%s)",
+                                errno, strerror(errno));
             } else {
                 char const c = (char)rc;
 
diff --git a/lib/util/nstring.c b/lib/util/nstring.c
index 0fa78c7a..03439cad 100644
--- a/lib/util/nstring.c
+++ b/lib/util/nstring.c
@@ -190,12 +190,12 @@ static char credits[] = "\n\
 
 
 void
-vsnprintfN(char *       const str,
-           size_t       const str_m,
-           const char * const fmt,
-           va_list            ap,
-           size_t *     const sizeP) {
-
+pm_vsnprintf(char *       const str,
+             size_t       const str_m,
+             const char * const fmt,
+             va_list            ap,
+             size_t *     const sizeP) {
+    
     size_t str_l = 0;
     const char *p = fmt;
 
@@ -704,17 +704,17 @@ vsnprintfN(char *       const str,
 
 
 int
-snprintfN(char *       const dest,
-          size_t       const str_m,
-          const char * const fmt,
-          ...) {
+pm_snprintf(char *       const dest,
+            size_t       const str_m,
+            const char * const fmt,
+            ...) {
 
     size_t size;
     va_list ap;
 
     va_start(ap, fmt);
     
-    vsnprintfN(dest, str_m, fmt, ap, &size);
+    pm_vsnprintf(dest, str_m, fmt, ap, &size);
 
     va_end(ap);
 
@@ -726,24 +726,24 @@ snprintfN(char *       const dest,
 
 
 /* When a function that is supposed to return a malloc'ed string cannot
-   get the memory for it, it should return 'strsol'.  That has a much
+   get the memory for it, it should return 'pm_strsol'.  That has a much
    better effect on the caller, if the caller doesn't explicitly allow for
    the out of memory case, than returning NULL.  Note that it is very
    rare for the system not to have enough memory to return a small string,
    so it's OK to have somewhat nonsensical behavior when it happens.  We
    just don't want catastrophic behavior.
 
-   'strsol' is an external symbol, so if Caller wants to detect the
+   'pm_strsol' is an external symbol, so if Caller wants to detect the
    out-of-memory failure, he certainly can.
 */
-const char * const strsol = "NO MEMORY TO CREATE STRING!";
+const char * const pm_strsol = "NO MEMORY TO CREATE STRING!";
 
 
 
 void PM_GNU_PRINTF_ATTR(2,3)
-asprintfN(const char ** const resultP,
-          const char *  const fmt, 
-          ...) {
+pm_asprintf(const char ** const resultP,
+            const char *  const fmt, 
+            ...) {
 
     va_list varargs;
     
@@ -751,26 +751,26 @@ asprintfN(const char ** const resultP,
     
     va_start(varargs, fmt);
     
-    vsnprintfN(NULL, 0, fmt, varargs, &dryRunLen);
+    pm_vsnprintf(NULL, 0, fmt, varargs, &dryRunLen);
 
     va_end(varargs);
 
     if (dryRunLen + 1 < dryRunLen)
         /* arithmetic overflow */
-        *resultP = strsol;
+        *resultP = pm_strsol;
     else {
         size_t const allocSize = dryRunLen + 1;
         char * result;
         result = malloc(allocSize);
         if (result == NULL)
-            *resultP = strsol;
+            *resultP = pm_strsol;
         else {
             va_list varargs;
             size_t realLen;
 
             va_start(varargs, fmt);
 
-            vsnprintfN(result, allocSize, fmt, varargs, &realLen);
+            pm_vsnprintf(result, allocSize, fmt, varargs, &realLen);
                 
             assert(realLen == dryRunLen);
             va_end(varargs);
@@ -783,16 +783,16 @@ asprintfN(const char ** const resultP,
 
 
 void
-strfree(const char * const string) {
+pm_strfree(const char * const string) {
 
-    if (string != strsol)
+    if (string != pm_strsol)
         free((void *) string);
 }
 
 
 
 const char *
-strsepN(char ** const stringP, const char * const delim) {
+pm_strsep(char ** const stringP, const char * const delim) {
     const char * retval;   
 
     if (stringP == NULL || *stringP == NULL)
@@ -824,8 +824,8 @@ strsepN(char ** const stringP, const char * const delim) {
 
 
 int
-stripeq(const char * const comparand,
-        const char * const comparator) {
+pm_stripeq(const char * const comparand,
+           const char * const comparator) {
 /*----------------------------------------------------------------------------
   Compare two strings, ignoring leading and trailing white space.
 
@@ -879,10 +879,10 @@ stripeq(const char * const comparand,
 
 
 const void *
-memmemN(const void * const haystackArg,
-        size_t       const haystacklen,
-        const void * const needleArg,
-        size_t       const needlelen) {
+pm_memmem(const void * const haystackArg,
+          size_t       const haystacklen,
+          const void * const needleArg,
+          size_t       const needlelen) {
 
     const unsigned char * const haystack = haystackArg;
     const unsigned char * const needle   = needleArg;
@@ -902,7 +902,7 @@ memmemN(const void * const haystackArg,
 
 
 bool
-strishex(const char * const subject) {
+pm_strishex(const char * const subject) {
 
     bool retval;
     unsigned int i;
@@ -919,12 +919,12 @@ strishex(const char * const subject) {
 
 
 void
-interpret_uint(const char *   const string,
-               unsigned int * const valueP,
-               const char **  const errorP) {
+pm_interpret_uint(const char *   const string,
+                  unsigned int * const valueP,
+                  const char **  const errorP) {
 
     if (string[0] == '\0')
-        asprintfN(errorP, "Null string.");
+        pm_asprintf(errorP, "Null string.");
     else {
         /* strtoul() does a bizarre thing where if the number is out
            of range, it returns a clamped value but tells you about it
@@ -939,13 +939,13 @@ interpret_uint(const char *   const string,
         ulongValue = strtoul(string, &tail, 10);
 
         if (tail[0] != '\0')
-            asprintfN(errorP, "Non-digit stuff in string: %s", tail);
+            pm_asprintf(errorP, "Non-digit stuff in string: %s", tail);
         else if (errno == ERANGE)
-            asprintfN(errorP, "Number too large");
+            pm_asprintf(errorP, "Number too large");
         else if (ulongValue > UINT_MAX)
-            asprintfN(errorP, "Number too large");
+            pm_asprintf(errorP, "Number too large");
         else if (string[0] == '-')
-            asprintfN(errorP, "Negative number");
+            pm_asprintf(errorP, "Negative number");
             /* Sleazy code; string may have leading spaces. */
         else {
             *valueP = ulongValue;
diff --git a/lib/util/nstring.h b/lib/util/nstring.h
index 53f1e4c0..60bab9ae 100644
--- a/lib/util/nstring.h
+++ b/lib/util/nstring.h
@@ -137,62 +137,62 @@ strncaseeq(const char * const comparand,
      - The returned string is a const char * instead of a char *.  The
        const is more correct.
 
-     - If the function can't get the memory, it returns 'strsol',
+     - If the function can't get the memory, it returns 'pm_strsol',
        which is a string that is in static memory that contains text
        indicating an out of memory failure has occurred, intead of
        NULL.  This makes it much easier for programs to ignore this
        possibility.
 
    strfree() is strictly a Netpbm invention, to allow proper type checking
-   when freeing storage allocated by the Netpbm asprintfN().
+   when freeing storage allocated by the Netpbm pm_asprintf().
 */
 
-extern const char * const strsol;
+extern const char * const pm_strsol;
 
 int
-snprintfN(char *       const dest,
-          size_t       const str_m,
-          const char * const fmt,
-          ...) PM_GNU_PRINTF_ATTR(3,4);
+pm_snprintf(char *       const dest,
+            size_t       const str_m,
+            const char * const fmt,
+            ...) PM_GNU_PRINTF_ATTR(3,4);
 
 void
-vsnprintfN(char *       const str,
-           size_t       const str_m,
-           const char * const fmt,
-           va_list            ap,
-           size_t *     const sizeP);
+pm_vsnprintf(char *       const str,
+             size_t       const str_m,
+             const char * const fmt,
+             va_list            ap,
+             size_t *     const sizeP);
 
 void
-asprintfN(const char ** const resultP,
-          const char *  const fmt,
-          ...) PM_GNU_PRINTF_ATTR(2,3);
+pm_asprintf(const char ** const resultP,
+            const char *  const fmt,
+            ...) PM_GNU_PRINTF_ATTR(2,3);
 
 void
-vasprintfN(const char ** const resultP,
-           const char *  const format,
-           va_list             args);
+pm_vasprintf(const char ** const resultP,
+             const char *  const format,
+             va_list             args);
 
 void 
-strfree(const char * const string);
+pm_strfree(const char * const string);
 
 const char *
-strsepN(char ** const stringP, const char * const delim);
+pm_strsep(char ** const stringP, const char * const delim);
 
 int
-stripeq(const char * const comparand,
-        const char * const comparator);
+pm_stripeq(const char * const comparand,
+           const char * const comparator);
 
 const void *
-memmemN(const void * const haystackArg,
-        size_t       const haystacklen,
-        const void * const needleArg,
-        size_t       const needlelen);
+pm_memmem(const void * const haystackArg,
+          size_t       const haystacklen,
+          const void * const needleArg,
+          size_t       const needlelen);
 
 bool
-strishex(const char * const subject);
+pm_strishex(const char * const subject);
 
 void
-interpret_uint(const char *   const string,
+pm_interpret_uint(const char *   const string,
                unsigned int * const valueP,
                const char **  const errorP);
 
diff --git a/lib/util/shhopt.c b/lib/util/shhopt.c
index a557fcd5..2e7c6abd 100644
--- a/lib/util/shhopt.c
+++ b/lib/util/shhopt.c
@@ -737,13 +737,13 @@ fatalUnrecognizedLongOption(const char * const optionName,
         const char * entry;
 
         if (optEntryP->longName)
-            asprintfN(&entry, "-%s ", optEntryP->longName);
+            pm_asprintf(&entry, "-%s ", optEntryP->longName);
         else
-            asprintfN(&entry, "-%c ", optEntryP->shortName);
+            pm_asprintf(&entry, "-%c ", optEntryP->shortName);
 
         strncat(optList, entry, sizeof(optList) - strlen(optList) - 1);
 
-        strfree(entry);
+        pm_strfree(entry);
 
         if (strlen(optList) + 1 == sizeof(optList)) {
             /* Buffer is full.  Overwrite end of list with ellipsis */
@@ -1014,8 +1014,8 @@ pm_optDestroyNameValueList(struct optNameValue * const list) {
     unsigned int i;
 
     for (i = 0; list[i].name; ++i) {
-        strfree(list[i].name);
-        strfree(list[i].value);
+        pm_strfree(list[i].name);
+        pm_strfree(list[i].value);
     }
 
     free(list);
diff --git a/lib/util/token.c b/lib/util/token.c
index c4fe0aed..a68a4821 100644
--- a/lib/util/token.c
+++ b/lib/util/token.c
@@ -38,7 +38,8 @@ pm_gettoken(const char *  const tokenStart,
         if (*cursor == '\\') {
             ++cursor;
             if (*cursor == '\0')
-                asprintfN(errorP, "string ends with an escape character (\\)");
+                pm_asprintf(errorP,
+                            "string ends with an escape character (\\)");
         } else {
             ++cursor;
             ++charCount;
@@ -47,9 +48,9 @@ pm_gettoken(const char *  const tokenStart,
     if (!*errorP) {
         token = malloc(charCount + 1);
         if (token == NULL)
-            asprintfN(errorP, "Could not allocate %u bytes of memory "
-                      "to parse a string",
-                      charCount + 1);
+            pm_asprintf(errorP, "Could not allocate %u bytes of memory "
+                        "to parse a string",
+                        charCount + 1);
         else {
             /* Go back and do it again, this time copying the characters */
             charCount = 0;
diff --git a/lib/util/vasprintf.c b/lib/util/vasprintf.c
index ed8fc808..b9cc6a2f 100644
--- a/lib/util/vasprintf.c
+++ b/lib/util/vasprintf.c
@@ -14,9 +14,9 @@
 #endif
 
 void
-vasprintfN(const char ** const resultP,
-           const char *  const format,
-           va_list             varargs) {
+pm_vasprintf(const char ** const resultP,
+             const char *  const format,
+             va_list             varargs) {
 
     char * result;
 
@@ -24,7 +24,7 @@ vasprintfN(const char ** const resultP,
     vasprintf(&result, format, varargs);
 
     if (result == NULL)
-        *resultP = strsol;
+        *resultP = pm_strsol;
     else
         *resultP = result;
 #else