Skip to content

Commit b03b4de

Browse files
[cedev-config] handle edge case that will never happen
1 parent 2439816 commit b03b4de

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

tools/cedev-config/src/main.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
static int help(const char *prgm)
2020
{
21-
fprintf(stdout, "usage: %s <OPTION>\n", prgm);
21+
fprintf(stdout, "usage: %s <option>\n", prgm);
2222
fprintf(stdout, "\n");
2323
fprintf(stdout, "Get various configuration information needed to compile programs\n");
24-
fprintf(stdout, "using the CE C Toolchain.\n");
24+
fprintf(stdout, "using the CE C/C++ Toolchain.\n");
2525
fprintf(stdout, "\n");
2626
fprintf(stdout, "Options:\n");
27-
fprintf(stdout, " --version Print CE C Toolchain version.\n");
27+
fprintf(stdout, " --version Print CE C/C++ Toolchain version.\n");
2828
fprintf(stdout, " --prefix Print the installation prefix.\n");
2929
fprintf(stdout, " --makefile Core toolchain makefile path.\n");
3030
fprintf(stdout, " --help Show this page.\n");
@@ -52,21 +52,20 @@ static const char *executable_path(void)
5252
return path;
5353
}
5454

55-
static bool str_has_whitespace(const char *str, size_t max)
55+
static bool is_valid_path(const char *str, size_t max)
5656
{
5757
size_t i = 0;
5858

59-
for (i = 0; i < max; ++i)
59+
for (; i < max; ++i)
6060
{
6161
char c = str[i];
62-
switch (c)
62+
if (!c)
6363
{
64-
case '\0':
65-
return false;
66-
case '\t': case '\r': case '\n': case '\v': case '\f': case ' ':
67-
return true;
68-
default:
69-
break;
64+
return true;
65+
}
66+
if (isspace(c))
67+
{
68+
return false;
7069
}
7170
}
7271

@@ -120,7 +119,7 @@ int main(int argc, char *argv[])
120119

121120
case 'm':
122121
cwk_path_get_absolute(cedev, "./meta/makefile.mk", buffer, sizeof buffer);
123-
if (str_has_whitespace(buffer, sizeof buffer))
122+
if (is_valid_path(buffer, sizeof buffer))
124123
{
125124
fprintf(stderr, "The CE C Toolchain is installed in a directory containing\n");
126125
fprintf(stderr, "spaces. This does not work properly with the \'make\' command.\n");

0 commit comments

Comments
 (0)