mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-19 22:46:03 +02:00
48504: use SEEK_ macros in fseek() calls
This commit is contained in:
parent
6388156233
commit
704d10989e
|
@ -1,5 +1,11 @@
|
|||
2021-04-11 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 48504: Src/hist.c, Src/input.c, Src/watch.c:
|
||||
use SEEK_ macros in fseek() calls
|
||||
|
||||
* Michael Stapelberg: 45396: Src/hist.c: readhistfile:
|
||||
avoid thousands of lseek(2) syscalls via ftell()
|
||||
|
||||
* Marc Chantreux: 48466: Completion/Unix/Command/_surfraw:
|
||||
correct indentation and remove tabs and trailing spaces
|
||||
|
||||
|
|
|
@ -2664,7 +2664,7 @@ readhistfile(char *fn, int err, int readflags)
|
|||
pushheap();
|
||||
if (readflags & HFILE_FAST && lasthist.text) {
|
||||
if (lasthist.fpos < lasthist.fsiz) {
|
||||
fseek(in, lasthist.fpos, 0);
|
||||
fseek(in, lasthist.fpos, SEEK_SET);
|
||||
searching = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -2741,7 +2741,7 @@ readhistfile(char *fn, int err, int readflags)
|
|||
&& histstrcmp(pt, lasthist.text) == 0)
|
||||
searching = 0;
|
||||
else {
|
||||
fseek(in, 0, 0);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
histfile_linect = 0;
|
||||
searching = -1;
|
||||
}
|
||||
|
|
|
@ -495,9 +495,9 @@ stuff(char *fn)
|
|||
zerr("can't open %s", fn);
|
||||
return 1;
|
||||
}
|
||||
fseek(in, 0, 2);
|
||||
fseek(in, 0, SEEK_END);
|
||||
len = ftell(in);
|
||||
fseek(in, 0, 0);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
buf = (char *)zalloc(len + 1);
|
||||
if (!(fread(buf, len, 1, in))) {
|
||||
zerr("read error on %s", fn);
|
||||
|
|
|
@ -169,9 +169,9 @@ getlogtime(WATCH_STRUCT_UTMP *u, int inout)
|
|||
return u->ut_time;
|
||||
if (!(in = fopen(WATCH_WTMP_FILE, "r")))
|
||||
return time(NULL);
|
||||
fseek(in, 0, 2);
|
||||
fseek(in, 0, SEEK_END);
|
||||
do {
|
||||
if (fseek(in, ((first) ? -1 : -2) * sizeof(WATCH_STRUCT_UTMP), 1)) {
|
||||
if (fseek(in, ((first) ? -1 : -2) * sizeof(WATCH_STRUCT_UTMP), SEEK_CUR)) {
|
||||
fclose(in);
|
||||
return time(NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue