Skip to content

Commit c3398b7

Browse files
committed
Support uninitialized logical fields
dBASE allows logical fields to be uninitialized and marks such fields with '?'. To be able to distinguish such values from false, we retrieve them as NULL. git-svn-id: http://svn.php.net/repository/pecl/dbase/trunk@340804 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 5df341f commit c3398b7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

dbase.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc)
431431
} else {
432432
add_assoc_bool(return_value, cur_f->db_fname, 1);
433433
}
434+
} else if (*str_value == '?') {
435+
if (!assoc) {
436+
add_next_index_null(return_value);
437+
} else {
438+
add_assoc_null(return_value, cur_f->db_fname);
439+
}
434440
} else {
435441
if (!assoc) {
436442
add_next_index_bool(return_value, 0);

tests/type_logical.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $db = dbase_create(
1313
)
1414
);
1515

16-
foreach (array('T', 'Y', 'F', 'N', ' ', '1', '0') as $flag) {
16+
foreach (array('T', 'Y', 'F', 'N', ' ', '1', '0', '?') as $flag) {
1717
dbase_add_record($db, array($flag));
1818
}
1919

@@ -40,6 +40,8 @@ bool(false)
4040
bool(false)
4141
bool(false)
4242
bool(false)
43+
NULL
44+
NULL
4345
===DONE===
4446
--CLEAN--
4547
<?php

0 commit comments

Comments
 (0)