[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, feature/cpp-compile, created. gawk-4.1.0-4155-gf1224c
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, feature/cpp-compile, created. gawk-4.1.0-4155-gf1224c7 |
Date: |
Wed, 21 Oct 2020 06:55:18 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/cpp-compile has been created
at f1224c70613c235e52711e4d4f9f824a41f099de (commit)
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=f1224c70613c235e52711e4d4f9f824a41f099de
commit f1224c70613c235e52711e4d4f9f824a41f099de
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Oct 21 13:54:15 2020 +0300
Start on compiling with C++, fix just errors.
diff --git a/array.c b/array.c
index 60d1862..38195fb 100644
--- a/array.c
+++ b/array.c
@@ -111,7 +111,8 @@ null_array(NODE *symbol)
symbol->type = Node_var_array;
symbol->array_funcs = & null_array_func;
symbol->buckets = NULL;
- symbol->table_size = symbol->array_size = 0;
+ symbol->table_size = 0;
+ symbol->array_size = 0;
symbol->array_capacity = 0;
symbol->flags = 0;
@@ -1303,7 +1304,7 @@ assoc_list(NODE *symbol, const char *sort_str,
sort_context_t sort_ctxt)
static const struct qsort_funcs {
const char *name;
qsort_compfunc comp_func;
- assoc_kind_t kind;
+ int kind;
} sort_funcs[] = {
{ "@ind_str_asc", sort_up_index_string, AINDEX|AISTR|AASC },
{ "@ind_num_asc", sort_up_index_number, AINDEX|AINUM|AASC },
@@ -1325,13 +1326,12 @@ assoc_list(NODE *symbol, const char *sort_str,
sort_context_t sort_ctxt)
NODE **list;
NODE akind;
- unsigned long num_elems, j;
- int elem_size, qi;
+ int elem_size, qi, j, num_elems;
qsort_compfunc cmp_func = 0;
INSTRUCTION *code = NULL;
extern int currule;
int save_rule = 0;
- assoc_kind_t assoc_kind = ANONE;
+ int assoc_kind = ANONE;
elem_size = 1;
diff --git a/awk.h b/awk.h
index cf06d49..6c9342f 100644
--- a/awk.h
+++ b/awk.h
@@ -332,6 +332,84 @@ typedef struct {
afunc_t store;
} array_funcs_t;
+enum reflagvals {
+ CONSTANT = 1,
+ FS_DFLT = 2,
+};
+
+enum flagvals {
+/* type = Node_val */
+ /*
+ * STRING and NUMBER are mutually exclusive, except for the special
+ * case of an uninitialized value, represented internally by
+ * Nnull_string. They represent the type of a value as assigned.
+ * Nnull_string has both STRING and NUMBER attributes, but all other
+ * scalar values should have precisely one of these bits set.
+ *
+ * STRCUR and NUMCUR are not mutually exclusive. They represent that
+ * the particular type of value is up to date. For example,
+ *
+ * a = 5 # NUMBER | NUMCUR
+ * b = a "" # Adds STRCUR to a, since a string value
+ * # is now available. But the type hasn't changed!
+ *
+ * a = "42" # STRING | STRCUR
+ * b = a + 0 # Adds NUMCUR to a, since numeric value
+ * # is now available. But the type hasn't changed!
+ *
+ * USER_INPUT is the joker. When STRING|USER_INPUT is set, it means
+ * "this is string data, but the user may have really wanted it to be a
+ * number. If we have to guess, like in a comparison, turn it into a
+ * number if the string is indeed numeric."
+ * For example, gawk -v a=42 ....
+ * Here, `a' gets STRING|STRCUR|USER_INPUT and then when used where
+ * a number is needed, it gets turned into a NUMBER and STRING
+ * is cleared. In that case, we leave the USER_INPUT in place, so
+ * the combination NUMBER|USER_INPUT means it is a strnum a.k.a. a
+ * "numeric string".
+ *
+ * WSTRCUR is for efficiency. If in a multibyte locale, and we
+ * need to do something character based (substr, length, etc.)
+ * we create the corresponding wide character string and store it,
+ * and add WSTRCUR to the flags so that we don't have to do the
+ * conversion more than once.
+ *
+ * The NUMINT flag may be used with a value of any type -- NUMBER,
+ * STRING, or STRNUM. It indicates that the string representation
+ * equals the result of sprintf("%ld", <numeric value>). So, for
+ * example, NUMINT should NOT be set if it's a strnum or string value
+ * where the string is " 1" or "01" or "+1" or "1.0" or "0.1E1". This
+ * is a hint to indicate that an integer array optimization may be
+ * used when this value appears as a subscript.
+ *
+ * We hope that the rest of the flags are self-explanatory. :-)
+ */
+ MALLOC = 0x0001, /* stptr can be free'd, i.e. not a field node
pointing into a shared buffer */
+ STRING = 0x0002, /* assigned as string */
+ STRCUR = 0x0004, /* string value is current */
+ NUMCUR = 0x0008, /* numeric value is current */
+ NUMBER = 0x0010, /* assigned as number */
+ USER_INPUT = 0x0020, /* user input: if NUMERIC then
+ * a NUMBER */
+ INTLSTR = 0x0040, /* use localized version */
+ NUMINT = 0x0080, /* numeric value is an integer */
+ INTIND = 0x0100, /* integral value is array index;
+ * lazy conversion to string.
+ */
+ WSTRCUR = 0x0200, /* wide str value is current */
+ MPFN = 0x0400, /* arbitrary-precision floating-point number */
+ MPZN = 0x0800, /* arbitrary-precision integer */
+ NO_EXT_SET = 0x1000, /* extension cannot set a value for this
variable */
+ NULL_FIELD = 0x2000, /* this is the null field */
+
+/* type = Node_var_array */
+ ARRAYMAXED = 0x4000, /* array is at max size */
+ HALFHAT = 0x8000, /* half-capacity Hashed Array Tree;
+ * See cint_array.c */
+ XARRAY = 0x10000,
+ NUMCONSTSTR = 0x20000, /* have string value for numeric
constant */
+ REGEX = 0x40000, /* this is a typed regex */
+} flags;
/*
* NOTE - this struct is a rather kludgey -- it is packed to minimize
* space usage, at the expense of cleanliness. Alter at own risk.
@@ -363,10 +441,7 @@ typedef struct exp_node {
size_t reserved;
struct exp_node *rn;
unsigned long cnt;
- enum reflagvals {
- CONSTANT = 1,
- FS_DFLT = 2,
- } reflags;
+ int reflags;
} nodep;
struct {
@@ -390,79 +465,7 @@ typedef struct exp_node {
} val;
} sub;
NODETYPE type;
- enum flagvals {
- /* type = Node_val */
- /*
- * STRING and NUMBER are mutually exclusive, except for the
special
- * case of an uninitialized value, represented internally by
- * Nnull_string. They represent the type of a value as assigned.
- * Nnull_string has both STRING and NUMBER attributes, but all
other
- * scalar values should have precisely one of these bits set.
- *
- * STRCUR and NUMCUR are not mutually exclusive. They represent
that
- * the particular type of value is up to date. For example,
- *
- * a = 5 # NUMBER | NUMCUR
- * b = a "" # Adds STRCUR to a, since a string value
- * # is now available. But the type hasn't
changed!
- *
- * a = "42" # STRING | STRCUR
- * b = a + 0 # Adds NUMCUR to a, since numeric value
- * # is now available. But the type hasn't
changed!
- *
- * USER_INPUT is the joker. When STRING|USER_INPUT is set, it
means
- * "this is string data, but the user may have really wanted it
to be a
- * number. If we have to guess, like in a comparison, turn it
into a
- * number if the string is indeed numeric."
- * For example, gawk -v a=42 ....
- * Here, `a' gets STRING|STRCUR|USER_INPUT and then when used
where
- * a number is needed, it gets turned into a NUMBER and STRING
- * is cleared. In that case, we leave the USER_INPUT in place,
so
- * the combination NUMBER|USER_INPUT means it is a strnum
a.k.a. a
- * "numeric string".
- *
- * WSTRCUR is for efficiency. If in a multibyte locale, and we
- * need to do something character based (substr, length, etc.)
- * we create the corresponding wide character string and store
it,
- * and add WSTRCUR to the flags so that we don't have to do the
- * conversion more than once.
- *
- * The NUMINT flag may be used with a value of any type --
NUMBER,
- * STRING, or STRNUM. It indicates that the string
representation
- * equals the result of sprintf("%ld", <numeric value>). So, for
- * example, NUMINT should NOT be set if it's a strnum or string
value
- * where the string is " 1" or "01" or "+1" or "1.0" or
"0.1E1". This
- * is a hint to indicate that an integer array optimization may
be
- * used when this value appears as a subscript.
- *
- * We hope that the rest of the flags are self-explanatory. :-)
- */
- MALLOC = 0x0001, /* stptr can be free'd, i.e. not a
field node pointing into a shared buffer */
- STRING = 0x0002, /* assigned as string */
- STRCUR = 0x0004, /* string value is current */
- NUMCUR = 0x0008, /* numeric value is current */
- NUMBER = 0x0010, /* assigned as number */
- USER_INPUT = 0x0020, /* user input: if NUMERIC then
- * a NUMBER */
- INTLSTR = 0x0040, /* use localized version */
- NUMINT = 0x0080, /* numeric value is an integer */
- INTIND = 0x0100, /* integral value is array index;
- * lazy conversion to string.
- */
- WSTRCUR = 0x0200, /* wide str value is current */
- MPFN = 0x0400, /* arbitrary-precision floating-point
number */
- MPZN = 0x0800, /* arbitrary-precision integer */
- NO_EXT_SET = 0x1000, /* extension cannot set a value for
this variable */
- NULL_FIELD = 0x2000, /* this is the null field */
-
- /* type = Node_var_array */
- ARRAYMAXED = 0x4000, /* array is at max size */
- HALFHAT = 0x8000, /* half-capacity Hashed Array
Tree;
- * See cint_array.c */
- XARRAY = 0x10000,
- NUMCONSTSTR = 0x20000, /* have string value for
numeric constant */
- REGEX = 0x40000, /* this is a typed regex */
- } flags;
+ int flags;
long valref;
} NODE;
@@ -929,8 +932,15 @@ typedef struct exp_instruction {
/* Op_store_var */
#define initval x.xn
+enum iobuf_flags {
+ IOP_IS_TTY = 1,
+ IOP_AT_EOF = 2,
+ IOP_CLOSED = 4,
+ IOP_AT_START = 8,
+};
+
typedef struct iobuf {
- awk_input_buf_t public; /* exposed to extensions */
+ awk_input_buf_t public_; /* exposed to extensions */
char *buf; /* start data buffer */
char *off; /* start of current record in buffer */
char *dataend; /* first byte in buffer to hold new data,
@@ -944,33 +954,31 @@ typedef struct iobuf {
bool valid;
int errcode;
- enum iobuf_flags {
- IOP_IS_TTY = 1,
- IOP_AT_EOF = 2,
- IOP_CLOSED = 4,
- IOP_AT_START = 8,
- } flag;
+ int flag;
} IOBUF;
typedef void (*Func_ptr)(void);
/* structure used to dynamically maintain a linked-list of open files/pipes */
+enum redirect_flags {
+ RED_NONE = 0,
+ RED_FILE = 1,
+ RED_PIPE = 2,
+ RED_READ = 4,
+ RED_WRITE = 8,
+ RED_APPEND = 16,
+ RED_NOBUF = 32,
+ RED_USED = 64, /* closed temporarily to reuse fd */
+ RED_EOF = 128,
+ RED_TWOWAY = 256,
+ RED_PTY = 512,
+ RED_SOCKET = 1024,
+ RED_TCP = 2048,
+};
+typedef enum redirect_flags redirect_flags_t;
+
struct redirect {
- enum redirect_flags {
- RED_NONE = 0,
- RED_FILE = 1,
- RED_PIPE = 2,
- RED_READ = 4,
- RED_WRITE = 8,
- RED_APPEND = 16,
- RED_NOBUF = 32,
- RED_USED = 64, /* closed temporarily to reuse fd */
- RED_EOF = 128,
- RED_TWOWAY = 256,
- RED_PTY = 512,
- RED_SOCKET = 1024,
- RED_TCP = 2048,
- } flag;
+ int flag;
char *value;
FILE *ifp; /* input fp, needed for PIPES_SIMULATED */
IOBUF *iop;
@@ -981,7 +989,7 @@ struct redirect {
const char *mode;
awk_output_buf_t output;
};
-typedef enum redirect_flags redirect_flags_t;
+
/* values for BINMODE, used as bit flags */
@@ -995,18 +1003,19 @@ enum binmode_values {
/*
* structure for our source, either a command line string or a source file.
*/
+enum srctype {
+ SRC_CMDLINE = 1,
+ SRC_STDIN,
+ SRC_FILE,
+ SRC_INC,
+ SRC_EXTLIB
+};
typedef struct srcfile {
struct srcfile *next;
struct srcfile *prev;
- enum srctype {
- SRC_CMDLINE = 1,
- SRC_STDIN,
- SRC_FILE,
- SRC_INC,
- SRC_EXTLIB
- } stype;
+ enum srctype stype;
char *src; /* name on command line or include statement */
char *fullpath; /* full path after AWKPATH search */
time_t mtime;
@@ -1026,7 +1035,7 @@ typedef struct srcfile {
char *lexptr_begin;
int lasttok;
INSTRUCTION *comment; /* comment on @load line */
- const char *namespace;
+ const char *name_space;
} SRCFILE;
// structure for INSTRUCTION pool, needed mainly for debugger
@@ -1105,7 +1114,7 @@ extern int OFSlen;
extern char *ORS;
extern int ORSlen;
extern char *OFMT;
-extern char *CONVFMT;
+extern const char *CONVFMT;
extern int CONVFMTidx;
extern int OFMTidx;
#ifdef HAVE_MPFR
@@ -1145,7 +1154,8 @@ extern bool do_itrace; /* separate so can poke from a
debugger */
extern SRCFILE *srcfiles; /* source files */
-extern enum do_flag_values {
+enum do_flag_values {
+ DO_FLAG_NONE = 0x00000,
DO_LINT_INVALID = 0x00001, /* only warn about invalid */
DO_LINT_EXTENSIONS = 0x00002, /* warn about gawk extensions */
DO_LINT_ALL = 0x00004, /* warn about all things */
@@ -1162,7 +1172,8 @@ extern enum do_flag_values {
DO_PROFILE = 0x02000, /* profile the program */
DO_DEBUG = 0x04000, /* debug the program */
DO_MPFR = 0x08000, /* arbitrary-precision floating-point
math */
-} do_flags;
+};
+extern int do_flags;
#define do_traditional (do_flags & DO_TRADITIONAL)
#define do_posix (do_flags & DO_POSIX)
@@ -1338,7 +1349,7 @@ DEREF(NODE *r)
extern void *r_getblock(int id);
extern void r_freeblock(void *, int id);
-#define getblock(p, id, ty) (void) (p = r_getblock(id))
+#define getblock(p, id, ty) (void) (p = (ty) r_getblock(id))
#define freeblock(p, id) (void) (r_freeblock(p, id))
#else /* MEMDEBUG */
@@ -1449,7 +1460,7 @@ extern bool is_alpha(int c);
extern bool is_alnum(int c);
extern bool is_letter(int c);
extern bool is_identchar(int c);
-extern NODE *make_regnode(int type, NODE *exp);
+extern NODE *make_regnode(NODETYPE type, NODE *exp);
extern bool validate_qualified_name(char *token);
/* builtin.c */
extern double double_to_int(double d);
@@ -1584,7 +1595,7 @@ extern void print_ext_versions(void);
extern void free_api_string_copies(void);
/* gawkmisc.c */
-extern char *gawk_name(const char *filespec);
+extern const char *gawk_name(const char *filespec);
extern void os_arg_fixup(int *argcp, char ***argvp);
extern int os_devopen(const char *name, int flag);
extern void os_close_on_exec(int fd, const char *name, const char *what, const
char *dir);
diff --git a/awkgram.c b/awkgram.c
index 747c75e..62ff87f 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4721,10 +4721,10 @@ yyreturn:
struct token {
- const char *operator; /* text to match */
- OPCODE value; /* type */
- int class; /* lexical class */
- unsigned flags; /* # of args. allowed and compatability
*/
+ const char *oper; /* text to match */
+ OPCODE value; /* type */
+ int lex_class; /* lexical class */
+ unsigned flags; /* # of args. allowed and compatability */
# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
# define A(n) (1<<(n))
# define VERSION_MASK 0xFF00 /* old awk is zero */
@@ -4750,7 +4750,7 @@ tokcompare(const void *l, const void *r)
lhs = (struct token *) l;
rhs = (struct token *) r;
- return strcmp(lhs->operator, rhs->operator);
+ return strcmp(lhs->oper, rhs->oper);
}
#endif
@@ -4873,10 +4873,10 @@ getfname(NODE *(*fptr)(int), bool prepend_awk)
for (i = 0; i < j; i++) {
if (tokentab[i].ptr == fptr || tokentab[i].ptr2 == fptr) {
if (prepend_awk && (tokentab[i].flags & GAWKX) != 0) {
- sprintf(buf, "awk::%s", tokentab[i].operator);
+ sprintf(buf, "awk::%s", tokentab[i].oper);
return buf;
}
- return tokentab[i].operator;
+ return tokentab[i].oper;
}
}
@@ -5450,7 +5450,7 @@ include_source(INSTRUCTION *file, void **srcfile_p)
sourcefile->lexptr_begin = lexptr_begin;
sourcefile->lexeme = lexeme;
sourcefile->lasttok = lasttok;
- sourcefile->namespace = current_namespace;
+ sourcefile->name_space = current_namespace;
/* included file becomes the current source */
sourcefile = s;
@@ -5566,7 +5566,7 @@ next_sourcefile()
lexeme = sourcefile->lexeme;
sourceline = sourcefile->srclines;
source = sourcefile->src;
- set_current_namespace(sourcefile->namespace);
+ set_current_namespace(sourcefile->name_space);
} else {
lexptr = NULL;
sourceline = 0;
@@ -5592,7 +5592,7 @@ get_src_buf()
* avoids problems with some ancient systems where
* the types of arguments to read() aren't up to date.
*/
- static ssize_t (*readfunc)() = 0;
+ static ssize_t (*readfunc)(int, void *, size_t) = 0;
if (readfunc == NULL) {
char *cp = getenv("AWKREADFUNC");
@@ -5603,7 +5603,7 @@ get_src_buf()
* cast is to remove warnings on systems with
* different return types for read.
*/
- readfunc = ( ssize_t(*)() ) read;
+ readfunc = ( ssize_t(*)(int, void *, size_t) ) read;
else
readfunc = read_one_line;
}
@@ -6852,9 +6852,9 @@ retry:
/* See if it is a special token. */
if ((mid = check_qualified_special(tokstart)) >= 0) {
static int warntab[sizeof(tokentab) / sizeof(tokentab[0])];
- int class = tokentab[mid].class;
+ int lex_class = tokentab[mid].lex_class;
- switch (class) {
+ switch (lex_class) {
case LEX_EVAL:
case LEX_INCLUDE:
case LEX_LOAD:
@@ -6895,12 +6895,12 @@ retry:
if (do_lint) {
if (do_lint_extensions && (tokentab[mid].flags & GAWKX)
!= 0 && (warntab[mid] & GAWKX) == 0) {
lintwarn(_("`%s' is a gawk extension"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= GAWKX;
}
if ((tokentab[mid].flags & NOT_POSIX) != 0 &&
(warntab[mid] & NOT_POSIX) == 0) {
lintwarn(_("POSIX does not allow `%s'"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= NOT_POSIX;
}
}
@@ -6908,7 +6908,7 @@ retry:
&& (warntab[mid] & NOT_OLD) == 0
) {
lintwarn(_("`%s' is not supported in old awk"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= NOT_OLD;
}
@@ -6917,7 +6917,7 @@ retry:
if ((tokentab[mid].flags & CONTINUE) != 0)
continue_allowed++;
- switch (class) {
+ switch (lex_class) {
case LEX_NAMESPACE:
case LEX_INCLUDE:
case LEX_LOAD:
@@ -6946,7 +6946,7 @@ retry:
case LEX_DO:
case LEX_SWITCH:
if (! do_pretty_print)
- return lasttok = class;
+ return lasttok = lex_class;
/* fall through */
case LEX_CASE:
yylval = bcalloc(tokentab[mid].value, 2, sourceline);
@@ -6976,11 +6976,11 @@ retry:
default:
make_instruction:
yylval = GET_INSTRUCTION(tokentab[mid].value);
- if (class == LEX_BUILTIN || class == LEX_LENGTH)
+ if (lex_class == LEX_BUILTIN || lex_class == LEX_LENGTH)
yylval->builtin_idx = mid;
break;
}
- return lasttok = class;
+ return lasttok = lex_class;
}
out:
if (want_param_names == FUNC_HEADER)
@@ -7075,24 +7075,24 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
args_allowed = tokentab[idx].flags & ARGS;
if (args_allowed && (args_allowed & A(nexp)) == 0) {
yyerror(_("%d is invalid as number of arguments for %s"),
- nexp, tokentab[idx].operator);
+ nexp, tokentab[idx].oper);
return NULL;
}
/* special processing for sub, gsub and gensub */
if (tokentab[idx].value == Op_sub_builtin) {
- const char *operator = tokentab[idx].operator;
+ const char *oper= tokentab[idx].oper;
r->sub_flags = 0;
arg = subn->nexti; /* first arg list */
(void) mk_rexp(arg);
- if (strcmp(operator, "gensub") != 0) {
+ if (strcmp(oper, "gensub") != 0) {
/* sub and gsub */
- if (strcmp(operator, "gsub") == 0)
+ if (strcmp(oper, "gsub") == 0)
r->sub_flags |= GSUB;
arg = arg->lasti->nexti; /* 2nd arg list */
@@ -7110,12 +7110,12 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
if (ip->opcode == Op_push_i) {
if (do_lint)
lintwarn(_("%s: string literal as last
argument of substitute has no effect"),
- operator);
+ oper);
r->sub_flags |= LITERAL;
} else {
if (make_assignable(ip) == NULL)
yyerror(_("%s third parameter is not a
changeable object"),
- operator);
+ oper);
else
ip->do_reference = true;
}
@@ -7763,7 +7763,7 @@ variable(int location, char *name, NODETYPE type)
/* make_regnode --- make a regular expression node */
NODE *
-make_regnode(int type, NODE *exp)
+make_regnode(NODETYPE type, NODE *exp)
{
NODE *n;
@@ -8888,9 +8888,9 @@ check_special(const char *name)
high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
while (low <= high) {
mid = (low + high) / 2;
- i = *name - tokentab[mid].operator[0];
+ i = *name - tokentab[mid].oper[0];
if (i == 0)
- i = strcmp(name, tokentab[mid].operator);
+ i = strcmp(name, tokentab[mid].oper);
if (i < 0) /* token < mid */
high = mid - 1;
@@ -8965,7 +8965,7 @@ lookup_builtin(const char *name)
if (mid == -1)
return NULL;
- switch (tokentab[mid].class) {
+ switch (tokentab[mid].lex_class) {
case LEX_BUILTIN:
case LEX_LENGTH:
break;
@@ -9002,10 +9002,10 @@ install_builtins(void)
j = sizeof(tokentab) / sizeof(tokentab[0]);
for (i = 0; i < j; i++) {
- if ( (tokentab[i].class == LEX_BUILTIN
- || tokentab[i].class == LEX_LENGTH)
+ if ( (tokentab[i].lex_class == LEX_BUILTIN
+ || tokentab[i].lex_class == LEX_LENGTH)
&& (tokentab[i].flags & flags_that_must_be_clear) == 0) {
- (void) install_symbol(tokentab[i].operator,
Node_builtin_func);
+ (void) install_symbol(tokentab[i].oper,
Node_builtin_func);
}
}
}
@@ -9261,7 +9261,7 @@ check_qualified_special(char *token)
return i;
tok = & tokentab[i];
- if ((tok->flags & GAWKX) != 0 && tok->class == LEX_BUILTIN)
+ if ((tok->flags & GAWKX) != 0 && tok->lex_class == LEX_BUILTIN)
return -1;
else
return i;
@@ -9289,7 +9289,7 @@ check_qualified_special(char *token)
if (strcmp(ns, "awk") == 0) {
i = check_special(subname);
if (i >= 0) {
- if ((tokentab[i].flags & GAWKX) != 0 &&
tokentab[i].class == LEX_BUILTIN)
+ if ((tokentab[i].flags & GAWKX) != 0 &&
tokentab[i].lex_class == LEX_BUILTIN)
; // gawk additional builtin function, is
ok
else
error_ln(sourceline, _("using reserved
identifier `%s' as second component of a qualified name is not allowed"),
subname);
diff --git a/awkgram.y b/awkgram.y
index 72d7931..0987bd0 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2219,10 +2219,10 @@ comma
%%
struct token {
- const char *operator; /* text to match */
- OPCODE value; /* type */
- int class; /* lexical class */
- unsigned flags; /* # of args. allowed and compatability
*/
+ const char *oper; /* text to match */
+ OPCODE value; /* type */
+ int lex_class; /* lexical class */
+ unsigned flags; /* # of args. allowed and compatability */
# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
# define A(n) (1<<(n))
# define VERSION_MASK 0xFF00 /* old awk is zero */
@@ -2248,7 +2248,7 @@ tokcompare(const void *l, const void *r)
lhs = (struct token *) l;
rhs = (struct token *) r;
- return strcmp(lhs->operator, rhs->operator);
+ return strcmp(lhs->oper, rhs->oper);
}
#endif
@@ -2371,10 +2371,10 @@ getfname(NODE *(*fptr)(int), bool prepend_awk)
for (i = 0; i < j; i++) {
if (tokentab[i].ptr == fptr || tokentab[i].ptr2 == fptr) {
if (prepend_awk && (tokentab[i].flags & GAWKX) != 0) {
- sprintf(buf, "awk::%s", tokentab[i].operator);
+ sprintf(buf, "awk::%s", tokentab[i].oper);
return buf;
}
- return tokentab[i].operator;
+ return tokentab[i].oper;
}
}
@@ -2948,7 +2948,7 @@ include_source(INSTRUCTION *file, void **srcfile_p)
sourcefile->lexptr_begin = lexptr_begin;
sourcefile->lexeme = lexeme;
sourcefile->lasttok = lasttok;
- sourcefile->namespace = current_namespace;
+ sourcefile->name_space = current_namespace;
/* included file becomes the current source */
sourcefile = s;
@@ -3064,7 +3064,7 @@ next_sourcefile()
lexeme = sourcefile->lexeme;
sourceline = sourcefile->srclines;
source = sourcefile->src;
- set_current_namespace(sourcefile->namespace);
+ set_current_namespace(sourcefile->name_space);
} else {
lexptr = NULL;
sourceline = 0;
@@ -3090,7 +3090,7 @@ get_src_buf()
* avoids problems with some ancient systems where
* the types of arguments to read() aren't up to date.
*/
- static ssize_t (*readfunc)() = 0;
+ static ssize_t (*readfunc)(int, void *, size_t) = 0;
if (readfunc == NULL) {
char *cp = getenv("AWKREADFUNC");
@@ -3101,7 +3101,7 @@ get_src_buf()
* cast is to remove warnings on systems with
* different return types for read.
*/
- readfunc = ( ssize_t(*)() ) read;
+ readfunc = ( ssize_t(*)(int, void *, size_t) ) read;
else
readfunc = read_one_line;
}
@@ -4350,9 +4350,9 @@ retry:
/* See if it is a special token. */
if ((mid = check_qualified_special(tokstart)) >= 0) {
static int warntab[sizeof(tokentab) / sizeof(tokentab[0])];
- int class = tokentab[mid].class;
+ int lex_class = tokentab[mid].lex_class;
- switch (class) {
+ switch (lex_class) {
case LEX_EVAL:
case LEX_INCLUDE:
case LEX_LOAD:
@@ -4393,12 +4393,12 @@ retry:
if (do_lint) {
if (do_lint_extensions && (tokentab[mid].flags & GAWKX)
!= 0 && (warntab[mid] & GAWKX) == 0) {
lintwarn(_("`%s' is a gawk extension"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= GAWKX;
}
if ((tokentab[mid].flags & NOT_POSIX) != 0 &&
(warntab[mid] & NOT_POSIX) == 0) {
lintwarn(_("POSIX does not allow `%s'"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= NOT_POSIX;
}
}
@@ -4406,7 +4406,7 @@ retry:
&& (warntab[mid] & NOT_OLD) == 0
) {
lintwarn(_("`%s' is not supported in old awk"),
- tokentab[mid].operator);
+ tokentab[mid].oper);
warntab[mid] |= NOT_OLD;
}
@@ -4415,7 +4415,7 @@ retry:
if ((tokentab[mid].flags & CONTINUE) != 0)
continue_allowed++;
- switch (class) {
+ switch (lex_class) {
case LEX_NAMESPACE:
case LEX_INCLUDE:
case LEX_LOAD:
@@ -4444,7 +4444,7 @@ retry:
case LEX_DO:
case LEX_SWITCH:
if (! do_pretty_print)
- return lasttok = class;
+ return lasttok = lex_class;
/* fall through */
case LEX_CASE:
yylval = bcalloc(tokentab[mid].value, 2, sourceline);
@@ -4474,11 +4474,11 @@ retry:
default:
make_instruction:
yylval = GET_INSTRUCTION(tokentab[mid].value);
- if (class == LEX_BUILTIN || class == LEX_LENGTH)
+ if (lex_class == LEX_BUILTIN || lex_class == LEX_LENGTH)
yylval->builtin_idx = mid;
break;
}
- return lasttok = class;
+ return lasttok = lex_class;
}
out:
if (want_param_names == FUNC_HEADER)
@@ -4573,24 +4573,24 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
args_allowed = tokentab[idx].flags & ARGS;
if (args_allowed && (args_allowed & A(nexp)) == 0) {
yyerror(_("%d is invalid as number of arguments for %s"),
- nexp, tokentab[idx].operator);
+ nexp, tokentab[idx].oper);
return NULL;
}
/* special processing for sub, gsub and gensub */
if (tokentab[idx].value == Op_sub_builtin) {
- const char *operator = tokentab[idx].operator;
+ const char *oper= tokentab[idx].oper;
r->sub_flags = 0;
arg = subn->nexti; /* first arg list */
(void) mk_rexp(arg);
- if (strcmp(operator, "gensub") != 0) {
+ if (strcmp(oper, "gensub") != 0) {
/* sub and gsub */
- if (strcmp(operator, "gsub") == 0)
+ if (strcmp(oper, "gsub") == 0)
r->sub_flags |= GSUB;
arg = arg->lasti->nexti; /* 2nd arg list */
@@ -4608,12 +4608,12 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
if (ip->opcode == Op_push_i) {
if (do_lint)
lintwarn(_("%s: string literal as last
argument of substitute has no effect"),
- operator);
+ oper);
r->sub_flags |= LITERAL;
} else {
if (make_assignable(ip) == NULL)
yyerror(_("%s third parameter is not a
changeable object"),
- operator);
+ oper);
else
ip->do_reference = true;
}
@@ -5261,7 +5261,7 @@ variable(int location, char *name, NODETYPE type)
/* make_regnode --- make a regular expression node */
NODE *
-make_regnode(int type, NODE *exp)
+make_regnode(NODETYPE type, NODE *exp)
{
NODE *n;
@@ -6386,9 +6386,9 @@ check_special(const char *name)
high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1;
while (low <= high) {
mid = (low + high) / 2;
- i = *name - tokentab[mid].operator[0];
+ i = *name - tokentab[mid].oper[0];
if (i == 0)
- i = strcmp(name, tokentab[mid].operator);
+ i = strcmp(name, tokentab[mid].oper);
if (i < 0) /* token < mid */
high = mid - 1;
@@ -6463,7 +6463,7 @@ lookup_builtin(const char *name)
if (mid == -1)
return NULL;
- switch (tokentab[mid].class) {
+ switch (tokentab[mid].lex_class) {
case LEX_BUILTIN:
case LEX_LENGTH:
break;
@@ -6500,10 +6500,10 @@ install_builtins(void)
j = sizeof(tokentab) / sizeof(tokentab[0]);
for (i = 0; i < j; i++) {
- if ( (tokentab[i].class == LEX_BUILTIN
- || tokentab[i].class == LEX_LENGTH)
+ if ( (tokentab[i].lex_class == LEX_BUILTIN
+ || tokentab[i].lex_class == LEX_LENGTH)
&& (tokentab[i].flags & flags_that_must_be_clear) == 0) {
- (void) install_symbol(tokentab[i].operator,
Node_builtin_func);
+ (void) install_symbol(tokentab[i].oper,
Node_builtin_func);
}
}
}
@@ -6759,7 +6759,7 @@ check_qualified_special(char *token)
return i;
tok = & tokentab[i];
- if ((tok->flags & GAWKX) != 0 && tok->class == LEX_BUILTIN)
+ if ((tok->flags & GAWKX) != 0 && tok->lex_class == LEX_BUILTIN)
return -1;
else
return i;
@@ -6787,7 +6787,7 @@ check_qualified_special(char *token)
if (strcmp(ns, "awk") == 0) {
i = check_special(subname);
if (i >= 0) {
- if ((tokentab[i].flags & GAWKX) != 0 &&
tokentab[i].class == LEX_BUILTIN)
+ if ((tokentab[i].flags & GAWKX) != 0 &&
tokentab[i].lex_class == LEX_BUILTIN)
; // gawk additional builtin function, is
ok
else
error_ln(sourceline, _("using reserved
identifier `%s' as second component of a qualified name is not allowed"),
subname);
diff --git a/builtin.c b/builtin.c
index afd866a..b672d97 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4287,6 +4287,7 @@ char *
format_nan_inf(NODE *n, char format)
{
static char buf[100];
+ double val = n->numbr;
#ifdef HAVE_MPFR
if (is_mpg_integer(n))
@@ -4306,7 +4307,6 @@ format_nan_inf(NODE *n, char format)
/* else
fallthrough */
#endif
- double val = n->numbr;
if (isnan(val)) {
strcpy(buf, signbit(val) != 0 ? "-nan" : "+nan");
diff --git a/cint_array.c b/cint_array.c
index b77b001..6946f61 100644
--- a/cint_array.c
+++ b/cint_array.c
@@ -398,20 +398,20 @@ xremove:
static NODE **
cint_copy(NODE *symbol, NODE *newsymb)
{
- NODE **old, **new;
+ NODE **old, **newtab;
size_t i;
assert(symbol->nodes != NULL);
/* allocate new table */
- ezalloc(new, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy");
+ ezalloc(newtab, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy");
old = symbol->nodes;
for (i = NHAT; i < INT32_BIT; i++) {
if (old[i] == NULL)
continue;
- new[i] = make_node(Node_array_tree);
- tree_copy(newsymb, old[i], new[i]);
+ newtab[i] = make_node(Node_array_tree);
+ tree_copy(newsymb, old[i], newtab[i]);
}
if (symbol->xarray != NULL) {
@@ -424,7 +424,7 @@ cint_copy(NODE *symbol, NODE *newsymb)
} else
newsymb->xarray = NULL;
- newsymb->nodes = new;
+ newsymb->nodes = newtab;
newsymb->table_size = symbol->table_size;
newsymb->array_capacity = symbol->array_capacity;
newsymb->flags = symbol->flags;
@@ -443,7 +443,7 @@ cint_list(NODE *symbol, NODE *t)
unsigned long k = 0, num_elems, list_size;
size_t j, ja, jd;
int elem_size = 1;
- assoc_kind_t assoc_kind;
+ int assoc_kind;
num_elems = symbol->table_size;
if (num_elems == 0)
@@ -482,7 +482,7 @@ cint_list(NODE *symbol, NODE *t)
tn = symbol->nodes[j];
if (tn == NULL)
continue;
- k += tree_list(tn, list + k, assoc_kind);
+ k += tree_list(tn, list + k, (assoc_kind_t) assoc_kind);
if (k >= list_size)
return list;
}
@@ -936,15 +936,15 @@ tree_list(NODE *tree, NODE **list, assoc_kind_t
assoc_kind)
static void
tree_copy(NODE *newsymb, NODE *tree, NODE *newtree)
{
- NODE **old, **new;
+ NODE **old, **newtab;
size_t j, hsize;
hsize = tree->array_size;
if ((tree->flags & HALFHAT) != 0)
hsize /= 2;
- ezalloc(new, NODE **, hsize * sizeof(NODE *), "tree_copy");
- newtree->nodes = new;
+ ezalloc(newtab, NODE **, hsize * sizeof(NODE *), "tree_copy");
+ newtree->nodes = newtab;
newtree->array_base = tree->array_base;
newtree->array_size = tree->array_size;
newtree->table_size = tree->table_size;
@@ -955,11 +955,11 @@ tree_copy(NODE *newsymb, NODE *tree, NODE *newtree)
if (old[j] == NULL)
continue;
if (old[j]->type == Node_array_tree) {
- new[j] = make_node(Node_array_tree);
- tree_copy(newsymb, old[j], new[j]);
+ newtab[j] = make_node(Node_array_tree);
+ tree_copy(newsymb, old[j], newtab[j]);
} else {
- new[j] = make_node(Node_array_leaf);
- leaf_copy(newsymb, old[j], new[j]);
+ newtab[j] = make_node(Node_array_leaf);
+ leaf_copy(newsymb, old[j], newtab[j]);
}
}
}
@@ -1136,12 +1136,12 @@ leaf_remove(NODE *symbol, NODE *array, long k)
static void
leaf_copy(NODE *newsymb, NODE *array, NODE *newarray)
{
- NODE **old, **new;
+ NODE **old, **newtab;
long size, i;
size = array->array_size;
- ezalloc(new, NODE **, size * sizeof(NODE *), "leaf_copy");
- newarray->nodes = new;
+ ezalloc(newtab, NODE **, size * sizeof(NODE *), "leaf_copy");
+ newarray->nodes = newtab;
newarray->array_size = size;
newarray->array_base = array->array_base;
newarray->flags = array->flags;
@@ -1152,13 +1152,13 @@ leaf_copy(NODE *newsymb, NODE *array, NODE *newarray)
if (old[i] == NULL)
continue;
if (old[i]->type == Node_val)
- new[i] = dupnode(old[i]);
+ newtab[i] = dupnode(old[i]);
else {
NODE *r;
r = make_array();
r->vname = estrdup(old[i]->vname,
strlen(old[i]->vname));
r->parent_array = newsymb;
- new[i] = assoc_copy(old[i], r);
+ newtab[i] = assoc_copy(old[i], r);
}
}
}
diff --git a/cmd.h b/cmd.h
index 375ea08..df6035f 100644
--- a/cmd.h
+++ b/cmd.h
@@ -43,10 +43,10 @@ extern bool output_is_tty;
extern int input_fd;
extern bool input_from_tty;
extern FILE *out_fp;
-extern char *dbg_prompt;
-extern char *commands_prompt;
-extern char *eval_prompt;
-extern char *dgawk_prompt;
+extern const char *dbg_prompt;
+extern const char *commands_prompt;
+extern const char *eval_prompt;
+extern const char *dgawk_prompt;
enum argtype {
D_illegal,
@@ -148,9 +148,9 @@ typedef int (*Func_cmd)(CMDARG *, int);
struct cmdtoken {
const char *name;
- char *abbrvn; /* abbreviation */
+ const char *abbrvn; /* abbreviation */
enum argtype type;
- int class;
+ int lex_class;
Func_cmd cf_ptr;
const char *help_txt;
};
diff --git a/command.c b/command.c
index ba5a0e5..d5bcd2a 100644
--- a/command.c
+++ b/command.c
@@ -1703,7 +1703,7 @@ yyreduce:
case 34: /* command: frame_cmd opt_integer */
#line 288 "command.y"
{
- if (cmdtab[cmd_idx].class == D_FRAME
+ if (cmdtab[cmd_idx].lex_class == D_FRAME
&& yyvsp[0] != NULL && yyvsp[0]->a_int < 0)
yyerror(_("invalid frame number: %d"), yyvsp[0]->a_int);
}
@@ -2817,7 +2817,7 @@ again:
add_history(h->line);
#endif
cmd_idx = repeat_idx;
- return cmdtab[cmd_idx].class; /* repeat last command
*/
+ return cmdtab[cmd_idx].lex_class; /* repeat last
command */
}
repeat_idx = -1;
}
@@ -2877,7 +2877,7 @@ again:
arg->a_string = estrdup(lexptr_begin, lexend -
lexptr_begin);
append_cmdarg(arg);
}
- return cmdtab[cmd_idx].class;
+ return cmdtab[cmd_idx].lex_class;
} else {
yyerror(_("unknown command - `%.*s', try help"),
toklen, tokstart);
return '\n';
@@ -3138,7 +3138,7 @@ concat_args(CMDARG *arg, int count)
static int
find_command(const char *token, size_t toklen)
{
- char *name, *abrv;
+ const char *name, *abrv;
int i, k;
bool try_exact = true;
int abrv_match = -1;
diff --git a/command.y b/command.y
index 3936207..8282cf6 100644
--- a/command.y
+++ b/command.y
@@ -286,7 +286,7 @@ command
| control_cmd opt_plus_integer
| frame_cmd opt_integer
{
- if (cmdtab[cmd_idx].class == D_FRAME
+ if (cmdtab[cmd_idx].lex_class == D_FRAME
&& $2 != NULL && $2->a_int < 0)
yyerror(_("invalid frame number: %d"), $2->a_int);
}
@@ -1096,7 +1096,7 @@ again:
add_history(h->line);
#endif
cmd_idx = repeat_idx;
- return cmdtab[cmd_idx].class; /* repeat last command
*/
+ return cmdtab[cmd_idx].lex_class; /* repeat last
command */
}
repeat_idx = -1;
}
@@ -1156,7 +1156,7 @@ again:
arg->a_string = estrdup(lexptr_begin, lexend -
lexptr_begin);
append_cmdarg(arg);
}
- return cmdtab[cmd_idx].class;
+ return cmdtab[cmd_idx].lex_class;
} else {
yyerror(_("unknown command - `%.*s', try help"),
toklen, tokstart);
return '\n';
@@ -1417,7 +1417,7 @@ concat_args(CMDARG *arg, int count)
static int
find_command(const char *token, size_t toklen)
{
- char *name, *abrv;
+ const char *name, *abrv;
int i, k;
bool try_exact = true;
int abrv_match = -1;
diff --git a/debug.c b/debug.c
index 3dd53e1..67df3d7 100644
--- a/debug.c
+++ b/debug.c
@@ -54,9 +54,9 @@ static char *linebuf = NULL; /* used to print a single line
of source */
static size_t linebuf_len;
FILE *out_fp;
-char *dbg_prompt;
-char *commands_prompt = "> "; /* breakpoint or watchpoint commands list */
-char *eval_prompt = "@> "; /* awk statement(s) */
+const char *dbg_prompt;
+const char *commands_prompt = "> "; /* breakpoint or watchpoint commands
list */
+const char *eval_prompt = "@> "; /* awk statement(s) */
bool input_from_tty = false;
int input_fd;
@@ -219,7 +219,7 @@ static char line_sep;
struct dbg_option {
const char *name;
int *num_val;
- char **str_val;
+ const char **str_val;
void (*assign)(const char *);
const char *help_txt;
};
@@ -244,8 +244,8 @@ static const char *history_file = DEFAULT_HISTFILE;
/* debugger option related variables */
-static char *output_file = "/dev/stdout"; /* gawk output redirection */
-char *dgawk_prompt = NULL; /* initialized in interpret */
+static const char *output_file = "/dev/stdout"; /* gawk output redirection */
+const char *dgawk_prompt = NULL; /* initialized in interpret */
static int list_size = DEFAULT_LISTSIZE; /* # of lines that 'list' prints */
static int do_trace = false;
static int do_save_history = true;
@@ -766,7 +766,7 @@ do_info(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
gprintf(out_fp, _("Number Disp Enabled
Location\n\n"));
for (b = breakpoints.prev; b != &breakpoints; b =
b->prev) {
- char *disp = "keep";
+ const char *disp = "keep";
if ((b->flags & BP_ENABLE_ONCE) != 0)
disp = "dis";
else if ((b->flags & BP_TEMP) != 0)
@@ -1648,7 +1648,7 @@ find_subscript(struct list_item *item, NODE **ptr)
/* cmp_val --- compare values of watched item, returns true if different; */
static int
-cmp_val(struct list_item *w, NODE *old, NODE *new)
+cmp_val(struct list_item *w, NODE *old, NODE *new_val)
{
/*
* case old new result
@@ -1666,26 +1666,26 @@ cmp_val(struct list_item *w, NODE *old, NODE *new)
if (WATCHING_ARRAY(w)) {
long size = 0;
- if (! new) /* 9 */
+ if (! new_val) /* 9 */
return true;
- if (new->type == Node_val) /* 7 */
+ if (new_val->type == Node_val) /* 7 */
return true;
- /* new->type == Node_var_array */ /* 8 */
- size = assoc_length(new);
+ /* new_val->type == Node_var_array */ /* 8 */
+ size = assoc_length(new_val);
if (w->cur_size == size)
return false;
return true;
}
- if (! old && ! new) /* 3 */
+ if (! old && ! new_val) /* 3 */
return false;
- if ((! old && new) /* 1, 2 */
- || (old && ! new)) /* 6 */
+ if ((! old && new_val) /* 1, 2 */
+ || (old && ! new_val)) /* 6 */
return true;
- if (new->type == Node_var_array) /* 5 */
+ if (new_val->type == Node_var_array) /* 5 */
return true;
- return cmp_nodes(old, new, true); /* 4 */
+ return cmp_nodes(old, new_val, true); /* 4 */
}
/* watchpoint_triggered --- check if we should stop at this watchpoint;
@@ -3051,7 +3051,7 @@ next_step(CMDARG *arg, int cmd)
stop.repeat_count = arg->a_int;
else
stop.repeat_count = 1;
- stop.command = cmd;
+ stop.command = (argtype) cmd;
return true;
}
@@ -3231,7 +3231,7 @@ do_finish(CMDARG *arg ATTRIBUTE_UNUSED, int cmd)
fprintf(out_fp, _("Run until return from "));
print_numbered_frame(cur_frame);
stop.check_func = check_finish;
- stop.command = cmd;
+ stop.command = (argtype) cmd;
stop.print_ret = true;
return true;
}
@@ -3279,7 +3279,7 @@ do_return(CMDARG *arg, int cmd)
assert(stop.fcall_count >= 0);
stop.pc = (func->code_ptr + 1)->lasti;
assert(stop.pc->opcode == Op_K_return);
- stop.command = cmd;
+ stop.command = (argtype) cmd;
stop.check_func = check_return;
@@ -3342,7 +3342,7 @@ do_until(CMDARG *arg, int cmd)
stop.sourceline = sourceline;
stop.fcall_count = fcall_count - cur_frame;
stop.check_func = check_until;
- stop.command = cmd;
+ stop.command = (argtype) cmd;
return true;
}
@@ -3381,7 +3381,7 @@ func:
stop.pc = ip;
stop.fcall_count = fcall_count - cur_frame;
stop.check_func = check_until;
- stop.command = cmd;
+ stop.command = (argtype) cmd;
return true;
}
}
@@ -3402,7 +3402,7 @@ func:
stop.pc = ip;
stop.fcall_count = fcall_count - cur_frame;
stop.check_func = check_until;
- stop.command = cmd;
+ stop.command = (argtype) cmd;
return true;
}
if (ip == (rp + 1)->lasti)
@@ -3873,7 +3873,7 @@ print_instruction(INSTRUCTION *pc, Func_print print_func,
FILE *fp, int in_dump)
case Op_var_assign:
print_func(fp, "[set_%s()]", get_spec_varname(pc->assign_var));
if (pc->assign_ctxt != 0)
- print_func(fp, " [assign_ctxt = %s]",
opcode2str(pc->assign_ctxt));
+ print_func(fp, " [assign_ctxt = %s]",
opcode2str((OPCODE) pc->assign_ctxt));
print_func(fp, "\n");
break;
@@ -5284,7 +5284,7 @@ set_gawk_output(const char *file)
if (output_fp != stdout) {
if (output_fp != stderr) {
fclose(output_fp);
- efree(output_file);
+ efree((void*) output_file);
}
output_fp = stdout;
output_is_tty = os_isatty(fileno(stdout));
@@ -5355,7 +5355,7 @@ set_gawk_output(const char *file)
static void
set_prompt(const char *value)
{
- efree(dgawk_prompt);
+ efree((void *) dgawk_prompt);
dgawk_prompt = estrdup(value, strlen(value));
dbg_prompt = dgawk_prompt;
}
diff --git a/eval.c b/eval.c
index 9b3342c..c052b2c 100644
--- a/eval.c
+++ b/eval.c
@@ -261,8 +261,8 @@ static const char *const nodetypes[] = {
*/
static struct optypetab {
- char *desc;
- char *operator;
+ const char *desc;
+ const char *oper;
} optypes[] = {
{ "Op_illegal", NULL },
{ "Op_times", " * " },
@@ -420,8 +420,8 @@ const char *
op2str(OPCODE op)
{
if (op >= Op_illegal && op < Op_final) {
- if (optypes[(int) op].operator != NULL)
- return optypes[(int) op].operator;
+ if (optypes[(int) op].oper != NULL)
+ return optypes[(int) op].oper;
else
fatal(_("opcode %s not an operator or keyword"),
optypes[(int) op].desc);
@@ -1009,7 +1009,7 @@ set_TEXTDOMAIN()
void
update_ERRNO_int(int errcode)
{
- char *cp;
+ const char *cp;
update_PROCINFO_num("errno", errcode);
if (errcode) {
diff --git a/gawkapi.c b/gawkapi.c
index c85427b..c7d833d 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -71,7 +71,7 @@ api_get_argument(awk_ext_id_t id, size_t count,
/* if type is undefined */
if (arg->type == Node_var_new) {
if (wanted == AWK_UNDEFINED)
- return true;
+ return awk_true;
else if (wanted == AWK_ARRAY) {
goto array;
} else {
@@ -82,7 +82,7 @@ api_get_argument(awk_ext_id_t id, size_t count,
/* at this point, we have real type */
if (arg->type == Node_var_array || arg->type == Node_array_ref) {
if (wanted != AWK_ARRAY && wanted != AWK_UNDEFINED)
- return false;
+ return awk_false;
goto array;
} else
goto scalar;
@@ -148,6 +148,7 @@ awk_value_to_node(const awk_value_t *retval)
{
NODE *ext_ret_val = NULL;
NODE *v;
+ int tval = 0;
if (retval == NULL)
fatal(_("awk_value_to_node: received null retval"));
@@ -169,7 +170,7 @@ awk_value_to_node(const awk_value_t *retval)
if (! do_mpfr)
fatal(_("awk_value_to_node: not in MPFR mode"));
ext_ret_val = make_number_node(MPFN);
- int tval = mpfr_set(ext_ret_val->mpg_numbr, (mpfr_ptr)
retval->num_ptr, ROUND_MODE);
+ tval = mpfr_set(ext_ret_val->mpg_numbr, (mpfr_ptr)
retval->num_ptr, ROUND_MODE);
IEEE_FMT(ext_ret_val->mpg_numbr, tval);
#else
fatal(_("awk_value_to_node: MPFR not supported"));
@@ -1228,7 +1229,7 @@ api_release_flattened_array(awk_ext_id_t id,
awk_array_t a_cookie,
awk_flat_array_t *data)
{
- NODE *array = a_cookie;
+ NODE *array = (NODE *) a_cookie;
NODE **list;
size_t i, j, k;
@@ -1367,7 +1368,7 @@ api_get_file(awk_ext_id_t id, const char *name, size_t
namelen, const char *file
currule = save_rule;
source = save_source;
}
- *ibufp = &curfile->public;
+ *ibufp = &curfile->public_;
*obufp = NULL;
return awk_true;
@@ -1416,7 +1417,7 @@ api_get_file(awk_ext_id_t id, const char *name, size_t
namelen, const char *file
if ((f = redirect_string(name, namelen, 0, redirtype, &flag, fd,
false)) == NULL)
return awk_false;
- *ibufp = f->iop ? & f->iop->public : NULL;
+ *ibufp = f->iop ? & f->iop->public_ : NULL;
*obufp = f->output.fp ? & f->output : NULL;
return awk_true;
}
diff --git a/gawkapi.h b/gawkapi.h
index c0d9062..3a76141 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -126,14 +126,16 @@ typedef enum awk_bool {
* terms of bytes. The fields[0].skip value indicates how many bytes (or
* characters) to skip before $1, and fields[0].len is the length of $1, etc.
*/
+struct awk_field_info {
+ size_t skip; /* amount to skip before field starts */
+ size_t len; /* length of field */
+};
typedef struct {
awk_bool_t use_chars; /* false ==> use bytes */
size_t nf;
- struct awk_field_info {
- size_t skip; /* amount to skip before field starts */
- size_t len; /* length of field */
- } fields[1]; /* actual dimension should be nf */
+ /* actual dimension should be nf */
+ struct awk_field_info fields[1];
} awk_fieldwidth_info_t;
/*
@@ -190,7 +192,7 @@ typedef struct awk_input {
* No argument prototype on read_func to allow for older systems
* whose headers are not up to date.
*/
- ssize_t (*read_func)();
+ ssize_t (*read_func)(int, void *, size_t);
/*
* The close_func is called to allow the parser to free private data.
@@ -401,14 +403,15 @@ typedef struct awk_value {
* one at a time, using the separate API for that purpose.
*/
+enum awk_element_actions {
+ AWK_ELEMENT_DEFAULT = 0, /* set by gawk */
+ AWK_ELEMENT_DELETE = 1 /* set by extension if
+ should be deleted */
+};
typedef struct awk_element {
/* convenience linked list pointer, not used by gawk */
struct awk_element *next;
- enum {
- AWK_ELEMENT_DEFAULT = 0, /* set by gawk */
- AWK_ELEMENT_DELETE = 1 /* set by extension if
- should be deleted */
- } flags;
+ enum awk_element_actions flags;
awk_value_t index;
awk_value_t value;
} awk_element_t;
diff --git a/int_array.c b/int_array.c
index 382aa79..26d63bf 100644
--- a/int_array.c
+++ b/int_array.c
@@ -447,7 +447,7 @@ removed:
static NODE **
int_copy(NODE *symbol, NODE *newsymb)
{
- BUCKET **old, **new, **pnew;
+ BUCKET **old, **newtab, **pnew;
BUCKET *chain, *newchain;
int j;
unsigned long i, cursize;
@@ -458,12 +458,12 @@ int_copy(NODE *symbol, NODE *newsymb)
cursize = symbol->array_size;
/* allocate new table */
- ezalloc(new, BUCKET **, cursize * sizeof(BUCKET *), "int_copy");
+ ezalloc(newtab, BUCKET **, cursize * sizeof(BUCKET *), "int_copy");
old = symbol->buckets;
for (i = 0; i < cursize; i++) {
- for (chain = old[i], pnew = & new[i]; chain != NULL;
+ for (chain = old[i], pnew = & newtab[i]; chain != NULL;
chain = chain->ainext
) {
getbucket(newchain);
@@ -507,7 +507,7 @@ int_copy(NODE *symbol, NODE *newsymb)
newsymb->xarray = NULL;
newsymb->table_size = symbol->table_size;
- newsymb->buckets = new;
+ newsymb->buckets = newtab;
newsymb->array_size = cursize;
newsymb->flags = symbol->flags;
@@ -803,7 +803,7 @@ int_insert(NODE *symbol, long k, uint32_t hash1)
static void
grow_int_table(NODE *symbol)
{
- BUCKET **old, **new;
+ BUCKET **old, **newtab;
BUCKET *chain, *next;
int i, j;
unsigned long oldsize, newsize, k;
@@ -841,10 +841,10 @@ grow_int_table(NODE *symbol)
}
/* allocate new table */
- ezalloc(new, BUCKET **, newsize * sizeof(BUCKET *), "grow_int_table");
+ ezalloc(newtab, BUCKET **, newsize * sizeof(BUCKET *),
"grow_int_table");
old = symbol->buckets;
- symbol->buckets = new;
+ symbol->buckets = newtab;
symbol->array_size = newsize;
/* brand new hash table */
diff --git a/interpret.h b/interpret.h
index fedf525..63cbc09 100644
--- a/interpret.h
+++ b/interpret.h
@@ -1250,7 +1250,7 @@ match_re:
JUMPTO(ni);
case Op_K_getline_redir:
- r = do_getline_redir(pc->into_var, pc->redir_type);
+ r = do_getline_redir(pc->into_var, (enum redirval)
pc->redir_type);
PUSH(r);
break;
@@ -1348,7 +1348,7 @@ match_re:
update_ERRNO_int(errcode);
if (do_traditional || ! pc->has_endfile)
fatal(_("error reading input
file `%s': %s"),
- curfile->public.name,
strerror(errcode));
+ curfile->public_.name,
strerror(errcode));
}
JUMPTO(ni);
diff --git a/io.c b/io.c
index 2714398..0fa5314 100644
--- a/io.c
+++ b/io.c
@@ -217,7 +217,7 @@
#define at_eof(iop) (((iop)->flag & IOP_AT_EOF) != 0)
#define has_no_data(iop) ((iop)->dataend == NULL)
#define no_data_left(iop) ((iop)->off >= (iop)->dataend)
-#define buffer_has_all_data(iop) ((iop)->dataend - (iop)->off ==
(iop)->public.sbuf.st_size)
+#define buffer_has_all_data(iop) ((iop)->dataend - (iop)->off ==
(iop)->public_.sbuf.st_size)
/*
* The key point to the design is to split out the code that searches through
@@ -310,7 +310,7 @@ static bool inetfile(const char *str, size_t len, struct
inet_socket_info *isn);
static NODE *in_PROCINFO(const char *pidx1, const char *pidx2, NODE
**full_idx);
static long get_read_timeout(IOBUF *iop);
-static ssize_t read_with_timeout(int fd, char *buf, size_t size);
+static ssize_t read_with_timeout(int fd, void *buf, size_t size);
static bool read_can_timeout = false;
static long read_timeout;
@@ -415,7 +415,7 @@ after_beginfile(IOBUF **curfile)
int errcode;
bool valid;
- fname = iop->public.name;
+ fname = iop->public_.name;
errcode = iop->errcode;
valid = iop->valid;
errno = 0;
@@ -461,7 +461,7 @@ nextfile(IOBUF **curfile, bool skipping)
if (iop != NULL) {
if (at_eof(iop)) {
- assert(iop->public.fd != INVALID_HANDLE);
+ assert(iop->public_.fd != INVALID_HANDLE);
(void) iop_close(iop);
*curfile = NULL;
return 1; /* run endfile block */
@@ -510,7 +510,7 @@ nextfile(IOBUF **curfile, bool skipping)
update_ERRNO_int(errno);
iop = iop_alloc(fd, fname, errcode);
*curfile = iop_finish(iop);
- if (iop->public.fd == INVALID_HANDLE)
+ if (iop->public_.fd == INVALID_HANDLE)
iop->errcode = errcode;
else if (iop->valid)
iop->errcode = 0;
@@ -537,7 +537,7 @@ nextfile(IOBUF **curfile, bool skipping)
iop = iop_alloc(fileno(stdin), fname, 0);
*curfile = iop_finish(iop);
- if (iop->public.fd == INVALID_HANDLE) {
+ if (iop->public_.fd == INVALID_HANDLE) {
errcode = errno;
errno = 0;
update_ERRNO_int(errno);
@@ -659,21 +659,21 @@ iop_close(IOBUF *iop)
* So we remap the standard file to /dev/null.
* Thanks to Jim Meyering for the suggestion.
*/
- if (iop->public.close_func != NULL)
- iop->public.close_func(&iop->public);
-
- if (iop->public.fd != INVALID_HANDLE) {
- if (iop->public.fd == fileno(stdin)
- || iop->public.fd == fileno(stdout)
- || iop->public.fd == fileno(stderr))
- ret = remap_std_file(iop->public.fd);
+ if (iop->public_.close_func != NULL)
+ iop->public_.close_func(&iop->public_);
+
+ if (iop->public_.fd != INVALID_HANDLE) {
+ if (iop->public_.fd == fileno(stdin)
+ || iop->public_.fd == fileno(stdout)
+ || iop->public_.fd == fileno(stderr))
+ ret = remap_std_file(iop->public_.fd);
else
- ret = closemaybesocket(iop->public.fd);
+ ret = closemaybesocket(iop->public_.fd);
}
if (ret == -1)
- warning(_("close of fd %d (`%s') failed: %s"), iop->public.fd,
- iop->public.name, strerror(errno));
+ warning(_("close of fd %d (`%s') failed: %s"), iop->public_.fd,
+ iop->public_.name, strerror(errno));
/*
* Be careful -- $0 may still reference the buffer even though
* an explicit close is being done; in the future, maybe we
@@ -735,12 +735,12 @@ redflags2str(int flags)
static void
check_duplicated_redirections(const char *name, size_t len,
- redirect_flags_t oldflags, redirect_flags_t newflags)
+ redirect_flags_t oflags, redirect_flags_t nflags)
{
static struct mixture {
- redirect_flags_t common;
- redirect_flags_t mode;
- redirect_flags_t other_mode;
+ int common;
+ int mode;
+ int other_mode;
const char *message;
} mixtures[] = {
{ RED_FILE, RED_READ, RED_WRITE,
@@ -768,6 +768,9 @@ check_duplicated_redirections(const char *name, size_t len,
};
int i = 0, j = sizeof(mixtures) / sizeof(mixtures[0]);
+ int oldflags = oflags;
+ int newflags = nflags;
+
oldflags &= ~(RED_NOBUF|RED_EOF|RED_PTY);
newflags &= ~(RED_NOBUF|RED_EOF|RED_PTY);
@@ -798,8 +801,8 @@ redirect_string(const char *str, size_t explen, bool
not_string,
int redirtype, int *errflg, int extfd, bool failure_fatal)
{
struct redirect *rp;
- redirect_flags_t tflag = RED_NONE;
- redirect_flags_t outflag = RED_NONE;
+ int tflag = RED_NONE;
+ int outflag = RED_NONE;
const char *direction = "to";
const char *mode;
int fd;
@@ -896,7 +899,8 @@ redirect_string(const char *str, size_t explen, bool
not_string,
if (strlen(rp->value) == explen
&& memcmp(rp->value, str, explen) == 0) {
if (do_lint) {
- check_duplicated_redirections(rp->value,
explen, rp->flag, tflag);
+ check_duplicated_redirections(rp->value, explen,
+ (redirect_flags_t) rp->flag,
(redirect_flags_t) tflag);
}
if (((rp->flag & ~(RED_NOBUF|RED_EOF|RED_PTY)) == tflag
@@ -920,7 +924,7 @@ redirect_string(const char *str, size_t explen, bool
not_string,
newstr[explen] = '\0';
str = newstr;
rp->value = newstr;
- rp->flag = tflag;
+ rp->flag = (redirect_flags_t) tflag;
init_output_wrapper(& rp->output);
rp->output.name = str;
rp->iop = NULL;
@@ -1336,7 +1340,7 @@ close_rp(struct redirect *rp, two_way_close_type how)
if ((rp->flag & RED_SOCKET) != 0 && rp->iop != NULL) {
#ifdef HAVE_SOCKETS
if ((rp->flag & RED_TCP) != 0)
- (void) shutdown(rp->iop->public.fd,
SHUT_RD);
+ (void) shutdown(rp->iop->public_.fd,
SHUT_RD);
#endif /* HAVE_SOCKETS */
(void) iop_close(rp->iop);
} else
@@ -2810,7 +2814,7 @@ gawk_popen(const char *cmd, struct redirect *rp)
if (! do_traditional && rp->iop->errcode != 0)
update_ERRNO_int(rp->iop->errcode);
(void) pclose(current);
- rp->iop->public.fd = INVALID_HANDLE;
+ rp->iop->public_.fd = INVALID_HANDLE;
iop_close(rp->iop);
rp->iop = NULL;
current = NULL;
@@ -2824,10 +2828,10 @@ gawk_popen(const char *cmd, struct redirect *rp)
static int
gawk_pclose(struct redirect *rp)
{
- int rval, aval, fd = rp->iop->public.fd;
+ int rval, aval, fd = rp->iop->public_.fd;
if (rp->iop != NULL) {
- rp->iop->public.fd = dup(fd); /* kludge to allow close() +
pclose() */
+ rp->iop->public_.fd = dup(fd); /* kludge to allow close() +
pclose() */
rval = iop_close(rp->iop);
}
rp->iop = NULL;
@@ -3216,12 +3220,12 @@ find_input_parser(IOBUF *iop)
awk_input_parser_t *ip, *ip2;
/* if already associated with an input parser, bail out early */
- if (iop->public.get_record != NULL)
+ if (iop->public_.get_record != NULL)
return;
ip = ip2 = NULL;
for (ip2 = ip_head; ip2 != NULL; ip2 = ip2->next) {
- if (ip2->can_take_file(& iop->public)) {
+ if (ip2->can_take_file(& iop->public_)) {
if (ip == NULL)
ip = ip2; /* found first one */
else
@@ -3231,9 +3235,9 @@ find_input_parser(IOBUF *iop)
}
if (ip != NULL) {
- if (! ip->take_control_of(& iop->public))
+ if (! ip->take_control_of(& iop->public_))
warning(_("input parser `%s' failed to open `%s'"),
- ip->name, iop->public.name);
+ ip->name, iop->public_.name);
else
iop->valid = true;
}
@@ -3327,7 +3331,7 @@ find_two_way_processor(const char *name, struct redirect
*rp)
awk_two_way_processor_t *tw, *tw2;
/* if already associated with i/o, bail out early */
- if ( (rp->iop != NULL && rp->iop->public.fd != INVALID_HANDLE)
+ if ( (rp->iop != NULL && rp->iop->public_.fd != INVALID_HANDLE)
|| rp->output.fp != NULL)
return false;
@@ -3345,7 +3349,7 @@ find_two_way_processor(const char *name, struct redirect
*rp)
if (tw != NULL) {
if (rp->iop == NULL)
rp->iop = iop_alloc(INVALID_HANDLE, name, 0);
- if (! tw->take_control_of(name, & rp->iop->public, &
rp->output)) {
+ if (! tw->take_control_of(name, & rp->iop->public_, &
rp->output)) {
warning(_("two way processor `%s' failed to open `%s'"),
tw->name, name);
return false;
@@ -3384,12 +3388,12 @@ find_two_way_processor(const char *name, struct
redirect *rp)
* iop->valid should be set to false in this case.
*
* Otherwise, after the second stage, iop->errcode should be
- * zero, iop->valid should be true, and iop->public.fd should
+ * zero, iop->valid should be true, and iop->public_.fd should
* not be INVALID_HANDLE.
*
* The third stage is to set up the rest of the IOBUF for
* use by get_a_record(). In this case, iop->valid must
- * be true already, and iop->public.fd cannot be INVALID_HANDLE.
+ * be true already, and iop->public_.fd cannot be INVALID_HANDLE.
*
* Checking for input parsers for command line files is delayed
* to after_beginfile() so that the BEGINFILE rule has an
@@ -3407,18 +3411,18 @@ iop_alloc(int fd, const char *name, int errno_val)
ezalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
- iop->public.fd = fd;
- iop->public.name = name;
- iop->public.read_func = ( ssize_t(*)() ) read;
+ iop->public_.fd = fd;
+ iop->public_.name = name;
+ iop->public_.read_func = ( ssize_t(*)(int, void *, size_t) ) read;
iop->valid = false;
iop->errcode = errno_val;
if (fd != INVALID_HANDLE)
- fstat(fd, & iop->public.sbuf);
+ fstat(fd, & iop->public_.sbuf);
#if defined(__EMX__) || defined(__MINGW32__)
else if (errno_val == EISDIR) {
- iop->public.sbuf.st_mode = (_S_IFDIR | _S_IRWXU);
- iop->public.fd = FAKE_FD_VALUE;
+ iop->public_.sbuf.st_mode = (_S_IFDIR | _S_IRWXU);
+ iop->public_.fd = FAKE_FD_VALUE;
}
#endif
@@ -3432,8 +3436,8 @@ iop_finish(IOBUF *iop)
{
bool isdir = false;
- if (iop->public.fd != INVALID_HANDLE) {
- if (os_isreadable(& iop->public, & isdir))
+ if (iop->public_.fd != INVALID_HANDLE) {
+ if (os_isreadable(& iop->public_, & isdir))
iop->valid = true;
else {
if (isdir)
@@ -3450,10 +3454,10 @@ iop_finish(IOBUF *iop)
* The fcntl call works for Windows, too.
*/
#if defined(F_GETFL)
- if (fcntl(iop->public.fd, F_GETFL) >= 0)
+ if (fcntl(iop->public_.fd, F_GETFL) >= 0)
#endif
- (void) close(iop->public.fd);
- iop->public.fd = INVALID_HANDLE;
+ (void) close(iop->public_.fd);
+ iop->public_.fd = INVALID_HANDLE;
}
/*
* Don't close directories: after_beginfile(),
@@ -3462,15 +3466,15 @@ iop_finish(IOBUF *iop)
}
}
- if (! iop->valid || iop->public.fd == INVALID_HANDLE)
+ if (! iop->valid || iop->public_.fd == INVALID_HANDLE)
return iop;
- if (os_isatty(iop->public.fd))
+ if (os_isatty(iop->public_.fd))
iop->flag |= IOP_IS_TTY;
- iop->readsize = iop->size = optimal_bufsize(iop->public.fd, &
iop->public.sbuf);
- if (do_lint && S_ISREG(iop->public.sbuf.st_mode) &&
iop->public.sbuf.st_size == 0)
- lintwarn(_("data file `%s' is empty"), iop->public.name);
+ iop->readsize = iop->size = optimal_bufsize(iop->public_.fd, &
iop->public_.sbuf);
+ if (do_lint && S_ISREG(iop->public_.sbuf.st_mode) &&
iop->public_.sbuf.st_size == 0)
+ lintwarn(_("data file `%s' is empty"), iop->public_.name);
iop->errcode = errno = 0;
iop->count = iop->scanoff = 0;
emalloc(iop->buf, char *, iop->size += 1, "iop_finish");
@@ -3851,7 +3855,7 @@ find_longest_terminator:
static inline int
retryable(IOBUF *iop)
{
- return PROCINFO_node && in_PROCINFO(iop->public.name, "RETRY", NULL);
+ return PROCINFO_node && in_PROCINFO(iop->public_.name, "RETRY", NULL);
}
/* errno_io_retry --- Does the I/O error indicate that the operation should be
retried later? */
@@ -3907,10 +3911,10 @@ get_a_record(char **out, /* pointer to pointer
to data */
if (read_can_timeout)
read_timeout = get_read_timeout(iop);
- if (iop->public.get_record != NULL) {
+ if (iop->public_.get_record != NULL) {
char *rt_start;
size_t rt_len;
- int rc = iop->public.get_record(out, &iop->public, errcode,
+ int rc = iop->public_.get_record(out, &iop->public_, errcode,
&rt_start, &rt_len,
field_width);
if (rc == EOF)
@@ -3926,7 +3930,7 @@ get_a_record(char **out, /* pointer to pointer to
data */
/* fill initial buffer */
if (has_no_data(iop) || no_data_left(iop)) {
- iop->count = iop->public.read_func(iop->public.fd, iop->buf,
iop->readsize);
+ iop->count = iop->public_.read_func(iop->public_.fd, iop->buf,
iop->readsize);
if (iop->count == 0) {
iop->flag |= IOP_AT_EOF;
return EOF;
@@ -4005,7 +4009,7 @@ get_a_record(char **out, /* pointer to pointer to
data */
amt_to_read = MIN(amt_to_read, SSIZE_MAX);
#endif
- iop->count = iop->public.read_func(iop->public.fd,
iop->dataend, amt_to_read);
+ iop->count = iop->public_.read_func(iop->public_.fd,
iop->dataend, amt_to_read);
if (iop->count == -1) {
*errcode = errno;
if (errno_io_retry() && retryable(iop))
@@ -4362,7 +4366,7 @@ get_read_timeout(IOBUF *iop)
long tmout = 0;
if (PROCINFO_node != NULL) {
- const char *name = iop->public.name;
+ const char *name = iop->public_.name;
NODE *val = NULL;
static NODE *full_idx = NULL;
static const char *last_name = NULL;
@@ -4387,8 +4391,8 @@ get_read_timeout(IOBUF *iop)
tmout = read_default_timeout; /* initialized from env.
variable in init_io() */
/* overwrite read routine only if an extension has not done so */
- if ((iop->public.read_func == ( ssize_t(*)() ) read) && tmout > 0)
- iop->public.read_func = read_with_timeout;
+ if ((iop->public_.read_func == ( ssize_t(*)(int, void *, size_t) )
read) && tmout > 0)
+ iop->public_.read_func = read_with_timeout;
return tmout;
}
@@ -4399,7 +4403,7 @@ get_read_timeout(IOBUF *iop)
*/
static ssize_t
-read_with_timeout(int fd, char *buf, size_t size)
+read_with_timeout(int fd, void *buf, size_t size)
{
#if ! defined(VMS)
fd_set readfds;
diff --git a/main.c b/main.c
index 7c35139..d0de9b9 100644
--- a/main.c
+++ b/main.c
@@ -96,7 +96,7 @@ char *TEXTDOMAIN;
* set_CONVFMT -> fmt_index -> force_string: gets NULL CONVFMT
* Fun, fun, fun, fun.
*/
-char *CONVFMT = "%.6g";
+const char *CONVFMT = "%.6g";
NODE *Nnull_string; /* The global null string */
@@ -129,8 +129,9 @@ SRCFILE *srcfiles; /* source files */
/*
* structure to remember variable pre-assignments
*/
+enum assign_type { PRE_ASSIGN = 1, PRE_ASSIGN_FS } type;
struct pre_assign {
- enum assign_type { PRE_ASSIGN = 1, PRE_ASSIGN_FS } type;
+ enum assign_type type;
char *val;
};
@@ -145,14 +146,14 @@ static void parse_args(int argc, char **argv);
static void set_locale_stuff(void);
static bool stopped_early = false;
-enum do_flag_values do_flags = 0;
+int do_flags = 0;
bool do_itrace = false; /* provide simple instruction
trace */
bool do_optimize = true; /* apply default optimizations */
static int do_nostalgia = false; /* provide a blast from the past */
static int do_binary = false; /* hands off my data! */
static int do_version = false; /* print version info */
static const char *locale = ""; /* default value to setlocale */
-static char *locale_dir = LOCALEDIR; /* default locale dir */
+static const char *locale_dir = LOCALEDIR; /* default locale dir */
int use_lc_numeric = false; /* obey locale for decimal point */
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 5f44280..b366303 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -61,7 +61,7 @@ static const char* _os2_unixroot_path(const char *path);
/* gawk_name --- pull out the "gawk" part from how the OS called us */
-char *
+const char *
gawk_name(filespec)
const char *filespec;
{
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index 16cfeb0..378c263 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -36,10 +36,10 @@ char envsep = ':';
/* gawk_name --- pull out the "gawk" part from how the OS called us */
-char *
+const char *
gawk_name(const char *filespec)
{
- char *p;
+ const char *p;
/* "path/name" -> "name" */
p = strrchr(filespec, '/');
diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms
index 725cf66..edee431 100644
--- a/vms/gawkmisc.vms
+++ b/vms/gawkmisc.vms
@@ -132,7 +132,7 @@ static int sys_trnlnm
* passed exec() argv[0] and handle both cases.
*/
-char *
+const char *
gawk_name(filespec)
const char *filespec;
{
-----------------------------------------------------------------------
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, feature/cpp-compile, created. gawk-4.1.0-4155-gf1224c7,
Arnold Robbins <=