]> granicus.if.org Git - php/commitdiff
MFH: implement #38357 (dbase_open can't open DBase 3 dbf file)
authorMichael Wallner <mike@php.net>
Tue, 8 Aug 2006 15:55:27 +0000 (15:55 +0000)
committerMichael Wallner <mike@php.net>
Tue, 8 Aug 2006 15:55:27 +0000 (15:55 +0000)
NEWS
ext/dbase/dbase.c
ext/dbase/dbf_head.c

diff --git a/NEWS b/NEWS
index d32738ebc5b557332e949d93087200bb22640bb1..69d589b2a54d5deeb2958b654a4c45300c9e9baf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PHP                                                                        NEWS
 - Added an optional boolean parameter to memory_get_usage() and 
   memory_get_peak_usage() to get memory size allocated by emalloc() or real
   size of memory allocated from system. (Dmitry)
+- Implemented #38357 (dbase_open can't open DBase 3 dbf file).
+  (rodrigo at fabricadeideias dot com, Mike)
 
 - Moved extensions to PECL:
   . ext/filepro (Derick, Tony)
index d9fdf36bb0bc5e777b5feea9dcf79687aaa1e853..2862db46504ba9d6b66426824d438a88037ddda2 100644 (file)
@@ -503,6 +503,13 @@ static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc)
                                        }
                                }
                                break;
+                       case 'F':
+                               if (!assoc) {
+                                       add_next_index_double(return_value, atof(str_value));
+                               } else {
+                                       add_assoc_double(return_value, cur_f->db_fname, atof(str_value));
+                               }
+                               break;
                        case 'L':       /* we used to FALL 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/2001 LEW */
@@ -690,6 +697,9 @@ PHP_FUNCTION(dbase_create)
                case 'D':
                        cur_f->db_flen = 8;
                        break;
+               case 'F':
+                       cur_f->db_flen = 20;
+                       break;
                case 'N':
                case 'C':
                        /* field length */
@@ -862,6 +872,7 @@ PHP_FUNCTION(dbase_get_header_info)
                        case 'N': add_assoc_string(row, "type", "number", 1);           break;
                        case 'L': add_assoc_string(row, "type", "boolean", 1);          break;
                        case 'M': add_assoc_string(row, "type", "memo", 1);                     break;
+                       case 'F': add_assoc_string(row, "type", "float", 1);     break;
                        default:  add_assoc_string(row, "type", "unknown", 1);          break;
                }
                
index be3fe5cd98151ec0bcd5d9f77f78350869f22c82..24b3d06ac954108281d5e299962bdf77994fca5b 100644 (file)
@@ -148,6 +148,7 @@ int get_dbf_field(dbhead_t *dbh, dbfield_t *dbf)
        dbf->db_type = dbfield.dbf_type;
        switch (dbf->db_type) {
            case 'N':
+           case 'F':
                dbf->db_flen = dbfield.dbf_flen[0];
                dbf->db_fdc = dbfield.dbf_flen[1];
                break;
@@ -231,6 +232,7 @@ char *get_dbf_f_fmt(dbfield_t *dbf)
           case 'N':
           case 'L':
           case 'D':
+          case 'F':
                sprintf(format, "%%%ds", dbf->db_flen);
                break;
           case 'M':