]> git.pld-linux.org Git - packages/less.git/commitdiff
- use the locale to determine the charset, if not defined by LESSCHARSET
authorsaq <saq@pld-linux.org>
Sun, 29 Feb 2004 18:22:47 +0000 (18:22 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    less-locale-charmap.patch -> 1.1

less-locale-charmap.patch [new file with mode: 0644]

diff --git a/less-locale-charmap.patch b/less-locale-charmap.patch
new file mode 100644 (file)
index 0000000..c8d44cd
--- /dev/null
@@ -0,0 +1,76 @@
+--- less-381/charset.c.orig    2004-02-29 18:44:58.924400032 +0100
++++ less-381/charset.c 2004-02-29 18:54:08.049920264 +0100
+@@ -18,13 +18,14 @@
+ #if HAVE_LOCALE
+ #include <locale.h>
+ #include <ctype.h>
++#include <langinfo.h>
+ #endif
+ public int utf_mode = 0;
+ /*
+  * Predefined character sets,
+- * selected by the LESSCHARSET environment variable.
++ * selected by the locale or the LESSCHARSET environment variable.
+  */
+ struct charset {
+       char *name;
+@@ -216,6 +217,16 @@
+       binfmt = s;
+ }
++static char *
++charmap2chardef(const char *s) {
++      if (strcmp(s, "UTF-8") == 0) return "utf-8";
++      if (strncmp(s, "ISO-8859-", 9) == 0) return "iso8859";
++      if (strcmp(s, "ANSI_X3.4-1968") == 0) return "ascii";
++      if (strcmp(s, "KOI8-R") == 0) return "koi8-r";
++      /* The charmap hasn't been recognized */
++      return NULL;
++}
++
+ /*
+  * Initialize charset data structures.
+  */
+@@ -242,18 +253,14 @@
+               ichardef(s);
+               return;
+       }
+-
+-#if HAVE_STRSTR
+       /*
+-       * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
++       * Use the locale charset as a fallback.
+        */
+-      if ((s = lgetenv("LC_ALL")) != NULL ||
+-          (s = lgetenv("LC_CTYPE")) != NULL ||
+-          (s = lgetenv("LANG")) != NULL)
+-      {
+-              if (strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL)
+-                      if (icharset("utf-8"))
+-                              return;
++#if HAVE_LOCALE
++      setlocale(LC_ALL, "");
++      s = charmap2chardef(nl_langinfo(CODESET));
++      if (s != NULL) {
++              if (icharset(s)) return;
+       }
+ #endif
+--- less-381/less.nro.orig     2004-02-29 18:57:02.153452504 +0100
++++ less-381/less.nro  2004-02-29 18:59:32.351618912 +0100
+@@ -1102,7 +1102,12 @@
+ .PP
+ A "character set" is simply a description of which characters are to
+ be considered normal, control, and binary.
+-The LESSCHARSET environment variable may be used to select a character set.
++If available, the locale settings are used to determine the character set
++used. The following locale character maps are recognized: UTF-8,
++ANSI_X3.4-1968, KOI8-R, ISO-8859-*. If the locale-based selection fails 
++for you,
++the LESSCHARSET environment variable may be used to select a character 
++set.
+ Possible values for LESSCHARSET are:
+ .IP ascii
+ BS, TAB, NL, CR, and formfeed are control characters,
This page took 0.191148 seconds and 4 git commands to generate.