From patchwork Tue Jun 18 22:45:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 2745671 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 391A79F39E for ; Tue, 18 Jun 2013 22:48:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C6E8202DF for ; Tue, 18 Jun 2013 22:48:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D1E2202DD for ; Tue, 18 Jun 2013 22:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933415Ab3FRWp1 (ORCPT ); Tue, 18 Jun 2013 18:45:27 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:42073 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933236Ab3FRWpZ (ORCPT ); Tue, 18 Jun 2013 18:45:25 -0400 Received: by mail-wi0-f182.google.com with SMTP id m6so49697wiv.15 for ; Tue, 18 Jun 2013 15:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=Qei4m83gWI7aPawH0CqNBHCfW+UNIaSOZx6O6GvfsAc=; b=RPfcndXVQp2B6t9TrMrS1akxM+odUsjWO/wzJjjhGXbeQAK626ubgSeGAMJj2lc02G 4dKip5q+7GajM5Gih6q/yfh5/Wqe/Kv9KdzITF2uNVEw4JaNdZb1APF8hdFcX4UOt2UA tcaiVBLkWj1Eib/u1oJWp3XSoXXqxXFXkss/5OLcl35/Wvy0Aewpyp9WGTgST7Izb4Ya buB9GIMbbnODNyFn5RHcxR7556YwhuLWMrOwFb3ix5y10inMENKENraELY7EJD5XjGP4 +yJXs4+ZYiy8miK+T44O9OE2cGcEe47G4tdDiSyDPQWzfV1O/dstqOZwNKLVbADeu4BD 1Ugw== X-Received: by 10.180.76.103 with SMTP id j7mr21071wiw.21.1371595523383; Tue, 18 Jun 2013 15:45:23 -0700 (PDT) Received: from gourin.bzh.lan (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id o14sm5307237wiv.3.2013.06.18.15.45.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Jun 2013 15:45:22 -0700 (PDT) From: "Yann E. MORIN" To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michal Marek , Dirk Gouders , "Yann E. MORIN" Subject: [PATCH 04/14] kconfig/lxdialog: handle newline characters in print_autowrap() Date: Wed, 19 Jun 2013 00:45:00 +0200 Message-Id: <1376391621654cc369c5e8b60497f7c184f0ed47.1371595499.git.yann.morin.1998@free.fr> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dirk Gouders When exiting menuconfig with unsaved changes, a dialog like the following is shown: Do you wish to save your new configuration ? to continue. The author of the dialog text specified a newline after the '?', and probably expected it to be processed, so let print_autowrap() handle newlines propperly. Also, reword that dialog's second phrase with a real sentence. Signed-off-by: Dirk Gouders Tested-by: "Yann E. MORIN" Reviewed-by: "Yann E. MORIN" [yann.morin.1998@free.fr: very slightly tweak the commit message] Signed-off-by: Yann E. MORIN --- scripts/kconfig/lxdialog/util.c | 31 +++++++++++++++++-------------- scripts/kconfig/mconf.c | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index 78fe4e9..0fa567e 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -371,27 +371,19 @@ void print_title(WINDOW *dialog, const char *title, int width) /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline - * characters '\n' are replaced by spaces. We start on a new line + * characters '\n' are propperly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) { int newl, cur_x, cur_y; - int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + int prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0; strcpy(tempstr, prompt); prompt_len = strlen(tempstr); - /* - * Remove newlines - */ - for (i = 0; i < prompt_len; i++) { - if (tempstr[i] == '\n') - tempstr[i] = ' '; - } - if (prompt_len <= width - x * 2) { /* If prompt is short */ wmove(win, y, (width - prompt_len) / 2); waddstr(win, tempstr); @@ -401,7 +393,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) newl = 1; word = tempstr; while (word && *word) { - sp = strchr(word, ' '); + sp = strpbrk(word, "\n "); + if (sp && *sp == '\n') + newline_separator = sp; + if (sp) *sp++ = 0; @@ -413,7 +408,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room - && (!(sp2 = strchr(sp, ' ')) + && (!(sp2 = strpbrk(sp, "\n ")) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; @@ -421,7 +416,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) wmove(win, cur_y, cur_x); waddstr(win, word); getyx(win, cur_y, cur_x); - cur_x++; + + /* Move to the next line if the word separator was a newline */ + if (newline_separator) { + cur_y++; + cur_x = x; + newline_separator = 0; + } else + cur_x++; + if (sp && *sp == ' ') { cur_x++; /* double space */ while (*++sp == ' ') ; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 2396c5b..cb8cf4a 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -958,8 +958,8 @@ static int handle_exit(void) dialog_clear(); if (conf_get_changed()) res = dialog_yesno(NULL, - _("Do you wish to save your new configuration ?\n" - " to continue."), + _("Do you wish to save your new configuration?\n" + "(Press to continue kernel configuration.)"), 6, 60); else res = -1;