~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/bna/ogrbnaparser.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: ogrbnadataparser.c
 
2
 * $Id: ogrbnaparser.cpp 20996 2010-10-28 18:38:15Z rouault $
3
3
 *
4
4
 * Project:  BNA Parser
5
5
 * Purpose:  Parse a BNA record
146
146
    BNA_LINE_TOO_LONG
147
147
};
148
148
 
149
 
static int BNA_GetLine(char szLineBuffer[LINE_BUFFER_SIZE+1], FILE* f)
 
149
static int BNA_GetLine(char szLineBuffer[LINE_BUFFER_SIZE+1], VSILFILE* f)
150
150
{
151
151
    char* ptrCurLine = szLineBuffer;
152
 
    int nRead = VSIFRead(szLineBuffer, 1, LINE_BUFFER_SIZE, f);
 
152
    int nRead = VSIFReadL(szLineBuffer, 1, LINE_BUFFER_SIZE, f);
153
153
    szLineBuffer[nRead] = 0;
154
154
    if (nRead == 0)
155
155
    {
180
180
        if (ptrCurLine == szLineBuffer + LINE_BUFFER_SIZE - 1)
181
181
        {
182
182
            char c;
183
 
            nRead = VSIFRead(&c, 1, 1, f);
 
183
            nRead = VSIFReadL(&c, 1, 1, f);
184
184
            if (nRead == 1)
185
185
            {
186
186
                if (c == 0x0a)
189
189
                }
190
190
                else
191
191
                {
192
 
                    VSIFSeek(f, -1, SEEK_CUR);
 
192
                    VSIFSeekL(f, VSIFTellL(f) - 1, SEEK_SET);
193
193
                }
194
194
            }
195
195
        }
196
196
        else if (ptrCurLine[1] == 0x0a)
197
197
        {
198
 
            VSIFSeek(f, ptrCurLine + 2 - (szLineBuffer + nRead), SEEK_CUR);
 
198
            VSIFSeekL(f, VSIFTellL(f) + ptrCurLine + 2 - (szLineBuffer + nRead), SEEK_SET);
199
199
        }
200
200
        else
201
201
        {
202
 
            VSIFSeek(f, ptrCurLine + 1 - (szLineBuffer + nRead), SEEK_CUR);
 
202
            VSIFSeekL(f, VSIFTellL(f) + ptrCurLine + 1 - (szLineBuffer + nRead), SEEK_SET);
203
203
        }
204
204
    }
205
205
    else /* *ptrCurLine == 0x0a */
206
206
    {
207
 
        VSIFSeek(f, ptrCurLine + 1 - (szLineBuffer + nRead), SEEK_CUR);
 
207
        VSIFSeekL(f, VSIFTellL(f) + ptrCurLine + 1 - (szLineBuffer + nRead), SEEK_SET);
208
208
    }
209
209
    *ptrCurLine = 0;
210
210
 
212
212
}
213
213
 
214
214
 
215
 
BNARecord* BNA_GetNextRecord(FILE* f,
 
215
BNARecord* BNA_GetNextRecord(VSILFILE* f,
216
216
                             int* ok,
217
217
                             int* curLine,
218
218
                             int verbose,
222
222
    char c;
223
223
    int inQuotes = FALSE;
224
224
    int numField = 0;
225
 
    const char* ptrBeginningOfNumber = NULL;
 
225
    char* ptrBeginningOfNumber = NULL;
226
226
    int exponentFound = 0;
227
227
    int exponentSignFound = 0;
228
228
    int dotFound = 0;
253
253
          break;
254
254
      }
255
255
 
256
 
      const char* ptrCurLine = szLineBuffer;
 
256
      char* ptrCurLine = szLineBuffer;
257
257
      const char* ptrBeginLine = szLineBuffer;
258
258
 
259
259
      if (*ptrCurLine == 0)
313
313
            if (interestFeatureType == BNA_READ_ALL ||
314
314
                interestFeatureType == currentFeatureType)
315
315
            {
 
316
              char* pszComma = strchr(ptrBeginningOfNumber, ',');
 
317
              if (pszComma)
 
318
                  *pszComma = '\0';
316
319
              record->tabCoords[(numField - nbExtraId - NB_MIN_BNA_IDS - 1) / 2]
317
320
                               [1 - ((numField - nbExtraId) % 2)] =
318
321
                  CPLAtof(ptrBeginningOfNumber);
 
322
              if (pszComma)
 
323
                  *pszComma = ',';
319
324
            }
320
325
            if (numField == NB_MIN_BNA_IDS + 1 + nbExtraId + 2 * record->nCoords - 1)
321
326
            {
451
456
            if (interestFeatureType == BNA_READ_ALL ||
452
457
                interestFeatureType == currentFeatureType)
453
458
            {
 
459
              char* pszComma = strchr(ptrBeginningOfNumber, ',');
 
460
              if (pszComma)
 
461
                  *pszComma = '\0';
454
462
              record->tabCoords[(numField - nbExtraId - NB_MIN_BNA_IDS - 1) / 2]
455
463
                               [1 - ((numField - nbExtraId) % 2)] =
456
464
                  CPLAtof(ptrBeginningOfNumber);
 
465
              if (pszComma)
 
466
                  *pszComma = ',';
457
467
            }
458
468
            if (numField == NB_MIN_BNA_IDS + 1 + nbExtraId + 2 * record->nCoords - 1)
459
469
            {