From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aDzpl-00081R-Hc for mharc-grub-devel@gnu.org; Tue, 29 Dec 2015 14:21:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDzpi-00081I-V6 for grub-devel@gnu.org; Tue, 29 Dec 2015 14:21:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDzph-000529-RG for grub-devel@gnu.org; Tue, 29 Dec 2015 14:21:22 -0500 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:36700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDzph-000523-Ku for grub-devel@gnu.org; Tue, 29 Dec 2015 14:21:21 -0500 Received: by mail-wm0-x22e.google.com with SMTP id l65so41192490wmf.1 for ; Tue, 29 Dec 2015 11:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=xrzK7uJ83t1ADcat+t/2eJq+R/Lxgs/Imi9Ny3iaAbw=; b=Qob4txWEinbvQptHOkY1Tg8/BlV6HvYRuolBlazKn1druU3HZQRLQngkFagHriuHNV DwF/h7PJs0hNf/O7uI0YIs1EGaJCYM1LUc8gQ7Sh6miiUlad29pG2010IDkEDaWTUDU0 9HRp4Eato2jdUeEQoTBw62v+blDlenDSBUpZOPubcydZ/4uLWzcNbSxLdjNz3lJ/fgwy /5AdkEDrhrrrmE9yXJyYkGjliG6Xu+kqTFVgTnOp+AMTd22SHYSGrkPZZsHML2B2zSSK Cqwwew9fW7KKFvct/z1TGmrv8Kx8hHLNGhvK3vwNPaxUPpAfJSapPvFq79bdFv8XWKsE rbcw== X-Received: by 10.194.63.142 with SMTP id g14mr65210647wjs.161.1451416881132; Tue, 29 Dec 2015 11:21:21 -0800 (PST) Received: from ?IPv6:2a02:120b:2c2b:b80:a2a8:cdff:fe64:b3b5? ([2a02:120b:2c2b:b80:a2a8:cdff:fe64:b3b5]) by smtp.gmail.com with ESMTPSA id x10sm27952540wjx.8.2015.12.29.11.21.20 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Dec 2015 11:21:20 -0800 (PST) Subject: Re: [PATCH] normal: fix get_logical_num_lines To: The development of GNU GRUB References: <20151223044505.GA28369@linux-dsax.tai.apac.novell.com> <20151228040958.GB17636@linux-dsax.tai.apac.novell.com> From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= Message-ID: <5682DD2A.6000702@gmail.com> Date: Tue, 29 Dec 2015 20:21:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151228040958.GB17636@linux-dsax.tai.apac.novell.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gufdEcs9FsumFu6Q81NDVbo3IUqIjKBBN" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22e X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2015 19:21:24 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gufdEcs9FsumFu6Q81NDVbo3IUqIjKBBN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 28.12.2015 05:09, Michael Chang wrote: > On Thu, Dec 24, 2015 at 02:48:34PM +0300, Andrei Borzenkov wrote: >> On Wed, Dec 23, 2015 at 7:45 AM, Michael Chang wrote= : >>> In menu editing mode, grub2 shows bogus line if the character being >>> edited is at last column of entry. This patch fixes the problem by >>> having the get_logical_num_lines function to calculate correct number= of >>> lines. >>> >>> --- >>> grub-core/normal/menu_entry.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_en= try.c >>> index 62c7e16..1d4b0c6 100644 >>> --- a/grub-core/normal/menu_entry.c >>> +++ b/grub-core/normal/menu_entry.c >>> @@ -128,7 +128,7 @@ get_logical_num_lines (struct line *linep, struct= per_term_screen *term_screen) >>> { >>> return (grub_getstringwidth (linep->buf, linep->buf + linep->len, >>> term_screen->term) >>> - / (unsigned) term_screen->geo.entry_width) + 1; >>> + / ((unsigned) term_screen->geo.entry_width + 1)) + 1; >> >> No, that's wrong. Consider entry_width =3D 10 and grub_getstringwidth = =3D >> 21. It needs 3 lines but your change gives only 2. >=20 > Alas! Indeed I am mistaken here. We should minus the numerator by one > but not adding one to denominator. Thanks for your check. :) >=20 >> >> It sounds like we need >> >> string_width =3D grub_getstringwidth (linep->buf, linep->buf + >> linep->len, term_screen->term); >> if (!string_width) >> return 1; >> return (string_width + (unsigned) term_screen->geo.entry_width - 1) / >> (unsigned) term_screen->geo.entry_width; >> >> Could you test if it works for you? >=20 > Yes. It works great. @Anrei: please go ahead. >=20 > Thanks, > Michael >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --gufdEcs9FsumFu6Q81NDVbo3IUqIjKBBN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREKAAYFAlaC3SoACgkQmBXlbbo5nOvfuwD+MrN5cdmWM6E+/FFweUVW54MA ee2zBsVlFrItqMrumokA/jYiLRqRyTa4ASioc4E3amGWg9UxYYt/sE9DQI6mCyAr =iqO6 -----END PGP SIGNATURE----- --gufdEcs9FsumFu6Q81NDVbo3IUqIjKBBN--