aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--awk.h11
-rw-r--r--main.c10
-rw-r--r--symbol.c12
4 files changed, 25 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 569fc039..32582ae1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-09-07 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h: Move libsigsegv stuff to ...
+ * main.c: here. Thanks to Yehezkel Bernat for motivating
+ the cleanup.
+ * symbol.c (make_symbol, install, install_symbol): Add const to
+ first parameter. Adjust decls and fix up uses.
+
2014-09-05 Arnold D. Robbins <arnold@skeeve.com>
Add builtin functions to FUNCTAB for consistency.
diff --git a/awk.h b/awk.h
index 4f39ffcf..cb737eb2 100644
--- a/awk.h
+++ b/awk.h
@@ -193,15 +193,6 @@ extern void *memset_ulong(void *dest, int val, unsigned long l);
#define memset memset_ulong
#endif
-#ifdef HAVE_LIBSIGSEGV
-#include <sigsegv.h>
-#else
-typedef void *stackoverflow_context_t;
-#define sigsegv_install_handler(catchsegv) signal(SIGSEGV, catchsig)
-/* define as 0 rather than empty so that (void) cast on it works */
-#define stackoverflow_install_handler(catchstackoverflow, extra_stack, STACK_SIZE) 0
-#endif
-
#if defined(__EMX__) || defined(__MINGW32__)
#include "nonposix.h"
#endif /* defined(__EMX__) || defined(__MINGW32__) */
@@ -1642,7 +1633,7 @@ extern void load_symbols();
extern void init_symbol_table();
extern NODE *symbol_table;
extern NODE *func_table;
-extern NODE *install_symbol(char *name, NODETYPE type);
+extern NODE *install_symbol(const char *name, NODETYPE type);
extern NODE *remove_symbol(NODE *r);
extern void destroy_symbol(NODE *r);
extern void release_symbols(NODE *symlist, int keep_globals);
diff --git a/main.c b/main.c
index 129382c1..e46b0796 100644
--- a/main.c
+++ b/main.c
@@ -33,6 +33,16 @@
#include <mcheck.h>
#endif
+#ifdef HAVE_LIBSIGSEGV
+#include <sigsegv.h>
+#else
+typedef void *stackoverflow_context_t;
+/* the argument to this macro is purposely not used */
+#define sigsegv_install_handler(catchsegv) signal(SIGSEGV, catchsig)
+/* define as 0 rather than empty so that (void) cast on it works */
+#define stackoverflow_install_handler(catchstackoverflow, extra_stack, STACK_SIZE) 0
+#endif
+
#define DEFAULT_PROFILE "awkprof.out" /* where to put profile */
#define DEFAULT_VARFILE "awkvars.out" /* where to put vars */
#define DEFAULT_PREC 53
diff --git a/symbol.c b/symbol.c
index 5add8968..e89214c0 100644
--- a/symbol.c
+++ b/symbol.c
@@ -35,8 +35,8 @@ static int var_count; /* total number of global variables and functions */
static NODE *symbol_list;
static void (*install_func)(NODE *) = NULL;
-static NODE *make_symbol(char *name, NODETYPE type);
-static NODE *install(char *name, NODE *parm, NODETYPE type);
+static NODE *make_symbol(const char *name, NODETYPE type);
+static NODE *install(const char *name, NODE *parm, NODETYPE type);
static void free_bcpool(INSTRUCTION *pl);
static AWK_CONTEXT *curr_ctxt = NULL;
@@ -75,7 +75,7 @@ init_symbol_table()
*/
NODE *
-install_symbol(char *name, NODETYPE type)
+install_symbol(const char *name, NODETYPE type)
{
return install(name, NULL, type);
}
@@ -275,7 +275,7 @@ destroy_symbol(NODE *r)
/* make_symbol --- allocates a global symbol for the symbol table. */
static NODE *
-make_symbol(char *name, NODETYPE type)
+make_symbol(const char *name, NODETYPE type)
{
NODE *r;
@@ -285,7 +285,7 @@ make_symbol(char *name, NODETYPE type)
null_array(r);
else if (type == Node_var)
r->var_value = dupnode(Nnull_string);
- r->vname = name;
+ r->vname = (char *) name;
r->type = type;
return r;
@@ -294,7 +294,7 @@ make_symbol(char *name, NODETYPE type)
/* install --- install a global name or function parameter in the symbol table */
static NODE *
-install(char *name, NODE *parm, NODETYPE type)
+install(const char *name, NODE *parm, NODETYPE type)
{
NODE *r;
NODE **aptr;