Просмотр исходного кода

Add strsep_cs to replace strsep.
-This line, and those below, will be ignored--

M exec/mainconfig.c


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2214 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 лет назад
Родитель
Сommit
0140854704
1 измененных файлов с 30 добавлено и 1 удалено
  1. 30 1
      exec/mainconfig.c

+ 30 - 1
exec/mainconfig.c

@@ -251,6 +251,35 @@ parse_error:
 	return (-1);
 }
 
+static char * strsep_cs(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);
+	}
+}
+
 static int corosync_main_config_set (
 	struct objdb_iface_ver0 *objdb,
 	hdb_handle_t object_handle,
@@ -466,7 +495,7 @@ static int corosync_main_config_set (
 			goto parse_error;
 		}
 
-		while ((token = strsep(&temp, "|")) != NULL) {
+		while ((token = strsep_cs(&temp, "|")) != NULL) {
 			int val;
 
 			val = logsys_tag_id_get(token);