From: Tim Kientzle Date: Wed, 25 Dec 2013 01:13:30 +0000 (-0800) Subject: Move the strsep() implementation to the mtree reader, which is X-Git-Tag: v3.1.900a~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e96fff75f2de4e7dfbd37cf9669489e13e7c8073;p=thirdparty%2Flibarchive.git Move the strsep() implementation to the mtree reader, which is the only place it's used. --- diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index ab91095c8..44799dfc9 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -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"); diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c index 1b36f51a2..d4e93fe78 100644 --- a/libarchive/archive_windows.c +++ b/libarchive/archive_windows.c @@ -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__ */ diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h index 1ef4fa048..6e9277e97 100644 --- a/libarchive/archive_windows.h +++ b/libarchive/archive_windows.h @@ -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 *);