cvs: php4(PHP_4_0_7) /ext/dbase dbase.c

From: Date: Fri, 14 Dec 2001 10:21:05 +0000
Subject: cvs: php4(PHP_4_0_7) /ext/dbase dbase.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8631@lists.php.net to get a copy of this message
vlad Fri Dec 14 05:21:05 2001 EDT Modified files: (Branch: PHP_4_0_7) /php4/ext/dbase dbase.c Log: MFH Index: php4/ext/dbase/dbase.c diff -u php4/ext/dbase/dbase.c:1.47.2.2 php4/ext/dbase/dbase.c:1.47.2.3 --- php4/ext/dbase/dbase.c:1.47.2.2 Thu Oct 11 19:51:16 2001 +++ php4/ext/dbase/dbase.c Fri Dec 14 05:21:04 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbase.c,v 1.47.2.2 2001/10/11 23:51:16 ssb Exp $ */ +/* $Id: dbase.c,v 1.47.2.3 2001/12/14 10:21:04 vlad Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -431,6 +431,8 @@ dbfield_t *dbf, *cur_f; char *data, *fnp, *str_value; size_t cursize = 0; + long overflow_test; + int errno_save; DBase_TLS_VARS; if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { @@ -475,7 +477,16 @@ break; case 'N': if (cur_f->db_fdc == 0) { - add_next_index_long(return_value, strtol(str_value, NULL, 10)); + /* Large integers in dbase can be larger than long */ + errno_save = errno; + overflow_test = strtol(str_value, NULL, 10); + if (errno == ERANGE) { + /* If the integer is too large, keep it as string */ + add_next_index_string(return_value, str_value, 1); + } else { + add_next_index_long(return_value, overflow_test); + } + errno = errno_save; } else { add_next_index_double(return_value, atof(str_value)); } @@ -527,6 +538,8 @@ int dbh_type; dbfield_t *dbf, *cur_f; char *data, *fnp, *str_value; + long overflow_test; + int errno_save; DBase_TLS_VARS; if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { @@ -566,7 +579,16 @@ break; case 'N': if (cur_f->db_fdc == 0) { - add_assoc_long(return_value, cur_f->db_fname, strtol(str_value, NULL, 10)); + /* Large integers in dbase can be larger than long */ + errno_save = errno; + overflow_test = strtol(str_value, NULL, 10); + if (errno == ERANGE) { + /* If the integer is too large, keep it as string */ + add_assoc_string(return_value, cur_f->db_fname, str_value, 1); + } else { + add_assoc_long(return_value, cur_f->db_fname, overflow_test); + } + errno = errno_save; } else { add_assoc_double(return_value, cur_f->db_fname, atof(str_value)); }

« previous php.cvs (#8631) next »