home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
036
/
less232.zip
/
PATCHES.OS2
< prev
next >
Wrap
Text File
|
1994-09-24
|
21KB
|
879 lines
Only in new: README.OS2
Only in new: Makefile.os2
Only in new: patches.os2
Only in new: defines.os2
Only in new: less.ini
Only in new: lesskey.inp
Only in new: termcap.c
Only in new: termcap.dat
Only in new: termcap.h
Only in new: zfiles.c
diff -cbr orig/ch.c new/ch.c
*** orig/ch.c Fri Aug 26 06:54:28 1994
--- new/ch.c Sat Sep 24 10:40:10 1994
***************
*** 87,93 ****
static struct filestate *thisfile;
! extern int ispipe;
extern int autobuf;
extern int sigs;
#if LOGFILE
--- 87,93 ----
static struct filestate *thisfile;
! extern int ispipe, iscompressed;
extern int autobuf;
extern int sigs;
#if LOGFILE
***************
*** 501,507 ****
{
register struct buf *bp;
! if (ispipe)
{
/*
* If input is a pipe, we don't flush buffer contents,
--- 501,507 ----
{
register struct buf *bp;
! if (ispipe && !iscompressed)
{
/*
* If input is a pipe, we don't flush buffer contents,
***************
*** 528,533 ****
--- 528,539 ----
ch_fpos = 0;
ch_block = ch_fpos / LBUFSIZE;
ch_offset = ch_fpos % LBUFSIZE;
+
+ if (iscompressed)
+ {
+ ch_fsize = NULL_POSITION;
+ return;
+ }
if (lseek(file, (off_t)0, 0) == BAD_LSEEK)
{
diff -cbr orig/charset.c new/charset.c
*** orig/charset.c Sun Aug 28 23:26:22 1994
--- new/charset.c Sat Sep 24 10:41:20 1994
***************
*** 47,52 ****
--- 47,53 ----
{ "ascii", "8bcccbcc18b95.b" },
{ "latin1", "8bcccbcc18b95.33b." },
{ "dos", "8bcccbcc12bc5b95.98b.b" },
+ { "pc8", "8bcccbcc18b95.b128." },
{ "koi8-r", "8bcccbcc18b95.b128." },
{ NULL }
};
***************
*** 237,243 ****
--- 238,248 ----
/*
* Default to "ascii".
*/
+ #if OS2
+ (void) icharset("pc8");
+ #else
(void) icharset("ascii");
+ #endif
#endif
}
diff -cbr orig/command.c new/command.c
*** orig/command.c Fri Sep 02 22:19:24 1994
--- new/command.c Sat Sep 24 10:40:12 1994
***************
*** 35,41 ****
#include "cmd.h"
extern int erase_char, kill_char;
! extern int ispipe;
extern int sigs;
extern int quit_at_eof;
extern int hit_eof;
--- 35,41 ----
#include "cmd.h"
extern int erase_char, kill_char;
! extern int ispipe, iscompressed;
extern int sigs;
extern int quit_at_eof;
extern int hit_eof;
***************
*** 432,438 ****
*/
if (empty_screen())
{
! if (initial_scrpos.pos == NULL_POSITION)
/*
* {{ Maybe this should be:
* jump_loc(ch_zero(), jump_sline);
--- 432,438 ----
*/
if (empty_screen())
{
! if (initial_scrpos.pos == NULL_POSITION || iscompressed)
/*
* {{ Maybe this should be:
* jump_loc(ch_zero(), jump_sline);
diff -cbr orig/decode.c new/decode.c
*** orig/decode.c Thu Aug 25 06:28:26 1994
--- new/decode.c Sat Sep 24 10:40:12 1994
***************
*** 310,316 ****
* Try to open the lesskey file.
* If we can't, return an error.
*/
! f = open(filename, 0);
if (f < 0)
return (-1);
--- 310,316 ----
* 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);
diff -cbr orig/edit.c new/edit.c
*** orig/edit.c Fri Sep 09 08:23:44 1994
--- new/edit.c Sat Sep 24 10:40:14 1994
***************
*** 34,40 ****
public int fd0 = 0;
#define ISPIPE(fd) ((fd)==fd0)
! extern int ispipe;
extern int new_file;
extern int errmsgs;
extern int quit_at_eof;
--- 34,40 ----
public int fd0 = 0;
#define ISPIPE(fd) ((fd)==fd0)
! extern int ispipe, iscompressed, newcompressed;
extern int new_file;
extern int errmsgs;
extern int quit_at_eof;
***************
*** 151,156 ****
--- 151,159 ----
/*
* Close the current file, unless it is a pipe.
*/
+ if (iscompressed)
+ Zclose(file);
+ else
if (!ISPIPE(file))
{
close(file);
***************
*** 235,246 ****
}
del_ifile(ifile);
return (1);
}
- #if MSOFTC
else if ((f = open(open_filename, O_RDONLY|O_BINARY)) < 0)
- #else
- else if ((f = open(open_filename, 0)) < 0)
- #endif
{
parg.p_string = errno_message(filename);
error("%s", &parg);
--- 238,258 ----
}
del_ifile(ifile);
return (1);
+ } else if ((answer = isZfile(filename)) >= 0)
+ {
+ f = Zopen(filename, answer);
+
+ if ( f < 0 )
+ {
+ parg.p_string = errno_message(filename);
+ error("%s", &parg);
+ free(parg.p_string);
+ return (1);
+ }
+
+ newcompressed = 1;
}
else if ((f = open(open_filename, O_RDONLY|O_BINARY)) < 0)
{
parg.p_string = errno_message(filename);
error("%s", &parg);
***************
*** 258,264 ****
}
}
! ispipe = ISPIPE(f);
#if LOGFILE
{
char *s;
--- 270,279 ----
}
}
! iscompressed = newcompressed;
! newcompressed = 0;
! ispipe = ISPIPE(f) || iscompressed;
!
#if LOGFILE
{
char *s;
***************
*** 520,526 ****
{
if (isatty(fd0))
{
! #if MSOFTC
error("Missing filename (\"less -?\" for help)", NULL_PARG);
#else
error("Missing filename (\"less -\\?\" for help)", NULL_PARG);
--- 535,541 ----
{
if (isatty(fd0))
{
! #if MSOFTC || OS2
error("Missing filename (\"less -?\" for help)", NULL_PARG);
#else
error("Missing filename (\"less -\\?\" for help)", NULL_PARG);
***************
*** 598,604 ****
/*
* Append: open the file and seek to the end.
*/
! #if MSOFTC
logfile = open(filename, O_APPEND|O_WRONLY);
#else
logfile = open(filename, 1);
--- 613,619 ----
/*
* Append: open the file and seek to the end.
*/
! #if MSOFTC || OS2
logfile = open(filename, O_APPEND|O_WRONLY);
#else
logfile = open(filename, 1);
diff -cbr orig/filename.c new/filename.c
*** orig/filename.c Fri Sep 02 22:20:34 1994
--- new/filename.c Sat Sep 24 10:40:14 1994
***************
*** 85,90 ****
--- 85,103 ----
}
#else
+ #if 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,
***************
*** 93,98 ****
--- 106,112 ----
return (NULL);
sprintf(pathname, "%s/%s", homedir, filename);
#endif
+ #endif
return (pathname);
}
***************
*** 106,112 ****
if ((helpfile = getenv("LESSHELP")) != NULL)
return (save(helpfile));
! #if MSOFTC
return (homefile(HELPFILE));
#else
return (save(HELPFILE));
--- 120,126 ----
if ((helpfile = getenv("LESSHELP")) != NULL)
return (save(helpfile));
! #if MSOFTC || OS2
return (homefile(HELPFILE));
#else
return (save(HELPFILE));
***************
*** 314,319 ****
--- 328,334 ----
(s2 == NULL ? 0 : strlen(s2)) + 1;
scmd = (char *) ecalloc(len, sizeof(char));
sprintf(scmd, cmd, s1, s2);
+ #if !OS2
shell = getenv("SHELL");
if (shell != NULL && *shell != '\0')
{
***************
*** 326,332 ****
free(scmd);
scmd = scmd2;
}
!
fd = popen(scmd, "r");
free(scmd);
return (fd);
--- 341,347 ----
free(scmd);
scmd = scmd2;
}
! #endif
fd = popen(scmd, "r");
free(scmd);
return (fd);
***************
*** 336,341 ****
--- 351,368 ----
glob(filename)
char *filename;
{
+ #if OS2
+ char **list = _fnexplode(filename);
+ char *names;
+ int cnt, length = 0;
+ for (cnt = 0; list[cnt]; cnt++)
+ length += strlen(list[cnt]) + 1;
+ names = (char *) ecalloc(length, sizeof(char));
+ for (cnt = 0; list[cnt]; cnt++)
+ strcat(strcat(names, list[cnt]), " ");
+ _fnexplodefree(list);
+ return names;
+ #else
FILE *fd;
char *gfilename;
***************
*** 362,367 ****
--- 389,395 ----
if (*gfilename == '\0')
return (NULL);
return (gfilename);
+ #endif
}
public char *
diff -cbr orig/help.c new/help.c
*** orig/help.c Tue Jul 26 02:40:10 1994
--- new/help.c Sat Sep 24 10:40:16 1994
***************
*** 69,77 ****
--- 69,83 ----
#else
cmd = (char *) ecalloc(strlen(helpfile) + strlen(progname) + 150,
sizeof(char));
+ #if 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 -cbr orig/less.h new/less.h
*** orig/less.h Fri Aug 26 06:59:10 1994
--- new/less.h Sat Sep 24 10:40:16 1994
***************
*** 62,67 ****
--- 62,70 ----
#include <stdlib.h>
#include <string.h>
#endif
+ #if HAVE_FCNTL_H
+ #include <fcntl.h>
+ #endif
#if !STDC_HEADERS
char *getenv();
***************
*** 199,204 ****
--- 202,211 ----
/* Flags for editchar() */
#define EC_PEEK 01
#define EC_NOHISTORY 02
+
+ #ifndef O_BINARY
+ #define O_BINARY 0
+ #endif
#define SIGNAL(sig,func) signal(sig,func)
diff -cbr orig/less.nro new/less.nro
*** orig/less.nro Tue Sep 13 06:48:42 1994
--- new/less.nro Sat Sep 24 10:40:18 1994
***************
*** 1122,1127 ****
--- 1122,1193 ----
.I less
is being run.
+ .SH "REGULAR EXPRESSION SYNTAX"
+ This segment is extracted from regexp.3 in Henry Spencer's regexp package.
+ The entire regexp package can be obtained separately.
+ .PP
+ A regular expression is zero or more \fIbranches\fR, separated by `|'.
+ It matches anything that matches one of the branches.
+ .PP
+ A branch is zero or more \fIpieces\fR, concatenated.
+ It matches a match for the first, followed by a match for the second, etc.
+ .PP
+ A piece is an \fIatom\fR possibly followed by `*', `+', or `?'.
+ An atom followed by `*' matches a sequence of 0 or more matches of the atom.
+ An atom followed by `+' matches a sequence of 1 or more matches of the atom.
+ An atom followed by `?' matches a match of the atom, or the null string.
+ .PP
+ An atom is a regular expression in parentheses (matching a match for the
+ regular expression), a \fIrange\fR (see below), `.'
+ (matching any single character), `^' (matching the null string at the
+ beginning of the input string), `$' (matching the null string at the
+ end of the input string), a `\e' followed by a single character (matching
+ that character), or a single character with no other significance
+ (matching that character).
+ .PP
+ A \fIrange\fR is a sequence of characters enclosed in `[]'.
+ It normally matches any single character from the sequence.
+ If the sequence begins with `^',
+ it matches any single character \fInot\fR from the rest of the sequence.
+ If two characters in the sequence are separated by `\-', this is shorthand
+ for the full list of ASCII characters between them
+ (e.g. `[0-9]' matches any decimal digit).
+ To include a literal `]' in the sequence, make it the first character
+ (following a possible `^').
+ To include a literal `\-', make it the first or last character.
+ .SH AMBIGUITY
+ If a regular expression could match two different parts of the input string,
+ it will match the one which begins earliest.
+ If both begin in the same place but match different lengths, or match
+ the same length in different ways, life gets messier, as follows.
+ .PP
+ In general, the possibilities in a list of branches are considered in
+ left-to-right order, the possibilities for `*', `+', and `?' are
+ considered longest-first, nested constructs are considered from the
+ outermost in, and concatenated constructs are considered leftmost-first.
+ The match that will be chosen is the one that uses the earliest
+ possibility in the first choice that has to be made.
+ If there is more than one choice, the next will be made in the same manner
+ (earliest possibility) subject to the decision on the first choice.
+ And so forth.
+ .PP
+ For example, `(ab|a)b*c' could match `abc' in one of two ways.
+ The first choice is between `ab' and `a'; since `ab' is earlier, and does
+ lead to a successful overall match, it is chosen.
+ Since the `b' is already spoken for,
+ the `b*' must match its last possibility\(emthe empty string\(emsince
+ it must respect the earlier choice.
+ .PP
+ In the particular case where no `|'s are present and there is only one
+ `*', `+', or `?', the net effect is that the longest possible
+ match will be chosen.
+ So `ab*', presented with `xabbbby', will match `abbbb'.
+ Note that if `ab*' is tried against `xabyabbbz', it
+ will match `ab' just after `x', due to the begins-earliest rule.
+ (In effect, the decision on where to start the match is the first choice
+ to be made, hence subsequent choices must respect it even if this leads them
+ to less-preferred alternatives.)
+
.SH "SEE ALSO"
lesskey(1)
diff -cbr orig/lesskey.c new/lesskey.c
*** orig/lesskey.c Tue Sep 13 06:56:02 1994
--- new/lesskey.c Sat Sep 24 10:41:48 1994
***************
*** 202,208 ****
usage()
{
! fprintf(stderr, "usage: lesskey [-o output] [input]\n");
exit(1);
}
--- 202,208 ----
usage()
{
! fprintf(stderr, "\nUsage: lesskey [-o output] [input]\n");
exit(1);
}
***************
*** 257,262 ****
--- 257,265 ----
exit(1);
}
} else
+ if ( isatty(fileno(stdin)) )
+ usage();
+ else
desc = stdin;
/*
***************
*** 380,385 ****
--- 383,396 ----
*/
if (outfile == NULL)
{
+ #if OS2
+ if ( p = getenv("INIT") )
+ strcpy(line, p);
+ else
+ strcpy(line, ".");
+
+ strcat(line, "\\less.ini");
+ #else
p = getenv("HOME");
if (p == NULL || *p == '\0')
{
***************
*** 396,401 ****
--- 407,413 ----
strcat(line, LESSKEYFILE);
}
outfile = line;
+ #endif
}
if ((out = fopen(outfile, "w")) == NULL)
perror(outfile);
diff -cbr orig/lsystem.c new/lsystem.c
*** orig/lsystem.c Fri Sep 02 22:23:16 1994
--- new/lsystem.c Sat Sep 24 10:40:20 1994
***************
*** 40,45 ****
--- 40,48 ----
#if MSOFTC
#include <dos.h>
#endif
+ #if OS2
+ #include <process.h>
+ #endif
extern int screen_trashed;
extern IFILE curr_ifile;
***************
*** 56,62 ****
char *cmd;
{
register int inp;
! #if MSOFTC
register int inp2;
#endif
register char *shell;
--- 59,65 ----
char *cmd;
{
register int inp;
! #if MSOFTC || OS2
register int inp2;
#endif
register char *shell;
***************
*** 100,106 ****
* (the normal standard input), even if less's standard input
* is coming from a pipe.
*/
! #if MSOFTC
inp = dup(0);
inp2 = open("CON", O_TEXT|O_RDONLY);
dup2(0,inp2);
--- 103,109 ----
* (the normal standard input), even if less's standard input
* is coming from a pipe.
*/
! #if MSOFTC || OS2
inp = dup(0);
inp2 = open("CON", O_TEXT|O_RDONLY);
dup2(0,inp2);
***************
*** 141,153 ****
system(p);
free(p);
#else
system(cmd);
#endif
/*
* Restore standard input, reset signals, raw mode, etc.
*/
! #if MSOFTC
close(inp2);
dup2(0,inp);
close(inp);
--- 144,166 ----
system(p);
free(p);
#else
+ #if OS2
+ if ( *cmd == 0 )
+ {
+ if ( (p = getenv("COMSPEC")) == NULL )
+ p = "cmd.exe";
+
+ spawnlp(P_WAIT, p, p, NULL);
+ }
+ else
+ #endif
system(cmd);
#endif
/*
* Restore standard input, reset signals, raw mode, etc.
*/
! #if MSOFTC || OS2
close(inp2);
dup2(0,inp);
close(inp);
diff -cbr orig/main.c new/main.c
*** orig/main.c Wed Sep 21 23:05:20 1994
--- new/main.c Sat Sep 24 10:40:20 1994
***************
*** 32,38 ****
#include "less.h"
#include "position.h"
! public int ispipe;
public char * every_first_cmd = NULL;
public int new_file;
public int is_tty;
--- 32,38 ----
#include "less.h"
#include "position.h"
! public int ispipe, iscompressed, newcompressed;
public char * every_first_cmd = NULL;
public int new_file;
public int is_tty;
***************
*** 69,74 ****
--- 69,90 ----
extern int jump_sline;
#endif
+ extern char version[];
+
+ extern char *strchr();
+
+
+ usage()
+ {
+ int x = strlen(progname);
+
+ printf("\n%s.\n", version + 5);
+ printf("\nUsage: %s [-[+]aABcCdeEfgimMnNqQruUsw] [-bN] [-hN] [-xN] [-[z]N]", progname);
+ printf("\n %*s [-P[mM=]string] [-[lL]logfile] [-kkeyfile]", x, "");
+ printf("\n %*s [+cmd] [-ttag] [filename]...\n", x, "");
+ printf("\n or: %s -?\n", progname);
+ exit(1);
+ }
/*
***************
*** 81,88 ****
--- 97,112 ----
{
IFILE ifile;
+ #ifdef __EMX__
+ _response(&argc, &argv);
+ _wildcard(&argc, &argv);
+ #endif
+
progname = *argv++;
+ if (isatty(0) && argc == 1)
+ usage();
+
/*
* Process command line arguments and LESS environment arguments.
* Command line arguments override environment arguments.
***************
*** 129,135 ****
ifile = NULL_IFILE;
while (--argc >= 0)
{
! #if MSOFTC
/*
* Because the "shell" doesn't expand filename patterns,
* treat each argument as a filename pattern rather than
--- 153,159 ----
ifile = NULL_IFILE;
while (--argc >= 0)
{
! #if MSOFTC || OS2
/*
* Because the "shell" doesn't expand filename patterns,
* treat each argument as a filename pattern rather than
diff -cbr orig/screen.c new/screen.c
*** orig/screen.c Fri Sep 23 19:51:38 1994
--- new/screen.c Sat Sep 24 10:44:24 1994
***************
*** 152,157 ****
--- 152,162 ----
if (on == curr_on)
return;
+ #if OS2
+ signal(SIGINT, SIG_IGN);
+ erase_char = '\b';
+ kill_char = '\033';
+ #else
#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
{
struct termios s;
***************
*** 318,323 ****
--- 323,329 ----
}
#endif
#endif
+ #endif
curr_on = on;
}
***************
*** 343,348 ****
--- 349,362 ----
public void
scrsize()
{
+ #if OS2
+ {
+ int s[2];
+ _scrsize(s);
+ sc_width = s[0];
+ sc_height = s[1];
+ }
+ #else
register char *s;
#ifdef TIOCGWINSZ
struct winsize w;
***************
*** 385,390 ****
--- 399,405 ----
sc_width = atoi(s);
else
sc_width = tgetnum("co");
+ #endif
if (sc_width <= 0)
sc_width = 80;
***************
*** 539,545 ****
--- 554,564 ----
* Find out what kind of terminal this is.
*/
if ((term = getenv("TERM")) == NULL)
+ #if OS2
+ term = "ansi";
+ #else
term = "unknown";
+ #endif
if (tgetent(termbuf, term) <= 0)
strcpy(termbuf, "dumb:hc:");
***************
*** 727,736 ****
--- 746,761 ----
t2 = tgetstr("sr", &sp);
if (hard || t2 == NULL)
t2 = "";
+ #if OS2
+ if (*t1 == '\0' && *t2 == '\0')
+ sc_addline = "";
+ else
+ #endif
if (above_mem)
sc_addline = t1;
else
sc_addline = cheaper(t1, t2, "scroll backwards", "");
+
if (*sc_addline == '\0')
{
/*
diff -cbr orig/ttyin.c new/ttyin.c
*** orig/ttyin.c Wed Aug 03 02:43:16 1994
--- new/ttyin.c Sat Sep 24 10:40:22 1994
***************
*** 42,48 ****
public void
open_getchr()
{
! #if MSOFTC
extern int fd0;
/*
* Open a new handle to CON: in binary mode
--- 42,48 ----
public void
open_getchr()
{
! #if MSOFTC || OS2
extern int fd0;
/*
* Open a new handle to CON: in binary mode
***************
*** 85,90 ****
--- 85,109 ----
if (c == '\003')
return (READ_INTR);
#else
+ #if OS2
+ static int scan = -1;
+ flush();
+ if ( scan != -1 )
+ {
+ c = scan;
+ scan = -1;
+ result = 1;
+ }
+ else
+ {
+ while ( _read_kbd(0, 0, 0) != -1);
+ if ( (c = _read_kbd(0, 1, 0)) == -1 )
+ return READ_INTR;
+ if ( c == 0 && (scan = _read_kbd(0, 0, 0)) != -1 )
+ c = 0xE0;
+ result = 1;
+ }
+ #else
result = iread(tty, &c, sizeof(char));
if (result == READ_INTR)
return (READ_INTR);
***************
*** 96,101 ****
--- 115,121 ----
*/
quit(1);
}
+ #endif
#endif
/*
* Various parts of the program cannot handle