修正printk不输出的问题

This commit is contained in:
rtt 2017-06-12 05:56:37 -07:00
parent 239dcd5710
commit 1849b220d5
4 changed files with 20 additions and 15 deletions

View File

@ -3,11 +3,12 @@
void printk_test();
void memory_test();
void other_test();
int main() {
// TODO: snprtinf copies @n chars including the final \0
printk_test();
//memory_test();
other_test();
// Finally reaches here.
assert(1 == 0);
}

View File

@ -0,0 +1,12 @@
#include<klib.h>
void other_test(){
printk("hello,there is other_test\n");
char buf[128];
sprintf(buf, "%s", "Hello world!\n");
assert(strcmp(buf, "Hello world!\n") == 0);
sprintf(buf, "%d + %d = %d\n", 1, 1, 2);
assert(strcmp(buf, "1 + 1 = 2\n") == 0);
sprintf(buf, "%d + %d = %d\n", 2, 10, 12);
assert(strcmp(buf, "2 + 10 = 12\n") == 0);
printk("bye,other_test is over here\n");
}

View File

@ -24,7 +24,7 @@ void printk_test() {
printk("=======================================================\n");
printk("Test end!!! Good luck!!!\n");
*/
/*
static char src[1024]="hello";
printk("0, -1, -2147483648, -1412505855, -32768, 102030\n");
printk("%d, %d, %d, %d, %d, %d\n", 0, 0xffffffff, 0x80000000, 0xabcedf01, -32768, 102030);
@ -45,16 +45,7 @@ void printk_test() {
printk("ffffffff\n");
printk("%x\n",0xffffffff);
printk("0, -1, -2\n");
*/
char buf[128];
sprintf(buf, "%s", "Hello world!\n");
// printk("%s\n",buf);
assert(strcmp(buf, "Hello world!\n") == 0);
sprintf(buf, "%d + %d = %d\n", 1, 1, 2);
assert(strcmp(buf, "1 + 1 = 2\n") == 0);
sprintf(buf, "%d + %d = %d\n", 2, 10, 12);
assert(strcmp(buf, "2 + 10 = 12\n") == 0);
//snprintf(src,10,"%d, %d, %d, %d, %d\n", 0, 0xffffffff, 0x80000000, 0xabcedf01, -102030);
//sprintf(src,"%d",-2040);
//printk("%s",src);

View File

@ -9,9 +9,10 @@ int vprintdec(unsigned int dec,int base,int width,char abs,char flagc,char** s,i
//char* printstr(char* str,int width,char flagc,char* s);
char* printstr(char* str,char** s);
void myputc(char c,char** s_h){
if(s_h==0)_putc(c);
else **s_h=c;
(*s_h)++;
if(*s_h==0)_putc(c);
else {**s_h=c;
(*s_h)++;
}
}