home *** CD-ROM | disk | FTP | other *** search
- Only in new: README.OS2
- Only in new: Makefile
- Only in new: Defines.h
- Only in new: Patches.os2
- Only in new: pipe.c
- Only in new: regerror.c
- Only in new: regexp.c
- Only in new: regexp.h
- Only in new: regmagic.h
- Only in new: regsub.c
- Only in new: termcap.c
- Only in new: termcap.dat
- Only in new: less.cs
- Only in new: less.bad
- Only in new: less.def
- Only in new: lesskey.cs
- Only in new: less.ini
- Only in new: lesskey.inp
- diff -cbBw orig/charset.c new/charset.c
- *** orig/charset.c Thu Apr 04 06:43:56 1991
- --- new/charset.c Thu Jun 27 14:37:22 1991
- ***************
- *** 15,20 ****
- --- 15,21 ----
- } charsets[] = {
- { "ascii", "8bcccbcc18b95.b" },
- { "latin1", "8bcccbcc18b95.33b." },
- + { "pc8", "8bcccbcc18b95.b128." },
- { NULL }
- };
-
- ***************
- *** 144,150 ****
- --- 145,155 ----
- return;
- }
-
- + #ifdef OS2
- + (void) icharset("pc8");
- + #else
- (void) icharset("ascii");
- + #endif
-
- s = getenv("LESSBINFMT");
- if (s != NULL && *s != '\0')
- diff -cbBw orig/decode.c new/decode.c
- *** orig/decode.c Thu Apr 04 06:43:16 1991
- --- new/decode.c Thu Jun 27 14:42:38 1991
- ***************
- *** 25,30 ****
- --- 25,34 ----
- #include <io.h>
- #include <stdlib.h>
- #endif
- + #ifdef OS2
- + #include <io.h>
- + #include <fcntl.h>
- + #endif
-
- /*
- * Command table is ordered roughly according to expected
- ***************
- *** 281,287 ****
- * Try to open the lesskey file.
- * If we can't, return an error.
- */
- ! f = open(filename, 0);
- if (f < 0)
- return (-1);
-
- --- 285,291 ----
- * Try to open the lesskey file.
- * If we can't, return an error.
- */
- ! f = open(filename, O_RDONLY | O_BINARY);
- if (f < 0)
- return (-1);
-
- ***************
- *** 308,314 ****
- close(f);
- return (-1);
- }
- ! if ((t->t_start = (char *) calloc(len, sizeof(char))) == NULL)
- {
- free((char *)t);
- close(f);
- --- 312,318 ----
- close(f);
- return (-1);
- }
- ! if ((t->t_start = (char *) calloc((int) len, sizeof(char))) == NULL)
- {
- free((char *)t);
- close(f);
- ***************
- *** 352,361 ****
- --- 356,369 ----
- {
- char *filename;
-
- + #ifdef OS2
- + filename = homefile("less.ini");
- + #else
- #if __MSDOS__
- filename = homefile("_less");
- #else
- filename = homefile(".less");
- + #endif
- #endif
- if (filename == NULL)
- return;
- diff -cbBw orig/edit.c new/edit.c
- *** orig/edit.c Thu Apr 04 06:43:56 1991
- --- new/edit.c Thu Jun 27 14:43:40 1991
- ***************
- *** 7,14 ****
- #include <io.h>
- #endif
-
- #define ISPIPE(fd) ((fd)==0)
- ! extern int ispipe;
- extern int new_file;
- extern int errmsgs;
- extern int quit_at_eof;
- --- 7,22 ----
- #include <io.h>
- #endif
-
- + #ifdef OS2
- + #include <stdio.h>
- + #include <fcntl.h>
- + #include <io.h>
- + #endif
- +
- + extern FILE *popen();
- +
- #define ISPIPE(fd) ((fd)==0)
- ! extern int ispipe, iscompressed, wascompressed;
- extern int new_file;
- extern int errmsgs;
- extern int quit_at_eof;
- ***************
- *** 22,27 ****
- --- 30,38 ----
- extern IFILE old_ifile;
- extern struct scrpos initial_scrpos;
-
- + extern FILE * compress;
- + extern FILE * oldcompr;
- +
- #if LOGFILE
- extern int logfile;
- extern int force_logfile;
- ***************
- *** 63,73 ****
- --- 74,105 ----
- error("%s", &parg);
- free(parg.p_string);
- return (1);
- + } else if (isZfile(filename))
- + {
- + char cmd[255];
- +
- + sprintf(cmd, "compress -dc <%s", filename);
- + compress = popen(cmd, "r");
- + f = fileno(compress);
- +
- + if ( compress == NULL || f < 0 )
- + {
- + s = errno_message(filename);
- + error(s);
- + free(s);
- + return (1);
- + }
- +
- + iscompressed = 1;
- #if __MSDOS__
- } else if ((f = open(filename, O_RDONLY|O_BINARY)) < 0)
- #else
- + #ifdef OS2
- + } else if ((f = open(filename, O_RDONLY|O_BINARY)) < 0)
- + #else
- } else if ((f = open(filename, 0)) < 0)
- #endif
- + #endif
- {
- parg.p_string = errno_message(filename);
- error("%s", &parg);
- ***************
- *** 98,105 ****
- --- 130,142 ----
- #else
- parg.p_string = "less -\\?";
- #endif
- + #ifdef OS2
- + usage();
- + error("\nCannot take input from a terminal.");
- + #else
- error("Cannot take input from a terminal (\"%s\" for help)",
- &parg);
- + #endif
- if (!ISPIPE(f))
- close(f);
- return (1);
- ***************
- *** 133,141 ****
- --- 170,182 ----
- /*
- * Close the current file, unless it is a pipe.
- */
- + if (wascompressed)
- + pclose(oldcompr);
- + else
- if (!ISPIPE(file))
- close(file);
- file = f;
- + oldcompr = compress;
-
- if (f < 0)
- return (1);
- ***************
- *** 148,154 ****
- curr_ifile = get_ifile(filename, curr_ifile);
- get_pos(curr_ifile, &initial_scrpos);
-
- ! ispipe = ISPIPE(f);
- if (ispipe)
- ch_pipe();
- else
- --- 189,197 ----
- curr_ifile = get_ifile(filename, curr_ifile);
- get_pos(curr_ifile, &initial_scrpos);
-
- ! ispipe = ISPIPE(f) || iscompressed;
- ! wascompressed = iscompressed;
- ! iscompressed = 0;
- if (ispipe)
- ch_pipe();
- else
- diff -cbBw orig/filename.c new/filename.c
- *** orig/filename.c Thu Apr 04 06:43:58 1991
- --- new/filename.c Thu Jun 27 14:40:34 1991
- ***************
- *** 45,50 ****
- --- 45,63 ----
- sprintf(pathname, "%s\\%s", homedir, filename);
- }
- #else
- + #ifdef OS2
- + pathname = (char *) calloc(256, sizeof(char));
- + if (pathname == NULL)
- + return NULL;
- + _searchenv(filename, "INIT", pathname);
- + if ( pathname[0] == 0 )
- + _searchenv(filename, "PATH", pathname);
- + if ( pathname[0] == 0 )
- + {
- + free(pathname);
- + return NULL;
- + }
- + #else
- if (homedir == NULL)
- return (NULL);
- pathname = (char *) calloc(strlen(homedir)+strlen(filename)+2,
- ***************
- *** 53,58 ****
- --- 66,72 ----
- return (NULL);
- sprintf(pathname, "%s/%s", homedir, filename);
- #endif
- + #endif
- return (pathname);
- }
-
- ***************
- *** 70,76 ****
- * Look in current directory.
- */
- if (access(HELPFILE,0) == 0)
- ! return (HELPFILE);
- /*
- * Find the basename of HELPFILE,
- * and look for it in each directory in the search path.
- --- 84,90 ----
- * Look in current directory.
- */
- if (access(HELPFILE,0) == 0)
- ! return (save(HELPFILE));
- /*
- * Find the basename of HELPFILE,
- * and look for it in each directory in the search path.
- ***************
- *** 83,89 ****
- --- 97,107 ----
- #else
- if ((helpfile = getenv("LESSHELP")) != NULL)
- return (save(helpfile));
- + #ifdef OS2
- + return (homefile(HELPFILE));
- + #else
- return (save(HELPFILE));
- + #endif
- #endif
- }
-
- diff -cbBw orig/help.c new/help.c
- *** orig/help.c Thu Apr 04 06:43:16 1991
- --- new/help.c Thu Jun 27 14:37:30 1991
- ***************
- *** 9,14 ****
- --- 9,18 ----
-
- #include "less.h"
-
- + #ifndef HELPFILE
- + #define HELPFILE "less.hlp"
- + #endif
- +
- #if __MSDOS__
- #include <io.h>
- #include <dir.h>
- ***************
- *** 43,51 ****
- --- 47,61 ----
- #else
- cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
- sizeof(char));
- + #ifdef OS2
- + sprintf(cmd,
- + "-%s -m -H -+E -+s \"-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done \" %s",
- + progname, helpfile);
- + #else
- sprintf(cmd,
- "-%s -m -H -+E -+s '-PmHELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done ' %s",
- progname, helpfile);
- + #endif
- #endif
- free(helpfile);
- lsystem(cmd);
- diff -cbBw orig/less.h new/less.h
- *** orig/less.h Thu Apr 04 06:44:00 1991
- --- new/less.h Thu Jun 27 14:37:32 1991
- ***************
- *** 107,113 ****
- --- 107,117 ----
- /* Library function declarations */
- offset_t lseek();
- #define BAD_LSEEK ((offset_t)-1)
- + #ifdef OS2
- + VOID_POINTER calloc(unsigned, unsigned);
- + #else
- VOID_POINTER calloc();
- + #endif
-
- #define ch_zero() ((POSITION)0)
- #include "funcs.h"
- diff -cbBw orig/lesskey.c new/lesskey.c
- *** orig/lesskey.c Thu Apr 04 06:44:02 1991
- --- new/lesskey.c Thu Jun 27 14:37:34 1991
- ***************
- *** 128,133 ****
- --- 128,134 ----
- * Process command line arguments.
- */
- outfile = NULL;
- + p =argv[0];
- while (--argc > 0 && **(++argv) == '-')
- {
- switch (argv[0][1])
- ***************
- *** 137,152 ****
- if (*outfile == '\0')
- {
- if (--argc <= 0)
- ! usage();
- outfile = *(++argv);
- }
- break;
- default:
- ! usage();
- }
- }
- if (argc > 1)
- ! usage();
-
-
- /*
- --- 138,153 ----
- if (*outfile == '\0')
- {
- if (--argc <= 0)
- ! usage(p);
- outfile = *(++argv);
- }
- break;
- default:
- ! usage(p);
- }
- }
- if (argc > 1)
- ! usage(p);
-
-
- /*
- ***************
- *** 160,165 ****
- --- 161,169 ----
- exit(1);
- }
- } else
- + if ( isatty(fileno(stdin)) )
- + usage(p);
- + else
- desc = stdin;
-
- /*
- ***************
- *** 283,288 ****
- --- 287,300 ----
- */
- if (outfile == NULL)
- {
- + #ifdef OS2
- + if ( p = getenv("INIT") )
- + strcpy(line, p);
- + else
- + strcpy(line, ".");
- +
- + strcat(line, "\\less.ini");
- + #else
- p = getenv("HOME");
- if (p == NULL || *p == '\0')
- {
- ***************
- *** 302,307 ****
- --- 314,320 ----
- #endif
- }
- outfile = line;
- + #endif
- }
- if ((out = fopen(outfile, "w")) == NULL)
- perror(outfile);
- ***************
- *** 353,360 ****
- return (*p);
- }
-
- ! usage()
- {
- ! fprintf(stderr, "usage: lesskey [-o output] [input]\n");
- exit(1);
- }
- --- 366,374 ----
- return (*p);
- }
-
- ! usage(name)
- ! char *name;
- {
- ! fprintf(stderr, "\nUsage: %s [-o output] [input]\n", name);
- exit(1);
- }
- diff -cbBw orig/line.c new/line.c
- *** orig/line.c Thu Apr 04 06:44:02 1991
- --- new/line.c Thu Jun 27 14:37:36 1991
- ***************
- *** 29,34 ****
- --- 29,38 ----
- extern int bl_s_width, bl_e_width;
- extern int sc_width, sc_height;
-
- + #ifdef OS2
- + static int do_append();
- + #endif
- +
- /*
- * Rewind the line buffer.
- */
- ***************
- *** 320,326 ****
- {
- STOREC(' ', NORMAL);
- } while ((column % tabstop) != 0);
- ! } else if (control_char(c))
- {
- do_control_char:
- if (ctldisp == 0)
- --- 324,333 ----
- {
- STOREC(' ', NORMAL);
- } while ((column % tabstop) != 0);
- ! }
- ! /* else if (c == '\r')
- ! return(0); */
- ! else if (control_char(c))
- {
- do_control_char:
- if (ctldisp == 0)
- diff -cbBw orig/lsystem.c new/lsystem.c
- *** orig/lsystem.c Thu Apr 04 06:44:02 1991
- --- new/lsystem.c Thu Jun 27 14:37:38 1991
- ***************
- *** 25,30 ****
- --- 25,36 ----
- void swchar_to_unix();
- #endif
-
- + #ifdef OS2
- + #include <process.h>
- + extern int _osmode;
- + #define DOS_MODE 0
- + #endif
- +
- extern char *getenv();
-
- extern int screen_trashed;
- ***************
- *** 93,99 ****
- --- 99,109 ----
- #else
- inp = dup(0);
- close(0);
- + #ifdef OS2
- + if (open("con", 0) < 0)
- + #else
- if (open("/dev/tty", 0) < 0)
- + #endif
- dup(inp);
- #endif
-
- ***************
- *** 118,123 ****
- --- 128,144 ----
- }
- #else
- p = NULL;
- + #ifdef OS2
- + if ( *cmd == 0 )
- + {
- + if ( (p = getenv("COMSPEC")) == NULL )
- + p = (_osmode == DOS_MODE) ? "COMMAND" : "CMD";
- +
- + spawnlp(P_WAIT, p, p, NULL);
- + }
- + else
- + system(cmd);
- + #else
- if ((shell = getenv("SHELL")) != NULL && *shell != '\0')
- {
- if (*cmd == '\0')
- ***************
- *** 139,144 ****
- --- 160,166 ----
-
- system(p);
- free(p);
- + #endif
- #endif
-
- /*
- diff -cbBw orig/main.c new/main.c
- *** orig/main.c Thu Apr 04 06:44:04 1991
- --- new/main.c Thu Jun 27 14:37:40 1991
- ***************
- *** 5,11 ****
- #include "less.h"
- #include "position.h"
-
- ! public int ispipe;
- public char * every_first_cmd = NULL;
- public int new_file;
- public int is_tty;
- --- 5,16 ----
- #include "less.h"
- #include "position.h"
-
- ! #ifdef OS2
- ! #include <stdio.h>
- ! #include <fcntl.h>
- ! #endif
- !
- ! public int ispipe, iscompressed, wascompressed;
- public char * every_first_cmd = NULL;
- public int new_file;
- public int is_tty;
- ***************
- *** 24,29 ****
- --- 29,37 ----
- extern int screen_trashed;
- extern int force_open;
-
- + public FILE * compress;
- + public FILE * oldcompr;
- +
- #if LOGFILE
- public int logfile = -1;
- public int force_logfile = 0;
- ***************
- *** 41,46 ****
- --- 49,87 ----
- extern int tagoption;
- #endif
-
- + char *myname;
- + extern char version[];
- +
- + extern char *strchr();
- +
- +
- + usage()
- + {
- + int x = strlen(myname);
- +
- + printf("\nThis is %s.\n", version + 5);
- + printf("\nUsage: %s [-[+]aABcCdeEfgimMnNqQruUsw] [-bN] [-hN] [-xN] [-[z]N]", myname);
- + printf("\n %*s [-P[mM=]string] [-[lL]logfile] [-kkeyfile]", x, "");
- + printf("\n %*s [+cmd] [-ttag] [filename]...\n", x, "");
- + printf("\n or: %s -?\n", myname);
- + }
- +
- +
- + int isZfile(name)
- + char *name;
- + {
- + int res, magic, file;
- +
- + #ifdef OS2
- + file = open(name, O_RDONLY | O_BINARY);
- + #else
- + file = open(name, O_RDONLY);
- + #endif
- + res = read(file, &magic, 2);
- + close(file);
- +
- + return (res == 2) && (magic == 0x9D1F);
- + }
-
-
- /*
- ***************
- *** 54,59 ****
- --- 95,101 ----
- int nofiles;
- extern char *getenv();
-
- + myname = argv[0];
- progname = *argv++;
-
- /*
- ***************
- *** 257,262 ****
- --- 299,310 ----
- {
- lower_left();
- clear_eol();
- +
- + if (file > 0)
- + if (wascompressed)
- + pclose(oldcompr);
- + else
- + close(file);
- }
- deinit();
- flush();
- diff -cbBw orig/option.c new/option.c
- *** orig/option.c Thu Apr 04 06:44:04 1991
- --- new/option.c Thu Jun 27 14:37:42 1991
- ***************
- *** 20,25 ****
- --- 20,29 ----
- extern int screen_trashed;
- extern char *every_first_cmd;
-
- + #ifdef OS2
- + static int toggle_triple();
- + #endif
- +
- /*
- * Scan an argument (either from the command line or from the
- * LESS environment variable) and process it.
- diff -cbBw orig/screen.c new/screen.c
- *** orig/screen.c Thu Apr 04 06:44:04 1991
- --- new/screen.c Thu Jun 27 14:37:44 1991
- ***************
- *** 5,10 ****
- --- 5,13 ----
- * {{ Someday this should be rewritten to use curses. }}
- */
-
- + #include <stdio.h>
- + #include <stdlib.h>
- +
- #include "less.h"
- #if XENIX
- #include <sys/types.h>
- ***************
- *** 11,21 ****
- --- 14,32 ----
- #include <sys/ioctl.h>
- #endif
-
- + #ifdef OS2
- + #undef VOID
- + #undef CONTROL
- + #define INCL_SUB
- + #define INCL_NOPM
- + #include <os2.h>
- + #else
- #if TERMIO
- #include <termio.h>
- #else
- #include <sgtty.h>
- #endif
- + #endif
-
- #if !TERMIO && defined(TIOCGWINSZ)
- #include <sys/ioctl.h>
- ***************
- *** 76,81 ****
- --- 87,93 ----
- public int bl_s_width, bl_e_width; /* Printing width of blink seq */
-
- static char *cheaper();
- + static int cost();
-
- /*
- * These two variables are sometimes defined in,
- ***************
- *** 113,118 ****
- --- 125,135 ----
-
- if (on == curr_on)
- return;
- + #ifdef OS2
- + signal(SIGINT, SIG_IGN);
- + erase_char = '\b';
- + kill_char = '\033';
- + #else
- #if TERMIO
- {
- struct termio s;
- ***************
- *** 185,190 ****
- --- 202,208 ----
- ioctl(2, TIOCSETN, &s);
- }
- #endif
- + #endif
- curr_on = on;
- }
-
- ***************
- *** 212,217 ****
- --- 230,254 ----
- int *p_height;
- int *p_width;
- {
- + #ifdef OS2
- + if ( _osmode == DOS_MODE )
- + {
- + *p_width = (* (char far *) 0x0040004A);
- + *p_height = (* (char far *) 0x00400084) + 1;
- +
- + if ( (*p_height < 25) || (*p_height > 75) )
- + *p_height = 25;
- + }
- + else
- + {
- + VIOMODEINFO mi;
- +
- + mi.cb = sizeof(mi);
- + VioGetMode(&mi, 0);
- + *p_width = mi.col;
- + *p_height = mi.row;
- + }
- + #else
- register char *s;
- #ifdef TIOCGWINSZ
- struct winsize w;
- ***************
- *** 254,259 ****
- --- 291,297 ----
- *p_width = atoi(s);
- else
- *p_width = tgetnum("co");
- + #endif /* OS2 */
-
- if (*p_width <= 0)
- *p_width = 80;
- ***************
- *** 277,283 ****
- --- 315,325 ----
- * Find out what kind of terminal this is.
- */
- if ((term = getenv("TERM")) == NULL)
- + #ifdef OS2
- + term = "ansi";
- + #else
- term = "unknown";
- + #endif
- if (tgetent(termbuf, term) <= 0)
- strcpy(termbuf, "dumb:hc:");
-
- ***************
- *** 446,452 ****
- --- 488,500 ----
- t2 = tgetstr("sr", &sp);
- if (hard || t2 == NULL)
- t2 = "";
- + #ifdef OS2
- + if (*t1 == '\0' && *t2 == '\0')
- + sc_addline = "";
- + else
- + #endif
- sc_addline = cheaper(t1, t2, "scroll backwards", "");
- +
- if (*sc_addline == '\0')
- {
- /*
- diff -cbBw orig/ttyin.c new/ttyin.c
- *** orig/ttyin.c Thu Apr 04 06:44:06 1991
- --- new/ttyin.c Thu Jun 27 14:37:46 1991
- ***************
- *** 10,15 ****
- --- 10,26 ----
- #include <signal.h>
- #endif
-
- + #ifdef OS2
- + #undef NULL
- + #undef VOID
- + #undef CONTROL
- + #define INCL_DOSPROCESS
- + #define INCL_SUB
- + #define INCL_NOPM
- + #include <os2.h>
- + #include <stdio.h>
- + #endif
- +
- static int tty;
-
- /*
- ***************
- *** 18,24 ****
- public void
- open_getchr()
- {
- ! #if __MDDOS__
- /*
- * Open a new handle to CON: in binary mode
- * for unbuffered keyboard read.
- --- 29,35 ----
- public void
- open_getchr()
- {
- ! #if __MSDOS__
- /*
- * Open a new handle to CON: in binary mode
- * for unbuffered keyboard read.
- ***************
- *** 43,56 ****
- public int
- getchr()
- {
- ! char c;
- int result;
-
- do
- {
- result = iread(tty, &c, sizeof(char));
- if (result == READ_INTR)
- return (READ_INTR);
- if (result < 0)
- {
- /*
- --- 54,93 ----
- public int
- getchr()
- {
- ! int c;
- int result;
-
- + flush();
- +
- do
- {
- + #ifdef OS2
- + static int ext, scan;
- + KBDKEYINFO ki;
- +
- + if ( ext )
- + {
- + ext = 0;
- + c = scan;
- + }
- + else
- + {
- + KbdCharIn(&ki, IO_WAIT, 0);
- + c = ki.chChar;
- +
- + if ( c == 0 || c == 0xE0 )
- + {
- + c = 0xE0;
- + ext = 1;
- + scan = ki.chScan;
- + }
- + }
- + result = 1;
- + #else
- result = iread(tty, &c, sizeof(char));
- if (result == READ_INTR)
- return (READ_INTR);
- + #endif
- if (result < 0)
- {
- /*
- ***************
- *** 77,79 ****
- --- 114,125 ----
-
- return (c);
- }
- +
- +
- + #ifdef OS2
- + sleep(x)
- + int x;
- + {
- + DosSleep(1000L * x);
- + }
- + #endif
-