summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 12:15:46 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 12:15:46 -0400
commit1f893091967ed6a9bd8469a62ddf4017e87d563d (patch)
tree5985b4036cf586410f210927f33ac86a4c6af0f9 /src/c
parentf2829abe30366bc78ce8e5bd6272fac06a7f5b84 (diff)
Error-parsing ints
Diffstat (limited to 'src/c')
-rw-r--r--src/c/urweb.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index bf697340..1286ca5e 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -105,10 +105,6 @@ __attribute__((noreturn)) void lw_error(lw_context ctx, failure_kind fk, const c
longjmp(ctx->jmp_buf, fk);
}
-__attribute__((noreturn)) void lw_Basis_error(lw_context ctx, const char *s) {
- lw_error(ctx, FATAL, s);
-}
-
char *lw_error_message(lw_context ctx) {
return ctx->error_message;
}
@@ -793,3 +789,13 @@ lw_Basis_bool *lw_Basis_stringToBool(lw_context ctx, lw_Basis_string s) {
else
return NULL;
}
+
+lw_Basis_int lw_Basis_stringToInt_error(lw_context ctx, lw_Basis_string s) {
+ char *endptr;
+ lw_Basis_int n = strtoll(s, &endptr, 10);
+
+ if (*s != '\0' && *endptr == '\0')
+ return n;
+ else
+ lw_error(ctx, FATAL, "Can't parse int: %s", s);
+}