mailing list of musl libc
 help / color / mirror / code / Atom feed
b458d93e6bc350bec5799edbfa25f80c5ff1ff9c blob 922 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
#include "shgetc.h"

/* The shcnt field stores the number of bytes read so far, offset by
 * the value of buf-rpos at the last function call (__shlim or __shgetc),
 * so that between calls the inline shcnt macro can add rpos-buf to get
 * the actual count. */

void __shlim(FILE *f, off_t lim)
{
	f->shlim = lim;
	f->shcnt = f->buf - f->rpos;
	/* If lim is nonzero, rend must be a valid pointer. */
	if (lim && f->rend - f->rpos > lim)
		f->shend = f->rpos + lim;
	else
		f->shend = f->rend;
}

int __shgetc(FILE *f)
{
	int c;
	off_t cnt = shcnt(f);
	if ((f->shlim && cnt >= f->shlim) || (c=__uflow(f)) < 0) {
		f->shcnt = f->buf - f->rpos + cnt;
		f->shend = f->rpos;
		f->shlim = -1;
		return EOF;
	}
	cnt++;
	if (f->shlim && f->rend - f->rpos > f->shlim - cnt)
		f->shend = f->rpos + (f->shlim - cnt);
	else
		f->shend = f->rend;
	f->shcnt = f->buf - f->rpos + cnt;
	if (f->rpos[-1] != c) f->rpos[-1] = c;
	return c;
}
debug log:

solving b458d93e ...
found b458d93e in https://inbox.vuxu.org/musl/20190722180740.16951-2-me@concati.me/
found a4a9c633 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 a4a9c633dc976033622003c3cc7e5068466076bd	src/internal/shgetc.c

applying [1/1] https://inbox.vuxu.org/musl/20190722180740.16951-2-me@concati.me/
diff --git a/src/internal/shgetc.c b/src/internal/shgetc.c
index a4a9c633..b458d93e 100644

Checking patch src/internal/shgetc.c...
Applied patch src/internal/shgetc.c cleanly.

index at:
100644 b458d93e6bc350bec5799edbfa25f80c5ff1ff9c	src/internal/shgetc.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).