Fossil SCM

manifest_parse() now stores the UUID before parsing begins and adds it to syntax error messages.

stephan 2014-10-15 18:31 better-error-msgs
Commit a87c0d89ae9b617cd6a27d1e245c0a807864c085
1 file changed +13 -2
+13 -2
--- src/manifest.c
+++ src/manifest.c
@@ -254,11 +254,11 @@
254254
** value.
255255
**
256256
** 0123456789 123456789 123456789 123456789
257257
** Z aea84f4f863865a8d59d0384e4d2a41c
258258
*/
259
-static int verify_z_card(const char *z, int n){
259
+static int verify_z_card(const char *z, int n ){
260260
if( n<35 ) return 0;
261261
if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0;
262262
md5sum_init();
263263
md5sum_step_text(z, n-35);
264264
if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){
@@ -360,13 +360,13 @@
360360
char *z;
361361
int n;
362362
char *zUuid;
363363
int sz = 0;
364364
int isRepeat, hasSelfRefTag = 0;
365
+ Blob bUuid = BLOB_INITIALIZER;
365366
static Bag seen;
366367
const char *zErr = 0;
367
-
368368
if( rid==0 ){
369369
isRepeat = 1;
370370
}else if( bag_find(&seen, rid) ){
371371
isRepeat = 1;
372372
}else{
@@ -403,10 +403,15 @@
403403
if( verify_z_card(z, n)==2 ){
404404
blob_reset(pContent);
405405
blob_appendf(pErr, "incorrect Z-card cksum");
406406
return 0;
407407
}
408
+
409
+ /* Store the UUID (before modifying the blob) only for error
410
+ ** reporting purposes.
411
+ */
412
+ sha1sum_blob(pContent, &bUuid);
408413
409414
/* Allocate a Manifest object to hold the parsed control artifact.
410415
*/
411416
p = fossil_malloc( sizeof(*p) );
412417
memset(p, 0, sizeof(*p));
@@ -944,13 +949,19 @@
944949
if( !seenZ ) SYNTAX("missing Z-card on control");
945950
p->type = CFTYPE_CONTROL;
946951
}
947952
md5sum_init();
948953
if( !isRepeat ) g.parseCnt[p->type]++;
954
+ blob_reset(&bUuid);
949955
return p;
950956
951957
manifest_syntax_error:
958
+ if(bUuid.nUsed){
959
+ blob_appendf(pErr, "manifest UUID %.40s ",
960
+ blob_str(&bUuid));
961
+ blob_reset(&bUuid);
962
+ }
952963
if( zErr ){
953964
blob_appendf(pErr, "line %d: %s", lineNo, zErr);
954965
}else{
955966
blob_appendf(pErr, "unknown error on line %d", lineNo);
956967
}
957968
--- src/manifest.c
+++ src/manifest.c
@@ -254,11 +254,11 @@
254 ** value.
255 **
256 ** 0123456789 123456789 123456789 123456789
257 ** Z aea84f4f863865a8d59d0384e4d2a41c
258 */
259 static int verify_z_card(const char *z, int n){
260 if( n<35 ) return 0;
261 if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0;
262 md5sum_init();
263 md5sum_step_text(z, n-35);
264 if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){
@@ -360,13 +360,13 @@
360 char *z;
361 int n;
362 char *zUuid;
363 int sz = 0;
364 int isRepeat, hasSelfRefTag = 0;
 
365 static Bag seen;
366 const char *zErr = 0;
367
368 if( rid==0 ){
369 isRepeat = 1;
370 }else if( bag_find(&seen, rid) ){
371 isRepeat = 1;
372 }else{
@@ -403,10 +403,15 @@
403 if( verify_z_card(z, n)==2 ){
404 blob_reset(pContent);
405 blob_appendf(pErr, "incorrect Z-card cksum");
406 return 0;
407 }
 
 
 
 
 
408
409 /* Allocate a Manifest object to hold the parsed control artifact.
410 */
411 p = fossil_malloc( sizeof(*p) );
412 memset(p, 0, sizeof(*p));
@@ -944,13 +949,19 @@
944 if( !seenZ ) SYNTAX("missing Z-card on control");
945 p->type = CFTYPE_CONTROL;
946 }
947 md5sum_init();
948 if( !isRepeat ) g.parseCnt[p->type]++;
 
949 return p;
950
951 manifest_syntax_error:
 
 
 
 
 
952 if( zErr ){
953 blob_appendf(pErr, "line %d: %s", lineNo, zErr);
954 }else{
955 blob_appendf(pErr, "unknown error on line %d", lineNo);
956 }
957
--- src/manifest.c
+++ src/manifest.c
@@ -254,11 +254,11 @@
254 ** value.
255 **
256 ** 0123456789 123456789 123456789 123456789
257 ** Z aea84f4f863865a8d59d0384e4d2a41c
258 */
259 static int verify_z_card(const char *z, int n ){
260 if( n<35 ) return 0;
261 if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0;
262 md5sum_init();
263 md5sum_step_text(z, n-35);
264 if( memcmp(&z[n-33], md5sum_finish(0), 32)==0 ){
@@ -360,13 +360,13 @@
360 char *z;
361 int n;
362 char *zUuid;
363 int sz = 0;
364 int isRepeat, hasSelfRefTag = 0;
365 Blob bUuid = BLOB_INITIALIZER;
366 static Bag seen;
367 const char *zErr = 0;
 
368 if( rid==0 ){
369 isRepeat = 1;
370 }else if( bag_find(&seen, rid) ){
371 isRepeat = 1;
372 }else{
@@ -403,10 +403,15 @@
403 if( verify_z_card(z, n)==2 ){
404 blob_reset(pContent);
405 blob_appendf(pErr, "incorrect Z-card cksum");
406 return 0;
407 }
408
409 /* Store the UUID (before modifying the blob) only for error
410 ** reporting purposes.
411 */
412 sha1sum_blob(pContent, &bUuid);
413
414 /* Allocate a Manifest object to hold the parsed control artifact.
415 */
416 p = fossil_malloc( sizeof(*p) );
417 memset(p, 0, sizeof(*p));
@@ -944,13 +949,19 @@
949 if( !seenZ ) SYNTAX("missing Z-card on control");
950 p->type = CFTYPE_CONTROL;
951 }
952 md5sum_init();
953 if( !isRepeat ) g.parseCnt[p->type]++;
954 blob_reset(&bUuid);
955 return p;
956
957 manifest_syntax_error:
958 if(bUuid.nUsed){
959 blob_appendf(pErr, "manifest UUID %.40s ",
960 blob_str(&bUuid));
961 blob_reset(&bUuid);
962 }
963 if( zErr ){
964 blob_appendf(pErr, "line %d: %s", lineNo, zErr);
965 }else{
966 blob_appendf(pErr, "unknown error on line %d", lineNo);
967 }
968

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button