Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
287:3ed7a7c7b060 | 288:4260ad920c36 |
---|---|
754 if (b == lw_Basis_False) | 754 if (b == lw_Basis_False) |
755 return "False"; | 755 return "False"; |
756 else | 756 else |
757 return "True"; | 757 return "True"; |
758 } | 758 } |
759 | |
760 | |
761 lw_Basis_int *lw_Basis_stringToInt(lw_context ctx, lw_Basis_string s) { | |
762 char *endptr; | |
763 lw_Basis_int n = strtoll(s, &endptr, 10); | |
764 | |
765 if (*s != '\0' && *endptr == '\0') { | |
766 lw_Basis_int *r = lw_malloc(ctx, sizeof(lw_Basis_int)); | |
767 *r = n; | |
768 return r; | |
769 } else | |
770 return NULL; | |
771 } |