Move string helpers from lib/misc.h to rpmio/rpmstring.h
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Nov 2007 06:21:23 +0000 (08:21 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Nov 2007 06:21:23 +0000 (08:21 +0200)
- splitString, freeSplitString, stripTrailingChar

build/files.c
build/parsePrep.c
lib/misc.c
lib/misc.h
lib/rpmfi.c
lib/transaction.c
rpmdb/legacy.c
rpmio/rpmstring.c
rpmio/rpmstring.h

index c79a300..6f944ec 100644 (file)
@@ -30,7 +30,6 @@
 #include "buildio.h"
 
 #include "legacy.h"    /* XXX domd5, expandFileList, compressFileList */
-#include "misc.h"      /* for splitString, freeSplitString */
 #include <rpmlog.h>
 #include "debug.h"
 
index 7f5b734..783b48f 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <rpmbuild.h>
 #include <rpmlog.h>
-#include "misc.h"      /* XXX for splitString */
 #include "debug.h"
 
 /* These have to be global to make up for stupid compilers */
index 6a2cf40..d0151e2 100644 (file)
@@ -47,49 +47,6 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname)
     return RPMRC_OK;
 }
 
-char ** splitString(const char * str, int length, char sep)
-{
-    const char * source;
-    char * s, * dest;
-    char ** list;
-    int i;
-    int fields;
-
-    s = xmalloc(length + 1);
-
-    fields = 1;
-    for (source = str, dest = s, i = 0; i < length; i++, source++, dest++) {
-       *dest = *source;
-       if (*dest == sep) fields++;
-    }
-
-    *dest = '\0';
-
-    list = xmalloc(sizeof(*list) * (fields + 1));
-
-    dest = s;
-    list[0] = dest;
-    i = 1;
-    while (i < fields) {
-       if (*dest == sep) {
-           list[i++] = dest + 1;
-           *dest = 0;
-       }
-       dest++;
-    }
-
-    list[i] = NULL;
-
-/* FIX: list[i] is NULL */
-    return list;
-}
-
-void freeSplitString(char ** list)
-{
-    list[0] = _free(list[0]);
-    list = _free(list);
-}
-
 int doputenv(const char *str)
 {
     char * a;
index 180740a..0730045 100644 (file)
@@ -22,36 +22,6 @@ extern "C" {
 rpmRC rpmMkdirPath (const char * dpath, const char * dname);
 
 /**
- * Split string into fields separated by a character.
- * @param str          string
- * @param length       length of string
- * @param sep          separator character
- * @return             (malloc'd) argv array
- */
-char ** splitString(const char * str, int length, char sep);
-
-/**
- * Free split string argv array.
- * @param list         argv array
- */
-void freeSplitString( char ** list);
-
-/**
- * Remove occurences of trailing character from string.
- * @param s            string
- * @param c            character to strip
- * @return             string
- */
-static inline
-char * stripTrailingChar(char * s, char c)
-{
-    char * t;
-    for (t = s + strlen(s) - 1; *t == c && t >= s; t--)
-       *t = '\0';
-    return s;
-}
-
-/**
  * Like the libc function, but malloc()'s the space needed.
  * @param name         variable name
  * @param value                variable value
index 3a12cb5..d38b4d3 100644 (file)
@@ -20,7 +20,7 @@
 #include <rpmts.h>
 
 #include "legacy.h"     /* XXX domd5 */
-#include "misc.h"      /* XXX stripTrailingChar */
+#include <rpmstring.h>
 #include <rpmmacro.h>  /* XXX rpmCleanPath */
 
 #include "debug.h"
index 23d9a88..be028b8 100644 (file)
@@ -28,7 +28,8 @@
 #include "cpio.h"
 #include "fprint.h"
 #include "legacy.h"    /* XXX domd5 */
-#include "misc.h" /* XXX (free)splitString, currentDirectory */
+#include <rpmstring.h>
+#include "misc.h"      /* currentDirectory */
 
 #include "debug.h"
 
index 2514d59..0be71e2 100644 (file)
@@ -21,7 +21,7 @@
 #include "rpmio_internal.h"    /* XXX fdInitDigest, fdFiniDigest */
 #include <rpmlib.h>
 #include <rpmmacro.h>
-#include "misc.h"      /* XXX stripTrailingChar */
+#include <rpmstring.h>
 #include "legacy.h"
 #include "debug.h"
 
index a14f9ad..45314be 100644 (file)
@@ -23,6 +23,57 @@ static inline int xisspace(int c)  {
     return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v');
 }
 
+char * stripTrailingChar(char * s, char c)
+{
+    char * t;
+    for (t = s + strlen(s) - 1; *t == c && t >= s; t--)
+       *t = '\0';
+    return s;
+}
+
+char ** splitString(const char * str, int length, char sep)
+{
+    const char * source;
+    char * s, * dest;
+    char ** list;
+    int i;
+    int fields;
+
+    s = xmalloc(length + 1);
+
+    fields = 1;
+    for (source = str, dest = s, i = 0; i < length; i++, source++, dest++) {
+       *dest = *source;
+       if (*dest == sep) fields++;
+    }
+
+    *dest = '\0';
+
+    list = xmalloc(sizeof(*list) * (fields + 1));
+
+    dest = s;
+    list[0] = dest;
+    i = 1;
+    while (i < fields) {
+       if (*dest == sep) {
+           list[i++] = dest + 1;
+           *dest = 0;
+       }
+       dest++;
+    }
+
+    list[i] = NULL;
+
+/* FIX: list[i] is NULL */
+    return list;
+}
+
+void freeSplitString(char ** list)
+{
+    list[0] = _free(list[0]);
+    list = _free(list);
+}
+
 StringBuf newStringBuf(void)
 {
     StringBuf sb = xmalloc(sizeof(*sb));
index ff0bdeb..a31957e 100644 (file)
@@ -10,6 +10,29 @@ extern "C" {
 #endif
 
 /**
+ * Split string into fields separated by a character.
+ * @param str          string
+ * @param length       length of string
+ * @param sep          separator character
+ * @return             (malloc'd) argv array
+ */
+char ** splitString(const char * str, int length, char sep);
+
+/**
+ * Free split string argv array.
+ * @param list         argv array
+ */
+void freeSplitString( char ** list);
+
+/**
+ * Remove occurences of trailing character from string.
+ * @param s            string
+ * @param c            character to strip
+ * @return             string
+ */
+char * stripTrailingChar(char * s, char c);
+
+/**
  */
 typedef struct StringBufRec *StringBuf;