Revision dfefcc0f
Von martin vor mehr als 14 Jahren hinzugefügt
src/os/gwendate.c | ||
---|---|---|
}
|
||
else {
|
||
char buffer[32];
|
||
int clen;
|
||
|
||
switch(e->character) {
|
||
case 'Y':
|
||
... | ... | |
snprintf(buffer, sizeof(buffer)-1, "%0*d", e->maxCount, v);
|
||
buffer[sizeof(buffer)-1]=0;
|
||
e->content=strdup(buffer);
|
||
e->nextChar=strlen(e->content)-(e->count);
|
||
/* adjust counter if there are more than maxCount template chars */
|
||
clen=strlen(e->content);
|
||
if (e->count>clen)
|
||
e->count=clen;
|
||
e->nextChar=clen-(e->count);
|
||
}
|
||
|
||
e=GWEN_DateTmplChar_List_Next(e);
|
||
... | ... | |
s++;
|
||
}
|
||
else {
|
||
c=e->content[e->nextChar++];
|
||
assert(c);
|
||
GWEN_Buffer_AppendByte(buf, c);
|
||
c=e->content[e->nextChar];
|
||
if (c!=0) {
|
||
GWEN_Buffer_AppendByte(buf, c);
|
||
e->nextChar++;
|
||
}
|
||
}
|
||
}
|
||
else
|
test/gwentest.c | ||
---|---|---|
assert(ti1);
|
||
|
||
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||
GWEN_Date_toStringWithTemplate(ti1, "w*, DD.MM.YYYY", dbuf);
|
||
GWEN_Date_toStringWithTemplate(ti1, "w*, DDDD.MM.YYYY", dbuf);
|
||
DBG_NOTICE(0, "Current date: %s", GWEN_Buffer_GetStart(dbuf));
|
||
|
||
GWEN_Buffer_Reset(dbuf);
|
||
GWEN_Date_toStringWithTemplate(ti1, "www, DD.M*.YYYY (W)", dbuf);
|
||
DBG_NOTICE(0, "or like this: %s", GWEN_Buffer_GetStart(dbuf));
|
||
|
||
GWEN_Buffer_Reset(dbuf);
|
||
GWEN_Date_toStringWithTemplate(ti1, "w*, D.M.YYYY (W)", dbuf);
|
||
DBG_NOTICE(0, "or like this: %s", GWEN_Buffer_GetStart(dbuf));
|
||
|
||
return 0;
|
||
}
|
||
|
Auch abrufbar als: Unified diff
Fixed a segfault on bad template strings.
git-svn-id: https://devel.aqbanking.de/svn/gwenhywfar/trunk@2067 70169cfe-8b10-0410-8925-dcb4b91034d8