Mercurial > urweb
diff src/c/urweb.c @ 292:6e665c7c96f6
Error-parsing ints
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 07 Sep 2008 12:15:46 -0400 |
parents | 0cc956a3216f |
children | 711aad3869d1 |
line wrap: on
line diff
--- a/src/c/urweb.c Sun Sep 07 11:56:53 2008 -0400 +++ b/src/c/urweb.c Sun Sep 07 12:15:46 2008 -0400 @@ -105,10 +105,6 @@ 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 @@ 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); +}