php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #52112
Patch bug52112 revision 2016-08-06 12:20 UTC by cmb@php.net

Patch bug52112 for dbase Bug #52112

Patch version 2016-08-06 12:20 UTC

Return to Bug #52112 | Download this patch
Patch Revisions:

Developer: cmb@php.net

Index: dbase.c
===================================================================
--- dbase.c	(revision 339808)
+++ dbase.c	(working copy)
@@ -513,17 +513,17 @@
 					errno = errno_save;
 				} else {
 					if (!assoc) {
-						add_next_index_double(return_value, atof(str_value));
+						add_next_index_double(return_value, zend_strtod(str_value, NULL));
 					} else {
-						add_assoc_double(return_value, cur_f->db_fname, atof(str_value));
+						add_assoc_double(return_value, cur_f->db_fname, zend_strtod(str_value, NULL));
 					}
 				}
 				break;
 			case 'F':
 				if (!assoc) {
-					add_next_index_double(return_value, atof(str_value));
+					add_next_index_double(return_value, zend_strtod(str_value, NULL));
 				} else {
-					add_assoc_double(return_value, cur_f->db_fname, atof(str_value));
+					add_assoc_double(return_value, cur_f->db_fname, zend_strtod(str_value, NULL));
 				}
 				break;
 			case 'L':	/* we used to FALL THROUGH, but now we check for T/Y and F/N
Index: tests/bug52112.phpt
===================================================================
--- tests/bug52112.phpt	(nonexistent)
+++ tests/bug52112.phpt	(working copy)
@@ -0,0 +1,62 @@
+--TEST--
+Bug #52112 (dbase_get_record() returns integer instead of decimal value)
+--SKIPIF--
+<?php
+if (!extension_loaded('dbase')) die('skip dbase extension not available');
+$locales = array('de_DE.UTF-8', 'de-DE');
+if (array_search(setlocale(LC_NUMERIC, $locales), $locales) === false) {
+    die('skip German locale not available');
+}
+?>
+--FILE--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'dbase_get_record_basic.dbf';
+copy(__DIR__ . DIRECTORY_SEPARATOR . 'example.dbf', $filename);
+setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de-DE');
+
+$db = dbase_open($filename, 0);
+var_dump($db);
+
+var_dump(dbase_get_record($db, 1));
+var_dump(dbase_get_record_with_names($db, 1));
+
+var_dump(dbase_close($db));
+?>
+===DONE===
+--EXPECTF--
+int(%d)
+array(6) {
+  [0]=>
+  int(1)
+  [1]=>
+  string(25) "dBase III                "
+  [2]=>
+  string(8) "19840501"
+  [3]=>
+  int(1)
+  [4]=>
+  float(123,45)
+  ["deleted"]=>
+  int(0)
+}
+array(6) {
+  ["ID"]=>
+  int(1)
+  ["NAME"]=>
+  string(25) "dBase III                "
+  ["RELEASED"]=>
+  string(8) "19840501"
+  ["SUPORTED"]=>
+  int(1)
+  ["PRICE"]=>
+  float(123,45)
+  ["deleted"]=>
+  int(0)
+}
+bool(true)
+===DONE===
+--CLEAN--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'dbase_get_record_basic.dbf';
+unlink($filename);
+?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 05:01:33 2024 UTC