NetBSD-Bugs archive

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

lib/44021: setlocale brekas the history of libedit



>Number:         44021
>Category:       lib
>Synopsis:       setlocale brekas the history of libedit
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 31 17:55:00 +0000 2010
>Originator:     Yui NARUSE
>Release:        NetBSD 5.99.39
>Organization:
>Environment:
NetBSD kelvena.airemix.net 5.99.39 NetBSD 5.99.39 (GENERIC) #0: Sun Oct 31 
00:39:11 JST 2010  
naruse%kelvena.airemix.net@localhost:/usr/obj/sys/arch/amd64/compile/GENERIC 
amd64

>Description:
Calling setlocale(LC_CTYPE, "") and use readline and addhistory of libedit,
its history shows broken strings.
>How-To-Repeat:
Reproducible program is:
% cat r.c
#include <stdio.h>
#include <locale.h>
#include <readline/readline.h>
#include <readline/history.h>

int
main(void)
{
    setlocale(LC_CTYPE, "");
    for (;;) {
        char *r = readline("> ");
        if (!r) {
            fprintf(stderr, "\n");
            return 0;
        }
        fprintf(stderr, "%s\n", r);
        add_history(r);
        free(r);
    }
    return 0;
}

Compile it:
% cc -ledit r.c

Run it:
% ./a.out
> 

It shows prompt, so type some string:
% ./a.out
> aaa

Type Enter
% ./a.out
> aaa
aaa
> 

Now push up arrow key and get a strange string:
% ./a.out
> aaa
aaa
> \U+16161
>Fix:



Home | Main Index | Thread Index | Old Index