* PATCH: silence compiler warning when USE_LSEEK is not defined
@ 2024-09-15 23:04 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2024-09-15 23:04 UTC (permalink / raw)
To: Zsh workers
If the autoconf test doesn't define USE_LSEEK, we get a compiler
warning for setting an unused variable. It's scope can be limited to
just an if statement within the #ifdef and I find the resulting code to
be somewhat simpler.
Oliver
diff --git a/Src/input.c b/Src/input.c
index d8ac2c0e7..320fd6500 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -217,26 +217,23 @@ shinbufrestore(void)
static int
shingetchar(void)
{
- int nread, rsize = isset(SHINSTDIN) ? 1 : SHINBUFSIZE;
+ int nread;
if (shinbufptr < shinbufendptr)
return (unsigned char) *shinbufptr++;
shinbufreset();
#ifdef USE_LSEEK
- if (rsize == 1 && lseek(SHIN, 0, SEEK_CUR) != (off_t)-1)
- rsize = SHINBUFSIZE;
- if (rsize > 1) {
+ if (!isset(SHINSTDIN) || lseek(SHIN, 0, SEEK_CUR) != (off_t) -1) {
do {
errno = 0;
- nread = read(SHIN, shinbuffer, rsize);
+ nread = read(SHIN, shinbuffer, SHINBUFSIZE);
} while (nread < 0 && errno == EINTR);
if (nread <= 0)
return -1;
if (isset(SHINSTDIN) &&
(shinbufendptr = memchr(shinbuffer, '\n', nread))) {
- shinbufendptr++;
- rsize = (shinbufendptr - shinbuffer);
+ int rsize = (++shinbufendptr - shinbuffer);
if (nread > rsize &&
lseek(SHIN, -(nread - rsize), SEEK_CUR) < 0)
zerr("lseek(%d, %d): %e", SHIN, -(nread - rsize), errno);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-15 23:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-15 23:04 PATCH: silence compiler warning when USE_LSEEK is not defined Oliver Kiddle
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).