Added special cases for %% and % at end of phrase for formatting of phrases defined in language definition files.

This commit is contained in:
Pavol Marko
2004-10-29 13:11:12 +00:00
parent 8761791473
commit cc4bbadfa2
+53 -44
View File
@@ -584,55 +584,64 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
if (*def == '%') if (*def == '%')
{ {
++def; ++def;
static char format[32]; if (*def == '%' || *def == 0)
format[0] = '%';
char *ptr = format+1;
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
/*nothing*/;
ZEROTERM(format);
*ptr = 0;
switch ( *(ptr-1) )
{ {
case 's': *outptr++ = '%';
++def;
}
else
{
static char format[32];
format[0] = '%';
char *ptr = format+1;
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
/*nothing*/;
ZEROTERM(format);
*ptr = 0;
switch ( *(ptr-1) )
{ {
static char tmpString[4096]; case 's':
char *tmpPtr = tmpString; {
NEXT_PARAM(); static char tmpString[4096];
cell *tmpCell = get_amxaddr(amx, params[parm++]); char *tmpPtr = tmpString;
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell) NEXT_PARAM();
*tmpPtr++ = *tmpCell++; cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
*tmpPtr++ = *tmpCell++;
*tmpPtr = 0; *tmpPtr = 0;
sprintf(outptr, format, tmpString); sprintf(outptr, format, tmpString);
ZEROTERM(outbuf); ZEROTERM(outbuf);
break; break;
} }
case 'g': case 'g':
case 'f': case 'f':
{ {
NEXT_PARAM(); NEXT_PARAM();
sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++])); sprintf(outptr, format, *(REAL*)get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf); ZEROTERM(outbuf);
break; break;
} }
case 'i': case 'i':
case 'd': case 'd':
case 'c': case 'c':
{ {
NEXT_PARAM(); NEXT_PARAM();
sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++])); sprintf(outptr, format, (int)*get_amxaddr(amx, params[parm++]));
ZEROTERM(outbuf); ZEROTERM(outbuf);
break; break;
} }
default: default:
{ {
CHECK_OUTPTR(strlen(format)+1); CHECK_OUTPTR(strlen(format)+1);
strcpy(outptr, format); strcpy(outptr, format);
break; break;
}
} }
outptr += strlen(outptr);
} }
outptr += strlen(outptr);
} }
else if (*def == '^') else if (*def == '^')
{ {