From af27ba4dd2ffdef8e4ee3abf187475c1b3303f71 Mon Sep 17 00:00:00 2001 From: Nima Talebi Date: Sun, 24 May 2009 00:26:23 +1000 Subject: Completed preliminary reimplementation of type() Updated test unit to match. Throw an exception instead of returning None/False in some functions. --- src/util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 58fd5ec..45bbd98 100644 --- a/src/util.c +++ b/src/util.c @@ -190,11 +190,12 @@ int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, return -1; } -int is_int(const char *s) +long is_int(const char *s) { + long i = strtol(s, (char **)NULL, 10); char _s[3]; - snprintf(_s, 3, "%ld", strtol(s, (char **)NULL, 10)); - return !strcmp(s, _s); + snprintf(_s, 3, "%ld", i); + return strcmp(s, _s)==0 ? i : -1; } -- cgit