From patchwork Wed Aug 31 07:46:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Renquan X-Patchwork-Id: 1115282 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7V83DL7028481 for ; Wed, 31 Aug 2011 08:03:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751040Ab1HaIDO (ORCPT ); Wed, 31 Aug 2011 04:03:14 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:63581 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998Ab1HaIDM (ORCPT ); Wed, 31 Aug 2011 04:03:12 -0400 Received: by mail-iy0-f174.google.com with SMTP id u26so511509iab.19 for ; Wed, 31 Aug 2011 01:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=mJVhHpSj1kQ/qauVeUJKlqPsYcofw1FETBy1vQfnuTw=; b=oQgdKQMQedSVAiun/szyHFKiy/VSyV4e5cj4Jq4OgvMu5K9KSeHEozcJii8W1kZ/q7 v1AXiercTS53ZSGk2v99RbMy1egCLJMJY+hXzUdOq6vbYlo/niWGKivIzgjjDAJpLG9T cBxGyfvGglpwJUiT1ZiLHSRKZUjuDnceHkaZE= Received: by 10.231.81.205 with SMTP id y13mr191404ibk.91.1314777791818; Wed, 31 Aug 2011 01:03:11 -0700 (PDT) Received: from localhost.localdomain ([67.188.70.153]) by mx.google.com with ESMTPS id m21sm3608665ibf.59.2011.08.31.01.03.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Aug 2011 01:03:11 -0700 (PDT) From: Cheng Renquan To: linux-kbuild@vger.kernel.org, Arnaud Lacombe Cc: Sam Ravnborg , Michal Marek , Nir Tzachar , Randy Dunlap , c.rq541@comcast.net Subject: [PATCH V2 6/6] scripts/kconfig/nconf: trunc too long string display in menu Date: Wed, 31 Aug 2011 00:46:13 -0700 Message-Id: <1314776773-9560-7-git-send-email-crquan@gmail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1314776773-9560-6-git-send-email-crquan@gmail.com> References: <1314776773-9560-1-git-send-email-crquan@gmail.com> <1314776773-9560-2-git-send-email-crquan@gmail.com> <1314776773-9560-3-git-send-email-crquan@gmail.com> <1314776773-9560-4-git-send-email-crquan@gmail.com> <1314776773-9560-5-git-send-email-crquan@gmail.com> <1314776773-9560-6-git-send-email-crquan@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 31 Aug 2011 08:03:15 +0000 (UTC) When the string is too long, only show the first COLS/2 bytes wide, to make sure there is some space to show the menu prompt. Signed-off-by: Cheng Renquan --- scripts/kconfig/nconf.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 4248759..4997ebf 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -887,8 +887,14 @@ static void build_conf(struct menu *menu) break; default: tmp = 2 + strlen(sym_get_string_value(sym)); - item_make(menu, 's', " (%s)", + if (tmp < COLS/2) + item_make(menu, 's', " (%s)", sym_get_string_value(sym)); + else { + char *s = strndupa(sym_get_string_value(sym), COLS/2); + strcpy(s + COLS/2 - 5, " ..."); + item_make(menu, 's', " (%s)", s); + } tmp = indent - tmp + 4; if (tmp < 0) tmp = 0;