Skip to content

Commit

Permalink
Use symbolic SEEK_xxx constants in lseek calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 6, 2007
1 parent 40e5bfc commit e8cf43d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fch_get()
*/
if (!(ch_flags & CH_CANSEEK))
return ('?');
if (lseek(ch_file, (off_t)pos, 0) == BAD_LSEEK)
if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
{
error("seek error", NULL_PARG);
clear_eol();
Expand Down Expand Up @@ -648,7 +648,7 @@ ch_flush()
}
#endif

if (lseek(ch_file, (off_t)0, 0) == BAD_LSEEK)
if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
{
/*
* Warning only; even if the seek fails for some reason,
Expand Down Expand Up @@ -737,7 +737,7 @@ seekable(f)
return (0);
}
#endif
return (lseek(f, (off_t)1, 0) != BAD_LSEEK);
return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ lesskey(filename, sysvar)
close(f);
return (-1);
}
if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
{
free(buf);
close(f);
Expand Down
2 changes: 1 addition & 1 deletion edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ use_logfile(filename)
* Append: open the file and seek to the end.
*/
logfile = open(filename, OPEN_APPEND);
if (lseek(logfile, (off_t)0, 2) == BAD_LSEEK)
if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK)
{
close(logfile);
logfile = -1;
Expand Down
4 changes: 2 additions & 2 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ bin_file(f)

if (!seekable(f))
return (0);
if (lseek(f, (off_t)0, 0) == BAD_LSEEK)
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
return (0);
n = read(f, data, sizeof(data));
for (i = 0; i < n; i++)
Expand Down Expand Up @@ -505,7 +505,7 @@ seek_filesize(f)
{
off_t spos;

spos = lseek(f, (off_t)0, 2);
spos = lseek(f, (off_t)0, SEEK_END);
if (spos == BAD_LSEEK)
return (NULL_POSITION);
return ((POSITION) spos);
Expand Down
7 changes: 7 additions & 0 deletions less.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ void free();

#define BAD_LSEEK ((off_t)-1)

#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif

#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
Expand Down
3 changes: 2 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ v407 8/16/07 Fix bugs; support CSI chars.
v408 10/1/07 Fix bug in -i with non-ASCII chars.
v409 10/12/07 Fix crash when viewing text with invalid UTF-8 sequences.
v411 11/6/07 Fix case-insensitive searching with non-ASCII text.
v412 11/6/07 Use symbolic SEEK constants.
*/

char version[] = "411";
char version[] = "412";

0 comments on commit e8cf43d

Please sign in to comment.