summaryrefslogtreecommitdiff
blob: eb8d9e2a94d2685085998602e2cbf65177f41f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Modified version of.
http://cvs.openpkg.org/fileview?f=openpkg-src/cvsps/cvsps.patch&v=1.13

--- a/cache.c
+++ b/cache.c
@@ -361,7 +361,7 @@ static void parse_cache_revision(PatchSetMember * psm, const char * p_buff)
 
     strcpy(buff, p_buff);
 
-    while ((s = strsep(&p, ";")))
+    while ((s = my_strsep(&p, ";")))
     {
 	char * c = strchr(s, ':');
 
--- a/cvs_direct.c
+++ b/cvs_direct.c
@@ -92,12 +92,12 @@ CvsServerCtx * open_cvs_server(char * p_root, int compress)
 
     strcpy_a(root, p_root, PATH_MAX);
 
-    tok = strsep(&p, ":");
+    tok = my_strsep(&p, ":");
 
     /* if root string looks like :pserver:... then the first token will be empty */
     if (strlen(tok) == 0)
     {
-	char * method = strsep(&p, ":");
+	char * method = my_strsep(&p, ":");
 	if (strcmp(method, "pserver") == 0)
 	{
 	    ctx = open_ctx_pserver(ctx, p);
@@ -185,14 +185,14 @@ static CvsServerCtx * open_ctx_pserver(CvsServerCtx * ctx, const char * p_root)
 
     strcpy_a(root, p_root, PATH_MAX);
 
-    tok = strsep(&p, ":");
+    tok = my_strsep(&p, ":");
     if (strlen(tok) == 0 || !p)
     {
 	debug(DEBUG_APPERROR, "parse error on third token");
 	goto out_free_err;
     }
 
-    tok2 = strsep(&tok, "@");
+    tok2 = my_strsep(&tok, "@");
     if (!strlen(tok2) || (!tok || !strlen(tok)))
     {
 	debug(DEBUG_APPERROR, "parse error on user@server in pserver");
@@ -272,7 +272,7 @@ static CvsServerCtx * open_ctx_forked(CvsServerCtx * ctx, const char * p_root)
     strcpy_a(root, p_root, PATH_MAX);
 
     /* if there's a ':', it's remote */
-    tok = strsep(&p, ":");
+    tok = my_strsep(&p, ":");
 
     if (p)
     {
@@ -281,7 +281,7 @@ static CvsServerCtx * open_ctx_forked(CvsServerCtx * ctx, const char * p_root)
 	if (!cvs_rsh)
 	    cvs_rsh = "rsh";
 
-	tok2 = strsep(&tok, "@");
+	tok2 = my_strsep(&tok, "@");
 
 	if (tok)
 	    snprintf(execcmd, PATH_MAX, "%s -l %s %s %s server", cvs_rsh, tok2, tok, cvs_server);
@@ -776,7 +776,7 @@ void cvs_rupdate(CvsServerCtx * ctx, const char * rep, const char * file, const
 static int parse_patch_arg(char * arg, char ** str)
 {
     char *tok, *tok2 = "";
-    tok = strsep(str, " ");
+    tok = my_strsep(str, " ");
     if (!tok)
 	return 0;
 
@@ -796,7 +796,7 @@ static int parse_patch_arg(char * arg, char ** str)
     /* see if command wants two args and they're separated by ' ' */
     if (tok[2] == 0 && strchr("BdDFgiorVxYz", tok[1]))
     {
-	tok2 = strsep(str, " ");
+	tok2 = my_strsep(str, " ");
 	if (!tok2)
 	{
 	    debug(DEBUG_APPERROR, "diff_opts parse_error: argument %s requires two arguments", tok);
--- a/util.c
+++ b/util.c
@@ -316,3 +316,31 @@ void strcpy_a(char * dst, const char * src, int n)
 	exit(1);
     }
 }
+
+char *my_strsep(char **stringp, const char *delim)
+{
+	char *s;
+	const char *spanp;
+	int c, sc;
+	char *tok;
+
+	if ((s = *stringp) == NULL)
+		return NULL;
+	for (tok = s;;) {
+		c = *s++;
+		spanp = delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == 0)
+					s = NULL;
+				else
+					s[-1] = 0;
+				*stringp = s;
+				return tok;
+			}
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+    return NULL;
+}
+
--- a/util.h
+++ b/util.h
@@ -24,5 +24,6 @@ void timing_stop(const char *);
 int my_system(const char *);
 int escape_filename(char *, int, const char *);
 void strcpy_a(char * dst, const char * src, int n);
+char *my_strsep(char **, const char *);
 
 #endif /* UTIL_H */