Bläddra i källkod

cmCsv.c Included some input file line numbers in some error message.

master
kevin 12 år sedan
förälder
incheckning
36430c0d0a
1 ändrade filer med 7 tillägg och 4 borttagningar
  1. 7
    4
      cmCsv.c

+ 7
- 4
cmCsv.c Visa fil

@@ -330,7 +330,7 @@ cmCsvRC_t  _cmCsvAllocCell( cmCsv_t* p, unsigned symId, unsigned flags, unsigned
330 330
 
331 331
   // allocate cell memory
332 332
   if(( cp = cmLHeapAllocZ(p->heapH, sizeof(cmCsvCell_t) )) == NULL )
333
-    return _cmCsvError(p,kMemAllocErrCsvRC,"Cell allocation failed. for row: %i column %i.",cellRow,cellCol);
333
+    return _cmCsvError(p,kMemAllocErrCsvRC,"Cell allocation failed. for row: %i column %i.",cellRow+1,cellCol+1);
334 334
 
335 335
   cp->row   = cellRow;
336 336
   cp->col   = cellCol;
@@ -482,7 +482,7 @@ cmCsvRC_t cmCsvParse(      cmCsvH_t h, const char* buf, unsigned bufCharCnt, uns
482 482
         {
483 483
           const cmCsvUdef_t* u;
484 484
           if((u = _cmCsvFindUdef(p,lexTId)) == NULL )
485
-            rc = _cmCsvError(p, kSyntaxErrCsvRC, "Unrecognized token type: '%s' for token: '%s'.",cmLexIdToLabel(p->lexH,lexTId),buf);
485
+            rc = _cmCsvError(p, kSyntaxErrCsvRC, "Unrecognized token type: '%s' for token: '%s' row:%i col:%i.",cmLexIdToLabel(p->lexH,lexTId),buf,csvRowIdx+1,csvColIdx+1);
486 486
           else
487 487
             flags = kStrCsvTFl | kUdefCsvTFl;            
488 488
         }
@@ -490,10 +490,13 @@ cmCsvRC_t cmCsvParse(      cmCsvH_t h, const char* buf, unsigned bufCharCnt, uns
490 490
 
491 491
     // if no error occurred and the token is not a comma  and the cell is not empty
492 492
     if( rc == kOkCsvRC && lexTId != kCommaLexTId && strlen(buf) > 0 )
493
-      rc = _cmCsvCreateCell( p, buf,flags, csvRowIdx, csvColIdx, lexTId );
493
+      if((rc = _cmCsvCreateCell( p, buf,flags, csvRowIdx, csvColIdx, lexTId )) != kOkCsvRC )
494
+        rc = _cmCsvError(p,rc,"CSV cell create fail on row:%i col:%i\n",csvRowIdx+1,csvColIdx+1);
494 495
   }
495 496
 
496
- 
497
+  if( lexTId == kErrorLexTId )
498
+    rc = _cmCsvError(p, kSyntaxErrCsvRC,"The lexer encountered an unrecognized token row:%i col:%i.",csvRowIdx+1,csvColIdx+1);
499
+
497 500
   return rc;
498 501
 }
499 502
 

Laddar…
Avbryt
Spara