From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4687 invoked by alias); 15 Jan 2018 10:36:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42285 Received: (qmail 26235 invoked by uid 1010); 15 Jan 2018 10:36:40 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f68.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.68):SA:0(-1.9/5.0):. Processed in 7.036002 secs); 15 Jan 2018 10:36:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: warepire.ml@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zhj0Kqif3kmZ1bgzyeE0vCd+pDGrWaAXskfBWXzWK9A=; b=aXKFhiY2g/NSrC+apdFte7Es8VOESMTQtV29zueTt8U/kVwGQkbiUVxvbEcwB9Igpt 7nntVtW5I4irbqY4RHFDmP8N+uyYJa2KGuIMbHiAlygJUyff7z8dD+h+ueePEpF2cL5K yF+2npedu63bmSUSE02QmjY0+dwGcoXocVuzj/DYNz1AaJdN+LM90UNLEYATKZyz86VH n1c24vxDal1l1VxeTtJUgxmi3Y69up+hlsRdHQEQvZ655udm3LoJgtgkDqiBapJ+u2oM sp9JXUoFLC3fy4YhezPBQeN3BZuYJaWkQrMXcPRg0pyKwuJM3EQ7Eg9p1I4rffy3S9er mG5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Zhj0Kqif3kmZ1bgzyeE0vCd+pDGrWaAXskfBWXzWK9A=; b=d6kfBoMB0MRga6fansZUF34sw9nczynGeN1Hevw0tkkiE8VSts42YUblvdptWgJ5ri 27ncckf5vzeB5UCgTkCXkSurzq3gTpypIOcDa+3fbAHZwIWipfkVoWzrr6IpmkkUmNxO rheL0LUVVPUlNLnC8IgQpWnr5KIuTBnEiJsqRhLaeCuihr421MY94UUERvcD6dhb8BPV sQ71TjBPF8eaUW28Kd34U+1UWA2HzsmILIky40BvQJBWyTUKgqMTEx0wx8EudrF3aTyz LHwqdnSvgH5Ac1MQH9lRrqCi3Or5b4bc8O+lqJfc9ikzQ27x8OlRvsP3MBobR4bRKxas StCg== X-Gm-Message-State: AKwxytdWZA0kXSeXk/0ogFoQHWQMNjPHCeQXHf55P9DQcA5gwHjVV5Sc Omt3IDYwDk5iggANxLJs/njLkkxoLA== X-Google-Smtp-Source: ACJfBovCn7+KdvGCabyw3Z70MXDFRUkbaEQYHUNIC40dYHAAQgDvXIqwIu931ViwL4rPDaFa8msY8A== X-Received: by 10.25.210.144 with SMTP id j138mr18973541lfg.42.1516012588032; Mon, 15 Jan 2018 02:36:28 -0800 (PST) From: warepire.ml@gmail.com To: zsh-workers@zsh.org Cc: Warepire Subject: [PATCH 1/1] prompt: Fix an off-by-one in the overf check in countpromt. Date: Mon, 15 Jan 2018 11:35:58 +0100 Message-Id: <20180115103558.1258-2-warepire.ml@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180115103558.1258-1-warepire.ml@gmail.com> References: <20180115103558.1258-1-warepire.ml@gmail.com> From: Warepire This triggers overf when the prompt is exactly as wide as the term, causes countprompt to count a 2-line prompt as 3 lines. Which transmits an errorneus TCUP to the PTY. In some terminals this causes the last line of the previous command to be erased. Hexdumping the PTY in benign and trouble cases, for my term TCUP is represented by "\x1b[A". The NOK dumps are when the prompt is exactly as wide as the term. OK chunk dump: 0000 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b ..[0m.[27m.[24m. 0010 5b 4a 1b 5b 33 33 6d 7e 2f 76 74 65 2d 6e 67 2d [J.[33m~/vte-ng- 0020 30 2e 35 30 2e 32 2e 61 1b 5b 30 30 6d 20 0d 0a 0.50.2.a.[00m .. 0030 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b .[37mwarepire %. 0040 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 [00m .[K.[64C.[0 0050 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 1;32m....[00m IN 0060 53 1b 5b 36 39 44 0d 0d 1b 5b 41 1b 5b 3f 32 30 S.[69D...[A.[?20 <-- Correct number of TCUP 0070 30 34 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 04h.[0m.[27m.[24 0080 6d 1b 5b 4a 1b 5b 33 33 6d 7e 2f 76 74 65 2d 6e m.[J.[33m~/vte-n 0090 67 2d 30 2e 35 30 2e 32 2e 61 1b 5b 30 30 6d 20 g-0.50.2.a.[00m 00a0 0d 0a 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 ...[37mwarepire 00b0 25 1b 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b %.[00m .[K.[64C. 00c0 5b 30 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 [01;32m....[00m 00d0 49 4e 53 1b 5b 36 39 44 INS.[69D NOK chunk dump: 0000 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b ..[0m.[27m.[24m. 0010 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 69 [J.[33m~/test-di 0020 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 61 r/aaaaaaaaaaaaaa 0030 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0050 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 62 aaaaa/bbbbbbbbbb 0060 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a 1b bbb/ccc.[00m ... 0070 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b 5b [37mwarepire %.[ 0080 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 00m .[K.[64C.[01 0090 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 ;32m....[00m INS 00a0 1b 5b 36 39 44 0d 0d 1b 5b 41 1b 5b 41 1b 5b 3f .[69D...[A.[A.[? <--- Incorrect number of TCUP 00b0 32 30 30 34 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 2004h.[0m.[27m.[ 00c0 32 34 6d 1b 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 24m.[J.[33m~/tes 00d0 74 2d 64 69 72 2f 61 61 61 61 61 61 61 61 61 61 t-dir/aaaaaaaaaa 00e0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 00f0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0100 61 61 61 61 61 61 61 61 61 2f 62 62 62 62 62 62 aaaaaaaaa/bbbbbb 0110 62 62 62 62 62 62 62 2f 63 63 63 1b 5b 30 30 6d bbbbbbb/ccc.[00m 0120 20 0d 0a 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 ...[37mwarepire 0130 20 25 1b 5b 30 30 6d 20 1b 5b 4b 1b 5b 36 34 43 %.[00m .[K.[64C 0140 1b 5b 30 31 3b 33 32 6d e2 9c 94 1b 5b 30 30 6d .[01;32m....[00m 0150 20 49 4e 53 1b 5b 36 39 44 INS.[69D NOK chunks from I/O channel: 0 chars and 0 bytes in 1 chunks left to process. read/bp: 0000 00 0d 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d ...[0m.[27m.[24m 0010 1b 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 .[J.[33m~/test-d 0020 69 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 ir/aaaaaaaaaaaaa 0030 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0050 61 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 aaaaaa/bbbbbbbbb 0060 62 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a bbbb/ccc.[00m .. 0070 1b 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b .[37mwarepire %. 0080 5b 30 30 6d 20 [00m read 132/5355 bytes, again? yes, active? yes read/bp: 0000 00 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 3b 33 32 ..[K.[64C.[01;32 0010 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 1b 5b 36 m....[00m INS.[6 0020 39 44 9D read 165/5355 bytes, again? yes, active? yes read/bp: 0000 00 0d 0d 1b 5b 41 1b 5b 41 1b 5b 3f 32 30 30 34 ....[A.[A.[?2004 <--- Incorrect number of TCUP 0010 68 1b 5b 30 6d 1b 5b 32 37 6d 1b 5b 32 34 6d 1b h.[0m.[27m.[24m. 0020 5b 4a 1b 5b 33 33 6d 7e 2f 74 65 73 74 2d 64 69 [J.[33m~/test-di 0030 72 2f 61 61 61 61 61 61 61 61 61 61 61 61 61 61 r/aaaaaaaaaaaaaa 0040 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0050 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa 0060 61 61 61 61 61 2f 62 62 62 62 62 62 62 62 62 62 aaaaa/bbbbbbbbbb 0070 62 62 62 2f 63 63 63 1b 5b 30 30 6d 20 0d 0a 1b bbb/ccc.[00m ... 0080 5b 33 37 6d 77 61 72 65 70 69 72 65 20 25 1b 5b [37mwarepire %.[ 0090 30 30 6d 20 00m read 312/5355 bytes, again? yes, active? yes read/bp: 0000 00 1b 5b 4b 1b 5b 36 34 43 1b 5b 30 31 3b 33 32 ..[K.[64C.[01;32 0010 6d e2 9c 94 1b 5b 30 30 6d 20 49 4e 53 1b 5b 36 m....[00m INS.[6 0020 39 44 9D Fixes: commit fa699be45debba815ea5e3ed5bfebde280d894a0 Signed-off-by: Warepire --- Src/prompt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/prompt.c b/Src/prompt.c index c478e69fb..9b9e33670 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1087,7 +1087,7 @@ countprompt(char *str, int *wp, int *hp, int overf) #endif for (; *str; str++) { - if (w >= zterm_columns && overf >= 0) { + if (w > zterm_columns && overf >= 0) { w = 0; h++; } -- 2.15.1