From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from m50-134.163.com ([123.125.50.134]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aqhcF-0000Wn-IR for barebox@lists.infradead.org; Thu, 14 Apr 2016 13:47:28 +0000 From: Du Huanpeng Date: Thu, 14 Apr 2016 21:46:54 +0800 Message-Id: <1460641614-4660-1-git-send-email-d-hp@163.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] readline: use a simple function to replace printf To: barebox@lists.infradead.org Cc: Du Huanpeng From: Du Huanpeng 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 --- 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 */ -#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