Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
291:550100a44cca | 292:6e665c7c96f6 |
---|---|
101 va_start(ap, fmt); | 101 va_start(ap, fmt); |
102 | 102 |
103 vsnprintf(ctx->error_message, ERROR_BUF_LEN, fmt, ap); | 103 vsnprintf(ctx->error_message, ERROR_BUF_LEN, fmt, ap); |
104 | 104 |
105 longjmp(ctx->jmp_buf, fk); | 105 longjmp(ctx->jmp_buf, fk); |
106 } | |
107 | |
108 __attribute__((noreturn)) void lw_Basis_error(lw_context ctx, const char *s) { | |
109 lw_error(ctx, FATAL, s); | |
110 } | 106 } |
111 | 107 |
112 char *lw_error_message(lw_context ctx) { | 108 char *lw_error_message(lw_context ctx) { |
113 return ctx->error_message; | 109 return ctx->error_message; |
114 } | 110 } |
791 else if (!strcasecmp (s, "False")) | 787 else if (!strcasecmp (s, "False")) |
792 return &false; | 788 return &false; |
793 else | 789 else |
794 return NULL; | 790 return NULL; |
795 } | 791 } |
792 | |
793 lw_Basis_int lw_Basis_stringToInt_error(lw_context ctx, lw_Basis_string s) { | |
794 char *endptr; | |
795 lw_Basis_int n = strtoll(s, &endptr, 10); | |
796 | |
797 if (*s != '\0' && *endptr == '\0') | |
798 return n; | |
799 else | |
800 lw_error(ctx, FATAL, "Can't parse int: %s", s); | |
801 } |