diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-04-12 12:16:41 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-04-12 12:16:41 +0300 |
commit | 3006a420c22133e40e6a0aeaeb9bcd402b0754bd (patch) | |
tree | f9700b1703106dd56cb392da6380611c4917cf99 /awk.h | |
parent | 4b68f4ebe7381644e5652a88a5104a10f10f66a7 (diff) | |
parent | 8f83ab76a1d8861d9a992290f2691443d5169c89 (diff) | |
download | egawk-3006a420c22133e40e6a0aeaeb9bcd402b0754bd.tar.gz egawk-3006a420c22133e40e6a0aeaeb9bcd402b0754bd.tar.bz2 egawk-3006a420c22133e40e6a0aeaeb9bcd402b0754bd.zip |
Merge branch 'master' into feature/api-mpfr
Diffstat (limited to 'awk.h')
-rw-r--r-- | awk.h | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1697,7 +1697,7 @@ extern Regexp *re_update(NODE *t); extern void resyntax(int syntax); extern void resetup(void); extern int reisstring(const char *text, size_t len, Regexp *re, const char *buf); -extern int get_numbase(const char *str, bool use_locale); +extern int get_numbase(const char *str, size_t len, bool use_locale); extern bool using_utf8(void); /* symbol.c */ @@ -1977,6 +1977,8 @@ erealloc_real(void *ptr, size_t count, const char *where, const char *var, const return ret; } +/* make_number_node --- make node with the give flags */ + static inline NODE * make_number_node(unsigned int tp) { @@ -1992,6 +1994,22 @@ make_number_node(unsigned int tp) return r; } +/* + * str_terminate_f, str_terminate, str_restore: function and macros to + * reduce chances of typos when terminating and restoring strings. + * This also helps to enforce that the NODE must be in scope when we restore. + */ + +static inline void +str_terminate_f(NODE *n, char *savep) +{ + *savep = n->stptr[n->stlen]; + n->stptr[n->stlen] = '\0'; +} + +#define str_terminate(n, save) str_terminate_f((n), &save) +#define str_restore(n, save) (n)->stptr[(n)->stlen] = save + #ifdef SIGPIPE #define ignore_sigpipe() signal(SIGPIPE, SIG_IGN) #define set_sigpipe_to_default() signal(SIGPIPE, SIG_DFL) |