aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-06-03 07:38:19 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-06-03 07:38:19 +0800
commite751e537459b681b4a0b56276e58f08296f9dc8f (patch)
tree01066c4e357dddfd1206fbea95c71440824fdaf5
parent1d7733675c3c265ba00094647d4910b0f5d8748d (diff)
downloadsyslinux-e751e537459b681b4a0b56276e58f08296f9dc8f.tar.gz
syslinux-e751e537459b681b4a0b56276e58f08296f9dc8f.tar.xz
syslinux-e751e537459b681b4a0b56276e58f08296f9dc8f.zip
printf error fixed
and removed the itao function as the printf function works well now
-rw-r--r--Makefile2
-rw-r--r--core/cache.c29
-rw-r--r--core/hello.c17
-rw-r--r--core/include/core.h1
-rw-r--r--core/printf.c13
5 files changed, 17 insertions, 45 deletions
diff --git a/Makefile b/Makefile
index de0d2fda..fb411e7a 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ BOBJECTS = $(BTARGET) \
# Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
# files that depend only on the B phase, but may have to be regenerated
# for "make installer".
-BSUBDIRS = codepage com32 lzo core memdisk modules mbr memdump gpxe sample \
+BSUBDIRS = codepage com32 lzo core memdisk modules mbr memdump sample \
libinstaller dos win32
ITARGET =
IOBJECTS = $(ITARGET) dos/copybs.com \
diff --git a/core/cache.c b/core/cache.c
index c2c7a917..dca85a7d 100644
--- a/core/cache.c
+++ b/core/cache.c
@@ -103,12 +103,9 @@ void get_cache_block(com32sys_t * regs)
static int total_read;
static int missed;
- char buf[10];
-
+
#if 0
- itoa(buf, block);
- myputs(buf);
- myputs(" this is what we are looking cache for block\n\r");
+ printf("we are looking for cache of %d\n", block);
#endif
if ( !block ) {
@@ -139,19 +136,7 @@ void get_cache_block(com32sys_t * regs)
missed ++;
}
- total_read ++;
-#if 0 /* testing how efficiency the cache is */
- if ( total_read % 5 == 0 ) {
- itoa(buf, total_read);
- myputs("total_read ");
- myputs(buf);
- myputs("\tmissed ");
- itoa(buf, missed);
- myputs(buf);
- myputs("\n\r");
- }
-#endif
/* remove cs from current position in list */
cs->prev->next = cs->next;
@@ -168,9 +153,17 @@ void get_cache_block(com32sys_t * regs)
cs->next = head;
out:
+
+ total_read ++;
+
+#if 0 /* testing how efficiency the cache is */
+ if ( total_read % 5 == 0 )
+ printf("total_read %d\tmissed %d\n", total_read, missed);
+#endif
+
/* in fact, that would never be happened */
if ( (char *)(cs->data) > (char*)0x100000 )
- myputs("the buffer addres higher than 1M limit\n\r");
+ printf("the buffer addres higher than 1M limit\n\r");
regs->gs = SEG(cs->data);
regs->esi.w[0]= OFFS(cs->data);
diff --git a/core/hello.c b/core/hello.c
index ae75ced3..a1591111 100644
--- a/core/hello.c
+++ b/core/hello.c
@@ -3,19 +3,6 @@
#include <stdio.h>
#include <string.h>
-void itoa(char *str, int num)
-{
- char buf[10];
- int i = 0;
-
- do {
- buf[i++] = num % 10 + 0x30;
- }while ( num /= 10 );
-
- str[i] = '\0';
- for (; i > 0; i -- )
- *str++ = buf[i-1];
-}
void myputchar(int c)
{
@@ -37,7 +24,7 @@ void myputs(const char *str)
void hello(void)
{
- static char hello_str[] = "Hello, World! (hello.c)\n";
+ static char hello_str[] = "Hello, World!";
- myputs(hello_str);
+ printf("%s from (%s)\n", hello_str, __FILE__); /* testing */
}
diff --git a/core/include/core.h b/core/include/core.h
index bd04feb0..8e7cd03c 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -12,7 +12,6 @@ extern void getlinsec(void);
/* hello.c */
extern void myputs(const char*);
-extern void itoa(char *, int);
void __cdecl core_intcall(uint8_t, const com32sys_t *, com32sys_t *);
diff --git a/core/printf.c b/core/printf.c
index 3872e927..b1b0466b 100644
--- a/core/printf.c
+++ b/core/printf.c
@@ -1,23 +1,16 @@
#include <stdio.h>
#include <unistd.h>
-
-
-
-#define BUF_SIZE 1024
-
-char buf[BUF_SIZE];
-
-
-extern void myputs(const char *);
+#include "core.h"
int printf(const char *format, ...)
{
+ char buf[1024];
va_list ap;
int rv;
va_start(ap, format);
- rv = sprintf(buf, format, ap);
+ rv = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
myputs(buf);