php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9739 Reading logical values doesn't work: fix attached
Submitted: 2001-03-14 06:31 UTC Modified: 2001-10-30 19:14 UTC
From: widman at cardiothink dot com Assigned:
Status: Closed Package: dBase related
PHP Version: 4.0.4pl1 OS: Redhat 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: widman at cardiothink dot com
New email:
PHP Version: OS:

 

 [2001-03-14 06:31 UTC] widman at cardiothink dot 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;
                             }


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-30 19:14 UTC] sniper@php.net
This should be fixed in latest CVS. Try the latest snapshot
from http://snaps.php.net/

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC