2086 int nOldRecordLength;
2093 if (iField < 0 || iField >= psDBF->
nFields)
2137 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth % 256);
2138 pszFInfo[17] =
STATIC_CAST(
unsigned char, nWidth / 256);
2142 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth);
2143 pszFInfo[17] =
STATIC_CAST(
unsigned char, nDecimals);
2149 if (nWidth != nOldWidth)
2151 for (i = iField + 1; i < psDBF->
nFields; i++)
2167 if (nWidth < nOldWidth || (nWidth == nOldWidth && chType != chOldType))
2170 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2173 pszOldField[nOldWidth] = 0;
2176 for (iRecord = 0; iRecord < psDBF->
nRecords; iRecord++)
2183 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2185 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2188 if (nWidth != nOldWidth)
2190 if ((chOldType ==
'N' || chOldType ==
'F' || chOldType ==
'D') && pszOldField[0] ==
' ')
2193 memmove( pszRecord + nOffset,
2194 pszRecord + nOffset + nOldWidth - nWidth,
2197 if (nOffset + nOldWidth < nOldRecordLength)
2199 memmove( pszRecord + nOffset + nWidth,
2200 pszRecord + nOffset + nOldWidth,
2201 nOldRecordLength - (nOffset + nOldWidth));
2208 memset( pszRecord + nOffset, chFieldFill, nWidth);
2234 else if (nWidth > nOldWidth)
2237 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2240 pszOldField[nOldWidth] = 0;
2243 for (iRecord = psDBF->
nRecords - 1; iRecord >= 0; iRecord--)
2250 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2252 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2255 if (nOffset + nOldWidth < nOldRecordLength)
2257 memmove( pszRecord + nOffset + nWidth,
2258 pszRecord + nOffset + nOldWidth,
2259 nOldRecordLength - (nOffset + nOldWidth));
2265 memset( pszRecord + nOffset, chFieldFill, nWidth);
2269 if ((chOldType ==
'N' || chOldType ==
'F'))
2272 memmove( pszRecord + nOffset + nWidth - nOldWidth,
2273 pszRecord + nOffset, nOldWidth );
2274 memset( pszRecord + nOffset,
' ', nWidth - nOldWidth );
2279 memset(pszRecord + nOffset + nOldWidth,
' ', nWidth - nOldWidth);
static int DBFIsValueNULL(char chType, const char *pszValue)
#define STATIC_CAST(type, x)
#define END_OF_FILE_CHARACTER
static void * SfRealloc(void *pMem, int nNewSize)
static char DBFGetNullCharacter(char chType)
static int DBFFlushRecord(DBFHandle psDBF)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)
#define XBASE_FLDNAME_LEN_WRITE
#define XBASE_FLD_MAX_WIDTH
int bCurrentRecordModified
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)