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
This commit is contained in:
parent
053a88680a
commit
a651f2bc6c
@ -68,7 +68,7 @@ static int no_op(void);
|
|||||||
static void printflg(unsigned int);
|
static void printflg(unsigned int);
|
||||||
static int c_frmt(const void *, const void *);
|
static int c_frmt(const void *, const void *);
|
||||||
static off_t str_offt(char *);
|
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_options(int, char **);
|
||||||
static void pax_usage(void);
|
static void pax_usage(void);
|
||||||
static void tar_options(int, char **);
|
static void tar_options(int, char **);
|
||||||
@ -76,10 +76,10 @@ static void tar_usage(void);
|
|||||||
static void cpio_options(int, char **);
|
static void cpio_options(int, char **);
|
||||||
static void cpio_usage(void);
|
static void cpio_usage(void);
|
||||||
|
|
||||||
/* errors from getline */
|
/* errors from get_line */
|
||||||
#define GETLINE_FILE_CORRUPT 1
|
#define GETLINE_FILE_CORRUPT 1
|
||||||
#define GETLINE_OUT_OF_MEM 2
|
#define GETLINE_OUT_OF_MEM 2
|
||||||
static int getline_error;
|
static int get_line_error;
|
||||||
|
|
||||||
char *chdname;
|
char *chdname;
|
||||||
|
|
||||||
@ -873,14 +873,14 @@ tar_options(int argc, char **argv)
|
|||||||
paxwarn(1, "Unable to open file '%s' for read", file);
|
paxwarn(1, "Unable to open file '%s' for read", file);
|
||||||
tar_usage();
|
tar_usage();
|
||||||
}
|
}
|
||||||
while ((str = getline(fp)) != NULL) {
|
while ((str = get_line(fp)) != NULL) {
|
||||||
if (pat_add(str, dir) < 0)
|
if (pat_add(str, dir) < 0)
|
||||||
tar_usage();
|
tar_usage();
|
||||||
sawpat = 1;
|
sawpat = 1;
|
||||||
}
|
}
|
||||||
if (strcmp(file, "-") != 0)
|
if (strcmp(file, "-") != 0)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (getline_error) {
|
if (get_line_error) {
|
||||||
paxwarn(1, "Problem with file '%s'", file);
|
paxwarn(1, "Problem with file '%s'", file);
|
||||||
tar_usage();
|
tar_usage();
|
||||||
}
|
}
|
||||||
@ -946,13 +946,13 @@ tar_options(int argc, char **argv)
|
|||||||
paxwarn(1, "Unable to open file '%s' for read", file);
|
paxwarn(1, "Unable to open file '%s' for read", file);
|
||||||
tar_usage();
|
tar_usage();
|
||||||
}
|
}
|
||||||
while ((str = getline(fp)) != NULL) {
|
while ((str = get_line(fp)) != NULL) {
|
||||||
if (ftree_add(str, 0) < 0)
|
if (ftree_add(str, 0) < 0)
|
||||||
tar_usage();
|
tar_usage();
|
||||||
}
|
}
|
||||||
if (strcmp(file, "-") != 0)
|
if (strcmp(file, "-") != 0)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (getline_error) {
|
if (get_line_error) {
|
||||||
paxwarn(1, "Problem with file '%s'",
|
paxwarn(1, "Problem with file '%s'",
|
||||||
file);
|
file);
|
||||||
tar_usage();
|
tar_usage();
|
||||||
@ -1159,11 +1159,11 @@ cpio_options(int argc, char **argv)
|
|||||||
paxwarn(1, "Unable to open file '%s' for read", optarg);
|
paxwarn(1, "Unable to open file '%s' for read", optarg);
|
||||||
cpio_usage();
|
cpio_usage();
|
||||||
}
|
}
|
||||||
while ((str = getline(fp)) != NULL) {
|
while ((str = get_line(fp)) != NULL) {
|
||||||
pat_add(str, NULL);
|
pat_add(str, NULL);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (getline_error) {
|
if (get_line_error) {
|
||||||
paxwarn(1, "Problem with file '%s'", optarg);
|
paxwarn(1, "Problem with file '%s'", optarg);
|
||||||
cpio_usage();
|
cpio_usage();
|
||||||
}
|
}
|
||||||
@ -1258,10 +1258,10 @@ cpio_options(int argc, char **argv)
|
|||||||
* no read errors allowed on updates/append operation!
|
* no read errors allowed on updates/append operation!
|
||||||
*/
|
*/
|
||||||
maxflt = 0;
|
maxflt = 0;
|
||||||
while ((str = getline(stdin)) != NULL) {
|
while ((str = get_line(stdin)) != NULL) {
|
||||||
ftree_add(str, 0);
|
ftree_add(str, 0);
|
||||||
}
|
}
|
||||||
if (getline_error) {
|
if (get_line_error) {
|
||||||
paxwarn(1, "Problem while reading stdin");
|
paxwarn(1, "Problem while reading stdin");
|
||||||
cpio_usage();
|
cpio_usage();
|
||||||
}
|
}
|
||||||
@ -1489,21 +1489,21 @@ str_offt(char *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getline(FILE *f)
|
get_line(FILE *f)
|
||||||
{
|
{
|
||||||
char *name, *temp;
|
char *name, *temp;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
name = fgetln(f, &len);
|
name = fgetln(f, &len);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
|
get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (name[len-1] != '\n')
|
if (name[len-1] != '\n')
|
||||||
len++;
|
len++;
|
||||||
temp = malloc(len);
|
temp = malloc(len);
|
||||||
if (!temp) {
|
if (!temp) {
|
||||||
getline_error = GETLINE_OUT_OF_MEM;
|
get_line_error = GETLINE_OUT_OF_MEM;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
memcpy(temp, name, len-1);
|
memcpy(temp, name, len-1);
|
||||||
|
@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
static void do_lineno(const char *);
|
static void do_lineno(const char *);
|
||||||
static void do_rexp(const char *);
|
static void do_rexp(const char *);
|
||||||
static char *getline(void);
|
static char *get_line(void);
|
||||||
static void handlesig(int);
|
static void handlesig(int);
|
||||||
static FILE *newfile(void);
|
static FILE *newfile(void);
|
||||||
static void toomuch(FILE *, long);
|
static void toomuch(FILE *, long);
|
||||||
@ -195,7 +195,7 @@ main(int argc, char *argv[])
|
|||||||
/* Copy the rest into a new file. */
|
/* Copy the rest into a new file. */
|
||||||
if (!feof(infile)) {
|
if (!feof(infile)) {
|
||||||
ofp = newfile();
|
ofp = newfile();
|
||||||
while ((p = getline()) != NULL && fputs(p, ofp) == 0)
|
while ((p = get_line()) != NULL && fputs(p, ofp) == 0)
|
||||||
;
|
;
|
||||||
if (!sflag)
|
if (!sflag)
|
||||||
printf("%jd\n", (intmax_t)ftello(ofp));
|
printf("%jd\n", (intmax_t)ftello(ofp));
|
||||||
@ -270,7 +270,7 @@ cleanup(void)
|
|||||||
|
|
||||||
/* Read a line from the input into a static buffer. */
|
/* Read a line from the input into a static buffer. */
|
||||||
static char *
|
static char *
|
||||||
getline(void)
|
get_line(void)
|
||||||
{
|
{
|
||||||
static char lbuf[LINE_MAX];
|
static char lbuf[LINE_MAX];
|
||||||
FILE *src;
|
FILE *src;
|
||||||
@ -291,7 +291,7 @@ again: if (fgets(lbuf, sizeof(lbuf), src) == NULL) {
|
|||||||
return (lbuf);
|
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
|
static void
|
||||||
toomuch(FILE *ofp, long n)
|
toomuch(FILE *ofp, long n)
|
||||||
{
|
{
|
||||||
@ -343,7 +343,7 @@ toomuch(FILE *ofp, long n)
|
|||||||
err(1, "%s", currfile);
|
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.
|
* truncofs in this file.
|
||||||
*/
|
*/
|
||||||
overfile = ofp;
|
overfile = ofp;
|
||||||
@ -391,7 +391,7 @@ do_rexp(const char *expr)
|
|||||||
|
|
||||||
/* Read and output lines until we get a match. */
|
/* Read and output lines until we get a match. */
|
||||||
first = 1;
|
first = 1;
|
||||||
while ((p = getline()) != NULL) {
|
while ((p = get_line()) != NULL) {
|
||||||
if (fputs(p, ofp) != 0)
|
if (fputs(p, ofp) != 0)
|
||||||
break;
|
break;
|
||||||
if (!first && regexec(&cre, p, 0, NULL, 0) == 0)
|
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
|
* Positive offset: copy the requested number of lines
|
||||||
* after the match.
|
* after the match.
|
||||||
*/
|
*/
|
||||||
while (--ofs > 0 && (p = getline()) != NULL)
|
while (--ofs > 0 && (p = get_line()) != NULL)
|
||||||
fputs(p, ofp);
|
fputs(p, ofp);
|
||||||
toomuch(NULL, 0);
|
toomuch(NULL, 0);
|
||||||
nwritten = (intmax_t)ftello(ofp);
|
nwritten = (intmax_t)ftello(ofp);
|
||||||
@ -451,7 +451,7 @@ do_lineno(const char *expr)
|
|||||||
while (nfiles < maxfiles - 1) {
|
while (nfiles < maxfiles - 1) {
|
||||||
ofp = newfile();
|
ofp = newfile();
|
||||||
while (lineno + 1 != lastline) {
|
while (lineno + 1 != lastline) {
|
||||||
if ((p = getline()) == NULL)
|
if ((p = get_line()) == NULL)
|
||||||
errx(1, "%ld: out of range", lastline);
|
errx(1, "%ld: out of range", lastline);
|
||||||
if (fputs(p, ofp) != 0)
|
if (fputs(p, ofp) != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -151,7 +151,7 @@ c_entries(void)
|
|||||||
* foo\n
|
* foo\n
|
||||||
* (arg1,
|
* (arg1,
|
||||||
*/
|
*/
|
||||||
getline();
|
get_line();
|
||||||
curline = lineno;
|
curline = lineno;
|
||||||
if (func_entry()) {
|
if (func_entry()) {
|
||||||
++level;
|
++level;
|
||||||
@ -180,7 +180,7 @@ c_entries(void)
|
|||||||
case ';':
|
case ';':
|
||||||
if (t_def && level == t_level) {
|
if (t_def && level == t_level) {
|
||||||
t_def = NO;
|
t_def = NO;
|
||||||
getline();
|
get_line();
|
||||||
if (sp != tok)
|
if (sp != tok)
|
||||||
*sp = EOS;
|
*sp = EOS;
|
||||||
pfnote(tok, lineno);
|
pfnote(tok, lineno);
|
||||||
@ -225,7 +225,7 @@ c_entries(void)
|
|||||||
* get line immediately;
|
* get line immediately;
|
||||||
* may change before '{'
|
* may change before '{'
|
||||||
*/
|
*/
|
||||||
getline();
|
get_line();
|
||||||
if (str_entry(c))
|
if (str_entry(c))
|
||||||
++level;
|
++level;
|
||||||
break;
|
break;
|
||||||
@ -369,7 +369,7 @@ hash_entry(void)
|
|||||||
}
|
}
|
||||||
*sp = EOS;
|
*sp = EOS;
|
||||||
if (dflag || c == '(') { /* only want macros */
|
if (dflag || c == '(') { /* only want macros */
|
||||||
getline();
|
get_line();
|
||||||
pfnote(tok, curline);
|
pfnote(tok, curline);
|
||||||
}
|
}
|
||||||
skip: if (c == '\n') { /* get rid of rest of define */
|
skip: if (c == '\n') { /* get rid of rest of define */
|
||||||
|
@ -84,7 +84,7 @@ extern char *lbp;
|
|||||||
extern char searchar; /* ex search character */
|
extern char searchar; /* ex search character */
|
||||||
|
|
||||||
extern int cicmp(const char *);
|
extern int cicmp(const char *);
|
||||||
extern void getline(void);
|
extern void get_line(void);
|
||||||
extern void pfnote(const char *, int);
|
extern void pfnote(const char *, int);
|
||||||
extern int skip_key(int);
|
extern int skip_key(int);
|
||||||
extern void put_entries(NODE *);
|
extern void put_entries(NODE *);
|
||||||
|
@ -124,7 +124,7 @@ PF_funcs(void)
|
|||||||
continue;
|
continue;
|
||||||
*cp = EOS;
|
*cp = EOS;
|
||||||
(void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */
|
(void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */
|
||||||
getline(); /* process line for ex(1) */
|
get_line(); /* process line for ex(1) */
|
||||||
pfnote(tok, lineno);
|
pfnote(tok, lineno);
|
||||||
pfcnt = YES;
|
pfcnt = YES;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ l_entries(void)
|
|||||||
*cp = EOS;
|
*cp = EOS;
|
||||||
(void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */
|
(void)strlcpy(tok, lbp, sizeof(tok)); /* possible trunc */
|
||||||
*cp = savedc;
|
*cp = savedc;
|
||||||
getline();
|
get_line();
|
||||||
pfnote(tok, lineno);
|
pfnote(tok, lineno);
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "ctags.h"
|
#include "ctags.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getline --
|
* get_line --
|
||||||
* get the line the token of interest occurred on,
|
* get the line the token of interest occurred on,
|
||||||
* prepare it for printing.
|
* prepare it for printing.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
getline(void)
|
get_line(void)
|
||||||
{
|
{
|
||||||
long saveftell;
|
long saveftell;
|
||||||
int c;
|
int c;
|
||||||
|
@ -98,7 +98,7 @@ y_entries(void)
|
|||||||
while (GETC(!=, EOF) && (intoken(c) || c == '.'))
|
while (GETC(!=, EOF) && (intoken(c) || c == '.'))
|
||||||
*sp++ = c;
|
*sp++ = c;
|
||||||
*sp = EOS;
|
*sp = EOS;
|
||||||
getline(); /* may change before ':' */
|
get_line(); /* may change before ':' */
|
||||||
while (iswhite(c)) {
|
while (iswhite(c)) {
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
SETLINE;
|
SETLINE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user