Opened 13 years ago
Closed 13 years ago
#4123 closed defect (fixed)
bug in gdal-1.8.0/ogr/ogrsf_frmts/mitab/mitab_utils.cpp
Reported by: | iskander | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.8.1 |
Component: | OGR_SF | Version: | 1.8.0 |
Severity: | normal | Keywords: | MITAB MIF basename parsing |
Cc: | Daniel Morissette |
Description (last modified by )
Dear
we are using GDAL 1.8.0 and we found a bug in this method when reading MIF file that has basename with '.' (e.g. shape.001.MIF)
file location gdal-1.8.0/ogr/ogrsf_frmts/mitab/mitab_utils.cpp
///code of the method /********************************************************************** * TABGetBasename() * * Extract the basename part of a complete file path. * * Returns a newly allocated string without the leading path (dirs) and * the extenstion. The returned string should be freed using CPLFree(). **********************************************************************/ char *TABGetBasename(const char *pszFname) { const char *pszTmp = NULL; /*----------------------------------------------------------------- * Skip leading path or use whole name if no path dividers are * encountered. *----------------------------------------------------------------*/ pszTmp = pszFname + strlen(pszFname) - 1; while ( pszTmp != pszFname && *pszTmp != '/' && *pszTmp != '\\' ) pszTmp--; if( pszTmp != pszFname ) pszTmp++; /*----------------------------------------------------------------- * Now allocate our own copy and remove extension *----------------------------------------------------------------*/ char *pszBasename = CPLStrdup(pszTmp); int i; //>>>> your old code //for(i=0; pszBasename[i] != '\0'; i++) //>>>> //>>>> our modification for(i=strlen(pszBasename)-1; i >= 0; i--) //>>>> { if (pszBasename[i] == '.') { pszBasename[i] = '\0'; break; } } return pszBasename; }
we replaced " for(i=0; pszBasename[i] != '\0'; i++)" by this " for(i=strlen(pszBasename)-1; i >= 0; i--)" and it worked TABGetBasename() doesn't support basename with . It should look for the '.' in the basename starting from the basename end
Please rectify this minor bug
Best Regards Iskander Benhadj
Change History (3)
comment:1 by , 13 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
Keywords: | MITAB added |
Priority: | high → normal |
Status: | new → assigned |
comment:3 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
I'll address this in GDAL and upstream in mitab. Daniel let me know if there is something that looks wrong about the fellows proposed solution.