Re: [dev] [st] [PATCH] Correct shift amount on MODE_INSERT in tputc()

From: Silvan Jegen <s.jegen_AT_gmail.com>
Date: Fri, 30 Jan 2015 10:22:08 +0100

On Fri, Jan 30, 2015 at 12:41 AM, FRIGN <dev_AT_frign.de> wrote:
> On Thu, 29 Jan 2015 15:08:39 -0800
> Rian Hunter <rian+suckless-dev_AT_thelig.ht> wrote:
>
>> When MODE_INSERT is set we'd shift characters on the same
>> line forward before inserting our character in tputc().
>> This did not account for wide characters where width != 1.
>> This patch makes it so we shift the correct amount.
>
>> - if(IS_SET(MODE_INSERT) && term.c.x+1 < term.col)
>> - memmove(gp+1, gp, (term.col - term.c.x - 1) * sizeof(Glyph));
>> + if(IS_SET(MODE_INSERT) && term.c.x+width < term.col)
>> + memmove(gp+width, gp, (term.col - term.c.x - 1) * sizeof(Glyph));
>
>> In tputc(), when a character wasn't large enough to fit
>> on the current line, we would call tnewline() to place it on
>> the next line. Unfortunately, we weren't resetting our glyph
>> pointer and this caused memory corruption when a
>> wide character (width == 2) was being written. This patch
>> resets our glyph pointer after calls to tnewline().
>
>> + gp = &term.line[term.c.y][term.c.x];
>
>> - if(term.c.x+width > term.col)
>> + if(term.c.x+width > term.col) {
>> tnewline(1);
>> + gp = &term.line[term.c.y][term.c.x];
>> + }
>
> Hey Rian,
>
> I tested both patches and second them. Nice work!

_AT_Rian: I tested them both as well and they seem to work fine, thanks!


> However, next time, please attach the patches
> instead of inserting them so people with insane
> mail clients can easily access them without hassle.

I don't think we should encourage this behavior on this list.
Shouldn't we rather assume that people on this list are using sane
mail clients that let them easily save their mails to disk so that
they can use 'git am' to apply them?


Cheers,

Silvan
Received on Fri Jan 30 2015 - 10:22:08 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 30 2015 - 10:24:07 CET