]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Move the strsep() implementation to the mtree reader, which is
authorTim Kientzle <kientzle@acm.org>
Wed, 25 Dec 2013 01:13:30 +0000 (17:13 -0800)
committerTim Kientzle <kientzle@acm.org>
Wed, 25 Dec 2013 01:13:30 +0000 (17:13 -0800)
the only place it's used.

libarchive/archive_read_support_format_mtree.c
libarchive/archive_windows.c
libarchive/archive_windows.h

index ab91095c8a30114a42c5d7f12bca47159ee62482..44799dfc95d7b624b603f560afcd48ee9d3c1492 100644 (file)
@@ -1297,6 +1297,23 @@ parse_line(struct archive_read *a, struct archive_entry *entry,
  *  - format,major,minor[,subdevice]
  * When parsing succeeded, `pdev' will contain the appropriate dev_t value.
  */
+
+/* strsep() is not in C90, but strcspn() is. */
+/* Taken from http://unixpapa.com/incnote/string.html */
+static char *
+la_strsep(char **sp, char *sep)
+{
+       char *p, *s;
+       if (sp == NULL || *sp == NULL || **sp == '\0')
+               return(NULL);
+       s = *sp;
+       p = s + strcspn(s, sep);
+       if (*p != '\0')
+               *p++ = '\0';
+       *sp = p;
+       return(s);
+}
+
 static int
 parse_device(dev_t *pdev, struct archive *a, char *val)
 {
@@ -1321,7 +1338,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
                        return ARCHIVE_WARN;
                }
                argc = 0;
-               while ((p = strsep(&dev, ",")) != NULL) {
+               while ((p = la_strsep(&dev, ",")) != NULL) {
                        if (*p == '\0') {
                                archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
                                    "Missing number");
index 1b36f51a22b9f0874af9ec4da0cc46a230bb2afd..d4e93fe78aaadb85397cebecf2f7b3874fb0e714 100644 (file)
@@ -905,19 +905,4 @@ __la_dosmaperr(unsigned long e)
        return;
 }
 
-/* Taken from http://unixpapa.com/incnote/string.html */
-char *
-__la_strsep(char **sp, char *sep)
-{
-       char *p, *s;
-       if (sp == NULL || *sp == NULL || **sp == '\0')
-               return(NULL);
-       s = *sp;
-       p = s + strcspn(s, sep);
-       if (*p != '\0')
-               *p++ = '\0';
-       *sp = p;
-       return(s);
-}
-
 #endif /* _WIN32 && !__CYGWIN__ */
index 1ef4fa048fa45ac9066074e540f9b3fa6eb75aa1..6e9277e97942e183aef593acb27b70f4e1e31312 100644 (file)
@@ -277,8 +277,6 @@ extern wchar_t *__la_win_permissive_name(const char *name);
 extern wchar_t *__la_win_permissive_name_w(const wchar_t *wname);
 extern void __la_dosmaperr(unsigned long e);
 #define la_dosmaperr(e) __la_dosmaperr(e)
-extern char *__la_strsep(char **sp, char *sep);
-#define strsep(sp, sep) __la_strsep(sp, sep)
 extern struct archive_entry *__la_win_entry_in_posix_pathseparator(
     struct archive_entry *);