aboutsummaryrefslogtreecommitdiffstats
path: root/field.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-06-08 09:51:47 -0400
committerArnold D. Robbins <arnold@skeeve.com>2015-06-08 09:51:47 -0400
commita6568baf060045cadad1f05af5cfe43e31626b31 (patch)
tree4471355f7fc25c1549a915a03ab8b14fbeb8783d /field.c
parentc70ee2ae9fc9fa99c0b3b1af20a7dd0203aaa0d1 (diff)
parent72882c6a1e76730e6e706941a1a3a855ea023b69 (diff)
downloadegawk-a6568baf060045cadad1f05af5cfe43e31626b31.tar.gz
egawk-a6568baf060045cadad1f05af5cfe43e31626b31.tar.bz2
egawk-a6568baf060045cadad1f05af5cfe43e31626b31.zip
Merge branch 'master' into feature/cmake
Diffstat (limited to 'field.c')
-rw-r--r--field.c81
1 files changed, 2 insertions, 79 deletions
diff --git a/field.c b/field.c
index 13a5db6f..b6840b08 100644
--- a/field.c
+++ b/field.c
@@ -44,8 +44,6 @@ static long re_parse_field(long, char **, int, NODE *,
Regexp *, Setfunc, NODE *, NODE *, bool);
static long def_parse_field(long, char **, int, NODE *,
Regexp *, Setfunc, NODE *, NODE *, bool);
-static long posix_def_parse_field(long, char **, int, NODE *,
- Regexp *, Setfunc, NODE *, NODE *, bool);
static long null_parse_field(long, char **, int, NODE *,
Regexp *, Setfunc, NODE *, NODE *, bool);
static long sc_parse_field(long, char **, int, NODE *,
@@ -538,75 +536,6 @@ def_parse_field(long up_to, /* parse only up to this field number */
}
/*
- * posix_def_parse_field --- default field parsing.
- *
- * This is called both from get_field() and from do_split()
- * via (*parse_field)(). This variation is for when FS is a single space
- * character. The only difference between this and def_parse_field()
- * is that this one does not allow newlines to separate fields.
- */
-
-static long
-posix_def_parse_field(long up_to, /* parse only up to this field number */
- char **buf, /* on input: string to parse; on output: point to start next */
- int len,
- NODE *fs,
- Regexp *rp ATTRIBUTE_UNUSED,
- Setfunc set, /* routine to set the value of the parsed field */
- NODE *n,
- NODE *dummy ATTRIBUTE_UNUSED, /* sep_arr not needed here: hence dummy */
- bool in_middle ATTRIBUTE_UNUSED)
-{
- char *scan = *buf;
- long nf = parse_high_water;
- char *field;
- char *end = scan + len;
- char sav;
-
- if (up_to == UNLIMITED)
- nf = 0;
- if (len == 0)
- return nf;
-
- /*
- * Nasty special case. If FS set to "", return whole record
- * as first field. This is not worth a separate function.
- */
- if (fs->stlen == 0) {
- (*set)(++nf, *buf, len, n);
- *buf += len;
- return nf;
- }
-
- /* before doing anything save the char at *end */
- sav = *end;
- /* because it will be destroyed now: */
-
- *end = ' '; /* sentinel character */
- for (; nf < up_to; scan++) {
- /*
- * special case: fs is single space, strip leading whitespace
- */
- while (scan < end && (*scan == ' ' || *scan == '\t'))
- scan++;
- if (scan >= end)
- break;
- field = scan;
- while (*scan != ' ' && *scan != '\t')
- scan++;
- (*set)(++nf, field, (long)(scan - field), n);
- if (scan == end)
- break;
- }
-
- /* everything done, restore original char at *end */
- *end = sav;
-
- *buf = scan;
- return nf;
-}
-
-/*
* null_parse_field --- each character is a separate field
*
* This is called both from get_field() and from do_split()
@@ -1020,10 +949,7 @@ do_split(int nargs)
}
} else if (fs->stlen == 1 && (sep->re_flags & CONSTANT) == 0) {
if (fs->stptr[0] == ' ') {
- if (do_posix)
- parseit = posix_def_parse_field;
- else
- parseit = def_parse_field;
+ parseit = def_parse_field;
} else
parseit = sc_parse_field;
} else {
@@ -1274,10 +1200,7 @@ choose_fs_function:
sprintf(buf, "[%c\n]", fs->stptr[0]);
}
} else {
- if (do_posix)
- parse_field = posix_def_parse_field;
- else
- parse_field = def_parse_field;
+ parse_field = def_parse_field;
if (fs->stlen == 1) {
if (fs->stptr[0] == ' ')