diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-11-23 19:57:09 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-11-23 19:57:09 +0200 |
commit | 0b07960513cbb8aa76b6f301b23cf73b5b2019c7 (patch) | |
tree | b6265a6641d4d203f6ed10cd0cd571aab8683811 /awk.h | |
parent | b15c7145da2b28bdb0f6521428d5f057a7dc8cfb (diff) | |
parent | 2513062a4c89b0b60c3717d506fce841d44d871e (diff) | |
download | egawk-0b07960513cbb8aa76b6f301b23cf73b5b2019c7.tar.gz egawk-0b07960513cbb8aa76b6f301b23cf73b5b2019c7.tar.bz2 egawk-0b07960513cbb8aa76b6f301b23cf73b5b2019c7.zip |
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'awk.h')
-rw-r--r-- | awk.h | 126 |
1 files changed, 63 insertions, 63 deletions
@@ -1246,74 +1246,12 @@ DEREF(NODE *r) #define cant_happen() r_fatal("internal error line %d, file: %s", \ __LINE__, __FILE__) -#define fatal set_loc(__FILE__, __LINE__), r_fatal - -static inline void * -emalloc_real(size_t count, const char *where, const char *var, const char *file, int line) -{ - void *ret; - - if (count == 0) - fatal("%s:%d: emalloc called with zero bytes", file, line); - - ret = (void *) malloc(count); - if (ret == NULL) - fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory (%s)"), - file, line, where, var, (long) count, strerror(errno)); - - return ret; -} - -static inline void * -erealloc_real(void *ptr, size_t count, const char *where, const char *var, const char *file, int line) -{ - void *ret; - - if (count == 0) - fatal("%s:%d: erealloc called with zero bytes", file, line); - - ret = (void *) realloc(ptr, count); - if (ret == NULL) - fatal(_("%s:%d:%s: %s: can't reallocate %ld bytes of memory (%s)"), - file, line, where, var, (long) count, strerror(errno)); - - return ret; -} - #define emalloc(var,ty,x,str) (void) (var = (ty) emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__)) #define erealloc(var,ty,x,str) (void) (var = (ty) erealloc_real((void *) var, (size_t)(x), str, #var, __FILE__, __LINE__)) #define efree(p) free(p) -static inline NODE * -force_string(NODE *s) -{ - if ((s->flags & STRCUR) != 0 - && (s->stfmt == -1 || s->stfmt == CONVFMTidx) - ) - return s; - return format_val(CONVFMT, CONVFMTidx, s); -} - -#ifdef GAWKDEBUG -#define unref r_unref -#define force_number str2number -#else /* not GAWKDEBUG */ - -static inline void -unref(NODE *r) -{ - if (r != NULL && --r->valref <= 0) - r_unref(r); -} - -static inline NODE * -force_number(NODE *n) -{ - return (n->flags & NUMCUR) ? n : str2number(n); -} - -#endif /* GAWKDEBUG */ +#define fatal set_loc(__FILE__, __LINE__), r_fatal extern jmp_buf fatal_tag; extern bool fatal_tag_valid; @@ -1804,3 +1742,65 @@ dupnode(NODE *n) return r_dupnode(n); } #endif + +static inline NODE * +force_string(NODE *s) +{ + if ((s->flags & STRCUR) != 0 + && (s->stfmt == -1 || s->stfmt == CONVFMTidx) + ) + return s; + return format_val(CONVFMT, CONVFMTidx, s); +} + +#ifdef GAWKDEBUG +#define unref r_unref +#define force_number str2number +#else /* not GAWKDEBUG */ + +static inline void +unref(NODE *r) +{ + if (r != NULL && --r->valref <= 0) + r_unref(r); +} + +static inline NODE * +force_number(NODE *n) +{ + return (n->flags & NUMCUR) ? n : str2number(n); +} + +#endif /* GAWKDEBUG */ + +static inline void * +emalloc_real(size_t count, const char *where, const char *var, const char *file, int line) +{ + void *ret; + + if (count == 0) + fatal("%s:%d: emalloc called with zero bytes", file, line); + + ret = (void *) malloc(count); + if (ret == NULL) + fatal(_("%s:%d:%s: %s: can't allocate %ld bytes of memory (%s)"), + file, line, where, var, (long) count, strerror(errno)); + + return ret; +} + +static inline void * +erealloc_real(void *ptr, size_t count, const char *where, const char *var, const char *file, int line) +{ + void *ret; + + if (count == 0) + fatal("%s:%d: erealloc called with zero bytes", file, line); + + ret = (void *) realloc(ptr, count); + if (ret == NULL) + fatal(_("%s:%d:%s: %s: can't reallocate %ld bytes of memory (%s)"), + file, line, where, var, (long) count, strerror(errno)); + + return ret; +} |