remove agetline
This commit is contained in:
parent
cca0522872
commit
84b08427a1
1
Makefile
1
Makefile
|
@ -27,7 +27,6 @@ LIBUTFSRC =\
|
|||
LIBUTIL = libutil.a
|
||||
LIBUTILSRC =\
|
||||
libutil/agetcwd.c\
|
||||
libutil/agetline.c\
|
||||
libutil/apathmax.c\
|
||||
libutil/concat.c\
|
||||
libutil/cp.c\
|
||||
|
|
2
cut.c
2
cut.c
|
@ -121,7 +121,7 @@ cut(FILE *fp)
|
|||
ssize_t len;
|
||||
Range *r;
|
||||
|
||||
while ((len = agetline(&buf, &size, fp)) != -1) {
|
||||
while ((len = getline(&buf, &size, fp)) != -1) {
|
||||
if (len && buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
if (mode == 'f' && !strchr(buf, delim)) {
|
||||
|
|
2
fold.c
2
fold.c
|
@ -64,7 +64,7 @@ fold(FILE *fp, long width)
|
|||
char *buf = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
while (agetline(&buf, &size, fp) != -1)
|
||||
while (getline(&buf, &size, fp) != -1)
|
||||
foldline(buf, width);
|
||||
free(buf);
|
||||
}
|
||||
|
|
2
grep.c
2
grep.c
|
@ -132,7 +132,7 @@ grep(FILE *fp, const char *str)
|
|||
struct pattern *pnode;
|
||||
int match = NoMatch;
|
||||
|
||||
for (n = 1; (len = agetline(&buf, &size, fp)) != -1; n++) {
|
||||
for (n = 1; (len = getline(&buf, &size, fp)) != -1; n++) {
|
||||
/* Remove the trailing newline if one is present. */
|
||||
if (len && buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
|
|
2
head.c
2
head.c
|
@ -56,7 +56,7 @@ head(FILE *fp, const char *str, long n)
|
|||
ssize_t len;
|
||||
unsigned long i = 0;
|
||||
|
||||
while (i < n && ((len = agetline(&buf, &size, fp)) != -1)) {
|
||||
while (i < n && ((len = getline(&buf, &size, fp)) != -1)) {
|
||||
fputs(buf, stdout);
|
||||
if (buf[len - 1] == '\n')
|
||||
i++;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../text.h"
|
||||
#include "../util.h"
|
||||
|
||||
ssize_t
|
||||
agetline(char **p, size_t *size, FILE *fp)
|
||||
{
|
||||
return getline(p, size, fp);
|
||||
}
|
|
@ -51,7 +51,7 @@ cryptcheck(char *sumfile, int argc, char *argv[],
|
|||
else if (!(cfp = fopen(sumfile, "r")))
|
||||
eprintf("fopen %s:", sumfile);
|
||||
|
||||
while (agetline(&line, &bufsiz, cfp) != -1) {
|
||||
while (getline(&line, &bufsiz, cfp) != -1) {
|
||||
if (!(file = strstr(line, " "))) {
|
||||
formatsucks++;
|
||||
continue;
|
||||
|
|
|
@ -13,7 +13,7 @@ getlines(FILE *fp, struct linebuf *b)
|
|||
size_t size = 0, linelen;
|
||||
ssize_t len;
|
||||
|
||||
while ((len = agetline(&line, &size, fp)) != -1) {
|
||||
while ((len = getline(&line, &size, fp)) != -1) {
|
||||
if (++b->nlines > b->capacity) {
|
||||
b->capacity += 512;
|
||||
nline = erealloc(b->lines, b->capacity * sizeof(*b->lines));
|
||||
|
|
2
nl.c
2
nl.c
|
@ -69,7 +69,7 @@ nl(FILE *fp)
|
|||
long n = 0;
|
||||
size_t size = 0;
|
||||
|
||||
while (agetline(&buf, &size, fp) != -1) {
|
||||
while (getline(&buf, &size, fp) != -1) {
|
||||
if ((mode == 'a')
|
||||
|| (mode == 'p'
|
||||
&& !regexec(&preg, buf, 0, NULL, 0))
|
||||
|
|
4
tail.c
4
tail.c
|
@ -61,7 +61,7 @@ dropinit(FILE *fp, const char *str, long n)
|
|||
ssize_t len;
|
||||
unsigned long i = 0;
|
||||
|
||||
while (i < n && ((len = agetline(&buf, &size, fp)) != -1))
|
||||
while (i < n && ((len = getline(&buf, &size, fp)) != -1))
|
||||
if (len && buf[len - 1] == '\n')
|
||||
i++;
|
||||
free(buf);
|
||||
|
@ -78,7 +78,7 @@ taketail(FILE *fp, const char *str, long n)
|
|||
ring = ecalloc(n, sizeof *ring);
|
||||
size = ecalloc(n, sizeof *size);
|
||||
|
||||
for (i = j = 0; agetline(&ring[i], &size[i], fp) != -1; i = j = (i + 1) % n)
|
||||
for (i = j = 0; getline(&ring[i], &size[i], fp) != -1; i = j = (i + 1) % n)
|
||||
;
|
||||
if (ferror(fp))
|
||||
eprintf("%s: read error:", str);
|
||||
|
|
1
text.h
1
text.h
|
@ -8,5 +8,4 @@ struct linebuf {
|
|||
#define EMPTY_LINEBUF {NULL, 0, 0,}
|
||||
void getlines(FILE *, struct linebuf *);
|
||||
|
||||
ssize_t agetline(char **, size_t *, FILE *);
|
||||
void concat(FILE *, const char *, FILE *, const char *);
|
||||
|
|
2
tr.c
2
tr.c
|
@ -346,7 +346,7 @@ main(int argc, char *argv[])
|
|||
usage();
|
||||
}
|
||||
|
||||
while ((nbytes = agetline(&buf, &size, stdin)) != -1)
|
||||
while ((nbytes = getline(&buf, &size, stdin)) != -1)
|
||||
mapfunc(buf, nbytes);
|
||||
free(buf);
|
||||
if (ferror(stdin))
|
||||
|
|
2
uniq.c
2
uniq.c
|
@ -92,7 +92,7 @@ uniq(FILE *fp, const char *str)
|
|||
char *buf = NULL;
|
||||
size_t size = 0;
|
||||
|
||||
while (agetline(&buf, &size, fp) != -1)
|
||||
while (getline(&buf, &size, fp) != -1)
|
||||
uniqline(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ uudecode(FILE *fp, FILE *outfp)
|
|||
#define IS_DEC(c) ( (((c) - ' ') >= 0) && (((c) - ' ') <= 077 + 1) )
|
||||
#define OUT_OF_RANGE(c) eprintf("character %c out of range: [%d-%d]", (c), 1 + ' ', 077 + ' ' + 1)
|
||||
|
||||
while ((len = agetline(&bufb, &n, fp)) != -1) {
|
||||
while ((len = getline(&bufb, &n, fp)) != -1) {
|
||||
p = bufb;
|
||||
/* trim newlines */
|
||||
if (len && bufb[len - 1] != '\n')
|
||||
|
@ -172,7 +172,7 @@ uudecode(FILE *fp, FILE *outfp)
|
|||
eprintf("read error:");
|
||||
}
|
||||
/* check for end or fail */
|
||||
len = agetline(&bufb, &n, fp);
|
||||
len = getline(&bufb, &n, fp);
|
||||
if (len < 3 || strncmp(bufb, "end", 3) != 0 || bufb[3] != '\n')
|
||||
eprintf("invalid uudecode footer \"end\" not found\n");
|
||||
free(bufb);
|
||||
|
|
Loading…
Reference in New Issue
Block a user