From ac6f06173082a74d22e6a39df025eb4aad98bc0a Mon Sep 17 00:00:00 2001 From: teodor Date: Wed, 1 Oct 2008 09:40:35 +0000 Subject: [PATCH] Fix bug in GListTruncate, extends templates tests --- expected/tmpl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ glist.c | 5 +++++ tmpltest.c | 16 ++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/expected/tmpl b/expected/tmpl index 7585c3b..d7dd7a7 100644 --- a/expected/tmpl +++ b/expected/tmpl @@ -64,3 +64,53 @@ NOT DEFINED zeroID-NO +================================================ +id: 23 - simple +idhex: 0x00000017 - HEX +idhexdef: HEX(0x00000017) -< +ndef: +ndef def: Wow +empty +empty def: "EmptyId" - default +zero 0 +zero def: 0 + +ID-YES +DEFINED ID-YES +NOT ID-NO +NOT DEFINED ID-NO + +ndefID-NO +DEFINED ndefID-NO +DEFINED ndefID-YES +DEFINED ndefID-YES + + +EmptyId-NO +DEFINED EmptyId-NO +DEFINED EmptyId-YES +DEFINED EmptyId-YES + +zeroID-NO +DEFINED zeroID-YES +DEFINED zeroID-YES +NOT DEFINED zeroID-NO + + + + ID!=0 && defined(zeroID) - right + + + + + + 1/1. odd:true even:false + + FIRST LAST id: 23 1234:FOO/1234 + + +
    +
  1. Again 1 +
+ + diff --git a/glist.c b/glist.c index 59213ac..9e79963 100644 --- a/glist.c +++ b/glist.c @@ -118,11 +118,15 @@ GListDelete(GList *l, GListCell *c) { l->head = c->next; if ( l->head ) l->head->prev = NULL; + else + l->tail = NULL; } else if ( l->tail == c ) { tassert( c->next == NULL ); l->tail = c->prev; if ( l->tail ) l->tail->next = NULL; + else + l->head = NULL; } else { c->prev->next = c->next; c->next->prev = c->prev; @@ -281,6 +285,7 @@ GListTruncate(GList *l, int n) { GListFreeCell(l, c); } + checkGList(l); return l; } diff --git a/tmpltest.c b/tmpltest.c index 6b54a3d..5c3986f 100644 --- a/tmpltest.c +++ b/tmpltest.c @@ -108,8 +108,24 @@ main(int argn, char *argv[]) { template.printString = outfunc; printTemplate( &template ); + resetTemplate(&template); + + setTemplateValueInt(&template, "ID", 23); + setTemplateValueUndefined(&template, "emptyID"); + setTemplateValueInt(&template, "zeroid", 0); + addTemplateRow(&template, "outerLoop"); + setTemplateValueString(&template, "outerLoop.data1", "ha1"); + setTemplateValueInt(&template, "outerLoop.data1", 1234); + setTemplateValueString(&template, "outerLoop.data2", "FOO"); + addTemplateRow(&template, "outerLoop.innerLoop"); + setTemplateValueString(&template, "outerLoop.innerLoop.camenty", "Again 1"); + + fputs("================================================\n", stdout); + printTemplate( &template ); + resetTemplate(&template); freeTemplate(&template); + return 0; } -- 2.46.1