Skip to content

Commit

Permalink
Shapefile: recogize ' 0' as a null date
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and github-actions[bot] committed Nov 28, 2023
1 parent 1723661 commit 813cca6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 6 additions & 1 deletion ogr/ogrsf_frmts/shape/dbfopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,12 @@ static bool DBFIsValueNULL(char chType, const char *pszValue)

case 'D':
/* NULL date fields have value "00000000" */
return strncmp(pszValue, "00000000", 8) == 0;
/* Some DBF files have fields filled with spaces */
/* (trimmed by DBFReadStringAttribute) to indicate null */
/* values for dates (#4265). */
/* And others have ' 0': https://lists.osgeo.org/pipermail/gdal-dev/2023-November/058010.html */
return strncmp(pszValue, "00000000", 8) == 0 ||
strcmp(pszValue, " ") == 0 || strcmp(pszValue, "0") == 0;

case 'L':
/* NULL boolean fields have value "?" */
Expand Down
6 changes: 0 additions & 6 deletions ogr/ogrsf_frmts/shape/shape2ogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,12 +1447,6 @@ OGRFeature *SHPReadOGRFeature(SHPHandle hSHP, DBFHandle hDBF,
const char *const pszDateValue =
DBFReadStringAttribute(hDBF, iShape, iField);

// Some DBF files have fields filled with spaces
// (trimmed by DBFReadStringAttribute) to indicate null
// values for dates (#4265).
if (pszDateValue[0] == '\0')
continue;

OGRField sFld;
memset(&sFld, 0, sizeof(sFld));

Expand Down

0 comments on commit 813cca6

Please sign in to comment.