From owner-svn-src-all@FreeBSD.ORG Thu Dec 1 09:01:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72029106566B; Thu, 1 Dec 2011 09:01:52 +0000 (UTC) (envelope-from fjoe@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 47F848FC0C; Thu, 1 Dec 2011 09:01:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB191qii036574; Thu, 1 Dec 2011 09:01:52 GMT (envelope-from fjoe@svn.freebsd.org) Received: (from fjoe@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB191qCW036572; Thu, 1 Dec 2011 09:01:52 GMT (envelope-from fjoe@svn.freebsd.org) Message-Id: <201112010901.pB191qCW036572@svn.freebsd.org> From: Max Khon Date: Thu, 1 Dec 2011 09:01:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228175 - head/usr.sbin/sade X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2011 09:01:52 -0000 Author: fjoe Date: Thu Dec 1 09:01:51 2011 New Revision: 228175 URL: http://svn.freebsd.org/changeset/base/228175 Log: Fix dialog autosizing: dlg_count_columns() does not handle NL characters. Modified: head/usr.sbin/sade/misc.c Modified: head/usr.sbin/sade/misc.c ============================================================================== --- head/usr.sbin/sade/misc.c Thu Dec 1 07:41:30 2011 (r228174) +++ head/usr.sbin/sade/misc.c Thu Dec 1 09:01:51 2011 (r228175) @@ -233,6 +233,23 @@ xdialog_count_rows(const char *p) return rows ? rows : 1; } +static int +xdialog_count_columns(const char *p) +{ + int len; + int max_len = 0; + const char *q; + + for (; (q = strchr(p, '\n')) != NULL; p = q + 1) { + len = q - p; + max_len = MAX(max_len, len); + } + + len = strlen(p); + max_len = MAX(max_len, len); + return max_len; +} + int xdialog_menu(const char *title, const char *cprompt, int height, int width, int menu_height, int item_no, dialogMenuItem *ditems) @@ -270,7 +287,7 @@ xdialog_menu(const char *title, const ch tag_x = MAX(tag_x, l + k + 2); } } - width = MAX(dlg_count_columns(cprompt), title != NULL ? dlg_count_columns(title) : 0); + width = MAX(xdialog_count_columns(cprompt), title != NULL ? xdialog_count_columns(title) : 0); width = MAX(width, tag_x + 4) + 4; } width = MAX(width, 24); @@ -345,7 +362,7 @@ xdialog_radiolist(const char *title, con check_x = MAX(check_x, l + k + 6); } } - width = MAX(dlg_count_columns(cprompt), title != NULL ? dlg_count_columns(title) : 0); + width = MAX(xdialog_count_columns(cprompt), title != NULL ? xdialog_count_columns(title) : 0); width = MAX(width, check_x + 4) + 4; } width = MAX(width, 24); @@ -397,8 +414,8 @@ xdialog_msgbox(const char *title, const /* calculate width */ if (width < 0) { - width = title != NULL ? dlg_count_columns(title) : 0; - width = MAX(width, dlg_count_columns(cprompt)) + 4; + width = title != NULL ? xdialog_count_columns(title) : 0; + width = MAX(width, xdialog_count_columns(cprompt)) + 4; } if (pauseopt) width = MAX(width, 10);