Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit From Jess Thrysoee



details:   https://anonhg.NetBSD.org/src/rev/05b20015c62d
branches:  trunk
changeset: 753980:05b20015c62d
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 15 00:56:40 2010 +0000

description:
>From Jess Thrysoee
   - use nl_langinfo to test for UTF-8, because some locales are UTF-8 without
     reflecting it in their names.

diffstat:

 lib/libedit/el.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (57 lines):

diff -r 929b510c2613 -r 05b20015c62d lib/libedit/el.c
--- a/lib/libedit/el.c  Thu Apr 15 00:55:57 2010 +0000
+++ b/lib/libedit/el.c  Thu Apr 15 00:56:40 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.58 2009/12/31 15:58:26 christos Exp $ */
+/*     $NetBSD: el.c,v 1.59 2010/04/15 00:56:40 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.58 2009/12/31 15:58:26 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.59 2010/04/15 00:56:40 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -51,6 +51,7 @@
 #include <stdarg.h>
 #include <ctype.h>
 #include <locale.h>
+#include <langinfo.h>
 #include "el.h"
 
 /* el_init():
@@ -59,9 +60,6 @@
 public EditLine *
 el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
 {
-#ifdef WIDECHAR
-       char *locale;
-#endif
        EditLine *el = (EditLine *) el_malloc(sizeof(EditLine));
 
        if (el == NULL)
@@ -86,8 +84,8 @@
          */
        el->el_flags = 0;
 #ifdef WIDECHAR
-       if ((locale = setlocale(LC_CTYPE, NULL)) != NULL){
-               if (strcasestr(locale, ".UTF-8") != NULL)
+       if (setlocale(LC_CTYPE, NULL) != NULL){
+               if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
                        el->el_flags |= CHARSET_IS_UTF8;
        }
 #endif
@@ -266,7 +264,8 @@
                ptr_t ptr = va_arg(ap, ptr_t);
 
                rv = hist_set(el, func, ptr);
-               el->el_flags &= ~NARROW_HISTORY;
+               if (!(el->el_flags & CHARSET_IS_UTF8))
+                       el->el_flags &= ~NARROW_HISTORY;
                break;
        }
 



Home | Main Index | Thread Index | Old Index