Bug #9739 Updated: Reading logical values doesn't work: fix attached
| From: | sniper@php.net | Date: | Wed, 31 Oct 2001 00:14:19 +0000 |
| Subject: | Bug #9739 Updated: Reading logical values doesn't work: fix attached | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-69380@lists.php.net to get a copy of this message | ||
ID: 9739
Updated by: sniper
Reported By: widman@cardiothink.com
Old Status: Open
Status: Closed
Bug Type: dBase related
Operating System: Redhat 6.2
PHP Version: 4.0.4pl1
New Comment:
This should be fixed in latest CVS. Try the latest snapshot
from http://snaps.php.net/
Previous Comments:
------------------------------------------------------------------------
[2001-03-14 06:31:51] widman@cardiothink.com
Reading logical values doesn't work, apparently because in
dbase.c logicals are interpreted as integers. So, the following patch treats logicals as their own
selves. If the original value is 'T' or 'Y', the imported value is 1. If the
original value is 'F' or 'N', the imported value is 0. Otherwise, the imported
value is whatever ' ' maps into (probably 0). I have verified that the first two sets of
cases works fine.
The following diff was generated with "diff -wrc". I apologize for the wrap-around in
this textarea. I'll be happy to email the original to you if you like, or you can find it at
http://www.tcacc.org/dbase.diff
*** dbase.c Tue Mar 13 23:40:10 2001
--- dbase.c.DISTRIB Thu Nov 2 16:08:04 2000
***************
*** 459,485 ****
case 'D':
add_next_index_string(return_value,str_value,1);
break;
! case 'N':
if (cur_f->db_fdc == 0) {
add_next_index_long(return_value, strtol(str_value, NULL, 10));
} else {
add_next_index_double(return_value, atof(str_value));
}
break;
- case 'L': /* we used to FALLS THROUGH, but now we check for T/Y and
F/N
- and insert 1 or 0, respectively. db_fdc is the number of
- decimals, which we don't care about. 3/14/01 LEW */
- if ( (*str_value == 'T') || ( *str_value == 'Y' ) ){
- add_next_index_long(return_value, strtol("1", NULL, 10));
- } else {
- if ( (*str_value == 'F') || ( *str_value == 'N' ) ){
- add_next_index_long(return_value, strtol("0", NULL,
10));
- }
- else {
- add_next_index_long(return_value, strtol(" ", NULL,
10));
- }
- }
- break;
case 'M':
/* this is a memo field. don't know how to deal with
this yet */
--- 459,472 ----
case 'D':
add_next_index_string(return_value,str_value,1);
break;
! case 'N': /* FALLS THROUGH */
! case 'L': /* FALLS THROUGH */
if (cur_f->db_fdc == 0) {
add_next_index_long(return_value, strtol(str_value, NULL, 10));
} else {
add_next_index_double(return_value, atof(str_value));
}
break;
case 'M':
/* this is a memo field. don't know how to deal with
this yet */
***************
*** 550,577 ****
case 'D':
add_assoc_string(return_value,cur_f->db_fname,str_value,1);
break;
! case 'N':
if (cur_f->db_fdc == 0) {
add_assoc_long(return_value,cur_f->db_fname,strtol(str_value, NULL
, 10));
} else {
add_assoc_double(return_value,cur_f->db_fname,atof(str_value));
break;
- case 'L': /* we used to FALLS THROUGH, but now we check for T/Y
and F/N
- and insert 1 or 0, respectively. db_fdc is the number of
- decimals, which we don't care about. 3/14/01 LEW */
- if ( (*str_value == 'T') || ( *str_value == 'Y'
) ){
-
add_assoc_long(return_value,cur_f->db_fname,strtol("1", NULL, 10));
- } else {
- if ( (*str_value == 'F') || ( *str_value ==
'N' ) ){
-
add_assoc_long(return_value,cur_f->db_fname,strtol("0", NULL, 10));
- }
- else {
- add_assoc_long(return_value,cur_f->db_fname,strtol("
", NULL, 10));
- }
- }
- break;
-
case 'M':
/* this is a memo field. don't know how to deal with this yet
*/
break;
--- 537,550 ----
case 'D':
add_assoc_string(return_value,cur_f->db_fname,str_value,1);
break;
! case 'N': /* FALLS THROUGH */
! case 'L': /* FALLS THROUGH */
if (cur_f->db_fdc == 0) {
add_assoc_long(return_value,cur_f->db_fname,strtol(str_value, NULL
, 10));
} else {
add_assoc_double(return_value,cur_f->db_fname,atof(str_value));
}
break;
case 'M':
/* this is a memo field. don't know how to deal with this yet
*/
break;
}
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=9739&edit=1