Skip to content

Commit

Permalink
Add PATHNAME_SEP.
Browse files Browse the repository at this point in the history
Minor cosmetic cleanups.
  • Loading branch information
gwsw committed May 2, 1996
1 parent 09bcaf5 commit c66f28f
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 48 deletions.
5 changes: 5 additions & 0 deletions defines.ds
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
#define MSDOS_COMPILER MSOFTC
#endif

/*
* Pathname separator character.
*/
#define PATHNAME_SEP "\\"

/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
Expand Down
5 changes: 5 additions & 0 deletions defines.o2
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
/* Settings always true for the emx compiler for OS/2 systems. */
#define OS2 1

/*
* Pathname separator character.
*/
#define PATHNAME_SEP "\\"

/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
Expand Down
5 changes: 5 additions & 0 deletions defines.o9
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
/* This is not needed; it is defined by the compiler. */
/* #define _OSK 1 */

/*
* Pathname separator character.
*/
#define PATHNAME_SEP "/"

/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
Expand Down
5 changes: 5 additions & 0 deletions defines.wn
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@

#define MSDOS_COMPILER WIN32C

/*
* Pathname separator character.
*/
#define PATHNAME_SEP "\\"

/*
* HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
*/
Expand Down
82 changes: 49 additions & 33 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ dirfile(dirname, filename)
sizeof(char));
if (pathname == NULL)
return (NULL);
#if MSDOS_COMPILER || OS2
sprintf(pathname, "%s\\%s", dirname, filename);
#else
sprintf(pathname, "%s/%s", dirname, filename);
#endif
sprintf(pathname, "%s%s%s", dirname, PATHNAME_SEP, filename);
/*
* Make sure the file exists.
*/
Expand All @@ -83,7 +79,7 @@ dirfile(dirname, filename)
pathname = NULL;
} else
{
close (f);
close(f);
}
return (pathname);
}
Expand Down Expand Up @@ -222,7 +218,7 @@ fcomplete(s)
*/
char *slash;
for (slash = s+strlen(s)-1; slash > s; slash--)
if (*slash == '/' || *slash == '\\')
if (*slash = *PATHNAME_SEP || *slash == '/')
break;
fpat = (char *) ecalloc(strlen(s)+4, sizeof(char));
if (strchr(slash, '.') == NULL)
Expand Down Expand Up @@ -343,7 +339,6 @@ shellcmd(cmd, s1, s2)
char *s2;
{
char *scmd;
char *scmd2;
char *shell;
FILE *fd;
int len;
Expand All @@ -360,6 +355,7 @@ shellcmd(cmd, s1, s2)
/*
* Read the output of <$SHELL -c "cmd">.
*/
char *scmd2;
scmd2 = (char *) ecalloc(strlen(shell) + strlen(scmd) + 7,
sizeof(char));
sprintf(scmd2, "%s -c \"%s\"", shell, scmd);
Expand Down Expand Up @@ -462,8 +458,10 @@ open_altfile(filename, pf, pfd)
{
char *lessopen;
char *gfilename;
int returnfd = 0;
FILE *fd;
#if HAVE_FILENO
int returnfd = 0;
#endif

if (secure)
return (NULL);
Expand All @@ -478,8 +476,13 @@ open_altfile(filename, pf, pfd)
* If LESSOPEN starts with a |, it indicates
* a "pipe preprocessor".
*/
#if HAVE_FILENO
lessopen++;
returnfd = 1;
#else
error("LESSOPEN pipe is not supported", NULL_PARG);
return (NULL);
#endif
}
fd = shellcmd(lessopen, filename, (char*)NULL);
if (fd == NULL)
Expand All @@ -489,9 +492,9 @@ open_altfile(filename, pf, pfd)
*/
return (NULL);
}
#if HAVE_FILENO
if (returnfd)
{
#if HAVE_FILENO
int f;
char c;

Expand All @@ -512,11 +515,8 @@ open_altfile(filename, pf, pfd)
*pfd = (void *) fd;
*pf = f;
return (save("-"));
#else
error("LESSOPEN pipe is not supported", NULL_PARG);
return (NULL);
#endif
}
#endif
gfilename = readfd(fd);
pclose(fd);
if (*gfilename == '\0')
Expand Down Expand Up @@ -552,35 +552,45 @@ close_altfile(altfilename, filename, pipefd)
#else
#if MSDOS_COMPILER

public char *
lglob(filename)
char *filename;
{
register char *gfilename;
register char *p;
register int len;
register int n;

/*
* Define macros for the MS-DOS "find file" interfaces.
*/
#if MSDOS_COMPILER==WIN32C

#define FIND_FIRST(filename,fndp) findfirst(filename, fndp, ~0)
#define FIND_NEXT(fndp) findnext(fndp)
#define FND_NAME ff_name
struct ffblk fnd;
char drive[MAXDRIVE];
char dir[MAXDIR];
char fname[MAXFILE];
char ext[MAXEXT];
#define DECLARE_FIND(fnd,drive,dir,fname,ext) \
struct ffblk fnd; \
char drive[MAXDRIVE]; \
char dir[MAXDIR]; \
char fname[MAXFILE]; \
char ext[MAXEXT];

#else

#define FIND_FIRST(filename,fndp) _dos_findfirst(filename, ~0, fndp)
#define FIND_NEXT(fndp) _dos_findnext(fndp)
#define FND_NAME name
struct find_t fnd;
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
#define DECLARE_FIND(fnd,drive,dir,fname,ext) \
struct find_t fnd; \
char drive[_MAX_DRIVE]; \
char dir[_MAX_DIR]; \
char fname[_MAX_FNAME]; \
char ext[_MAX_EXT];

#endif

public char *
lglob(filename)
char *filename;
{
register char *gfilename;
register char *p;
register int len;
register int n;
DECLARE_FIND(fnd,drive,dir,fname,ext)

filename = fexpand(filename);

if (secure)
Expand All @@ -597,6 +607,9 @@ lglob(filename)
n = strlen(drive) + strlen(dir) + strlen(fnd.FND_NAME);
while (p - gfilename + n+2 >= len)
{
/*
* No room in current buffer. Allocate a bigger one.
*/
len *= 2;
*p = '\0';
p = (char *) ecalloc(len, sizeof(char));
Expand All @@ -610,6 +623,9 @@ lglob(filename)
*p++ = ' ';
} while (FIND_NEXT(&fnd) == 0);

/*
* Overwrite the final trailing space with a null terminator.
*/
*--p = '\0';
return (gfilename);
}
Expand Down
22 changes: 14 additions & 8 deletions less.hlp.old
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
^N or ! Search for NON-matching lines.
^E or * Search multiple files (pass thru END OF FILE).
^F or @ Start search at FIRST file (for /) or last file (for ?).
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
^K Highlight matches, but don't move (KEEP position).
^R Don't use REGULAR EXPRESSIONS.
---------------------------------------------------
g < ESC-< * Go to first line in file (or line _N).
G > ESC-> * Go to last line in file (or line _N).
Expand All @@ -48,15 +48,21 @@
ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>.
ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_>
---------------------------------------------------
Each "find close bracket" command goes forward to the close bracket
matching the (_N-th) open bracket in the top line.
Each "find open bracket" command goes backward to the open bracket
matching the (_N-th) close bracket in the bottom line.
Each "find close bracket" command goes forward to the close bracket
matching the (_N-th) open bracket in the top line.
Each "find open bracket" command goes backward to the open bracket
matching the (_N-th) close bracket in the bottom line.
---------------------------------------------------
m_<_l_e_t_t_e_r_> Mark the current position with <letter>.
'_<_l_e_t_t_e_r_> Go to a previously marked position.
'' Go to the previous position.
^X^X Same as '.
---------------------------------------------------
A mark is any upper-case or lower-case letter.
Certain marks are predefined:
^ means beginning of the file
$ means end of the file
---------------------------------------------------

:e [_f_i_l_e] Examine a new file.
^X^V Same as :e.
Expand Down Expand Up @@ -97,8 +103,8 @@
-k [_f_i_l_e] Use a lesskey file.
-m -M Set prompt style.
-n -N Use line numbers.
-o [_f_i_l_e] Log file.
-O [_f_i_l_e] Log file (unconditionally overwrite).
-o [_f_i_l_e] Copy to log file (standard input only).
-O [_f_i_l_e] Copy to log file (unconditionally overwrite).
-p [_p_a_t_t_e_r_n] Start at pattern (from command line).
-P [_p_r_o_m_p_t] Define new prompt.
-q -Q Quiet the terminal bell.
Expand Down
6 changes: 1 addition & 5 deletions lesskey.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ mkpathname(dirname, filename)

pathname = calloc(strlen(dirname) + strlen(filename) + 2, sizeof(char));
strcpy(pathname, dirname);
#if MSDOS_COMPILER || OS2
strcat(pathname, "\\");
#else
strcat(pathname, "/");
#endif
strcat(pathname, PATHNAME_SEP);
strcat(pathname, filename);
return (pathname);
}
Expand Down
5 changes: 3 additions & 2 deletions version.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ v311 4/22/96 Add Windows32 support; merge doscreen.c into screen.c.
v312 4/24/96 Don't quit after "cannot reopen" error.
v313 4/25/96 Added horizontal scrolling.
v314 4/26/96 Modified -e to quit on reaching end of a squished file.
v315 4/2696 Fix "!;TAB" bug.
v315 4/26/96 Fix "!;TAB" bug.
v316 5/2/96 Make "|a" when (a < curr screen) go to end of curr screen.
*/

char version[] = "315";
char version[] = "316";

0 comments on commit c66f28f

Please sign in to comment.