Re: cvs: php4 /ext/dbase dbase.c

From: Date: Fri, 14 Dec 2001 09:24:19 +0000
Subject: Re: cvs: php4 /ext/dbase dbase.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8622@lists.php.net to get a copy of this message
> vlad Thu Dec 13 23:22:01 2001 EDT > > Modified files: > /php4/ext/dbase dbase.c > Log: > Fixed bug #5993. Now if the result returned from a database is bigger > than a long, dbase_get_record() and dbase_get_record_with_names() will > return a string instead. > # Need to update documentation to reflect that change > @ Fixed problem with dbase not returning very large (larger than long) > @ integers properly. (Vlad) > MFH please? :) -Sterling > > Index: php4/ext/dbase/dbase.c > diff -u php4/ext/dbase/dbase.c:1.53 php4/ext/dbase/dbase.c:1.54 > --- php4/ext/dbase/dbase.c:1.53 Tue Dec 11 10:29:03 2001 > +++ php4/ext/dbase/dbase.c Thu Dec 13 23:22:01 2001 > @@ -16,7 +16,7 @@ > +----------------------------------------------------------------------+ > */ > > -/* $Id: dbase.c,v 1.53 2001/12/11 15:29:03 sebastian Exp $ */ > +/* $Id: dbase.c,v 1.54 2001/12/14 04:22:01 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) { > @@ -476,7 +478,16 @@ > case 'I': /* FALLS THROUGH */ > 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)); > } > @@ -528,6 +539,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) { > @@ -568,7 +581,16 @@ > case 'I': /* FALLS THROUGH */ > 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)); > } > > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net > For additional commands, e-mail: php-cvs-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.cvs (#8622) next »