Deleted Added
sdiff udiff text old ( 60786 ) new ( 89019 )
full compact
1/*
2 * Copyright (C) 1984-2000 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.

--- 18 unchanged lines hidden (view full) ---

27 * selected by the LESSCHARSET environment variable.
28 */
29struct charset {
30 char *name;
31 int *p_flag;
32 char *desc;
33} charsets[] = {
34 { "ascii", NULL, "8bcccbcc18b95.b" },
35 { "dos", NULL, "8bcccbcc12bc5b95.b." },
36 { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
37 { "iso8859", NULL, "8bcccbcc18b95.33b." },
38 { "koi8-r", NULL, "8bcccbcc18b95.b128." },
39 { "latin1", NULL, "8bcccbcc18b95.33b." },
40 { "next", NULL, "8bcccbcc18b95.bb125.bb" },
41 { "utf-8", &utf_mode, "8bcccbcc18b." },
42 { NULL, NULL, NULL }
43};
44
45#define IS_BINARY_CHAR 01
46#define IS_CONTROL_CHAR 02
47
48static char chardef[256];
49static char *binfmt = NULL;
50public int binattr = AT_STANDOUT;
51
52

--- 68 unchanged lines hidden (view full) ---

121 * Define a charset, given a charset name.
122 * The valid charset names are listed in the "charsets" array.
123 */
124 static int
125icharset(name)
126 register char *name;
127{
128 register struct charset *p;
129
130 if (name == NULL || *name == '\0')
131 return (0);
132
133 for (p = charsets; p->name != NULL; p++)
134 {
135 if (strcmp(name, p->name) == 0)
136 {
137 ichardef(p->desc);
138 if (p->p_flag != NULL)
139 *(p->p_flag) = 1;
140 return (1);

--- 96 unchanged lines hidden (view full) ---

237#endif
238
239#if HAVE_LOCALE
240 /*
241 * Use setlocale.
242 */
243 ilocale();
244#else
245 /*
246 * Default to "latin1".
247 */
248 (void) icharset("latin1");
249#endif
250}
251
252/*
253 * Is a given character a "binary" character?
254 */
255 public int
256binary_char(c)
257 unsigned char c;

--- 23 unchanged lines hidden (view full) ---

281{
282 static char buf[8];
283
284 c &= 0377;
285 if (!control_char(c))
286 sprintf(buf, "%c", c);
287 else if (c == ESC)
288 sprintf(buf, "ESC");
289 else if (c < 128 && !control_char(c ^ 0100))
290 sprintf(buf, "^%c", c ^ 0100);
291 else
292 sprintf(buf, binfmt, c);
293 return (buf);
294}