MINOR: cfgparse: support the comma separator on parse_cpu_set

Allow to specify multiple cpu ids/ranges in parse_cpu_set separated by a
comma. This is optional and must be activated by a parameter.

The comma support is disabled for the parsing of the 'cpu-map' config
statement. However, it will be useful to parse files in sysfs when
inspecting the cpus topology for NUMA automatic process binding.
diff --git a/include/haproxy/cfgparse.h b/include/haproxy/cfgparse.h
index 8af4e47..2266ac6 100644
--- a/include/haproxy/cfgparse.h
+++ b/include/haproxy/cfgparse.h
@@ -114,7 +114,7 @@
 int alertif_too_many_args_idx(int maxarg, int index, const char *file, int linenum, char **args, int *err_code);
 int alertif_too_many_args(int maxarg, const char *file, int linenum, char **args, int *err_code);
 int parse_process_number(const char *arg, unsigned long *proc, int max, int *autoinc, char **err);
-unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err);
+unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, int comma_allowed, char **err);
 void free_email_alert(struct proxy *p);
 const char *cfg_find_best_match(const char *word, const struct list *list, int section, const char **extra);
 
diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c
index 694cd70..89e3b10 100644
--- a/src/cfgparse-global.c
+++ b/src/cfgparse-global.c
@@ -1070,7 +1070,7 @@
 			}
 		}
 
-		if (parse_cpu_set((const char **)args+2, &cpus, &errmsg)) {
+		if (parse_cpu_set((const char **)args+2, &cpus, 0, &errmsg)) {
 			ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
 			err_code |= ERR_ALERT | ERR_FATAL;
 			goto out;
diff --git a/src/cfgparse.c b/src/cfgparse.c
index dd8a2c1..f37b748 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -462,26 +462,35 @@
 #ifdef USE_CPU_AFFINITY
 /* Parse cpu sets. Each CPU set is either a unique number between 0 and
  * ha_cpuset_size() - 1 or a range with two such numbers delimited by a dash
- * ('-'). Multiple CPU numbers or ranges may be specified. On success, it
- * returns 0. otherwise it returns 1 with an error message in <err>.
+ * ('-'). If <comma_allowed> is set, each CPU set can be a list of unique
+ * numbers or ranges separated by a comma. It is also possible to specify
+ * multiple cpu numbers or ranges in distinct argument in <args>. On success,
+ * it returns 0, otherwise it returns 1 with an error message in <err>.
  */
-unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err)
+unsigned long parse_cpu_set(const char **args, struct hap_cpuset *cpu_set,
+                            int comma_allowed, char **err)
 {
 	int cur_arg = 0;
+	const char *arg;
 
 	ha_cpuset_zero(cpu_set);
 
-	while (*args[cur_arg]) {
-		char        *dash;
+	arg = args[cur_arg];
+	while (*arg) {
+		const char *dash, *comma;
 		unsigned int low, high;
 
 		if (!isdigit((unsigned char)*args[cur_arg])) {
-			memprintf(err, "'%s' is not a CPU range.", args[cur_arg]);
+			memprintf(err, "'%s' is not a CPU range.", arg);
 			return -1;
 		}
 
-		low = high = str2uic(args[cur_arg]);
-		if ((dash = strchr(args[cur_arg], '-')) != NULL)
+		low = high = str2uic(arg);
+
+		comma = comma_allowed ? strchr(arg, ',') : NULL;
+		dash = strchr(arg, '-');
+
+		if (dash && (!comma || dash < comma))
 			high = *(dash+1) ? str2uic(dash + 1) : ha_cpuset_size() - 1;
 
 		if (high < low) {
@@ -499,7 +508,9 @@
 		while (low <= high)
 			ha_cpuset_set(cpu_set, low++);
 
-		cur_arg++;
+		/* if a comma is present, parse the rest of the arg, else
+		 * skip to the next arg */
+		arg = comma ? comma + 1 : args[++cur_arg];
 	}
 	return 0;
 }