diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-10-13 02:41:42 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-10-13 02:41:42 +0200 |
commit | cae375549716c479d4e7121984df78a20d662386 (patch) | |
tree | 29412308a4b8d34fdcaa20836b6d4b55a4a446c1 /src | |
parent | 836ea885b2fc62cc7b483149937b91c93815e8ae (diff) | |
download | blogc-cae375549716c479d4e7121984df78a20d662386.tar.gz blogc-cae375549716c479d4e7121984df78a20d662386.tar.bz2 blogc-cae375549716c479d4e7121984df78a20d662386.zip |
renderer: fixed strtol error detection bug in freebsd
it seems that error detection for strtol using errno is a glibc
extension.
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc/renderer.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/blogc/renderer.c b/src/blogc/renderer.c index b4d7a90..398f4f8 100644 --- a/src/blogc/renderer.c +++ b/src/blogc/renderer.c @@ -6,7 +6,6 @@ * See the file LICENSE. */ -#include <errno.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> @@ -82,11 +81,11 @@ blogc_format_variable(const char *name, bc_trie_t *global, bc_trie_t *local, for (i = last - 1; i > 0 && var[i] >= '0' && var[i] <= '9'; i--); if (var[i] == '_' && (i + 1) < last) { // var ends with '_[0-9]+' - // passing NULL to endptr because our string was previously validated - len = strtol(var + i + 1, NULL, 10); - if (errno != 0) { - fprintf(stderr, "warning: invalid variable size for '%s' (%s), " - "ignoring.\n", var, strerror(errno)); + char *endptr; + len = strtol(var + i + 1, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "warning: invalid variable size for '%s', " + "ignoring.\n", var); len = -1; } else { |