Fixing unsigned int bug for 64-bit archs

This commit is contained in:
BlackLight 2011-02-09 03:09:41 +01:00
parent e1403d2719
commit ba1fa96fae

14
regex.c
View file

@ -161,8 +161,8 @@ char*
str_replace ( char *str, char *orig, char *rep ) str_replace ( char *str, char *orig, char *rep )
{ {
char *new_s = NULL; char *new_s = NULL;
unsigned int new_len = 0; unsigned long int new_len = 0;
unsigned int pos = 0; unsigned long int pos = 0;
if ( !( pos = (int) strstr ( str, orig ))) if ( !( pos = (int) strstr ( str, orig )))
return str; return str;
@ -173,17 +173,17 @@ str_replace ( char *str, char *orig, char *rep )
return NULL; return NULL;
memset ( new_s, 0, new_len ); memset ( new_s, 0, new_len );
strncpy ( new_s, str, pos - (unsigned int) str ); strncpy ( new_s, str, pos - (unsigned long int) str );
new_s[ pos - (unsigned int) str] = 0; new_s[ pos - (unsigned long int) str] = 0;
if ( rep ) if ( rep )
{ {
if ( strlen ( rep ) != 0 ) if ( strlen ( rep ) != 0 )
sprintf ( new_s + pos - (unsigned int) str, "%s%s", rep, (char*) pos + strlen ( orig )); sprintf ( new_s + pos - (unsigned long int) str, "%s%s", rep, (char*) pos + strlen ( orig ));
else else
sprintf ( new_s + pos - (unsigned int) str, "%s", (char*) pos + strlen ( orig )); sprintf ( new_s + pos - (unsigned long int) str, "%s", (char*) pos + strlen ( orig ));
} else { } else {
sprintf ( new_s + pos - (unsigned int) str, "%s", (char*) pos + strlen ( orig )); sprintf ( new_s + pos - (unsigned long int) str, "%s", (char*) pos + strlen ( orig ));
} }
return new_s; return new_s;