diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | awk.h | 126 | ||||
-rw-r--r-- | extension/ChangeLog | 5 | ||||
-rw-r--r-- | extension/inplace.c | 8 |
4 files changed, 79 insertions, 65 deletions
@@ -1,3 +1,8 @@ +2014-11-23 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h: Move all inline functions to the bottom of the file. + Keeps modern GCC happier. + 2014-11-22 Arnold D. Robbins <arnold@skeeve.com> * awk.h (emalloc, realloc): Redefine in terms of ... @@ -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; +} diff --git a/extension/ChangeLog b/extension/ChangeLog index 940f7f15..41c8a0e4 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,8 @@ +2014-11-23 Arnold D. Robbins <arnold@skeeve.com> + + * inplace.c (do_inplace_begin): Jump through hoops to silence + GCC warnings about return value of chown. + 2014-10-12 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (uninstall-so): Remove *.lib too, per suggestion diff --git a/extension/inplace.c b/extension/inplace.c index 8a7375c4..0693ad92 100644 --- a/extension/inplace.c +++ b/extension/inplace.c @@ -170,8 +170,12 @@ do_inplace_begin(int nargs, awk_value_t *result) state.tname, strerror(errno)); /* N.B. chown/chmod should be more portable than fchown/fchmod */ - if (chown(state.tname, sbuf.st_uid, sbuf.st_gid) < 0) - (void) chown(state.tname, -1, sbuf.st_gid); + if (chown(state.tname, sbuf.st_uid, sbuf.st_gid) < 0) { + /* jumping through hoops to silence gcc. :-( */ + int junk; + junk = chown(state.tname, -1, sbuf.st_gid); + junk = junk; + } if (chmod(state.tname, sbuf.st_mode) < 0) fatal(ext_id, _("inplace_begin: chmod failed (%s)"), |