Hi Pelle,
I discovered 2 scenarios that cause PoFmt to go off the rails ( mostly indentation ).
1) Optional args and 2) initialized variables
Here is a function that shows both after being processed by pofmt using either KR or PO styles.
char *join(int ArgCount, PCTSTR Str1, ...)
{
va_list ap = {
0
};
PSTR BCX_RetStr = NULL;
PSTR currentStr = NULL;
int i;
size_t totalLen;
totalLen = strlen(Str1);
// Calc memory reqmnt
va_start(ap, Str1);
for(i=1; i<=ArgCount-1; i++)
{
currentStr = va_arg(ap,PSTR);
if(strlen(currentStr)>0) {
totalLen += (int)strlen(currentStr);
}
}
va_end(ap);
// Allocate memory
BCX_RetStr = BCX_TempStr(totalLen);
if(BCX_RetStr == 0) {
return NULL; // Not a good sign :-(
}
// Init result with Str1
strcpy(BCX_RetStr,Str1);
// Concat remainiing strings
va_start(ap, Str1);
for(i=1; i<=ArgCount-1; i++)
{
currentStr = va_arg(ap,PSTR);
if((int)strlen(currentStr)>0) {
strcat(BCX_RetStr,currentStr);
}
}
va_end(ap);
return BCX_RetStr;
}