Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libterminfo



In article <20110310101719.721F2175D0%cvs.netbsd.org@localhost>,
Roy Marples <source-changes-d%NetBSD.org@localhost> wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  roy
>Date:          Thu Mar 10 10:17:19 UTC 2011
>
>Modified Files:
>       src/lib/libterminfo: termcap.c terminfo.5.in
>
>Log Message:
>Add support for translating the following termcap commands into terminfo:
>  %B %D %r %2 %3 %d %+ %> %.
>Fixes PR bin/44692.
>
>

Instead of:

        if (l + 30 > len)
                goto elen;
        *ip++ = '%';
        *ip++ = 'p';
        *ip++ = '0' + p;
        strcpy(ip, "%{10}%/%{16}%*%p");
        ip += 16;
        *ip++ = '0' + p;
        strcpy(ip, "%{10}%m%+");
        ip += 9;
        l += 29;
        nop = 1;


I would put everything in a single format and adjust it:

        static const char fmt[] = "%p0%{10}%/%{16}%*%p0%{10}%m%+";

        if (l + sizeof(fmt) > len)
                goto elen;
        memcpy(ip, fmt, sizeof(fmt) - 1);
        ip[2] += p;
        ip[19] += p;
        ip += sizeof(fmt) - 1;
        l += sizeof(fmt) - 1;
        nop = 1;

I could do all of it the same way assuming that I would encode all characters
in a consistent \000 sequence...

christos



Home | Main Index | Thread Index | Old Index