From f73b4cc0fa351ec3448812de9e127c537a082c10 Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 18 Jun 2024 00:32:22 +0000 Subject: [PATCH] Rename mf_fgets() and cu_fgets() to mf_getline() and cu_getline(). These functions now use getline(), not fgets(). From espie@ --- usr.bin/sed/compile.c | 8 ++++---- usr.bin/sed/extern.h | 6 +++--- usr.bin/sed/main.c | 10 +++++----- usr.bin/sed/process.c | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index bdb62d3ce16..f21fd0acdda 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compile.c,v 1.51 2022/12/26 19:16:02 jmc Exp $ */ +/* $OpenBSD: compile.c,v 1.52 2024/06/18 00:32:22 millert Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -151,7 +151,7 @@ compile_stream(struct s_command **link) stack = 0; for (;;) { - if ((p = cu_fgets(&lbuf, &bufsize)) == NULL) { + if ((p = cu_getline(&lbuf, &bufsize)) == NULL) { if (stack != 0) error(COMPILE, "unexpected EOF (pending }'s)"); return (link); @@ -538,7 +538,7 @@ compile_subst(char *p, struct s_subst *s) *sp++ = *p; } size += sp - op; - } while ((p = cu_fgets(&lbuf, &bufsize))); + } while ((p = cu_getline(&lbuf, &bufsize))); error(COMPILE, "unterminated substitute in regular expression"); } @@ -682,7 +682,7 @@ compile_text(void) lbuf = text = NULL; asize = size = 0; - while ((p = cu_fgets(&lbuf, &bufsize))) { + while ((p = cu_getline(&lbuf, &bufsize))) { size_t len = ROUNDLEN(strlen(p) + 1); if (asize - size < len) { do { diff --git a/usr.bin/sed/extern.h b/usr.bin/sed/extern.h index 772f0bab3ef..2d28ef8a86d 100644 --- a/usr.bin/sed/extern.h +++ b/usr.bin/sed/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.14 2018/11/14 10:59:33 martijn Exp $ */ +/* $OpenBSD: extern.h,v 1.15 2024/06/18 00:32:22 millert Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 @@ -48,10 +48,10 @@ extern FILE *infile, *outfile; void cfclose(struct s_command *, struct s_command *); void compile(void); void cspace(SPACE *, const char *, size_t, enum e_spflag); -char *cu_fgets(char **, size_t *); +char *cu_getline(char **, size_t *); __dead void error(int, const char *, ...); void warning(const char *, ...); -int mf_fgets(SPACE *, enum e_spflag); +int mf_getline(SPACE *, enum e_spflag); int lastline(void); void finish_file(void); void process(void); diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 9450d5b7433..0d741db69ce 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.44 2023/02/08 08:18:11 tb Exp $ */ +/* $OpenBSD: main.c,v 1.45 2024/06/18 00:32:22 millert Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -209,11 +209,11 @@ main(int argc, char *argv[]) } /* - * Like fgets, but go through the chain of compilation units chaining them + * Like getline, but go through the chain of compilation units chaining them * together. Empty strings and files are ignored. */ char * -cu_fgets(char **outbuf, size_t *outsize) +cu_getline(char **outbuf, size_t *outsize) { static enum {ST_EOF, ST_FILE, ST_STRING} state = ST_EOF; static FILE *f; /* Current open file */ @@ -328,11 +328,11 @@ finish_file(void) } /* - * Like fgets, but go through the list of files chaining them together. + * Like getline, but go through the list of files chaining them together. * Set len to the length of the line. */ int -mf_fgets(SPACE *sp, enum e_spflag spflag) +mf_getline(SPACE *sp, enum e_spflag spflag) { struct stat sb; size_t len; diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index 932e333fde4..308ab71eef8 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.35 2022/01/12 15:13:36 martijn Exp $ */ +/* $OpenBSD: process.c,v 1.36 2024/06/18 00:32:22 millert Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -90,7 +90,7 @@ process(void) size_t len, oldpsl; char *p; - for (linenum = 0; mf_fgets(&PS, REPLACE);) { + for (linenum = 0; mf_getline(&PS, REPLACE);) { pd = 0; top: cp = prog; @@ -164,14 +164,14 @@ redirect: if (!nflag && !pd) OUT(); flush_appends(); - if (!mf_fgets(&PS, REPLACE)) + if (!mf_getline(&PS, REPLACE)) exit(0); pd = 0; break; case 'N': flush_appends(); cspace(&PS, "\n", 1, 0); - if (!mf_fgets(&PS, 0)) + if (!mf_getline(&PS, 0)) exit(0); break; case 'p': -- 2.20.1