fkk@stasys.sta.sub.org (Frank Kaefer) (11/11/90)
Posting-number: Volume 2, Issue 1 Submitted-by: ud@nitmar.ddt.sub.org (Ulrich Dessauer) Archive-name: less8bit.diff [ hier sind die Diffs fuer den Less der TOP 2 Release, um ihn auf 8 Bit "aufzubohren". Damit ist es moeglich Files mit Umlauten und anderen 8 Bit Zeichen mittels Less anzuschauen. - ud ] [ these are the diffs for less (from the TOP release 2) to add the capability to display 8 bit characters. - fkk ] -----------------------------------------------------------------------cut here diff -c /dd/X/LESS/ch.c ./ch.c *** /dd/X/LESS/ch.c Thu Dec 1 12:40:00 1988 --- ./ch.c Wed May 23 13:50:00 1990 *************** *** 178,184 **** --- 178,188 ---- p = &bp->data[bp->datasize]; while (--n >= 0) { + #ifndef OSK *--p &= 0177; + #else OSK + --p; + #endif OSK if (*p == EOI) *p = '@'; } Only in .: ch.r Only in .: command.r Only in .: decode.r Only in .: help.r diff -c /dd/X/LESS/input.c ./input.c *** /dd/X/LESS/input.c Fri May 20 15:10:00 1988 --- ./input.c Wed May 23 16:05:00 1990 *************** *** 12,18 **** --- 12,22 ---- extern int squeeze; extern int sigs; + #ifndef LANG extern char *line; + #else LANG + extern ltype *line; + #endif LANG /* * Get the next line. *************** *** 66,72 **** --- 70,80 ---- } (void) pappend('\0'); + #ifndef LANG if (squeeze && *line == '\0') + #else LANG + if (squeeze && *line == 0) + #endif LANG { /* * This line is blank. Only in .: input.r diff -c /dd/X/LESS/less.h ./less.h *** /dd/X/LESS/less.h Sat May 21 11:15:00 1988 --- ./less.h Wed May 23 15:52:00 1990 *************** *** 59,68 **** --- 59,76 ---- #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ /* Special chars used to tell put_line() to do something special */ + #ifndef LANG #define UL_CHAR (unsigned) 0201 /* Enter underline mode */ #define UE_CHAR (unsigned) 0202 /* Exit underline mode */ #define BO_CHAR (unsigned) 0203 /* Enter boldface mode */ #define BE_CHAR (unsigned) 0204 /* Exit boldface mode */ + #else LANG + typedef unsigned short ltype; + #define UL_CHAR (ltype) 0601 + #define UE_CHAR (ltype) 0602 + #define BO_CHAR (ltype) 0603 + #define BE_CHAR (ltype) 0604 + #endif LANG #define CONTROL(c) ((c)&037) #define SIGNAL(sig,func) signal(sig,func) diff -c /dd/X/LESS/line.c ./line.c *** /dd/X/LESS/line.c Thu Dec 1 12:38:00 1988 --- ./line.c Thu May 24 13:34:00 1990 *************** *** 7,14 **** --- 7,19 ---- #include "less.h" + #ifndef LANG static char linebuf[1024]; /* Buffer which holds the current output line */ static char *curr; /* Pointer into linebuf */ + #else LANG + static ltype linebuf[1024]; + static ltype *curr; + #endif LANG static int column; /* Printable length, accounting for backspaces, etc. */ /* *************** *** 47,54 **** --- 52,63 ---- #define LN_BO_X 5 /* In boldface, got char, need \b */ #define LN_BO_XB 6 /* In boldface, got char & \b, need same char */ + #ifndef LANG public char *line; /* Pointer to the current line. Usually points to linebuf. */ + #else LANG + public ltype *line; + #endif LANG extern int bs_mode; extern int tabstop; *************** *** 80,85 **** --- 89,99 ---- pappend(c) int c; { + #ifdef LANG + while (c < 0) + c += 256; + #endif LANG + if (c == '\0') { /* *************** *** 108,118 **** --- 122,140 ---- break; } ln_state = LN_NORMAL; + #ifndef LANG *curr = '\0'; + #else LANG + *curr = 0; + #endif LANG return (0); } + #ifndef LANG if (curr > linebuf + sizeof(linebuf) - 12) + #else LANG + if (curr > linebuf + sizeof(linebuf) - (12 * sizeof (ltype))) + #endif LANG /* * Almost out of room in the line buffer. * Don't take any chances. *************** *** 130,141 **** --- 152,175 ---- switch (ln_state) { case LN_NORMAL: + #ifndef LANG if (curr <= linebuf + 1 || curr[-1] != '\b') + #else LANG + if (curr <= linebuf + sizeof (ltype) || curr[-1] != '\b') + #endif LANG break; + #ifndef LANG if (c == curr[-2]) + #else LANG + if ((ltype) c == curr[-2]) + #endif LANG goto enter_boldface; + #ifndef LANG if (c == '_' || curr[-2] == '_') + #else LANG + if ((ltype) c == (ltype) '_' || curr[-2] == (ltype) '_') + #endif LANG goto enter_underline; curr -= 2; break; *************** *** 152,159 **** --- 186,198 ---- */ return (1); + #ifndef LANG if (bo_width > 0 && curr > linebuf + 2 && curr[-3] == ' ') + #else LANG + if (bo_width > 0 && + curr > linebuf + (sizeof (ltype) * 2) && curr[-3] == ' ') + #endif LANG { /* * Special case for magic cookie terminals: *************** *** 183,190 **** --- 222,234 ---- */ return (1); + #ifndef LANG if (ul_width > 0 && curr > linebuf + 2 && curr[-3] == ' ') + #else LANG + if (ul_width > 0 && + curr > linebuf + (sizeof (ltype) * 2) && curr[-3] == ' ') + #endif LANG { /* * Special case for magic cookie terminals: *************** *** 200,205 **** --- 244,250 ---- column += ul_width; curr++; } + goto ln_ul_xb_case; /*NOTREACHED*/ case LN_UL_XB: *************** *** 231,237 **** --- 276,286 ---- /* * Termination of a sequnce "X\bX". */ + #ifndef LANG if (c != curr[-2] && (c == '_' || curr[-2] == '_')) + #else LANG + if ((ltype) c != curr[-2] && ((ltype) c == (ltype) '_' || curr[-2] == (ltype) '_')) + #endif LANG { /* * We seem to have run on from *************** *** 286,292 **** --- 335,345 ---- curr[0] = curr[-1]; curr[-1] = UE_CHAR; column += ue_width; + #ifndef LANG if (ue_width > 0 && curr[0] == ' ') + #else LANG + if (ue_width > 0 && curr[0] == (ltype) ' ') + #endif LANG /* * Another special case for magic * cookie terminals: if the next *************** *** 312,318 **** --- 365,375 ---- curr[0] = curr[-1]; curr[-1] = BE_CHAR; column += be_width; + #ifndef LANG if (be_width > 0 && curr[0] == ' ') + #else LANG + if (be_width > 0 && curr[0] == (ltype) ' ') + #endif LANG /* * Another special case for magic * cookie terminals: if the next *************** *** 337,343 **** --- 394,404 ---- { NEW_COLUMN(column+1); } while ((column % tabstop) != 0); + #ifndef LANG *curr++ = '\t'; + #else LANG + *curr++ = (ltype) '\t'; + #endif LANG return (0); } *************** *** 349,355 **** --- 410,420 ---- * Treat backspace as a control char: output "^H". */ NEW_COLUMN(column+2); + #ifndef LANG *curr++ = ('H' | 0200); + #else LANG + *curr++ = (ltype) ('H' | 0400); + #endif LANG } else { /* *************** *** 356,362 **** --- 421,431 ---- * Output a real backspace. */ column--; + #ifndef LANG *curr++ = '\b'; + #else LANG + *curr++ = (ltype) '\b'; + #endif LANG } return (0); } *************** *** 374,380 **** --- 443,453 ---- * 8 bit (e.g. international) character set. }} */ NEW_COLUMN(column+2); + #ifndef LANG *curr++ = (carat_char(c) | 0200); + #else LANG + *curr++ = (ltype) (carat_char(c) | 0400); + #endif LANG return (0); } *************** *** 382,388 **** --- 455,465 ---- * Ordinary character. Just put it in the buffer. */ NEW_COLUMN(column+1); + #ifndef LANG *curr++ = c; + #else LANG + *curr++ = (ltype) c; + #endif LANG return (0); } *************** *** 395,401 **** --- 472,482 ---- forw_raw_line(curr_pos) POSITION curr_pos; { + #ifndef LANG register char *p; + #else LANG + register ltype *p; + #endif LANG register int c; POSITION new_pos; *************** *** 423,432 **** --- 504,523 ---- new_pos = ch_tell() - 1; break; } + #ifndef LANG *p++ = c; + #else LANG + while (c < 0) + c += 256; + *p++ = (ltype) c; + #endif LANG c = ch_forw_get(); } + #ifndef LANG *p = '\0'; + #else LANG + *p = 0; + #endif LANG line = linebuf; return (new_pos); } *************** *** 439,445 **** --- 530,540 ---- back_raw_line(curr_pos) POSITION curr_pos; { + #ifndef LANG register char *p; + #else LANG + register ltype *p; + #endif LANG register int c; POSITION new_pos; *************** *** 448,454 **** --- 543,553 ---- return (NULL_POSITION); p = &linebuf[sizeof(linebuf)]; + #ifndef LANG *--p = '\0'; + #else LANG + *--p = 0; + #endif LANG for (;;) { *************** *** 481,487 **** --- 580,592 ---- new_pos = ch_tell() + 1; break; } + #ifndef LANG *--p = c; + #else LANG + while (c < 0) + c += 256; + *--p = (ltype) c; + #endif LANG } line = p; return (new_pos); Only in .: line.r Only in .: linenum.r diff -c /dd/X/LESS/main.c ./main.c *** /dd/X/LESS/main.c Fri May 20 18:03:00 1988 --- ./main.c Wed May 23 14:54:00 1990 *************** *** 232,244 **** /* * {{ We could use access() here. }} */ ! #ifdef OSK ! exists = open(namelogfile, 1); ! #else exists = open(namelogfile, 0); - #endif close(exists); exists = (exists >= 0); if (exists && !force_logfile) { --- 232,244 ---- /* * {{ We could use access() here. }} */ ! #ifndef OSK exists = open(namelogfile, 0); close(exists); exists = (exists >= 0); + #else OSK + exists = (access (namelogfile, 0) != -1); + #endif OSK if (exists && !force_logfile) { Only in .: main.r diff -c /dd/X/LESS/makefile ./makefile *** /dd/X/LESS/makefile Thu Dec 1 12:38:00 1988 --- ./makefile Wed May 23 14:42:00 1990 *************** *** 1,3 **** --- 1,4 ---- + G= -g # Makefile for "less" # Generated $DATE by $0. # *************** *** 16,27 **** # make clean # Removes "less" and the .r files. # make clobber # Pretty much the same as make "clean". ! SHELL = sh # LIBS is the list of libraries needed. ! LIBS = -l=/h0/lib/termlib.l ! LDLIBS = -l=/h0/lib/os9lib.l # INSTALL_LESS is a list of the public versions of less. # INSTALL_KEY is a list of the public versions of lesskey. --- 17,28 ---- # make clean # Removes "less" and the .r files. # make clobber # Pretty much the same as make "clean". ! SHELL = shell # LIBS is the list of libraries needed. ! LIBS = -l=/dd/lib/termlib.l ! LDLIBS = -l=/dd/lib/os9lib.l # INSTALL_LESS is a list of the public versions of less. # INSTALL_KEY is a list of the public versions of lesskey. *************** *** 39,49 **** # OPTIM is passed to the compiler and the loader. # It is normally "-O" but may be, for example, "-g". ! OPTIM = -ix -qt=/dd ! CFLAGS = $(OPTIM) ! LDFLAGS = -M=5 -G -BG ########################################################################## # Files --- 40,50 ---- # OPTIM is passed to the compiler and the loader. # It is normally "-O" but may be, for example, "-g". ! OPTIM = -qt=/dd $G ! CFLAGS = $(OPTIM) -DLANG ! LDFLAGS = -M=9 $G -BG ########################################################################## # Files *************** *** 62,79 **** # Rules for building stuff ########################################################################## ! all: less lesskey install: install_less install_help install_key install_lman install_kman less: $(OBJ) ! $(CC) $(LDFLAGS) $(OPTIM) -fd=less $(OBJ) $(LIBS) $(LDLIBS) lesskey: lesskey.r ! $(CC) $(LDFLAGS) $(OPTIM) -fd=lesskey lesskey.r $(LDLIBS) # help.r depends on makefile for the definition of HELPFILE help.r: makefile ! $(CC) $(CFLAGS) -r -DHELPFILE=\"$(HELPFILE)\" help.c install_less: less for f in $(INSTALL_LESS); do rm -f $$f; cp less $$f; done --- 63,81 ---- # Rules for building stuff ########################################################################## ! #all: less lesskey ! all: less install: install_less install_help install_key install_lman install_kman less: $(OBJ) ! $(CC) $(LDFLAGS) $(OPTIM) -f=/h0/CMDS/$@ $(OBJ) $(LIBS) $(LDLIBS) lesskey: lesskey.r ! $(CC) $(LDFLAGS) $(OPTIM) -f=/h0/ETC/CMDS/lesskey lesskey.r $(LDLIBS) # help.r depends on makefile for the definition of HELPFILE help.r: makefile ! $(CC) $(CFLAGS) -r '-DHELPFILE="$(HELPFILE)"' help.c install_less: less for f in $(INSTALL_LESS); do rm -f $$f; cp less $$f; done Only in .: option.r Only in .: os.r diff -c /dd/X/LESS/output.c ./output.c *** /dd/X/LESS/output.c Thu Dec 1 12:38:00 1988 --- ./output.c Thu May 24 13:34:00 1990 *************** *** 15,21 **** --- 15,25 ---- extern int twiddle; extern int screen_trashed; extern int any_display; + #ifndef LANG extern char *line; + #else LANG + extern ltype *line; + #endif LANG extern char *first_cmd; /* *************** *** 24,30 **** --- 28,38 ---- public void put_line() { + #ifndef LANG register char *p; + #else LANG + register ltype *p; + #endif LANG register int c; register int column; extern int auto_wrap, ignaw; *************** *** 39,50 **** --- 47,79 ---- } if (line == NULL) + #ifndef LANG line = (twiddle) ? "~" : ""; + #else LANG + if (line == NULL) { + static ltype emptybuf[3]; + line = emptybuf; + if (twiddle) { + line[0] = (ltype) '~'; + line[1] = 0; + } else + line[0] = 0; + } + #endif LANG + column = 0; + #ifndef LANG for (p = line; *p != '\0'; p++) + #else LANG + for (p = line; *p != 0; p++) + #endif LANG { + #ifndef LANG switch (c = *p & 0377) + #else LANG + switch (c = *p & 0777) + #endif LANG { case UL_CHAR: ul_enter(); *************** *** 74,80 **** --- 103,113 ---- column--; break; default: + #ifndef LANG if (c & 0200) + #else LANG + if (c & 0400) + #endif LANG { /* * Control characters arrive here as the Only in .: output.r Only in .: position.r diff -c /dd/X/LESS/prim.c ./prim.c *** /dd/X/LESS/prim.c Fri May 20 15:24:00 1988 --- ./prim.c Fri May 25 16:19:00 1990 *************** *** 20,26 **** --- 20,30 ---- extern int caseless; extern int linenums; extern int plusoption; + #ifndef LANG extern char *line; + #else LANG + extern ltype *line; + #endif LANG extern char *first_cmd; #if TAGS extern int tagoption; *************** *** 628,635 **** --- 632,645 ---- int wantmatch; { POSITION pos, linepos; + #ifndef LANG register char *p; register char *q; + #else LANG + register ltype *p; + register char *q; + char llinebuf[1024]; + #endif LANG int linenum; int linematch; #if RECOMP *************** *** 657,665 **** --- 667,681 ---- * For a caseless search, convert any uppercase * in the pattern to lowercase. */ + #ifndef LANG for (p = pattern; *p != '\0'; p++) if (*p >= 'A' && *p <= 'Z') *p += 'a' - 'A'; + #else LANG + for (q = pattern; *q != '\0'; q++) + if (*q >= 'A' && *q <= 'Z') + *q += 'a' - 'A'; + #endif LANG } #if RECOMP *************** *** 835,840 **** --- 851,857 ---- * This allows us to match text which is * underlined or overstruck. */ + #ifndef LANG for (p = q = line; *p != '\0'; p++, q++) { if (*p >= 'A' && *p <= 'Z') *************** *** 847,853 **** --- 864,894 ---- /* Otherwise, just copy. */ *q = *p; } + #else LANG + q = llinebuf; + for (p = line; *p != 0; p++, q++) + { + if ((char) *p >= 'A' && (char) *p <= 'Z') + *q = (char) *p + 'a' - 'A'; + else if (q > llinebuf && (char) *p == '\b') + q -= 2; + else + *q = (char) *p; + } + *q = '\0'; + #endif LANG + } + #ifdef LANG + else { + q = llinebuf; + for (p = line; *p != 0; p++, q++) + if (q > llinebuf && (char) *p == '\b') + q -= 2; + else + *q = (char) *p; + *q = '\0'; } + #endif LANG /* * Test the next line to see if we have a match. *************** *** 854,859 **** --- 895,901 ---- * This is done in a variety of ways, depending * on what pattern matching functions are available. */ + #ifndef LANG #if REGCMP linematch = (regex(cpattern, line) != NULL); #else *************** *** 863,868 **** --- 905,921 ---- linematch = match(pattern, line); #endif #endif + #else LANG + #if REGCMP + linematch = (regex(cpattern, llinebuf) != NULL); + #else + #if RECOMP + linematch = (re_exec(llinebuf) == 1); + #else + linematch = match(pattern, llinebuf); + #endif + #endif + #endif LANG /* * We are successful if wantmatch and linematch are * both true (want a match and got it), Only in .: prim.r Only in .: prompt.r Only in .: screen.r Only in .: signal.r Only in .: tags diff -c /dd/X/LESS/tags.c ./tags.c *** /dd/X/LESS/tags.c Fri May 20 15:10:00 1988 --- ./tags.c Thu May 24 13:09:00 1990 *************** *** 12,18 **** --- 12,22 ---- extern int linenums; extern int sigs; + #ifndef LANG extern char *line; + #else LANG + extern ltype *line; + #endif LANG /* * Find a tag in the "tags" file. *************** *** 161,168 **** --- 165,187 ---- /* * Test the line to see if we have a match. */ + #ifndef LANG if (strcmp(tagpattern, line) == 0) break; + #else LANG + { + register ltype *p; + register char *q; + char llinebuf[1024]; + + q = llinebuf; + for (p = line; *p != 0; ++p, ++q) + *q = (char) *p; + *q = '\0'; + if (strcmp(tagpattern, llinebuf) == 0) + break; + } + #endif LANG } jump_loc(linepos); Only in .: tags.r Only in .: ttyin.r Only in .: version.r -----------------------------------------------------------------------cut here -- | Frank Kaefer | fkk@stasys.sta.sub.org | Starnberg, Germany | | Compuserve: 72427,2101 | Internet: fkk@Germany.Sun.COM | | unido!sunde!fkaefer | postmaster@Germany.Sun.COM | | THE POWER OF SUN (Scott McNealy) |