[PATCH] readline: use a simple function to replace printf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Du Huanpeng <u74147@xxxxxxxxx>

maybe this patch is not very necessary, but this make we have
opportunity to use simplified version of printf.
  printf ("%.*s", n, str);

Signed-off-by: Du Huanpeng <u74147@xxxxxxxxx>
---
 lib/readline.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/readline.c b/lib/readline.c
index b5d99ca..31fd1ed 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -13,9 +13,6 @@
  * Author: Janghoon Lyu <nandy@xxxxxxxx>
  */
 
-#define putnstr(str,n)	do {			\
-		printf ("%.*s", n, str);	\
-	} while (0)
 
 #define CTL_BACKSPACE		('\b')
 #define DEL			255
@@ -36,6 +33,13 @@ static LIST_HEAD(history_list);
 static struct list_head *history_current;
 static int history_num_entries;
 
+static void putnstr(const char *str, int n)
+{
+	int i;
+	for(i=0; i<n && str[i]; i++) {
+		putchar(str[i]);
+	}
+}
 static void cread_add_to_hist(char *line)
 {
 	struct history *history;
-- 
1.9.1



_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux