revert r7435

git-svn-id: svn://kolibrios.org@7439 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-06 09:33:56 +00:00
parent 291945f295
commit a2eabdbf4a

View File

@ -830,50 +830,45 @@ inline signed csshexdec(dword text)
return ret; return ret;
} }
:dword stdcall sprintf(dword buf, format,...) inline cdecl int sprintf(dword buf, format,...)
{ {
#define END_ARGS 0xFF00FF //ARGS FUNCTION
byte s; byte s;
char X[10];
dword ret, tmp, l; dword ret, tmp, l;
dword arg = #format; dword arg = #format;
ret = buf; ret = buf;
s = DSBYTE[format]; s = DSBYTE[format];
while(s) while(s){
{ if(s=='%'){
if(s == '%')
{
arg+=4; arg+=4;
tmp = DSDWORD[arg]; tmp = DSDWORD[arg];
format++; if(tmp==END_ARGS)goto END_FUNC_SPRINTF;
$inc format
s = DSBYTE[format]; s = DSBYTE[format];
IF (!s) if(!s)goto END_FUNC_SPRINTF;
{
DSBYTE[buf] = 0;
return ret;
}
switch(s) switch(s)
{ {
case 's': case 's':
l = tmp; l = tmp;
WHILE(DSBYTE[tmp]) s = DSBYTE[tmp];
while(s)
{ {
DSBYTE[buf] = DSBYTE[tmp]; DSBYTE[buf] = s;
tmp++; $inc tmp
buf++; $inc buf
s = DSBYTE[tmp];
} }
break; break;
case 'c': case 'c':
DSBYTE[buf] = tmp; DSBYTE[buf] = tmp;
buf++; $inc buf
break; break;
case 'u': //if(tmp<0)return ret; case 'u': //if(tmp<0)return ret;
case 'd': case 'd':
case 'i': case 'i':
tmp = itoa(tmp); tmp = itoa(tmp);
IF (!DSBYTE[tmp]) if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
{
DSBYTE[buf] = 0;
return ret;
}
l = strlen(tmp); l = strlen(tmp);
strlcpy(buf,tmp,l); strlcpy(buf,tmp,l);
buf += l; buf += l;
@ -883,47 +878,39 @@ inline signed csshexdec(dword text)
strlcpy(buf,"0x00000000",10); strlcpy(buf,"0x00000000",10);
buf+=10; buf+=10;
l=buf; l=buf;
WHILE(tmp) while(tmp)
{ {
buf--; $dec buf
s=tmp&0xF; s=tmp&0xF;
IF (s > 9) DSBYTE[buf] = 'A' - 10 + s; if(s>9)DSBYTE[buf]='A'+s-10;
ELSE DSBYTE[buf] = '0' + s; else DSBYTE[buf]='0'+s;
tmp>>=4; tmp>>=4;
} }
buf=l; buf=l;
break; break;
case 'p': case 'p':
tmp = itoa(#tmp); tmp = itoa(#tmp);
IF (!DSBYTE[tmp]) if(!DSBYTE[tmp])goto END_FUNC_SPRINTF;
{
DSBYTE[buf] = 0;
return ret;
}
l = strlen(tmp); l = strlen(tmp);
strlcpy(buf,tmp,l); strlcpy(buf,tmp,l);
buf += l; buf += l;
break; break;
case '%': case '%':
DSBYTE[buf] = '%'; DSBYTE[buf] = '%';
buf++; $inc buf
break; break;
default: default:
{ goto END_FUNC_SPRINTF;
DSBYTE[buf] = 0;
return ret;
} }
} }
} else {
else
{
DSBYTE[buf] = s; DSBYTE[buf] = s;
buf++; $inc buf
} }
format++; $inc format
s = DSBYTE[format]; s = DSBYTE[format];
} }
END_FUNC_SPRINTF:
DSBYTE[buf] = 0; DSBYTE[buf] = 0;
return ret; return ret;
} }