mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Du Huanpeng <d-hp@163.com>
To: barebox@lists.infradead.org
Cc: Du Huanpeng <u74147@gmail.com>
Subject: [PATCH] readline: use a simple function to replace printf
Date: Thu, 14 Apr 2016 21:46:54 +0800	[thread overview]
Message-ID: <1460641614-4660-1-git-send-email-d-hp@163.com> (raw)

From: Du Huanpeng <u74147@gmail.com>

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@gmail.com>
---
 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@mizi.com>
  */
 
-#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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2016-04-14 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 13:46 Du Huanpeng [this message]
2016-04-19  7:15 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460641614-4660-1-git-send-email-d-hp@163.com \
    --to=d-hp@163.com \
    --cc=barebox@lists.infradead.org \
    --cc=u74147@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox