From a651f2bc6cb7aa4b3f343bad711cbd08c77ce2e8 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 10 May 2016 11:11:23 +0000 Subject: [PATCH] Rename getline with get_line to avoid collision with getline(3) When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added. This rename is made in preparation for the removal of this guard Obtained from: NetBSD --- bin/pax/options.c | 28 ++++++++++++++-------------- usr.bin/csplit/csplit.c | 16 ++++++++-------- usr.bin/ctags/C.c | 8 ++++---- usr.bin/ctags/ctags.h | 2 +- usr.bin/ctags/fortran.c | 2 +- usr.bin/ctags/lisp.c | 2 +- usr.bin/ctags/print.c | 4 ++-- usr.bin/ctags/yacc.c | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bin/pax/options.c b/bin/pax/options.c index 06e487c9c776..094b47eeb19b 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -68,7 +68,7 @@ static int no_op(void); static void printflg(unsigned int); static int c_frmt(const void *, const void *); static off_t str_offt(char *); -static char *getline(FILE *fp); +static char *get_line(FILE *fp); static void pax_options(int, char **); static void pax_usage(void); static void tar_options(int, char **); @@ -76,10 +76,10 @@ static void tar_usage(void); static void cpio_options(int, char **); static void cpio_usage(void); -/* errors from getline */ +/* errors from get_line */ #define GETLINE_FILE_CORRUPT 1 #define GETLINE_OUT_OF_MEM 2 -static int getline_error; +static int get_line_error; char *chdname; @@ -873,14 +873,14 @@ tar_options(int argc, char **argv) paxwarn(1, "Unable to open file '%s' for read", file); tar_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = get_line(fp)) != NULL) { if (pat_add(str, dir) < 0) tar_usage(); sawpat = 1; } if (strcmp(file, "-") != 0) fclose(fp); - if (getline_error) { + if (get_line_error) { paxwarn(1, "Problem with file '%s'", file); tar_usage(); } @@ -946,13 +946,13 @@ tar_options(int argc, char **argv) paxwarn(1, "Unable to open file '%s' for read", file); tar_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = get_line(fp)) != NULL) { if (ftree_add(str, 0) < 0) tar_usage(); } if (strcmp(file, "-") != 0) fclose(fp); - if (getline_error) { + if (get_line_error) { paxwarn(1, "Problem with file '%s'", file); tar_usage(); @@ -1159,11 +1159,11 @@ cpio_options(int argc, char **argv) paxwarn(1, "Unable to open file '%s' for read", optarg); cpio_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = get_line(fp)) != NULL) { pat_add(str, NULL); } fclose(fp); - if (getline_error) { + if (get_line_error) { paxwarn(1, "Problem with file '%s'", optarg); cpio_usage(); } @@ -1258,10 +1258,10 @@ cpio_options(int argc, char **argv) * no read errors allowed on updates/append operation! */ maxflt = 0; - while ((str = getline(stdin)) != NULL) { + while ((str = get_line(stdin)) != NULL) { ftree_add(str, 0); } - if (getline_error) { + if (get_line_error) { paxwarn(1, "Problem while reading stdin"); cpio_usage(); } @@ -1489,21 +1489,21 @@ str_offt(char *val) } char * -getline(FILE *f) +get_line(FILE *f) { char *name, *temp; size_t len; name = fgetln(f, &len); if (!name) { - getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; + get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0; return(0); } if (name[len-1] != '\n') len++; temp = malloc(len); if (!temp) { - getline_error = GETLINE_OUT_OF_MEM; + get_line_error = GETLINE_OUT_OF_MEM; return(0); } memcpy(temp, name, len-1); diff --git a/usr.bin/csplit/csplit.c b/usr.bin/csplit/csplit.c index 7143d7395898..a5e819f47c35 100644 --- a/usr.bin/csplit/csplit.c +++ b/usr.bin/csplit/csplit.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); static void cleanup(void); static void do_lineno(const char *); static void do_rexp(const char *); -static char *getline(void); +static char *get_line(void); static void handlesig(int); static FILE *newfile(void); static void toomuch(FILE *, long); @@ -195,7 +195,7 @@ main(int argc, char *argv[]) /* Copy the rest into a new file. */ if (!feof(infile)) { ofp = newfile(); - while ((p = getline()) != NULL && fputs(p, ofp) == 0) + while ((p = get_line()) != NULL && fputs(p, ofp) == 0) ; if (!sflag) printf("%jd\n", (intmax_t)ftello(ofp)); @@ -270,7 +270,7 @@ cleanup(void) /* Read a line from the input into a static buffer. */ static char * -getline(void) +get_line(void) { static char lbuf[LINE_MAX]; FILE *src; @@ -291,7 +291,7 @@ again: if (fgets(lbuf, sizeof(lbuf), src) == NULL) { return (lbuf); } -/* Conceptually rewind the input (as obtained by getline()) back `n' lines. */ +/* Conceptually rewind the input (as obtained by get_line()) back `n' lines. */ static void toomuch(FILE *ofp, long n) { @@ -343,7 +343,7 @@ toomuch(FILE *ofp, long n) err(1, "%s", currfile); /* - * getline() will read from here. Next call will truncate to + * get_line() will read from here. Next call will truncate to * truncofs in this file. */ overfile = ofp; @@ -391,7 +391,7 @@ do_rexp(const char *expr) /* Read and output lines until we get a match. */ first = 1; - while ((p = getline()) != NULL) { + while ((p = get_line()) != NULL) { if (fputs(p, ofp) != 0) break; if (!first && regexec(&cre, p, 0, NULL, 0) == 0) @@ -417,7 +417,7 @@ do_rexp(const char *expr) * Positive offset: copy the requested number of lines * after the match. */ - while (--ofs > 0 && (p = getline()) != NULL) + while (--ofs > 0 && (p = get_line()) != NULL) fputs(p, ofp); toomuch(NULL, 0); nwritten = (intmax_t)ftello(ofp); @@ -451,7 +451,7 @@ do_lineno(const char *expr) while (nfiles < maxfiles - 1) { ofp = newfile(); while (lineno + 1 != lastline) { - if ((p = getline()) == NULL) + if ((p = get_line()) == NULL) errx(1, "%ld: out of range", lastline); if (fputs(p, ofp) != 0) break; diff --git a/usr.bin/ctags/C.c b/usr.bin/ctags/C.c index 19de4689a055..22878488c3c9 100644 --- a/usr.bin/ctags/C.c +++ b/usr.bin/ctags/C.c @@ -151,7 +151,7 @@ c_entries(void) * foo\n * (arg1, */ - getline(); + get_line(); curline = lineno; if (func_entry()) { ++level; @@ -180,7 +180,7 @@ c_entries(void) case ';': if (t_def && level == t_level) { t_def = NO; - getline(); + get_line(); if (sp != tok) *sp = EOS; pfnote(tok, lineno); @@ -225,7 +225,7 @@ c_entries(void) * get line immediately; * may change before '{' */ - getline(); + get_line(); if (str_entry(c)) ++level; break; @@ -369,7 +369,7 @@ hash_entry(void) } *sp = EOS; if (dflag || c == '(') { /* only want macros */ - getline(); + get_line(); pfnote(tok, curline); } skip: if (c == '\n') { /* get rid of rest of define */ diff --git a/usr.bin/ctags/ctags.h b/usr.bin/ctags/ctags.h index 256c8531dba1..597723df59b8 100644 --- a/usr.bin/ctags/ctags.h +++ b/usr.bin/ctags/ctags.h @@ -84,7 +84,7 @@ extern char *lbp; extern char searchar; /* ex search character */ extern int cicmp(const char *); -extern void getline(void); +extern void get_line(void); extern void pfnote(const char *, int); extern int skip_key(int); extern void put_entries(NODE *); diff --git a/usr.bin/ctags/fortran.c b/usr.bin/ctags/fortran.c index 025dac9a7c63..66d4b54b00fe 100644 --- a/usr.bin/ctags/fortran.c +++ b/usr.bin/ctags/fortran.c @@ -124,7 +124,7 @@ PF_funcs(void) continue; *cp = EOS; (void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */ - getline(); /* process line for ex(1) */ + get_line(); /* process line for ex(1) */ pfnote(tok, lineno); pfcnt = YES; } diff --git a/usr.bin/ctags/lisp.c b/usr.bin/ctags/lisp.c index 19b983aa87a7..0d0e2c2e9d1a 100644 --- a/usr.bin/ctags/lisp.c +++ b/usr.bin/ctags/lisp.c @@ -99,7 +99,7 @@ l_entries(void) *cp = EOS; (void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */ *cp = savedc; - getline(); + get_line(); pfnote(tok, lineno); } /*NOTREACHED*/ diff --git a/usr.bin/ctags/print.c b/usr.bin/ctags/print.c index a374b389b50d..ca5b9deb41ba 100644 --- a/usr.bin/ctags/print.c +++ b/usr.bin/ctags/print.c @@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$"); #include "ctags.h" /* - * getline -- + * get_line -- * get the line the token of interest occurred on, * prepare it for printing. */ void -getline(void) +get_line(void) { long saveftell; int c; diff --git a/usr.bin/ctags/yacc.c b/usr.bin/ctags/yacc.c index d741edbe403a..5678da557e76 100644 --- a/usr.bin/ctags/yacc.c +++ b/usr.bin/ctags/yacc.c @@ -98,7 +98,7 @@ y_entries(void) while (GETC(!=, EOF) && (intoken(c) || c == '.')) *sp++ = c; *sp = EOS; - getline(); /* may change before ':' */ + get_line(); /* may change before ':' */ while (iswhite(c)) { if (c == '\n') SETLINE;