Pārlūkot izejas kodu

cmData.c : Minor bug fixes to complete initial testing of cmDataParser.

master
kevin 11 gadus atpakaļ
vecāks
revīzija
fd56025468
1 mainītis faili ar 18 papildinājumiem un 10 dzēšanām
  1. 18
    10
      cmData.c

+ 18
- 10
cmData.c Parādīt failu

@@ -1373,8 +1373,7 @@ bool _cmDataPairIsValid( const cmData_t* p )
1373 1373
 {
1374 1374
   assert( p->tid == kPairDtId );
1375 1375
 
1376
-  const cmData_t* cp = p->u.child;
1377
-  bool fl = cp->u.child == NULL || cp->u.child->sibling == NULL || cp->u.child->sibling->sibling!=NULL;
1376
+  bool fl = p->u.child == NULL || p->u.child->sibling == NULL || p->u.child->sibling->sibling!=NULL;
1378 1377
   return !fl;
1379 1378
 }
1380 1379
 
@@ -2194,7 +2193,7 @@ char* _cmDataSerializeWrite( cmData_t* np, char* dp, const char* ep )
2194 2193
 
2195 2194
 char* _cmDataSerialize( const cmData_t* p, char* buf, const char* ep )
2196 2195
 {
2197
-
2196
+  /*
2198 2197
   buf = _cmDataSerializeWrite(p,buf,ep);
2199 2198
 
2200 2199
   // if this data type has a child then write the child
@@ -2207,13 +2206,17 @@ char* _cmDataSerialize( const cmData_t* p, char* buf, const char* ep )
2207 2206
     buf = cmDataSerialize(dp->sibling,buf,ep);
2208 2207
 
2209 2208
   return buf;
2209
+  */
2210
+  return NULL;
2210 2211
 }
2211 2212
 
2212 2213
 cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )
2213 2214
 {
2215
+  /*
2214 2216
   const char* ep = (char*)p + bufByteCnt;
2215 2217
   buf = _cmDataSerialize(p,buf,bufByteCnt);
2216 2218
   assert( buf <= ep );
2219
+  */
2217 2220
   return kOkDtRC;
2218 2221
 }
2219 2222
 
@@ -2283,6 +2286,8 @@ cmDtRC_t _cmDataParserDestroy( cmDataParser_t* p )
2283 2286
   if( cmStackFree(&p->stH) != kOkStRC )
2284 2287
     cmErrMsg(&p->err,kParseStackFailDtRC,"The data object parser stack release failed.");
2285 2288
 
2289
+  cmMemFree(p);
2290
+
2286 2291
   return kOkDtRC;
2287 2292
 }
2288 2293
 
@@ -2717,11 +2722,10 @@ cmDtRC_t _cmDataParserOnComma( cmDataParserCtx_t* c )
2717 2722
 
2718 2723
 cmDtRC_t cmDataParserExec( cmDataParserH_t h, const cmChar_t* text, cmData_t** pp )
2719 2724
 {
2720
-  cmDtRC_t rc = kOkDtRC;
2721
-  unsigned tokenId;
2722
-
2725
+  cmDtRC_t          rc = kOkDtRC;
2726
+  cmDataParser_t*   p  = _cmDataParserHandleToPtr(h);
2727
+  unsigned          tokenId;
2723 2728
   cmDataParserCtx_t ctx;
2724
-  cmDataParser_t* p   = _cmDataParserHandleToPtr(h);
2725 2729
 
2726 2730
   ctx.cnp   = NULL;  // current node ptr
2727 2731
   ctx.p     = p;
@@ -2799,6 +2803,10 @@ cmDtRC_t cmDataParserExec( cmDataParserH_t h, const cmChar_t* text, cmData_t** p
2799 2803
   }
2800 2804
 
2801 2805
  errLabel:
2806
+
2807
+  if( rc == kOkDtRC )
2808
+    *pp = ctx.cnp;
2809
+
2802 2810
   return rc;
2803 2811
 }
2804 2812
 
@@ -2919,9 +2927,9 @@ cmDtRC_t cmDataParserTest( cmCtx_t* ctx )
2919 2927
   if( cmDataParserExec(h,text,&dp) != kOkDtRC )
2920 2928
     rc = cmErrMsg(&err,rc,"Data parser exec failed.");
2921 2929
   else
2922
-  {
2923
-    cmDataPrint(dp,&ctx->rpt);
2924
-  }
2930
+    if( dp != NULL )
2931
+      cmDataPrint(dp,&ctx->rpt);
2932
+
2925 2933
 
2926 2934
  errLabel:
2927 2935
   if( cmDataParserDestroy( &h ) != kOkDtRC )

Notiek ielāde…
Atcelt
Saglabāt