mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] readline: use a simple function to replace printf
@ 2016-04-14 13:46 Du Huanpeng
  2016-04-19  7:15 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Du Huanpeng @ 2016-04-14 13:46 UTC (permalink / raw)
  To: barebox; +Cc: Du Huanpeng

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] readline: use a simple function to replace printf
  2016-04-14 13:46 [PATCH] readline: use a simple function to replace printf Du Huanpeng
@ 2016-04-19  7:15 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-04-19  7:15 UTC (permalink / raw)
  To: Du Huanpeng; +Cc: barebox, Du Huanpeng

On Thu, Apr 14, 2016 at 09:46:54PM +0800, Du Huanpeng wrote:
> 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);

I see no real value in this patch since we do have a full printf.
Without full printf we likely also do not need readline.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-19  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14 13:46 [PATCH] readline: use a simple function to replace printf Du Huanpeng
2016-04-19  7:15 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox