some fixes

This commit is contained in:
timerix 2022-10-28 02:09:10 +06:00
parent 88815452bc
commit 1632c78300
3 changed files with 16 additions and 7 deletions

View File

@ -85,7 +85,7 @@ char* toString_bin(void* _bytes, uint32 size, bool withPrefix){
str[cn++]='b';
}
for(uint32 bn=0; bn<size; bn++){
char byte=bytes[bn];
unsigned char byte=bytes[bn];
for(uint8 i=0; i<8; i++)
str[cn++]='0' + (byte & (char)128>>i);
}
@ -100,8 +100,11 @@ char _4bitsHex(uint8 u, bool uppercase){
return '0'+u;
case 0xA: case 0xB: case 0xC:
case 0xD: case 0xE: case 0xF:
return (uppercase ? 'A'-10 : 'a'-10) + u;
default: return 219;
return (uppercase ? 'A' : 'a') + u -10;
default:
dbg(u);
throw("incorrect number");
return 219;
}
}
@ -114,7 +117,7 @@ char* toString_hex(void* _bytes, uint32 size, bool withPrefix, bool uppercase){
str[cn++]='x';
}
for(uint32 bn=0; bn<size; bn++){
char byte=bytes[bn];
unsigned char byte=bytes[bn];
str[cn++]=_4bitsHex(byte%16, uppercase);
str[cn++]=_4bitsHex(byte/16, uppercase);
}

View File

@ -59,7 +59,7 @@ void kprintf(const char* format, ...){
case 'u':
argstr=toString_uint(va_arg(vl, uint64),0,0);
break;
case 'i':
case 'i': case 'd':
argstr=toString_int(va_arg(vl, uint64));
break;
case 'f':
@ -101,6 +101,10 @@ void kprintf(const char* format, ...){
argstr[1]=0;
break;
default:
putc('\n',stdout);
putc('<',stdout);
putc(c,stdout);
putc('>',stdout);
throw(ERR_FORMAT);
}
if(argstr){

View File

@ -14,13 +14,15 @@ void test_all(){
kprintf("\e[96m--------------------------------------\e[0m\n");
}
int main(){
setlocale(LC_ALL, "en-US.Unicode");
if(!setlocale(LC_ALL, "C.UTF8"))
kprintf("\e[93msetlocale failed\n");
ktDescriptors_beginInit();
ktDescriptors_initKerepTypes();
ktDescriptors_endInit();
kprintf("\e[97mkerep tests are starting!\n");
optime("test_all",1,test_all());
//optime("test_all",1,test_all());
ktDescriptors_free();
kprintf("ъъъъ");
kprintf("\e[0m\n");
return 0;
}