Browse Source

configurator: fix single-arg case.

In this case, CCAN_CFLAGS should be "".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 13 years ago
parent
commit
d21d629add
1 changed files with 4 additions and 4 deletions
  1. 4 4
      tools/configurator/configurator.c

+ 4 - 4
tools/configurator/configurator.c

@@ -340,7 +340,8 @@ static char *connect_args(const char *argv[], const char *extra)
 	for (i = 1; argv[i]; i++) {
 	for (i = 1; argv[i]; i++) {
 		strcpy(ret + len, argv[i]);
 		strcpy(ret + len, argv[i]);
 		len += strlen(argv[i]);
 		len += strlen(argv[i]);
-		ret[len++] = ' ';
+		if (argv[i+1])
+			ret[len++] = ' ';
 	}
 	}
 	strcpy(ret + len, extra);
 	strcpy(ret + len, extra);
 	return ret;
 	return ret;
@@ -506,14 +507,13 @@ int main(int argc, const char *argv[])
 	if (argc == 1)
 	if (argc == 1)
 		argv = default_args;
 		argv = default_args;
 
 
-	cmd = connect_args(argv, "-o " OUTPUT_FILE " " INPUT_FILE);
+	cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE);
 	for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
 	for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
 		run_test(cmd, &tests[i]);
 		run_test(cmd, &tests[i]);
 
 
 	unlink(OUTPUT_FILE);
 	unlink(OUTPUT_FILE);
 	unlink(INPUT_FILE);
 	unlink(INPUT_FILE);
 
 
-	cmd[strlen(cmd) - strlen(" -o " OUTPUT_FILE " " INPUT_FILE)] = '\0';
 	printf("/* Generated by CCAN configurator */\n"
 	printf("/* Generated by CCAN configurator */\n"
 	       "#ifndef CCAN_CONFIG_H\n"
 	       "#ifndef CCAN_CONFIG_H\n"
 	       "#define CCAN_CONFIG_H\n");
 	       "#define CCAN_CONFIG_H\n");
@@ -521,7 +521,7 @@ int main(int argc, const char *argv[])
 	printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n");
 	printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n");
 	printf("#endif\n");
 	printf("#endif\n");
 	printf("#define CCAN_COMPILER \"%s\"\n", argv[1]);
 	printf("#define CCAN_COMPILER \"%s\"\n", argv[1]);
-	printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd + strlen(argv[1]) + 1);
+	printf("#define CCAN_CFLAGS \"%s\"\n\n", connect_args(argv+1, ""));
 	/* This one implies "#include <ccan/..." works, eg. for tdb2.h */
 	/* This one implies "#include <ccan/..." works, eg. for tdb2.h */
 	printf("#define HAVE_CCAN 1\n");
 	printf("#define HAVE_CCAN 1\n");
 	for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
 	for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)