summaryrefslogtreecommitdiff
path: root/lib/fmt.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-05 01:58:08 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-05 01:58:26 +0100
commit62d27d872769ebcd79a931fa07b1128576e65e65 (patch)
tree0a99e87809c9055dcdcfbd9ed4bec1a72534ced9 /lib/fmt.c
parenta6c056ce150bd0339d5325edc18717b2d02a5b8d (diff)
error: remove and use standard errno codes instead
This change also adds strerror to string.h.
Diffstat (limited to 'lib/fmt.c')
-rw-r--r--lib/fmt.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/fmt.c b/lib/fmt.c
index 0940f24..f180606 100644
--- a/lib/fmt.c
+++ b/lib/fmt.c
@@ -24,6 +24,7 @@
*/
#include <assert.h>
+#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdarg.h>
@@ -35,8 +36,6 @@
#include <lib/fmt.h>
#include <lib/macros.h>
-#include <src/error.h>
-
/*
* XXX This type is specified by POSIX. Directly declare it for simplicity.
*/
@@ -410,12 +409,12 @@ fmt_sprintf_state_consume(struct fmt_sprintf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return ERROR_IO;
+ return EIO;
}
if (c != '%') {
fmt_sprintf_state_produce_raw_char(state, c);
- return ERROR_AGAIN;
+ return EAGAIN;
}
fmt_sprintf_state_consume_flags(state);
@@ -794,7 +793,7 @@ fmt_vsnprintf(char *str, size_t size, const char *format, va_list ap)
for (;;) {
error = fmt_sprintf_state_consume(&state);
- if (error == ERROR_AGAIN) {
+ if (error == EAGAIN) {
continue;
} else if (error) {
break;
@@ -1075,7 +1074,7 @@ fmt_sscanf_state_discard_char(struct fmt_sscanf_state *state, char c)
state->nr_convs = EOF;
}
- return ERROR_INVAL;
+ return EINVAL;
}
return 0;
@@ -1092,7 +1091,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state)
c = fmt_consume(&state->format);
if (c == '\0') {
- return ERROR_IO;
+ return EIO;
}
if (c != '%') {
@@ -1102,7 +1101,7 @@ fmt_sscanf_state_consume(struct fmt_sscanf_state *state)
return error;
}
- return ERROR_AGAIN;
+ return EAGAIN;
}
fmt_sscanf_state_consume_flags(state);
@@ -1194,7 +1193,7 @@ fmt_sscanf_state_produce_int(struct fmt_sscanf_state *state)
if (i == 0) {
if (c == '\0') {
fmt_sscanf_state_report_error(state);
- return ERROR_INVAL;
+ return EINVAL;
}
buf[0] = '0';
@@ -1388,7 +1387,7 @@ fmt_sscanf_state_produce_str(struct fmt_sscanf_state *state)
if (state->str == orig) {
fmt_sscanf_state_report_error(state);
- return ERROR_INVAL;
+ return EINVAL;
}
if (dest != NULL) {
@@ -1423,7 +1422,7 @@ fmt_sscanf_state_produce(struct fmt_sscanf_state *state)
return fmt_sscanf_state_discard_char(state, '%');
default:
fmt_sscanf_state_report_error(state);
- return ERROR_INVAL;
+ return EINVAL;
}
}
@@ -1451,7 +1450,7 @@ fmt_vsscanf(const char *str, const char *format, va_list ap)
for (;;) {
error = fmt_sscanf_state_consume(&state);
- if (error == ERROR_AGAIN) {
+ if (error == EAGAIN) {
continue;
} else if (error) {
break;