aboutsummaryrefslogtreecommitdiffhomepage
path: root/util.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-01-09 13:20:05 +1000
committerGravatar axel <axel@liljencrantz.se>2007-01-09 13:20:05 +1000
commitb70092e28140dc1725f568d0522e0a26507a0964 (patch)
tree07235edceca6eba99c437e6ae80c092a17557eb2 /util.c
parent602eac89c4f446b46d9a4023b06f878f07c3abac (diff)
Check for errors during string to integer conversion in various places
darcs-hash:20070109032005-ac50b-29514c9c8c19c70b7cfe7670a5c74899f316931f.gz
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/util.c b/util.c
index f6de95ca..e709ce4d 100644
--- a/util.c
+++ b/util.c
@@ -1112,9 +1112,23 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b )
if( iswdigit( *a ) && iswdigit( *b ) )
{
wchar_t *aend, *bend;
- long al = wcstol( a, &aend, 10 );
- long bl = wcstol( b, &bend, 10 );
- int diff = al - bl;
+ long al;
+ long bl;
+ int diff;
+
+ errno = 0;
+ al = wcstol( a, &aend, 10 );
+ bl = wcstol( b, &bend, 10 );
+
+ if( errno )
+ {
+ /*
+ Huuuuuuuuge numbers - fall back to regular string comparison
+ */
+ return wcscmp( a, b );
+ }
+
+ diff = al - bl;
if( diff )
return diff>0?2:-2;