Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: silence compiler warning when USE_LSEEK is not defined
- X-seq: zsh-workers 53093
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: silence compiler warning when USE_LSEEK is not defined
- Date: Mon, 16 Sep 2024 01:04:12 +0200
- Archived-at: <https://zsh.org/workers/53093>
- List-id: <zsh-workers.zsh.org>
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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author