From f9e52c4acbd8f53da1b083770c6aab9c67cb0368 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Sep 2015 20:49:08 +0200 Subject: misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/assert.c | 2 +- src/err.c | 1 + src/error.c | 9 ++++++--- src/slibc-error.c | 1 + src/string/strerror.c | 5 +++-- src/wchar/wcsspn.c | 12 ++++++++---- 6 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/assert.c b/src/assert.c index 8e7561a..ffd61a3 100644 --- a/src/assert.c +++ b/src/assert.c @@ -50,7 +50,7 @@ void __assert_fail(const char* expression, int errnum, const char* file, int lin tty, line, tty, tty, file, tty, tty, func, tty, - tty, expression != NULL, (expression ? expression : stderror(errnum)), tty); + tty, expression != NULL, (expression ? expression : strerror(errnum)), tty); fflush(NULL); /* Flush all streams. */ abort(); diff --git a/src/err.c b/src/err.c index caa8d3f..b873a93 100644 --- a/src/err.c +++ b/src/err.c @@ -19,6 +19,7 @@ #include #include #include +#include diff --git a/src/error.c b/src/error.c index eb73276..c560d2a 100644 --- a/src/error.c +++ b/src/error.c @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include @@ -85,7 +88,7 @@ void error_at_line(int status, int errnum, const char* filename, { va_list args; va_start(args, format); - verror_at_line(status, errnu, filename, linenum, format, args); + verror_at_line(status, errnum, filename, linenum, format, args); va_end(args); } @@ -130,7 +133,7 @@ void verror_at_line(int status, int errnum, const char* filename, } fprintf(stderr, "%(: %(\033[35m%)%s%(\033[0m%): %(\033[32m%)%u%(\033[0m%)%)%(: %s%)%(: %)", - filename != NULL, tty, filename, tty, tty, filenum, tty, + filename != NULL, tty, filename, tty, tty, linenum, tty, errnum != 0, strerror(errnum) /* TODO strerror is not MT-Safe */, format != NULL); if (filename != NULL) @@ -185,5 +188,5 @@ volatile int error_one_per_line = 1; * * This is a GNU extension. */ -volatile void (*error_print_progname)(void) = NULL; +void (*volatile error_print_progname)(void) = NULL; diff --git a/src/slibc-error.c b/src/slibc-error.c index 0680751..fd103d1 100644 --- a/src/slibc-error.c +++ b/src/slibc-error.c @@ -21,6 +21,7 @@ #include #include #include +#include diff --git a/src/string/strerror.c b/src/string/strerror.c index 87f3261..ccce049 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -40,7 +40,7 @@ */ char* strerror(int errnum) { - return strerror_l(errnum, CURRENT_LOCALE /* TODO not defined */); + return strerror_l(errnum, 0 /* TODO CURRENT_LOCALE, not defined */); } @@ -63,7 +63,8 @@ char* strerror(int errnum) char* strerror_l(int errnum, locale_t locale) { /* TODO implement strerror_l */ - return (void) errnum, (void) locale, NULL: + return strerror(errnum); + (void) locale; } diff --git a/src/wchar/wcsspn.c b/src/wchar/wcsspn.c index 239b863..63dc60b 100644 --- a/src/wchar/wcsspn.c +++ b/src/wchar/wcsspn.c @@ -53,12 +53,16 @@ size_t wcsspn(const wchar_t* string, const wchar_t* skipset) */ size_t wcscspn(const wchar_t* string, const wchar_t* stopset) { - size_t end = wcslen(string); - wchar_t* p; + size_t i, end = wcslen(string); + wchar_t* s; wchar_t c; while ((c = *stopset++)) - if (p = wcsnchr(string, c, end), p != NULL) - end = (size_t)(p - string); + for (i = 0, s = string; *s && (i < end); i++, s++) + if (*s == c) + { + end = (size_t)(s - string); + break; + } return end; } -- cgit v1.2.3-70-g09d2