diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-06-26 18:26:39 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-06-26 18:26:39 +0300 |
commit | e18ebe10166e2c63f3385666978b678fe6ce67a2 (patch) | |
tree | 7f6a2249dfda678c8651f0e24a273bb8b54bb886 /builtin.c | |
parent | 278767f062a9c6f8ae9ff777b1a41e094813fa09 (diff) | |
download | egawk-e18ebe10166e2c63f3385666978b678fe6ce67a2.tar.gz egawk-e18ebe10166e2c63f3385666978b678fe6ce67a2.tar.bz2 egawk-e18ebe10166e2c63f3385666978b678fe6ce67a2.zip |
Minor improvements after Andy's reworking of stuff.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -1048,6 +1048,7 @@ check_pos: case 'c': need_format = false; parse_next_arg(); + /* user input that looks numeric is numeric */ fixtype(arg); if ((arg->flags & NUMBER) != 0) { uval = get_number_uj(arg); @@ -2034,12 +2035,16 @@ do_mktime(int nargs) int month, day, hour, minute, second, count; int dst = -1; /* default is unknown */ time_t then_stamp; + char save; t1 = POP_SCALAR(); if (do_lint && (fixtype(t1)->flags & STRING) == 0) lintwarn(_("mktime: received non-string argument")); t1 = force_string(t1); + save = t1->stptr[t1->stlen]; + t1->stptr[t1->stlen] = '\0'; + count = sscanf(t1->stptr, "%ld %d %d %d %d %d %d", & year, & month, & day, & hour, & minute, & second, @@ -2053,6 +2058,7 @@ do_mktime(int nargs) || (month < 1 || month > 12) )) lintwarn(_("mktime: at least one of the values is out of the default range")); + t1->stptr[t1->stlen] = save; DEREF(t1); if (count < 6 @@ -2859,10 +2865,9 @@ do_sub(int nargs, unsigned int flags) target = POP_STRING(); /* original string */ glob_flag = POP_SCALAR(); /* value of global flag */ - if (((glob_flag->flags & STRING) != 0) - && (glob_flag->stlen > 0 - && (glob_flag->stptr[0] == 'g' - || glob_flag->stptr[0] == 'G'))) + if ( (glob_flag->flags & STRING) != 0 + && glob_flag->stlen > 0 + && (glob_flag->stptr[0] == 'g' || glob_flag->stptr[0] == 'G')) how_many = -1; else { (void) force_number(glob_flag); @@ -2875,7 +2880,9 @@ do_sub(int nargs, unsigned int flags) how_many = LONG_MAX; if (d <= 0) { (void) force_string(glob_flag); - warning(_("gensub: third argument `%s' treated as 1"), glob_flag->stptr); + warning(_("gensub: third argument `%.*s' treated as 1"), + (int) glob_flag->stlen, + glob_flag->stptr); } } DEREF(glob_flag); @@ -3561,6 +3568,7 @@ AWKNUM nondec2awknum(char *str, size_t len, char **endptr) { AWKNUM retval = 0.0; + char save; short val; char *start = str; @@ -3632,7 +3640,10 @@ nondec2awknum(char *str, size_t len, char **endptr) *endptr = str; } else { decimal: + save = str[len]; + str[len] = '\0'; retval = strtod(str, endptr); + str[len] = save; } done: return retval; |