diff options
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r-- | src/c/urweb.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 9836e502..dce33bf1 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -756,3 +756,16 @@ lw_Basis_string lw_Basis_boolToString(lw_context ctx, lw_Basis_bool b) { else return "True"; } + + +lw_Basis_int *lw_Basis_stringToInt(lw_context ctx, lw_Basis_string s) { + char *endptr; + lw_Basis_int n = strtoll(s, &endptr, 10); + + if (*s != '\0' && *endptr == '\0') { + lw_Basis_int *r = lw_malloc(ctx, sizeof(lw_Basis_int)); + *r = n; + return r; + } else + return NULL; +} |