From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id E0BF61381F3 for ; Fri, 20 Sep 2013 08:30:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EB30EE0BD8; Fri, 20 Sep 2013 08:30:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6F786E0BD8 for ; Fri, 20 Sep 2013 08:30:43 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1EE9A33ED16 for ; Fri, 20 Sep 2013 08:30:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id BE42BE5463 for ; Fri, 20 Sep 2013 08:30:40 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1379594199.7f75f89ccdb4a80ed469db1a2fe81a12bad49450.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-checklist.c ufed-curses-types.c X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 7f75f89ccdb4a80ed469db1a2fe81a12bad49450 X-VCS-Branch: master Date: Fri, 20 Sep 2013 08:30:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 1d528880-b745-4a5e-a597-72b5ab3de5d8 X-Archives-Hash: c82559ecf307ec09aea5b8b67ff9e479 commit: 7f75f89ccdb4a80ed469db1a2fe81a12bad49450 Author: Sven Eden gmx net> AuthorDate: Thu Sep 19 12:36:39 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Thu Sep 19 12:36:39 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=7f75f89c Fixed stray 0-bytes that the wrapped description display accidently inserted. --- ufed-curses-checklist.c | 30 ++++++++++++++++++------------ ufed-curses-types.c | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 6a48ba7..e5506c4 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -212,18 +212,20 @@ static int drawflag(sFlag* flag, bool highlight) int lWidth = wWidth(List); // Set up needed buffers - char buf[lWidth + 1]; // Buffer for the line to print - char desc[maxDescWidth]; // Buffer to assemble the description accoring to e_order and e_desc - char special, *pBuf; // force/mask/none character, Helper to fill buf - memset(buf, 0, sizeof(char) * (lWidth + 1)); - memset(desc, 0, sizeof(char) * maxDescWidth); + char buf[lWidth + 1]; // Buffer for the line to print + char desc[maxDescWidth + 1]; // Buffer to assemble the description accoring to e_order and e_desc + char special, *pBuf; // force/mask/none character, Helper to fill buf + memset(buf, ' ', sizeof(char) * lWidth); + memset(desc, ' ', sizeof(char) * maxDescWidth); + buf[lWidth] = 0x0; + desc[maxDescWidth] = 0x0; // Description and wrapped lines state values bool hasBlankLeft = false; // Set to true once the left side is blanked bool hasBlankRight = false; // Set to true once the right (state) side is blanked bool hasHead = false; // Set to true once the left side (flag name and states) are printed - int maxDescWidth = lWidth - minwidth - 8; // Space on the right to print descriptions - size_t length = maxDescWidth; // Characters to print when not wrapping + int rightwidth = lWidth - minwidth - 8; // Space on the right to print descriptions + size_t length = rightwidth; // Characters to print when not wrapping bool newDesc = true; // Set to fals when wrapped parts advance size_t pos = descriptionleft; // position in desc to start printing on int leftover = 0; // When wrapping lines, this is left on the right @@ -295,16 +297,16 @@ static int drawflag(sFlag* flag, bool highlight) } // The right side of buf can be added now: - leftover = maxDescWidth - (int)length; + leftover = rightwidth - (int)length; pBuf = buf + minwidth + (newDesc ? 8 : 10); sprintf(pBuf, "%-*.*s", (int)length, (int)length, - strlen(desc) > pos ? &desc[pos] : ""); + strlen(desc) > pos ? &desc[pos] : " "); // Note: Follow up lines of wrapped descriptions are indented by 2 // Leftover characters on the right must be blanked: if (leftover > 0) - sprintf(pBuf + length, "%-*s", leftover, " "); + sprintf(pBuf + length, "%-*.*s", leftover, leftover, " "); /* Set correct color set according to highlighting and status*/ if(highlight) @@ -736,7 +738,7 @@ static char getFlagSpecialChar(sFlag* flag, int index) static void printFlagInfo(char* buf, sFlag* flag, int index, bool printFlagName, bool printFlagState) { - if (printFlagName) + if (printFlagName) { sprintf(buf, " %c%c%c %s%s%s%-*s ", /* State of selection */ flag->stateConf == ' ' ? '(' : '[', @@ -750,8 +752,10 @@ static void printFlagInfo(char* buf, sFlag* flag, int index, bool printFlagName, (int)(minwidth - (flag->globalForced ? 3 : flag->globalMasked ? 2 : 5) - strlen(flag->name)), " "); + buf[minwidth] = ' '; // No automatic \0, please! + } - if (printFlagState) + if (printFlagState) { /* Display flag state * The order in which the states are to be displayed is: * 1. [D]efaults (make.defaults, IUSE, package.mask, package.force) @@ -767,6 +771,8 @@ static void printFlagInfo(char* buf, sFlag* flag, int index, bool printFlagName, flag->stateConf : flag->desc[index].statePkgUse, flag->desc[index].isGlobal ? ' ' : 'L', flag->desc[index].isInstalled ? 'i' : ' '); + buf[minwidth + 8] = ' '; // No automatic \0, please! + } } static void setFlagWrapDraw(sFlag* flag, int index, sWrap** wrap, size_t* pos, size_t* len, bool* isFirstWrap) diff --git a/ufed-curses-types.c b/ufed-curses-types.c index 9d59234..e6b1139 100644 --- a/ufed-curses-types.c +++ b/ufed-curses-types.c @@ -573,7 +573,7 @@ static void calculateDescWrap(sDesc* desc) end = wLen - 1; // Step 2: Find last space character before end+1 - if ((end > start) && (end < (wLen - 1)) && (' ' != pch[end])) { + if ((end > start) && (' ' != pch[end])) { size_t newEnd = end; for (; (newEnd > start) && (' ' != pch[newEnd]) ; --newEnd) ; if (newEnd > start)