Mercurial > urweb
diff src/c/urweb.c @ 288:4260ad920c36
Converting string to int
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 07 Sep 2008 11:33:13 -0400 |
parents | ffe5b01908ae |
children | 0cc956a3216f |
line wrap: on
line diff
--- a/src/c/urweb.c Sun Sep 07 10:52:51 2008 -0400 +++ b/src/c/urweb.c Sun Sep 07 11:33:13 2008 -0400 @@ -756,3 +756,16 @@ 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; +}