diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-09-04 20:03:25 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-09-04 20:03:25 +0200 |
commit | c9df78f02b66513c6e831d81c3240a715fee7e70 (patch) | |
tree | 1d4db4b982fea5a4525110b3561bb49ad7892474 /src | |
parent | c12bdb94ecdc44f200a8030dfde4a5ec46053ea6 (diff) | |
download | blogc-c9df78f02b66513c6e831d81c3240a715fee7e70.tar.gz blogc-c9df78f02b66513c6e831d81c3240a715fee7e70.tar.bz2 blogc-c9df78f02b66513c6e831d81c3240a715fee7e70.zip |
blogc: fixed bug that prevented digits in -D arguments
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc/main.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/blogc/main.c b/src/blogc/main.c index 2f93d18..550aec8 100644 --- a/src/blogc/main.c +++ b/src/blogc/main.c @@ -236,12 +236,23 @@ main(int argc, char **argv) goto cleanup; } for (size_t j = 0; pieces[0][j] != '\0'; j++) { - if (!((pieces[0][j] >= 'A' && pieces[0][j] <= 'Z') || - pieces[0][j] == '_')) - { + char c = pieces[0][j]; + if (j == 0) { + if (!(c >= 'A' && c <= 'Z')) { + fprintf(stderr, "blogc: error: invalid value " + "for -D (first character in configuration " + "key must be uppercase): %s\n", pieces[0]); + bc_strv_free(pieces); + rv = 1; + goto cleanup; + } + continue; + } + if (!((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { fprintf(stderr, "blogc: error: invalid value " "for -D (configuration key must be uppercase " - "with '_'): %s\n", pieces[0]); + "with '_' and digits after first character): %s\n", + pieces[0]); bc_strv_free(pieces); rv = 1; goto cleanup; |