diff options
47 files changed, 695 insertions, 585 deletions
@@ -1,3 +1,47 @@ +2017-06-22 Arnold D. Robbins <arnold@skeeve.com> + + Make pretty-printing include parentheses that were explicitly + in the source code. Thanks to Hermann Peifer for the bug report. + + * awk.h (OPCODE): Add Op_parens. + * awkgram.y [Grammar]: If pretty-printing, add Op_parens ot end of + list for parenthesized expression. + * eval.c (optypetab): Add Op_parens. + * interpret.h (r_interpret): Ditto. + * profile.c (pprint): Ditto. For ?:, don't parenthesize it. + (pp_parenthesize): If string starts with left paren, return early. + (parenthesize): Don't call div_on_left_mul_on_right. + (div_on_left_mul_on_right): Remove function. + (pp_concat): Don't add parentheses if expressions already have them. + * NEWS: Updated. + +2017-06-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + Replace malloc/memset combinations with calloc by using the new ezalloc + macro. + * awkgram.y (yyerror, do_add_srcfile, funcuse): Replace emalloc+memset + with ezalloc. + * cint_array.c (cint_lookup, cint_copy, tree_lookup, tree_copy, + leaf_lookup, leaf_copy): Ditto. + * command.y (mk_cmdarg): Ditto. + * debug.c (add_item): Ditto. + * eval.c (setup_frame): Ditto. + * field.c (set_record): Ditto. + * gawkapi.c (api_flatten_array_typed): Ditto. + * int_array.c (int_copy, grow_int_table): Ditto. + * io.c (init_awkpath, iop_alloc): Ditto. + * node.c (str2wstr): Ditto. + * re.c (make_regexp): Ditto. + * str_array.c (str_copy, grow_table): Ditto. + * symbol.c (make_params, new_context): Ditto. + +2017-06-19 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * awk.h (ezalloc): Add new macro to allocate memory initialized to zero. + (ezalloc_real): New inline function to call calloc. + * gawkapi.h (ezalloc): Add new API macro to allocate memory initialized + to zero. + 2017-06-18 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (mbc_char_count): Fix code to correctly traverse @@ -74,7 +74,7 @@ Changes from 4.1.x to 4.2.0 18. Support for GNU/Linux on Alpha systems has been removed. 19. Optimizations are now enabled by default. Use the new -s/--no-optimize - option(s) to disable them. Pretty printing and profiling automatically + option(s) to disable them. Pretty-printing and profiling automatically disable optimizations so that the output program is the same as the original input program. @@ -84,8 +84,8 @@ Changes from 4.1.x to 4.2.0 20. Gawk now uses fwrite_unlocked if it's available. The yields a 7% - 18% improvement in raw output speed (gawk '{ print }' on a large file). -21. Pretty printing now uses the original text of constant numeric values for - pretty printing and profiling. +21. Pretty-printing now uses the original text of constant numeric values for + pretty-printing and profiling. 22. Passing negative operands to any of the bitwise functions now produces a fatal error. @@ -118,6 +118,10 @@ Changes from 4.1.x to 4.2.0 28. The PROCINFO["argv"] array records all of gawk's command line arguments as gawk received them (the values of the C level argv array). +29. Pretty-printing now preserves parenthesized expressions as they + were in the source file. This solves several niggling corner cases + with such things. + Changes from 4.1.3 to 4.1.4 --------------------------- @@ -736,6 +736,7 @@ typedef enum opcodeval { Op_K_else, Op_K_function, Op_cond_exp, + Op_parens, Op_final /* sentry value, not legal */ } OPCODE; @@ -1333,6 +1334,7 @@ DEREF(NODE *r) __LINE__, __FILE__) #define emalloc(var,ty,x,str) (void) (var = (ty) emalloc_real((size_t)(x), str, #var, __FILE__, __LINE__)) +#define ezalloc(var,ty,x,str) (void) (var = (ty) ezalloc_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) @@ -1952,6 +1954,24 @@ emalloc_real(size_t count, const char *where, const char *var, const char *file, return ret; } +/* ezalloc_real --- malloc zero-filled bytes with error checking */ + +static inline void * +ezalloc_real(size_t count, const char *where, const char *var, const char *file, int line) +{ + void *ret; + + if (count == 0) + fatal("%s:%d: ezalloc called with zero bytes", file, line); + + ret = (void *) calloc(1, 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; +} + /* erealloc_real --- realloc with error checking */ static inline void * @@ -686,11 +686,11 @@ static const yytype_uint16 yyrline[] = 1520, 1527, 1529, 1534, 1536, 1538, 1546, 1548, 1553, 1555, 1560, 1562, 1564, 1620, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1648, 1653, 1658, 1683, 1689, 1691, 1693, 1695, 1697, - 1699, 1704, 1708, 1740, 1742, 1748, 1754, 1767, 1768, 1769, - 1774, 1779, 1783, 1787, 1802, 1823, 1828, 1865, 1894, 1895, - 1901, 1902, 1907, 1909, 1916, 1933, 1950, 1952, 1959, 1964, - 1972, 1982, 1994, 2003, 2007, 2011, 2015, 2019, 2023, 2026, - 2028, 2032, 2036, 2040 + 1699, 1704, 1708, 1740, 1747, 1753, 1759, 1772, 1773, 1774, + 1779, 1784, 1788, 1792, 1807, 1828, 1833, 1870, 1899, 1900, + 1906, 1907, 1912, 1914, 1921, 1938, 1955, 1957, 1964, 1969, + 1977, 1987, 1999, 2008, 2012, 2016, 2020, 2024, 2028, 2031, + 2033, 2037, 2041, 2045 }; #endif @@ -3842,32 +3842,37 @@ regular_print: case 163: #line 1741 "awkgram.y" /* yacc.c:1646 */ - { (yyval) = (yyvsp[-1]); } -#line 3847 "awkgram.c" /* yacc.c:1646 */ + { + if (do_pretty_print) + (yyval) = list_append((yyvsp[-1]), bcalloc(Op_parens, 1, sourceline)); + else + (yyval) = (yyvsp[-1]); + } +#line 3852 "awkgram.c" /* yacc.c:1646 */ break; case 164: -#line 1743 "awkgram.y" /* yacc.c:1646 */ +#line 1748 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3857 "awkgram.c" /* yacc.c:1646 */ +#line 3862 "awkgram.c" /* yacc.c:1646 */ break; case 165: -#line 1749 "awkgram.y" /* yacc.c:1646 */ +#line 1754 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3867 "awkgram.c" /* yacc.c:1646 */ +#line 3872 "awkgram.c" /* yacc.c:1646 */ break; case 166: -#line 1755 "awkgram.y" /* yacc.c:1646 */ +#line 1760 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3880,45 +3885,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3884 "awkgram.c" /* yacc.c:1646 */ +#line 3889 "awkgram.c" /* yacc.c:1646 */ break; case 169: -#line 1770 "awkgram.y" /* yacc.c:1646 */ +#line 1775 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3893 "awkgram.c" /* yacc.c:1646 */ +#line 3898 "awkgram.c" /* yacc.c:1646 */ break; case 170: -#line 1775 "awkgram.y" /* yacc.c:1646 */ +#line 1780 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3902 "awkgram.c" /* yacc.c:1646 */ +#line 3907 "awkgram.c" /* yacc.c:1646 */ break; case 171: -#line 1780 "awkgram.y" /* yacc.c:1646 */ +#line 1785 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3910 "awkgram.c" /* yacc.c:1646 */ +#line 3915 "awkgram.c" /* yacc.c:1646 */ break; case 172: -#line 1784 "awkgram.y" /* yacc.c:1646 */ +#line 1789 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3918 "awkgram.c" /* yacc.c:1646 */ +#line 3923 "awkgram.c" /* yacc.c:1646 */ break; case 173: -#line 1788 "awkgram.y" /* yacc.c:1646 */ +#line 1793 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & STRING) == 0 @@ -3933,11 +3938,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3937 "awkgram.c" /* yacc.c:1646 */ +#line 3942 "awkgram.c" /* yacc.c:1646 */ break; case 174: -#line 1803 "awkgram.y" /* yacc.c:1646 */ +#line 1808 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & STRING) == 0 @@ -3955,20 +3960,20 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3959 "awkgram.c" /* yacc.c:1646 */ +#line 3964 "awkgram.c" /* yacc.c:1646 */ break; case 175: -#line 1824 "awkgram.y" /* yacc.c:1646 */ +#line 1829 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3968 "awkgram.c" /* yacc.c:1646 */ +#line 3973 "awkgram.c" /* yacc.c:1646 */ break; case 176: -#line 1829 "awkgram.y" /* yacc.c:1646 */ +#line 1834 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -4002,11 +4007,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); at_seen = false; } -#line 4006 "awkgram.c" /* yacc.c:1646 */ +#line 4011 "awkgram.c" /* yacc.c:1646 */ break; case 177: -#line 1866 "awkgram.y" /* yacc.c:1646 */ +#line 1871 "awkgram.y" /* yacc.c:1646 */ { NODE *n; @@ -4031,49 +4036,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 4035 "awkgram.c" /* yacc.c:1646 */ +#line 4040 "awkgram.c" /* yacc.c:1646 */ break; case 178: -#line 1894 "awkgram.y" /* yacc.c:1646 */ +#line 1899 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 4041 "awkgram.c" /* yacc.c:1646 */ +#line 4046 "awkgram.c" /* yacc.c:1646 */ break; case 179: -#line 1896 "awkgram.y" /* yacc.c:1646 */ +#line 1901 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 4047 "awkgram.c" /* yacc.c:1646 */ +#line 4052 "awkgram.c" /* yacc.c:1646 */ break; case 180: -#line 1901 "awkgram.y" /* yacc.c:1646 */ +#line 1906 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 4053 "awkgram.c" /* yacc.c:1646 */ +#line 4058 "awkgram.c" /* yacc.c:1646 */ break; case 181: -#line 1903 "awkgram.y" /* yacc.c:1646 */ +#line 1908 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 4059 "awkgram.c" /* yacc.c:1646 */ +#line 4064 "awkgram.c" /* yacc.c:1646 */ break; case 182: -#line 1908 "awkgram.y" /* yacc.c:1646 */ +#line 1913 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 4065 "awkgram.c" /* yacc.c:1646 */ +#line 4070 "awkgram.c" /* yacc.c:1646 */ break; case 183: -#line 1910 "awkgram.y" /* yacc.c:1646 */ +#line 1915 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 4073 "awkgram.c" /* yacc.c:1646 */ +#line 4078 "awkgram.c" /* yacc.c:1646 */ break; case 184: -#line 1917 "awkgram.y" /* yacc.c:1646 */ +#line 1922 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -4087,11 +4092,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 4091 "awkgram.c" /* yacc.c:1646 */ +#line 4096 "awkgram.c" /* yacc.c:1646 */ break; case 185: -#line 1934 "awkgram.y" /* yacc.c:1646 */ +#line 1939 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -4105,31 +4110,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 4109 "awkgram.c" /* yacc.c:1646 */ +#line 4114 "awkgram.c" /* yacc.c:1646 */ break; case 186: -#line 1951 "awkgram.y" /* yacc.c:1646 */ +#line 1956 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 4115 "awkgram.c" /* yacc.c:1646 */ +#line 4120 "awkgram.c" /* yacc.c:1646 */ break; case 187: -#line 1953 "awkgram.y" /* yacc.c:1646 */ +#line 1958 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 4123 "awkgram.c" /* yacc.c:1646 */ +#line 4128 "awkgram.c" /* yacc.c:1646 */ break; case 188: -#line 1960 "awkgram.y" /* yacc.c:1646 */ +#line 1965 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 4129 "awkgram.c" /* yacc.c:1646 */ +#line 4134 "awkgram.c" /* yacc.c:1646 */ break; case 189: -#line 1965 "awkgram.y" /* yacc.c:1646 */ +#line 1970 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -4137,22 +4142,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 4141 "awkgram.c" /* yacc.c:1646 */ +#line 4146 "awkgram.c" /* yacc.c:1646 */ break; case 190: -#line 1973 "awkgram.y" /* yacc.c:1646 */ +#line 1978 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-1])->lextok; (yyvsp[-1])->memory = variable((yyvsp[-1])->source_line, arr, Node_var_new); (yyvsp[-1])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[0]), (yyvsp[-1])); } -#line 4152 "awkgram.c" /* yacc.c:1646 */ +#line 4157 "awkgram.c" /* yacc.c:1646 */ break; case 191: -#line 1983 "awkgram.y" /* yacc.c:1646 */ +#line 1988 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -4164,73 +4169,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 4168 "awkgram.c" /* yacc.c:1646 */ +#line 4173 "awkgram.c" /* yacc.c:1646 */ break; case 192: -#line 1995 "awkgram.y" /* yacc.c:1646 */ +#line 2000 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 4178 "awkgram.c" /* yacc.c:1646 */ +#line 4183 "awkgram.c" /* yacc.c:1646 */ break; case 193: -#line 2004 "awkgram.y" /* yacc.c:1646 */ +#line 2009 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 4186 "awkgram.c" /* yacc.c:1646 */ +#line 4191 "awkgram.c" /* yacc.c:1646 */ break; case 194: -#line 2008 "awkgram.y" /* yacc.c:1646 */ +#line 2013 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 4194 "awkgram.c" /* yacc.c:1646 */ +#line 4199 "awkgram.c" /* yacc.c:1646 */ break; case 195: -#line 2011 "awkgram.y" /* yacc.c:1646 */ +#line 2016 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 4200 "awkgram.c" /* yacc.c:1646 */ +#line 4205 "awkgram.c" /* yacc.c:1646 */ break; case 197: -#line 2019 "awkgram.y" /* yacc.c:1646 */ +#line 2024 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 4206 "awkgram.c" /* yacc.c:1646 */ +#line 4211 "awkgram.c" /* yacc.c:1646 */ break; case 198: -#line 2023 "awkgram.y" /* yacc.c:1646 */ +#line 2028 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 4212 "awkgram.c" /* yacc.c:1646 */ +#line 4217 "awkgram.c" /* yacc.c:1646 */ break; case 201: -#line 2032 "awkgram.y" /* yacc.c:1646 */ +#line 2037 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 4218 "awkgram.c" /* yacc.c:1646 */ +#line 4223 "awkgram.c" /* yacc.c:1646 */ break; case 202: -#line 2036 "awkgram.y" /* yacc.c:1646 */ +#line 2041 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 4224 "awkgram.c" /* yacc.c:1646 */ +#line 4229 "awkgram.c" /* yacc.c:1646 */ break; case 203: -#line 2040 "awkgram.y" /* yacc.c:1646 */ +#line 2045 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 4230 "awkgram.c" /* yacc.c:1646 */ +#line 4235 "awkgram.c" /* yacc.c:1646 */ break; -#line 4234 "awkgram.c" /* yacc.c:1646 */ +#line 4239 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4458,7 +4463,7 @@ yyreturn: #endif return yyresult; } -#line 2042 "awkgram.y" /* yacc.c:1906 */ +#line 2047 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -4815,8 +4820,7 @@ yyerror(const char *m, ...) count = strlen(mesg) + 1; if (lexptr != NULL) count += (lexeme - thisline) + 2; - emalloc(buf, char *, count+1, "yyerror"); - memset(buf, 0, count+1); + ezalloc(buf, char *, count+1, "yyerror"); bp = buf; @@ -5035,8 +5039,7 @@ do_add_srcfile(enum srctype stype, char *src, char *path, SRCFILE *thisfile) { SRCFILE *s; - emalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); - memset(s, 0, sizeof(SRCFILE)); + ezalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); s->src = estrdup(src, strlen(src)); s->fullpath = path; s->stype = stype; @@ -7317,8 +7320,7 @@ func_use(const char *name, enum defref how) /* not in the table, fall through to allocate a new one */ - emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); - memset(fp, '\0', sizeof(struct fdesc)); + ezalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); emalloc(fp->name, char *, len + 1, "func_use"); strcpy(fp->name, name); fp->next = ftable[ind]; @@ -8336,7 +8338,7 @@ add_lint(INSTRUCTION *list, LINTTYPE linttype) // closest to the opcode if that opcode doesn't have one if (ip->source_line != 0) line = ip->source_line; - } + } if (do_lint) { /* compile-time warning */ if (isnoeffect(ip->opcode)) { @@ -1738,7 +1738,12 @@ non_post_simp_exp } } | '(' exp r_paren - { $$ = $2; } + { + if (do_pretty_print) + $$ = list_append($2, bcalloc(Op_parens, 1, sourceline)); + else + $$ = $2; + } | LEX_BUILTIN '(' opt_fcall_expression_list r_paren { $$ = snode($3, $1); @@ -2395,8 +2400,7 @@ yyerror(const char *m, ...) count = strlen(mesg) + 1; if (lexptr != NULL) count += (lexeme - thisline) + 2; - emalloc(buf, char *, count+1, "yyerror"); - memset(buf, 0, count+1); + ezalloc(buf, char *, count+1, "yyerror"); bp = buf; @@ -2615,8 +2619,7 @@ do_add_srcfile(enum srctype stype, char *src, char *path, SRCFILE *thisfile) { SRCFILE *s; - emalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); - memset(s, 0, sizeof(SRCFILE)); + ezalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); s->src = estrdup(src, strlen(src)); s->fullpath = path; s->stype = stype; @@ -4897,8 +4900,7 @@ func_use(const char *name, enum defref how) /* not in the table, fall through to allocate a new one */ - emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); - memset(fp, '\0', sizeof(struct fdesc)); + ezalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); emalloc(fp->name, char *, len + 1, "func_use"); strcpy(fp->name, name); fp->next = ftable[ind]; @@ -5916,7 +5918,7 @@ add_lint(INSTRUCTION *list, LINTTYPE linttype) // closest to the opcode if that opcode doesn't have one if (ip->source_line != 0) line = ip->source_line; - } + } if (do_lint) { /* compile-time warning */ if (isnoeffect(ip->opcode)) { diff --git a/cint_array.c b/cint_array.c index 092ce88a..851e980e 100644 --- a/cint_array.c +++ b/cint_array.c @@ -228,8 +228,7 @@ cint_lookup(NODE *symbol, NODE *subs) assert(symbol->table_size == 0); /* nodes[0] .. nodes[NHAT- 1] not used */ - emalloc(symbol->nodes, NODE **, INT32_BIT * sizeof(NODE *), "cint_lookup"); - memset(symbol->nodes, '\0', INT32_BIT * sizeof(NODE *)); + ezalloc(symbol->nodes, NODE **, INT32_BIT * sizeof(NODE *), "cint_lookup"); } symbol->table_size++; /* one more element in array */ @@ -387,8 +386,7 @@ cint_copy(NODE *symbol, NODE *newsymb) assert(symbol->nodes != NULL); /* allocate new table */ - emalloc(new, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy"); - memset(new, '\0', INT32_BIT * sizeof(NODE *)); + ezalloc(new, NODE **, INT32_BIT * sizeof(NODE *), "cint_copy"); old = symbol->nodes; for (i = NHAT; i < INT32_BIT; i++) { @@ -754,8 +752,7 @@ tree_lookup(NODE *symbol, NODE *tree, long k, int m, long base) actual_size /= 2; tree->flags |= HALFHAT; } - emalloc(table, NODE **, actual_size * sizeof(NODE *), "tree_lookup"); - memset(table, '\0', actual_size * sizeof(NODE *)); + ezalloc(table, NODE **, actual_size * sizeof(NODE *), "tree_lookup"); tree->nodes = table; } else size = tree->array_size; @@ -928,8 +925,7 @@ tree_copy(NODE *newsymb, NODE *tree, NODE *newtree) if ((tree->flags & HALFHAT) != 0) hsize /= 2; - emalloc(new, NODE **, hsize * sizeof(NODE *), "tree_copy"); - memset(new, '\0', hsize * sizeof(NODE *)); + ezalloc(new, NODE **, hsize * sizeof(NODE *), "tree_copy"); newtree->nodes = new; newtree->array_base = tree->array_base; newtree->array_size = tree->array_size; @@ -1047,8 +1043,7 @@ leaf_lookup(NODE *symbol, NODE *array, long k, long size, long base) array->table_size = 0; /* sanity */ array->array_size = size; array->array_base = base; - emalloc(array->nodes, NODE **, size * sizeof(NODE *), "leaf_lookup"); - memset(array->nodes, '\0', size * sizeof(NODE *)); + ezalloc(array->nodes, NODE **, size * sizeof(NODE *), "leaf_lookup"); symbol->array_capacity += size; } @@ -1127,8 +1122,7 @@ leaf_copy(NODE *newsymb, NODE *array, NODE *newarray) long size, i; size = array->array_size; - emalloc(new, NODE **, size * sizeof(NODE *), "leaf_copy"); - memset(new, '\0', size * sizeof(NODE *)); + ezalloc(new, NODE **, size * sizeof(NODE *), "leaf_copy"); newarray->nodes = new; newarray->array_size = size; newarray->array_base = array->array_base; @@ -2707,8 +2707,7 @@ static CMDARG * mk_cmdarg(enum argtype type) { CMDARG *arg; - emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); - memset(arg, 0, sizeof(CMDARG)); + ezalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); arg->type = type; return arg; } @@ -957,8 +957,7 @@ static CMDARG * mk_cmdarg(enum argtype type) { CMDARG *arg; - emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); - memset(arg, 0, sizeof(CMDARG)); + ezalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); arg->type = type; return arg; } @@ -1371,8 +1371,7 @@ add_item(struct list_item *list, int type, NODE *symbol, char *pname) { struct list_item *d; - emalloc(d, struct list_item *, sizeof(struct list_item), "add_item"); - memset(d, 0, sizeof(struct list_item)); + ezalloc(d, struct list_item *, sizeof(struct list_item), "add_item"); d->commands.next = d->commands.prev = &d->commands; d->number = ++list->number; diff --git a/doc/ChangeLog b/doc/ChangeLog index da02085c..2c72aebe 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2017-06-19 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawktexi.in (Memory Allocation Functions and Convenience Macros): + Document new ezalloc API macro. + 2017-06-18 Andrew J. Schorr <aschorr@telemetry-investments.com> * gawkworkflow.texi: Fix typo. diff --git a/doc/gawk.info b/doc/gawk.info index 996e3669..6fc7fd91 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -23939,10 +23939,11 @@ library than was used for the 'gawk' executable.(1) If 'gawk' were to use its version of 'free()' when the memory came from an unrelated version of 'malloc()', unexpected behavior would likely result. - Two convenience macros may be used for allocating storage from -'gawk_malloc()' and 'gawk_realloc()'. If the allocation fails, they -cause 'gawk' to exit with a fatal error message. They should be used as -if they were procedure calls that do not return a value: + Three convenience macros may be used for allocating storage from +'gawk_malloc()', 'gawk_calloc', and 'gawk_realloc()'. If the allocation +fails, they cause 'gawk' to exit with a fatal error message. They +should be used as if they were procedure calls that do not return a +value: '#define emalloc(pointer, type, size, message) ...' The arguments to this macro are as follows: @@ -23971,6 +23972,12 @@ if they were procedure calls that do not return a value: strcpy(message, greet); make_malloced_string(message, strlen(message), & result); +'#define ezalloc(pointer, type, size, message) ...' + This is like 'emalloc()', but it calls 'gawk_calloc()' instead of + 'gawk_malloc()'. The arguments are the same as for the 'emalloc()' + macro, but this macro guarantees that the memory returned is + initialized to zero. + '#define erealloc(pointer, type, size, message) ...' This is like 'emalloc()', but it calls 'gawk_realloc()' instead of 'gawk_malloc()'. The arguments are the same as for the 'emalloc()' @@ -36106,140 +36113,140 @@ Node: Extension API Functions Introduction958934 Node: General Data Types964268 Ref: General Data Types-Footnote-1971473 Node: Memory Allocation Functions971772 -Ref: Memory Allocation Functions-Footnote-1974617 -Node: Constructor Functions974716 -Node: Registration Functions977715 -Node: Extension Functions978400 -Node: Exit Callback Functions983613 -Node: Extension Version String984863 -Node: Input Parsers985526 -Node: Output Wrappers998233 -Node: Two-way processors1002745 -Node: Printing Messages1005010 -Ref: Printing Messages-Footnote-11006181 -Node: Updating ERRNO1006334 -Node: Requesting Values1007073 -Ref: table-value-types-returned1007810 -Node: Accessing Parameters1008746 -Node: Symbol Table Access1009981 -Node: Symbol table by name1010493 -Node: Symbol table by cookie1012282 -Ref: Symbol table by cookie-Footnote-11016467 -Node: Cached values1016531 -Ref: Cached values-Footnote-11020067 -Node: Array Manipulation1020158 -Ref: Array Manipulation-Footnote-11021249 -Node: Array Data Types1021286 -Ref: Array Data Types-Footnote-11023944 -Node: Array Functions1024036 -Node: Flattening Arrays1028435 -Node: Creating Arrays1035376 -Node: Redirection API1040145 -Node: Extension API Variables1042987 -Node: Extension Versioning1043620 -Ref: gawk-api-version1044057 -Node: Extension API Informational Variables1045785 -Node: Extension API Boilerplate1046849 -Node: Changes from API V11050711 -Node: Finding Extensions1051371 -Node: Extension Example1051930 -Node: Internal File Description1052728 -Node: Internal File Ops1056808 -Ref: Internal File Ops-Footnote-11068208 -Node: Using Internal File Ops1068348 -Ref: Using Internal File Ops-Footnote-11070731 -Node: Extension Samples1071005 -Node: Extension Sample File Functions1072534 -Node: Extension Sample Fnmatch1080183 -Node: Extension Sample Fork1081670 -Node: Extension Sample Inplace1082888 -Node: Extension Sample Ord1086105 -Node: Extension Sample Readdir1086941 -Ref: table-readdir-file-types1087830 -Node: Extension Sample Revout1088635 -Node: Extension Sample Rev2way1089224 -Node: Extension Sample Read write array1089964 -Node: Extension Sample Readfile1091906 -Node: Extension Sample Time1093001 -Node: Extension Sample API Tests1094349 -Node: gawkextlib1094841 -Node: Extension summary1097288 -Node: Extension Exercises1100990 -Node: Language History1102488 -Node: V7/SVR3.11104144 -Node: SVR41106296 -Node: POSIX1107730 -Node: BTL1109109 -Node: POSIX/GNU1109838 -Node: Feature History1115616 -Node: Common Extensions1129981 -Node: Ranges and Locales1131264 -Ref: Ranges and Locales-Footnote-11135880 -Ref: Ranges and Locales-Footnote-21135907 -Ref: Ranges and Locales-Footnote-31136142 -Node: Contributors1136363 -Node: History summary1141923 -Node: Installation1143303 -Node: Gawk Distribution1144247 -Node: Getting1144731 -Node: Extracting1145692 -Node: Distribution contents1147330 -Node: Unix Installation1153672 -Node: Quick Installation1154354 -Node: Shell Startup Files1156768 -Node: Additional Configuration Options1157857 -Node: Configuration Philosophy1159846 -Node: Non-Unix Installation1162215 -Node: PC Installation1162675 -Node: PC Binary Installation1163513 -Node: PC Compiling1163948 -Node: PC Using1165065 -Node: Cygwin1168110 -Node: MSYS1168880 -Node: VMS Installation1169381 -Node: VMS Compilation1170172 -Ref: VMS Compilation-Footnote-11171401 -Node: VMS Dynamic Extensions1171459 -Node: VMS Installation Details1173144 -Node: VMS Running1175397 -Node: VMS GNV1179676 -Node: VMS Old Gawk1180411 -Node: Bugs1180882 -Node: Bug address1181545 -Node: Usenet1183942 -Node: Maintainers1184719 -Node: Other Versions1186095 -Node: Installation summary1192679 -Node: Notes1193714 -Node: Compatibility Mode1194579 -Node: Additions1195361 -Node: Accessing The Source1196286 -Node: Adding Code1197721 -Node: New Ports1203939 -Node: Derived Files1208427 -Ref: Derived Files-Footnote-11213912 -Ref: Derived Files-Footnote-21213947 -Ref: Derived Files-Footnote-31214545 -Node: Future Extensions1214659 -Node: Implementation Limitations1215317 -Node: Extension Design1216500 -Node: Old Extension Problems1217654 -Ref: Old Extension Problems-Footnote-11219172 -Node: Extension New Mechanism Goals1219229 -Ref: Extension New Mechanism Goals-Footnote-11222593 -Node: Extension Other Design Decisions1222782 -Node: Extension Future Growth1224895 -Node: Old Extension Mechanism1225731 -Node: Notes summary1227494 -Node: Basic Concepts1228676 -Node: Basic High Level1229357 -Ref: figure-general-flow1229639 -Ref: figure-process-flow1230324 -Ref: Basic High Level-Footnote-11233625 -Node: Basic Data Typing1233810 -Node: Glossary1237138 -Node: Copying1269085 -Node: GNU Free Documentation License1306624 -Node: Index1331742 +Ref: Memory Allocation Functions-Footnote-1974924 +Node: Constructor Functions975023 +Node: Registration Functions978022 +Node: Extension Functions978707 +Node: Exit Callback Functions983920 +Node: Extension Version String985170 +Node: Input Parsers985833 +Node: Output Wrappers998540 +Node: Two-way processors1003052 +Node: Printing Messages1005317 +Ref: Printing Messages-Footnote-11006488 +Node: Updating ERRNO1006641 +Node: Requesting Values1007380 +Ref: table-value-types-returned1008117 +Node: Accessing Parameters1009053 +Node: Symbol Table Access1010288 +Node: Symbol table by name1010800 +Node: Symbol table by cookie1012589 +Ref: Symbol table by cookie-Footnote-11016774 +Node: Cached values1016838 +Ref: Cached values-Footnote-11020374 +Node: Array Manipulation1020465 +Ref: Array Manipulation-Footnote-11021556 +Node: Array Data Types1021593 +Ref: Array Data Types-Footnote-11024251 +Node: Array Functions1024343 +Node: Flattening Arrays1028742 +Node: Creating Arrays1035683 +Node: Redirection API1040452 +Node: Extension API Variables1043294 +Node: Extension Versioning1043927 +Ref: gawk-api-version1044364 +Node: Extension API Informational Variables1046092 +Node: Extension API Boilerplate1047156 +Node: Changes from API V11051018 +Node: Finding Extensions1051678 +Node: Extension Example1052237 +Node: Internal File Description1053035 +Node: Internal File Ops1057115 +Ref: Internal File Ops-Footnote-11068515 +Node: Using Internal File Ops1068655 +Ref: Using Internal File Ops-Footnote-11071038 +Node: Extension Samples1071312 +Node: Extension Sample File Functions1072841 +Node: Extension Sample Fnmatch1080490 +Node: Extension Sample Fork1081977 +Node: Extension Sample Inplace1083195 +Node: Extension Sample Ord1086412 +Node: Extension Sample Readdir1087248 +Ref: table-readdir-file-types1088137 +Node: Extension Sample Revout1088942 +Node: Extension Sample Rev2way1089531 +Node: Extension Sample Read write array1090271 +Node: Extension Sample Readfile1092213 +Node: Extension Sample Time1093308 +Node: Extension Sample API Tests1094656 +Node: gawkextlib1095148 +Node: Extension summary1097595 +Node: Extension Exercises1101297 +Node: Language History1102795 +Node: V7/SVR3.11104451 +Node: SVR41106603 +Node: POSIX1108037 +Node: BTL1109416 +Node: POSIX/GNU1110145 +Node: Feature History1115923 +Node: Common Extensions1130288 +Node: Ranges and Locales1131571 +Ref: Ranges and Locales-Footnote-11136187 +Ref: Ranges and Locales-Footnote-21136214 +Ref: Ranges and Locales-Footnote-31136449 +Node: Contributors1136670 +Node: History summary1142230 +Node: Installation1143610 +Node: Gawk Distribution1144554 +Node: Getting1145038 +Node: Extracting1145999 +Node: Distribution contents1147637 +Node: Unix Installation1153979 +Node: Quick Installation1154661 +Node: Shell Startup Files1157075 +Node: Additional Configuration Options1158164 +Node: Configuration Philosophy1160153 +Node: Non-Unix Installation1162522 +Node: PC Installation1162982 +Node: PC Binary Installation1163820 +Node: PC Compiling1164255 +Node: PC Using1165372 +Node: Cygwin1168417 +Node: MSYS1169187 +Node: VMS Installation1169688 +Node: VMS Compilation1170479 +Ref: VMS Compilation-Footnote-11171708 +Node: VMS Dynamic Extensions1171766 +Node: VMS Installation Details1173451 +Node: VMS Running1175704 +Node: VMS GNV1179983 +Node: VMS Old Gawk1180718 +Node: Bugs1181189 +Node: Bug address1181852 +Node: Usenet1184249 +Node: Maintainers1185026 +Node: Other Versions1186402 +Node: Installation summary1192986 +Node: Notes1194021 +Node: Compatibility Mode1194886 +Node: Additions1195668 +Node: Accessing The Source1196593 +Node: Adding Code1198028 +Node: New Ports1204246 +Node: Derived Files1208734 +Ref: Derived Files-Footnote-11214219 +Ref: Derived Files-Footnote-21214254 +Ref: Derived Files-Footnote-31214852 +Node: Future Extensions1214966 +Node: Implementation Limitations1215624 +Node: Extension Design1216807 +Node: Old Extension Problems1217961 +Ref: Old Extension Problems-Footnote-11219479 +Node: Extension New Mechanism Goals1219536 +Ref: Extension New Mechanism Goals-Footnote-11222900 +Node: Extension Other Design Decisions1223089 +Node: Extension Future Growth1225202 +Node: Old Extension Mechanism1226038 +Node: Notes summary1227801 +Node: Basic Concepts1228983 +Node: Basic High Level1229664 +Ref: figure-general-flow1229946 +Ref: figure-process-flow1230631 +Ref: Basic High Level-Footnote-11233932 +Node: Basic Data Typing1234117 +Node: Glossary1237445 +Node: Copying1269392 +Node: GNU Free Documentation License1306931 +Node: Index1332049 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 7e9b5987..44b04a70 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -32986,8 +32986,8 @@ to use its version of @code{free()} when the memory came from an unrelated version of @code{malloc()}, unexpected behavior would likely result. -Two convenience macros may be used for allocating storage -from @code{gawk_malloc()} and +Three convenience macros may be used for allocating storage +from @code{gawk_malloc()}, @code{gawk_calloc}, and @code{gawk_realloc()}. If the allocation fails, they cause @command{gawk} to exit with a fatal error message. They should be used as if they were procedure calls that do not return a value: @@ -33026,6 +33026,12 @@ strcpy(message, greet); make_malloced_string(message, strlen(message), & result); @end example +@item #define ezalloc(pointer, type, size, message) @dots{} +This is like @code{emalloc()}, but it calls @code{gawk_calloc()} +instead of @code{gawk_malloc()}. +The arguments are the same as for the @code{emalloc()} macro, but this +macro guarantees that the memory returned is initialized to zero. + @item #define erealloc(pointer, type, size, message) @dots{} This is like @code{emalloc()}, but it calls @code{gawk_realloc()} instead of @code{gawk_malloc()}. diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 8ca76fd6..02cba2ea 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -32000,8 +32000,8 @@ to use its version of @code{free()} when the memory came from an unrelated version of @code{malloc()}, unexpected behavior would likely result. -Two convenience macros may be used for allocating storage -from @code{gawk_malloc()} and +Three convenience macros may be used for allocating storage +from @code{gawk_malloc()}, @code{gawk_calloc}, and @code{gawk_realloc()}. If the allocation fails, they cause @command{gawk} to exit with a fatal error message. They should be used as if they were procedure calls that do not return a value: @@ -32040,6 +32040,12 @@ strcpy(message, greet); make_malloced_string(message, strlen(message), & result); @end example +@item #define ezalloc(pointer, type, size, message) @dots{} +This is like @code{emalloc()}, but it calls @code{gawk_calloc()} +instead of @code{gawk_malloc()}. +The arguments are the same as for the @code{emalloc()} macro, but this +macro guarantees that the memory returned is initialized to zero. + @item #define erealloc(pointer, type, size, message) @dots{} This is like @code{emalloc()}, but it calls @code{gawk_realloc()} instead of @code{gawk_malloc()}. @@ -381,6 +381,7 @@ static struct optypetab { { "Op_K_else", "else" }, { "Op_K_function", "function" }, { "Op_cond_exp", NULL }, + { "Op_parens", NULL }, { "Op_final --- this should never appear", NULL }, { NULL, NULL }, }; @@ -1269,8 +1270,7 @@ setup_frame(INSTRUCTION *pc) sp = frame_ptr->stack; } else if (pcount > 0) { - emalloc(sp, NODE **, pcount * sizeof(NODE *), "setup_frame"); - memset(sp, 0, pcount * sizeof(NODE *)); + ezalloc(sp, NODE **, pcount * sizeof(NODE *), "setup_frame"); } diff --git a/extension/ChangeLog b/extension/ChangeLog index 7307a11a..7c8a828a 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,23 @@ +2017-06-22 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * rwarray.c (read_value): Use malloc instead of calloc, since + we immediately overwrite the buffer with data from the file. + * rwarray0.c (read_value): Ditto. + +2017-06-22 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * readfile.c (read_file_to_buffer): Use emalloc instead of ezalloc, + since there's no need to initialize the memory to zero before + overwriting it with the file's contents. + +2017-06-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * filefuncs.c (do_fts): Replace emalloc+memset with ezalloc. + * readfile.c (read_file_to_buffer): Ditto. + * rwarray.c (read_value): Replace gawk_malloc+memset with gawk_calloc. + * gawkfts.c (fts_open): Replace malloc+memset with calloc. + * rwarray0.c (read_value): Ditto. + 2017-04-16 Arnold D. Robbins <arnold@skeeve.com> * intdiv.c (func_table): Function is now named intdiv. diff --git a/extension/filefuncs.c b/extension/filefuncs.c index 394de504..9ca22de8 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -877,8 +877,7 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func *unused) /* make pathvector */ count = path_array->count + 1; - emalloc(pathvector, char **, count * sizeof(char *), "do_fts"); - memset(pathvector, 0, count * sizeof(char *)); + ezalloc(pathvector, char **, count * sizeof(char *), "do_fts"); /* fill it in */ count--; /* ignore final NULL at end of vector */ diff --git a/extension/gawkfts.c b/extension/gawkfts.c index 4a712153..d9edd87f 100644 --- a/extension/gawkfts.c +++ b/extension/gawkfts.c @@ -162,9 +162,8 @@ fts_open(char * const *argv, int options, } /* Allocate/initialize the stream */ - if ((sp = malloc((unsigned int)sizeof(FTS))) == NULL) + if ((sp = calloc(1, (unsigned int)sizeof(FTS))) == NULL) return (NULL); - memset(sp, 0, sizeof(FTS)); sp->fts_compar = compar; sp->fts_options = options; diff --git a/extension/readfile.c b/extension/readfile.c index fb1a376b..b600f27a 100644 --- a/extension/readfile.c +++ b/extension/readfile.c @@ -73,25 +73,22 @@ int plugin_is_GPL_compatible; static char * read_file_to_buffer(int fd, const struct stat *sbuf) { - char *text = NULL; - int ret; + char *text; if ((sbuf->st_mode & S_IFMT) != S_IFREG) { errno = EINVAL; update_ERRNO_int(errno); - goto done; + return NULL; } emalloc(text, char *, sbuf->st_size + 1, "do_readfile"); - memset(text, '\0', sbuf->st_size + 1); - if ((ret = read(fd, text, sbuf->st_size)) != sbuf->st_size) { + if (read(fd, text, sbuf->st_size) != sbuf->st_size) { update_ERRNO_int(errno); gawk_free(text); - text = NULL; - /* fall through to return */ + return NULL; } -done: + text[sbuf->st_size] = '\0'; return text; } diff --git a/extension/rwarray.c b/extension/rwarray.c index a7d752cf..53c908df 100644 --- a/extension/rwarray.c +++ b/extension/rwarray.c @@ -483,12 +483,12 @@ read_value(FILE *fp, awk_value_t *value) } value->str_value.len = len; value->str_value.str = gawk_malloc(len + 1); - memset(value->str_value.str, '\0', len + 1); if (fread(value->str_value.str, 1, len, fp) != (ssize_t) len) { gawk_free(value->str_value.str); return awk_false; } + value->str_value.str[len] = '\0'; } return awk_true; diff --git a/extension/rwarray0.c b/extension/rwarray0.c index faa73783..79dee79e 100644 --- a/extension/rwarray0.c +++ b/extension/rwarray0.c @@ -447,12 +447,12 @@ read_value(int fd, awk_value_t *value) value->val_type = AWK_STRING; value->str_value.len = len; value->str_value.str = malloc(len + 1); - memset(value->str_value.str, '\0', len + 1); if (read(fd, value->str_value.str, len) != (ssize_t) len) { free(value->str_value.str); return awk_false; } + value->str_value.str[len] = '\0'; } return awk_true; @@ -274,10 +274,8 @@ set_record(const char *buf, int cnt, const awk_fieldwidth_info_t *fw) /* buffer management: */ if (databuf_size == 0) { /* first time */ - emalloc(databuf, char *, INITIAL_SIZE, "set_record"); + ezalloc(databuf, char *, INITIAL_SIZE, "set_record"); databuf_size = INITIAL_SIZE; - memset(databuf, '\0', INITIAL_SIZE); - } /* * Make sure there's enough room. Since we sometimes need @@ -1174,9 +1174,8 @@ api_flatten_array_typed(awk_ext_id_t id, alloc_size = sizeof(awk_flat_array_t) + (array->table_size - 1) * sizeof(awk_element_t); - emalloc(*data, awk_flat_array_t *, alloc_size, + ezalloc(*data, awk_flat_array_t *, alloc_size, "api_flatten_array_typed"); - memset(*data, 0, alloc_size); list = assoc_list(array, "@unsorted", ASORTI); @@ -912,6 +912,12 @@ typedef struct gawk_api { fatal(ext_id, "%s: malloc of %d bytes failed\n", message, size); \ } while(0) +#define ezalloc(pointer, type, size, message) \ + do { \ + if ((pointer = (type) gawk_calloc(1, size)) == 0) \ + fatal(ext_id, "%s: calloc of %d bytes failed\n", message, size); \ + } while(0) + #define erealloc(pointer, type, size, message) \ do { \ if ((pointer = (type) gawk_realloc(pointer, size)) == 0) \ diff --git a/int_array.c b/int_array.c index 992da4a6..1c309cfd 100644 --- a/int_array.c +++ b/int_array.c @@ -458,8 +458,7 @@ int_copy(NODE *symbol, NODE *newsymb) cursize = symbol->array_size; /* allocate new table */ - emalloc(new, BUCKET **, cursize * sizeof(BUCKET *), "int_copy"); - memset(new, '\0', cursize * sizeof(BUCKET *)); + ezalloc(new, BUCKET **, cursize * sizeof(BUCKET *), "int_copy"); old = symbol->buckets; @@ -842,8 +841,7 @@ grow_int_table(NODE *symbol) } /* allocate new table */ - emalloc(new, BUCKET **, newsize * sizeof(BUCKET *), "grow_int_table"); - memset(new, '\0', newsize * sizeof(BUCKET *)); + ezalloc(new, BUCKET **, newsize * sizeof(BUCKET *), "grow_int_table"); old = symbol->buckets; symbol->buckets = new; diff --git a/interpret.h b/interpret.h index 13394e22..ec6a3dda 100644 --- a/interpret.h +++ b/interpret.h @@ -1437,6 +1437,7 @@ match_re: case Op_K_else: case Op_cond_exp: case Op_comment: + case Op_parens: break; default: @@ -2803,8 +2803,7 @@ init_awkpath(path_info *pi) max_path++; // +3 --> 2 for null entries at front and end of path, 1 for NULL end of list - emalloc(pi->awkpath, char **, (max_path + 3) * sizeof(char *), "init_awkpath"); - memset(pi->awkpath, 0, (max_path + 3) * sizeof(char *)); + ezalloc(pi->awkpath, char **, (max_path + 3) * sizeof(char *), "init_awkpath"); start = path; i = 0; @@ -3211,9 +3210,8 @@ iop_alloc(int fd, const char *name, int errno_val) { IOBUF *iop; - emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); + ezalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); - memset(iop, '\0', sizeof(IOBUF)); iop->public.fd = fd; iop->public.name = name; iop->public.read_func = ( ssize_t(*)() ) read; diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog index 83f5b93e..7d9bddc4 100644 --- a/missing_d/ChangeLog +++ b/missing_d/ChangeLog @@ -1,3 +1,7 @@ +2017-06-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * getaddrinfo.c (getaddrinfo): Replace malloc+memset with calloc. + 2016-10-23 Arnold D. Robbins <arnold@skeeve.com> * General: Remove trailing whitespace from all relevant files. diff --git a/missing_d/getaddrinfo.c b/missing_d/getaddrinfo.c index f24ac598..5233cf56 100644 --- a/missing_d/getaddrinfo.c +++ b/missing_d/getaddrinfo.c @@ -33,12 +33,11 @@ getaddrinfo(const char *hostname, const char *portname, if (res == NULL) return EINVAL; - out = (struct addrinfo *) malloc(sizeof(*out)); + out = (struct addrinfo *) calloc(1, sizeof(*out)); if (out == NULL) { *res = NULL; return ENOMEM; } - memset(out, '\0', sizeof(*out)); out->ai_addr = (struct sockaddr *) malloc(sizeof(struct sockaddr_in)); if (out->ai_addr == NULL) { @@ -720,8 +720,7 @@ str2wstr(NODE *n, size_t **ptr) * Create the array. */ if (ptr != NULL) { - emalloc(*ptr, size_t *, sizeof(size_t) * n->stlen, "str2wstr"); - memset(*ptr, 0, sizeof(size_t) * n->stlen); + ezalloc(*ptr, size_t *, sizeof(size_t) * n->stlen, "str2wstr"); } sp = n->stptr; diff --git a/old-extension/ChangeLog b/old-extension/ChangeLog index bd848f9a..99352c6e 100644 --- a/old-extension/ChangeLog +++ b/old-extension/ChangeLog @@ -1,3 +1,7 @@ +2017-06-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * bindarr.c (do_bind_array): Replace emalloc+memset with ezalloc. + 2016-10-23 Arnold D. Robbins <arnold@skeeve.com> * General: Remove trailing whitespace from all relevant files. diff --git a/old-extension/bindarr.c b/old-extension/bindarr.c index 1a0104db..34e7e983 100644 --- a/old-extension/bindarr.c +++ b/old-extension/bindarr.c @@ -209,8 +209,7 @@ do_bind_array(int nargs) assoc_clear(symbol); - emalloc(aq, array_t *, sizeof(array_t), "do_bind_array"); - memset(aq, '\0', sizeof(array_t)); + ezalloc(aq, array_t *, sizeof(array_t), "do_bind_array"); t = get_array_argument(1, false); @@ -427,6 +427,13 @@ cleanup: pp_push(pc->opcode, str, CAN_FREE); break; + case Op_parens: + t1 = pp_pop(); + str = pp_group3("(", t1->pp_str, ")"); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + case Op_plus: case Op_minus: case Op_times: @@ -546,7 +553,7 @@ cleanup: } else { t2 = pp_pop(); if (prec_level(t2->type) < prec_level(Op_in_array)) { - pp_parenthesize(t2); + pp_parenthesize(t2); } sub = t2->pp_str; str = pp_group3(sub, op2str(Op_in_array), array); @@ -1008,7 +1015,7 @@ cleanup: len = f->pp_len + t->pp_len + cond->pp_len + 12; emalloc(str, char *, len, "pprint"); - sprintf(str, "(%s ? %s : %s)", cond->pp_str, t->pp_str, f->pp_str); + sprintf(str, "%s ? %s : %s", cond->pp_str, t->pp_str, f->pp_str); pp_free(cond); pp_free(t); @@ -1363,6 +1370,9 @@ pp_parenthesize(NODE *sp) char *p = sp->pp_str; size_t len = sp->pp_len; + if (p[0] == '(') // already parenthesized + return; + emalloc(p, char *, len + 3, "pp_parenthesize"); *p = '('; memcpy(p + 1, sp->pp_str, len); @@ -1375,26 +1385,6 @@ pp_parenthesize(NODE *sp) sp->flags |= CAN_FREE; } -/* div_on_left_mul_on_right --- have / or % on left and * on right */ - -static bool -div_on_left_mul_on_right(int o1, int o2) -{ - OPCODE op1 = (OPCODE) o1; - OPCODE op2 = (OPCODE) o2; - - switch (op1) { - case Op_quotient: - case Op_quotient_i: - case Op_mod: - case Op_mod_i: - return (op2 == Op_times || op2 == Op_times_i); - - default: - return false; - } -} - /* parenthesize --- parenthesize two nodes relative to parent node type */ static void @@ -1404,11 +1394,9 @@ parenthesize(int type, NODE *left, NODE *right) int lprec = prec_level(left->type); int prec = prec_level(type); - if (lprec < prec - || (lprec == prec && div_on_left_mul_on_right(left->type, type))) + if (lprec < prec) pp_parenthesize(left); - if (rprec < prec - || (rprec == prec && div_on_left_mul_on_right(type, right->type))) + if (rprec < prec) pp_parenthesize(right); } @@ -1643,22 +1631,27 @@ pp_concat(int nargs) for (i = 1; i < nargs; i++) { r = pp_args[i]; - pl_l = prec_level(pp_args[i]->type); - pl_r = prec_level(pp_args[i+1]->type); - - if (i >= 2 && is_unary_minus(r->pp_str)) { - *s++ = '('; - memcpy(s, r->pp_str, r->pp_len); - s += r->pp_len; - *s++ = ')'; - } else if (is_scalar(pp_args[i]->type) && is_scalar(pp_args[i+1]->type)) { - memcpy(s, r->pp_str, r->pp_len); - s += r->pp_len; - } else if (pl_l <= pl_r || is_scalar(pp_args[i+1]->type)) { - *s++ = '('; - memcpy(s, r->pp_str, r->pp_len); - s += r->pp_len; - *s++ = ')'; + if (r->pp_str[0] != '(') { + pl_l = prec_level(pp_args[i]->type); + pl_r = prec_level(pp_args[i+1]->type); + + if (i >= 2 && is_unary_minus(r->pp_str)) { + *s++ = '('; + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + *s++ = ')'; + } else if (is_scalar(pp_args[i]->type) && is_scalar(pp_args[i+1]->type)) { + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + } else if (pl_l <= pl_r || is_scalar(pp_args[i+1]->type)) { + *s++ = '('; + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + *s++ = ')'; + } else { + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + } } else { memcpy(s, r->pp_str, r->pp_len); s += r->pp_len; @@ -1673,7 +1666,10 @@ pp_concat(int nargs) pl_l = prec_level(pp_args[nargs-1]->type); pl_r = prec_level(pp_args[nargs]->type); r = pp_args[nargs]; - if (is_unary_minus(r->pp_str) || ((pl_l >= pl_r && ! is_scalar(pp_args[nargs]->type)))) { + if (r->pp_str[0] == '(') { + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + } else if (is_unary_minus(r->pp_str) || ((pl_l >= pl_r && ! is_scalar(pp_args[nargs]->type)))) { *s++ = '('; memcpy(s, r->pp_str, r->pp_len); s += r->pp_len; @@ -168,8 +168,7 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) *dest = '\0'; len = dest - buf; - emalloc(rp, Regexp *, sizeof(*rp), "make_regexp"); - memset((char *) rp, 0, sizeof(*rp)); + ezalloc(rp, Regexp *, sizeof(*rp), "make_regexp"); rp->pat.allocated = 0; /* regex will allocate the buffer */ emalloc(rp->pat.fastmap, char *, 256, "make_regexp"); diff --git a/str_array.c b/str_array.c index fe07ce4b..0f75b300 100644 --- a/str_array.c +++ b/str_array.c @@ -325,8 +325,7 @@ str_copy(NODE *symbol, NODE *newsymb) cursize = symbol->array_size; /* allocate new table */ - emalloc(new, BUCKET **, cursize * sizeof(BUCKET *), "str_copy"); - memset(new, '\0', cursize * sizeof(BUCKET *)); + ezalloc(new, BUCKET **, cursize * sizeof(BUCKET *), "str_copy"); old = symbol->buckets; @@ -666,8 +665,7 @@ grow_table(NODE *symbol) } /* allocate new table */ - emalloc(new, BUCKET **, newsize * sizeof(BUCKET *), "grow_table"); - memset(new, '\0', newsize * sizeof(BUCKET *)); + ezalloc(new, BUCKET **, newsize * sizeof(BUCKET *), "grow_table"); old = symbol->buckets; symbol->buckets = new; diff --git a/support/ChangeLog b/support/ChangeLog index 54756048..ec54675a 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,8 @@ +2017-06-22 Arnold D. Robbins <arnold@skeeve.com> + + * regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, + regexec.c: Sync with GLIBC. + 2017-06-18 Arnold D. Robbins <arnold@skeeve.com> * intprops.h: Sync with GNULIB. diff --git a/support/regcomp.c b/support/regcomp.c index 5ac53701..c45e91fc 100644 --- a/support/regcomp.c +++ b/support/regcomp.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -961,8 +961,9 @@ static void internal_function init_word_char (re_dfa_t *dfa) { - int i, j, ch; dfa->word_ops_used = 1; + int i = 0; + int ch = 0; #ifndef GAWK if (BE (dfa->map_notascii == 0, 1)) { @@ -996,8 +997,8 @@ init_word_char (re_dfa_t *dfa) } #endif - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + for (; i < BITSET_WORDS; ++i) + for (int j = 0; j < BITSET_WORD_BITS; ++j, ++ch) if (isalnum (ch) || ch == '_') dfa->word_char[i] |= (bitset_word_t) 1 << j; } diff --git a/support/regex.c b/support/regex.c index 9f133fab..d3a44851 100644 --- a/support/regex.c +++ b/support/regex.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. diff --git a/support/regex.h b/support/regex.h index 143b3afa..adddd9ee 100644 --- a/support/regex.h +++ b/support/regex.h @@ -1,6 +1,6 @@ /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985, 1989-2016 Free Software Foundation, Inc. + Copyright (C) 1985, 1989-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or diff --git a/support/regex_internal.c b/support/regex_internal.c index 18641ef1..2b3120c2 100644 --- a/support/regex_internal.c +++ b/support/regex_internal.c @@ -840,7 +840,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags) } static unsigned char -internal_function __attribute__ ((__pure__)) +internal_function __attribute ((pure)) re_string_peek_byte_case (const re_string_t *pstr, int idx) { int ch, off; @@ -1372,7 +1372,7 @@ re_node_set_insert_last (re_node_set *set, int elem) return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */ static int -internal_function __attribute__ ((__pure__)) +internal_function __attribute ((pure)) re_node_set_compare (const re_node_set *set1, const re_node_set *set2) { int i; @@ -1387,7 +1387,7 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2) /* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ static int -internal_function __attribute__ ((__pure__)) +internal_function __attribute ((pure)) re_node_set_contains (const re_node_set *set, int elem) { unsigned int idx, right, mid; diff --git a/support/regex_internal.h b/support/regex_internal.h index 01465e76..9f4ff070 100644 --- a/support/regex_internal.h +++ b/support/regex_internal.h @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -44,9 +44,6 @@ #if defined HAVE_STDINT_H || defined _LIBC # include <stdint.h> #endif /* HAVE_STDINT_H || _LIBC */ - -#include "intprops.h" - #if defined _LIBC # include <libc-lock.h> #else diff --git a/support/regexec.c b/support/regexec.c index c8f11e52..14813596 100644 --- a/support/regexec.c +++ b/support/regexec.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -55,7 +55,8 @@ static int re_search_stub (struct re_pattern_buffer *bufp, int ret_len) internal_function; static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs, int regs_allocated) internal_function; -static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx); +static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) + internal_function; static int check_matching (re_match_context_t *mctx, int fl_longest_match, int *p_match_first) internal_function; static int check_halt_state_context (const re_match_context_t *mctx, @@ -362,12 +363,10 @@ re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1, { const char *str; int rval; - int len; + int len = length1 + length2; char *s = NULL; - if (BE ((length1 < 0 || length2 < 0 || stop < 0 - || INT_ADD_WRAPV (length1, length2, &len)), - 0)) + if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) return -2; /* Concatenate the strings. */ @@ -939,6 +938,7 @@ re_search_internal (const regex_t *preg, const char *string, int length, } static reg_errcode_t +internal_function __attribute_warn_unused_result__ prune_impossible_nodes (re_match_context_t *mctx) { const re_dfa_t *const dfa = mctx->dfa; @@ -1034,7 +1034,7 @@ prune_impossible_nodes (re_match_context_t *mctx) since initial states may have constraints like "\<", "^", etc.. */ static inline re_dfastate_t * -__attribute__ ((always_inline)) internal_function +__attribute ((always_inline)) internal_function acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, int idx) { @@ -2395,7 +2395,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, /* Skip bytes in the input that correspond to part of a multi-byte match, then look in the log for a state from which to restart matching. */ -static re_dfastate_t * +re_dfastate_t * internal_function find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) { @@ -133,8 +133,7 @@ make_params(char **pnames, int pcount) if (pcount <= 0 || pnames == NULL) return NULL; - emalloc(parms, NODE *, pcount * sizeof(NODE), "make_params"); - memset(parms, '\0', pcount * sizeof(NODE)); + ezalloc(parms, NODE *, pcount * sizeof(NODE), "make_params"); for (i = 0, p = parms; i < pcount; i++, p++) { p->type = Node_param_list; @@ -759,8 +758,7 @@ new_context() { AWK_CONTEXT *ctxt; - emalloc(ctxt, AWK_CONTEXT *, sizeof(AWK_CONTEXT), "new_context"); - memset(ctxt, 0, sizeof(AWK_CONTEXT)); + ezalloc(ctxt, AWK_CONTEXT *, sizeof(AWK_CONTEXT), "new_context"); ctxt->srcfiles.next = ctxt->srcfiles.prev = & ctxt->srcfiles; ctxt->rule_list.opcode = Op_list; ctxt->rule_list.lasti = & ctxt->rule_list; diff --git a/test/ChangeLog b/test/ChangeLog index 4cd0322f..a1d1fd4c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2017-06-22 Arnold D. Robbins <arnold@skeeve.com> + + * profile4.ok, profile5.ok, profile7.ok: Updated after code changes. + * profile7.awk: Added two more statements. + 2017-06-18 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (mbprintf5): New test. diff --git a/test/profile4.ok b/test/profile4.ok index 9d2b9430..06b31bc1 100644 --- a/test/profile4.ok +++ b/test/profile4.ok @@ -1,9 +1,9 @@ BEGIN { - a = "foo" (c = "bar") + a = ("foo" (c = "bar")) a = (b - c) "foo" a = "foo" (b - c) q = (d = "x") (e = "y") - a = (c = tolower("FOO")) in JUNK - x = y == 0 && z == 2 && q == 45 + a = ((c = tolower("FOO")) in JUNK) + x = (y == 0 && z == 2 && q == 45) } diff --git a/test/profile5.ok b/test/profile5.ok index 0fb8589e..c8abf1fb 100644 --- a/test/profile5.ok +++ b/test/profile5.ok @@ -103,7 +103,7 @@ BEGIN { #___________________________________________________________________________________ BEGIN { _SYS_STDCON = "CON" - _CON_WIDTH = (match(_cmd("MODE " _SYS_STDCON " 2>NUL"), /Columns:[ \t]*([0-9]+)/, A) ? strtonum(A[1]) : 80) + _CON_WIDTH = match(_cmd("MODE " _SYS_STDCON " 2>NUL"), /Columns:[ \t]*([0-9]+)/, A) ? strtonum(A[1]) : 80 } BEGIN { @@ -286,7 +286,7 @@ BEGIN { a = ENVIRON["EGAWK_CMDLINE"] gsub(/^[ \t]*/, "", a) a = _lib_CMDLN(a) - if (a != "" && ! _LIBAPI["F"]["!"]) { + if ((a != "") && (! _LIBAPI["F"]["!"])) { _out(_lib_HELP()) _fatal("Bad comandline argument `" a "'") } @@ -733,7 +733,7 @@ function _BASE(c, t, P, A) return _endpass(_basexit_fl = 1) } if (_cmdln_version) { - _out(_ln(_PRODUCT_NAME " v" _PRODUCT_VERSION) _ln(_PRODUCT_COPYRIGHT) _ln() ((_cmdln_version == "v" ? "" : _lib_NAMEVER()))) + _out(_ln(_PRODUCT_NAME " v" _PRODUCT_VERSION) _ln(_PRODUCT_COPYRIGHT) _ln() (_cmdln_version == "v" ? "" : _lib_NAMEVER())) return _endpass(_basexit_fl = 1) } return @@ -826,7 +826,7 @@ function _ERRLOG(c, t, P, a, b, A) } } if (_ERRLOG_IF) { - _info("Log-message types inherited acc/deny: " "TRACE " ((_ERRLOG_TF ? "ON" : "OFF")) "/" "VERBOSE " ((_ERRLOG_VF ? "ON" : "OFF")) "/" "INFO " ((_ERRLOG_IF ? "ON" : "OFF")) "/" "WARNING " ((_ERRLOG_WF ? "ON" : "OFF")) "/" "ERROR " ((_ERRLOG_EF ? "ON" : "OFF")) "/" "FATAL " ((_ERRLOG_FF ? "ON" : "OFF"))) + _info("Log-message types inherited acc/deny: " "TRACE " (_ERRLOG_TF ? "ON" : "OFF") "/" "VERBOSE " (_ERRLOG_VF ? "ON" : "OFF") "/" "INFO " (_ERRLOG_IF ? "ON" : "OFF") "/" "WARNING " (_ERRLOG_WF ? "ON" : "OFF") "/" "ERROR " (_ERRLOG_EF ? "ON" : "OFF") "/" "FATAL " (_ERRLOG_FF ? "ON" : "OFF")) } } return @@ -1118,7 +1118,7 @@ function _START(t, i, A) _defile(p, "config.dll", "config.dll", "") _defsrv(p, "DS Plug-in Service", "Altiris Deployment Solution - System Configuration") _defreg(p, "Deployment Agent Path", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Altiris\\Deployment\\AgentInstallPath.STR") - _defile(p, "Altiris_DeploymentSolutionAgent_7_1_x86.msi", (_SYS["OSArchitecture"] == "64-bit" ? "C:\\Program Files\\Altiris\\Altiris Agent\\Agents\\SoftwareManagement\\Software Delivery\\{9D76E4CA-377A-472D-A82E-EDAD77E7E4ED}\\cache\\Altiris_DeploymentSolutionAgent_7_1_x64.msi" : "C:\\Program Files\\Altiris\\Altiris Agent\\Agents\\SoftwareManagement\\Software Delivery\\{4B747D25-612F-48FC-B6B5-9916D1BB755C}\\cache\\Altiris_DeploymentSolutionAgent_7_1_x86.msi"), "") + _defile(p, "Altiris_DeploymentSolutionAgent_7_1_x86.msi", _SYS["OSArchitecture"] == "64-bit" ? "C:\\Program Files\\Altiris\\Altiris Agent\\Agents\\SoftwareManagement\\Software Delivery\\{9D76E4CA-377A-472D-A82E-EDAD77E7E4ED}\\cache\\Altiris_DeploymentSolutionAgent_7_1_x64.msi" : "C:\\Program Files\\Altiris\\Altiris Agent\\Agents\\SoftwareManagement\\Software Delivery\\{4B747D25-612F-48FC-B6B5-9916D1BB755C}\\cache\\Altiris_DeploymentSolutionAgent_7_1_x86.msi", "") _defdir(p, "Deployment Folder", a = gensub(/[^\\]*$/, "", 1, _rdsafe(_REG, "HKEY_LOCAL_MACHINE\\SOFTWARE\\Altiris\\Deployment\\AgentInstallPath.STR", "C:\\Program Files\\Altiris\\Altiris Agent\\Agents\\Deployment\\Agent\\"))) #___________________________________________________________________________________ p = _defsolution(pp, "DS Auto", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Altiris\\Altiris Agent\\Plugin Objects\\Agents\\") @@ -1191,7 +1191,7 @@ function _Zexparr(S, s, t, i) t = "" if (isarray(S)) { for (i in S) { - t = t ((isarray(S[i]) ? _Zexparr_i1(i) "\020" _Zexparr_i0(S[i]) "\021\021\020" : _Zexparr_i2(_Zexparr_i3(i) "\021" _Zexparr_i3(S[i])) "\020")) + t = t (isarray(S[i]) ? (_Zexparr_i1(i) "\020" _Zexparr_i0(S[i]) "\021\021\020") : (_Zexparr_i2(_Zexparr_i3(i) "\021" _Zexparr_i3(S[i])) "\020")) } } if (s != "") { @@ -1207,7 +1207,7 @@ function _Zexparr(S, s, t, i) function _Zexparr_i0(S, t, i) { for (i in S) { - t = t ((isarray(S[i]) ? _Zexparr_i1(i) "\020" _Zexparr_i0(S[i]) "\021\021\020" : _Zexparr_i2(_Zexparr_i3(i) "\021" _Zexparr_i3(S[i])) "\020")) + t = t (isarray(S[i]) ? (_Zexparr_i1(i) "\020" _Zexparr_i0(S[i]) "\021\021\020") : (_Zexparr_i2(_Zexparr_i3(i) "\021" _Zexparr_i3(S[i])) "\020")) } return t } @@ -1252,7 +1252,7 @@ function _Zimparr(D, t, A, B) #_________________________________________________________________ function _Zimparr_i0(A, B, i) { - return ((i in A ? A[i] B[i] _Zimparr_i0(A, B, i + 1) : "")) + return (i in A ? (A[i] B[i] _Zimparr_i0(A, B, i + 1)) : "") } #_________________________________________________________________ @@ -1453,7 +1453,7 @@ function _addf(A, f) function _addfile(f, d, a, b) { ################################## - if ((f = _wfilerdnehnd(f)) == "" || _filene(f) == "") { + if (((f = _wfilerdnehnd(f)) == "") || (_filene(f) == "")) { ERRNO = "Filename error" return } @@ -1497,7 +1497,7 @@ function _addlist(A, v) function _bearray(A) { #_______________________________________________________________________ - if (isarray(A) || A == 0 && A == "") { + if (isarray(A) || (A == 0 && A == "")) { return 1 #################################################### } } @@ -1512,7 +1512,7 @@ function _bframe(A, t, p) #___________________________________________________________ function _bframe_i0(A, t, p, f) { - return ((f ? _bframe_i0(A, t, p, A[f]) (@f(t, p)) : "")) + return (f ? (_bframe_i0(A, t, p, A[f]) (@f(t, p))) : "") } # add to _dumparr: checking that if element is undefined @@ -1547,8 +1547,8 @@ function _cfguid(p, optr, pfx, sfx, hstrcnt, lstrchr) _UIDOBL[p] = _UIDOBL[optr] } } - _UIDPFX[p] = (_istr(pfx) ? pfx : "") - _UIDSFX[p] = (_istr(sfx) ? sfx : "") + _UIDPFX[p] = _istr(pfx) ? pfx : "" + _UIDSFX[p] = _istr(sfx) ? sfx : "" if (_isptr(hstrcnt)) { if (hstrcnt != p) { _UIDCHR[p] = _UIDCHR[_UIDCNT[p] = _UIDCNT[hstrcnt]] @@ -1615,7 +1615,7 @@ function _check(p) function _chrline(t, ts, w, s) { ############################################# - return ((t = " " _tabtospc(t, ts) ((t ? (t ~ /[ \t]$/ ? "" : " ") : ""))) _getchrln((s ? s : "_"), ((w ? w : _CON_WIDTH - 1)) - length(t)) _CHR["EOL"]) + return (t = " " _tabtospc(t, ts) (t ? t ~ /[ \t]$/ ? "" : " " : "")) _getchrln(s ? s : "_", (w ? w : _CON_WIDTH - 1) - length(t)) _CHR["EOL"] } #_____________________________________________________________________________ @@ -1674,23 +1674,23 @@ function _con(t, ts, a, b, c, d, i, r, A, B) if ((i = length(t = _tabtospc(A[1], ts, _conlastrln))) < _constatstrln) { t = t _getchrln(" ", _constatstrln - i) } - print(t B[1]) > _SYS_STDCON + print((t B[1])) > _SYS_STDCON for (i = 2; i < c; i++) { - print(_tabtospc(A[i], ts) B[i]) > _SYS_STDCON + print((_tabtospc(A[i], ts) B[i])) > _SYS_STDCON } - print(_conlastr = _tabtospc(A[c], ts)) > _SYS_STDCON + print((_conlastr = _tabtospc(A[c], ts))) > _SYS_STDCON fflush(_SYS_STDCON) } else { - print(t = _tabtospc(t, ts, _conlastrln)) > _SYS_STDCON + print((t = _tabtospc(t, ts, _conlastrln))) > _SYS_STDCON fflush(_SYS_STDCON) _conlastr = _conlastr t } if ((i = length(_conlastr)) >= _CON_WIDTH) { - _conlastr = substr(_conlastr, 1 + int(i / _CON_WIDTH) * _CON_WIDTH) + _conlastr = substr(_conlastr, 1 + (int(i / _CON_WIDTH) * _CON_WIDTH)) } _conlastrln = length(_conlastr) if (_constatstr) { - print((t = _constatgtstr(_constatstr, _CON_WIDTH - 1 - _conlastrln)) _CHR["CR"] _conlastr) > _SYS_STDCON + print(((t = _constatgtstr(_constatstr, _CON_WIDTH - 1 - _conlastrln)) _CHR["CR"] _conlastr)) > _SYS_STDCON fflush(_SYS_STDCON) _constatstrln = length(t) } @@ -1728,7 +1728,7 @@ function _conin(t, a, b) function _conl(t, ts) { #################################################### - return _con(t ((t ~ /\x0A$/ ? "" : _CHR["EOL"])), ts) + return _con(t (t ~ /\x0A$/ ? "" : _CHR["EOL"]), ts) } #_______________________________________________________________________ @@ -1757,7 +1757,7 @@ function _constat(t, ts, ln, a) a = BINMODE BINMODE = "rw" ORS = "" - print(t _CHR["CR"] _conlastr) > _SYS_STDCON + print((t _CHR["CR"] _conlastr)) > _SYS_STDCON fflush(_SYS_STDCON) ORS = ln BINMODE = a @@ -1806,7 +1806,7 @@ function _constatpush(t, ts) #___________________________________________________________________________________ function _creport(p, t, f, z) { - _[p]["REPORT"] = _[p]["REPORT"] _ln(t ((f == "" ? "" : ": " f))) + _[p]["REPORT"] = _[p]["REPORT"] _ln(t (f == "" ? "" : ": " f)) } #_________________________________________________________________________________________ @@ -1909,7 +1909,7 @@ function _del(f, c, a, A) { ################################################# if (match(f, /\\[ \t]*$/)) { - if ((c = toupper(_filerd(f))) && length(f) == FLENGTH) { + if ((c = toupper(_filerd(f))) && (length(f) == FLENGTH)) { _cmd("rd " c " /S /Q 2>NUL") _deletepfx(_WFILEROOTDIR, c) _deletepfx(_FILEIO_RDTMP, c) @@ -1996,7 +1996,7 @@ function _dir(A, rd, i, r, f, ds, pf, B, C) return "" } i = split(_cmd("dir \"" rd "\" 2>NUL"), B, /\x0D?\x0A/) - 3 - pf = (match(B[4], /Directory of ([^\x00-\x1F]+)/, C) ? C[1] ((C[1] ~ /\\$/ ? "" : "\\")) : "") + pf = (match(B[4], /Directory of ([^\x00-\x1F]+)/, C) ? (C[1] (C[1] ~ /\\$/ ? "" : "\\")) : "") for (r = 0; i > 5; i--) { if (match(B[i], /^([^ \t]*)[ \t]+([^ \t]*)[ \t]+((<DIR>)|([0-9\,]+))[ \t]+([^\x00-\x1F]+)$/, C)) { if (C[6] !~ /^\.\.?$/) { @@ -2006,7 +2006,7 @@ function _dir(A, rd, i, r, f, ds, pf, B, C) ds = C[5] " " gsub(/\,/, "", ds) } - if ((f = _filepath(pf C[6] ((C[4] ? "\\" : "")))) != "") { + if ((f = _filepath(pf C[6] (C[4] ? "\\" : ""))) != "") { A[f] = ds C[1] " " C[2] r++ } @@ -2142,13 +2142,13 @@ function _dllerr(p, t, f) t = "ERROR: \000" t } _errfl = 1 - _[p]["ERROR"] = _[p]["ERROR"] _ln(t ((f == "" ? "" : ": " f))) + _[p]["ERROR"] = _[p]["ERROR"] _ln(t (f == "" ? "" : ": " f)) } function _drawuid(p, cn, ch, o) { _conl("uid: " p) - _conl("\toblptr: " ((p in _UIDOBL ? _UIDOBL[p] "'" : "-"))) + _conl("\toblptr: " (p in _UIDOBL ? _UIDOBL[p] "'" : "-")) if (p in _UIDOBL) { if (! _isptr(o = _UIDOBL[p])) { _conl(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> oblptr not pointer") @@ -2157,14 +2157,14 @@ function _drawuid(p, cn, ch, o) _conl(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> no OBLV array at ptr") } } - _conl("\tprefix: " ((p in _UIDPFX ? _UIDPFX[p] "'" : "-"))) - _conl("\tsuffix: " ((p in _UIDSFX ? _UIDSFX[p] "'" : "-"))) - _conl("\tcounters: " (cn = (p in _UIDCNT ? _UIDCNT[p] "'" : "-"))) + _conl("\tprefix: " (p in _UIDPFX ? _UIDPFX[p] "'" : "-")) + _conl("\tsuffix: " (p in _UIDSFX ? _UIDSFX[p] "'" : "-")) + _conl("\tcounters: " (cn = p in _UIDCNT ? _UIDCNT[p] "'" : "-")) if (cn != "-") { _conl("\t\tcntrL: " _UIDCNTL[_UIDCNT[p]] "'") _conl("\t\tcntrH: " _UIDCNTH[_UIDCNT[p]] "'") } - _conl("\tcharset: " (ch = (p in _UIDCHR ? _UIDCHR[p] "'" : "-"))) + _conl("\tcharset: " (ch = p in _UIDCHR ? _UIDCHR[p] "'" : "-")) if (ch != "-") { _conl("chrH: ") _conl(_dumparr(_UIDCHRH[_UIDCHR[p]])) @@ -2184,7 +2184,7 @@ function _dumparr(A, t, lv, a) if (isarray(A)) { delete _DUMPARR _dumparrc = _dumparrd = "" - _dumparr_i1(A, lv = ((lv == "" ? 16 : (lv == 0 || lv + 0 != 0 ? lv : (lv == "-*" ? -3 : (lv ~ /^\+?\*$/ ? 3 : 16))))) + 0, (lv < 0 ? -1 : 1), 0, _tabtospc(t)) + _dumparr_i1(A, lv = (lv == "" ? 16 : lv == 0 || (lv + 0) != 0 ? lv : lv == "-*" ? -3 : lv ~ /^\+?\*$/ ? 3 : 16) + 0, lv < 0 ? -1 : 1, 0, _tabtospc(t)) PROCINFO["sorted_in"] = a return _retarrd(_DUMPARR, _dumparrd, _dumparrd = "") } @@ -2201,10 +2201,10 @@ function _dumparr_i1(A, lv, ls, ln, t, t2, i, a, f) } } else { for (i in A) { - (isarray(A[i]) ? ++a : "") + isarray(A[i]) ? ++a : "" } } - if (length(_dumparrd = _dumparrd t ((a > 0 ? " ... (x" a ")" : "")) _CHR["EOL"]) > 262144) { + if (length(_dumparrd = _dumparrd t (a > 0 ? " ... (x" a ")" : "") _CHR["EOL"]) > 262144) { _DUMPARR[++_dumparrc] = _dumparrd _dumparrd = "" } @@ -2213,7 +2213,7 @@ function _dumparr_i1(A, lv, ls, ln, t, t2, i, a, f) if (ls >= 0) { for (i in A) { if (! isarray(A[i])) { - if (length(_dumparrd = _dumparrd ((f ? t2 : t _nop(f = 1))) "[" i "]=" A[i] "'" _CHR["EOL"]) > 262144) { + if (length(_dumparrd = _dumparrd (f ? t2 : t _nop(f = 1)) "[" i "]=" A[i] "'" _CHR["EOL"]) > 262144) { _DUMPARR[++_dumparrc] = _dumparrd _dumparrd = "" } @@ -2222,7 +2222,7 @@ function _dumparr_i1(A, lv, ls, ln, t, t2, i, a, f) } for (i in A) { if (isarray(A[i])) { - _dumparr_i1(A[i], lv, ls, ln + ls, _th0((f ? t2 : t), f = 1) "[" i "]") + _dumparr_i1(A[i], lv, ls, ln + ls, _th0(f ? t2 : t, f = 1) "[" i "]") } } if (! f) { @@ -2245,8 +2245,8 @@ function _dumpobj(p, f, t, s) { ################################################### s = _dumpobj_i0(p, f, t = t "." p "{") - if (p = _rFCHLD(p)) { - return (s = s _dumpobjm(p, f, (s ? _getchrln(" ", length(t) - 1) : t " "))) + if ((p = _rFCHLD(p))) { + return (s = s _dumpobjm(p, f, s ? _getchrln(" ", length(t) - 1) : t " ")) } return s } @@ -2266,7 +2266,7 @@ function _dumpobj_i0(p, f, t) #___________________________________________________________ function _dumpobj_i1(p, t) { - return _ln(t substr(((p in _tPREV ? "\253" _tPREV[p] : "")) " ", 1, 7) " " substr(((p in _tPARENT ? "\210" _tPARENT[p] : "")) " ", 1, 7) " " substr(((p in _tFCHLD ? _tFCHLD[p] : "")) "\205" ((p in _tQCHLD ? " (" _tQCHLD[p] ") " : "\205")) "\205" ((p in _tLCHLD ? _tLCHLD[p] : "")) " ", 1, 22) substr(((p in _tNEXT ? "\273" _tNEXT[p] : "")) " ", 1, 8)) + return _ln(t substr(((p in _tPREV) ? "\253" _tPREV[p] : "") " ", 1, 7) " " substr(((p in _tPARENT) ? "\210" _tPARENT[p] : "") " ", 1, 7) " " substr(((p in _tFCHLD) ? _tFCHLD[p] : "") "\205" ((p in _tQCHLD) ? " (" _tQCHLD[p] ") " : "\205") "\205" ((p in _tLCHLD) ? _tLCHLD[p] : "") " ", 1, 22) substr(((p in _tNEXT) ? "\273" _tNEXT[p] : "") " ", 1, 8)) } #___________________________________________________________ @@ -2291,7 +2291,7 @@ function _dumpobj_i3(A, t, p, e, s, i, t2) } return s } - return ((e == "" ? "" : t e)) + return (e == "" ? "" : t e) } if (A == 0 && A == "") { return @@ -2323,7 +2323,7 @@ function _dumpobjm(p, f, t, s, t2) do { s = s _dumpobj(p, f, t) t = t2 - } while (p = _rNEXT(p)) + } while ((p = _rNEXT(p))) return s } @@ -2335,13 +2335,13 @@ function _dumpobjm_nc(p, f, t, s, t2) do { s = s _dumpobj_nc(p, f, t) t = t2 - } while (p = _rNEXT(p)) + } while ((p = _rNEXT(p))) return s } function _dumpuidgen(p, pd, pc, ps) { - _conline("#" ++cntdm ": " p "'") + _conline("#" (++cntdm) ": " p "'") _conl() if (p in _tuidel) { _conl("DEL: " _var(pd = _tuidel[p])) @@ -2349,13 +2349,13 @@ function _dumpuidgen(p, pd, pc, ps) } _conl("PFX: " _tUIDPFX[p] "'") _conl("SFX: " _tUIDSFX[p] "'") - _conl("COUNT: " ((p in _tuidcnt ? (pc = _tuidcnt[p]) "'" : _th0("-", pc = -2)))) + _conl("COUNT: " (p in _tuidcnt ? (pc = _tuidcnt[p]) "'" : _th0("-", pc = -2))) _con("CHARS: ") if (p in _tuidchr) { _conl((ps = _tuidchr[p]) "'") - _conl("HCHR: " ((pc == -2 ? "-" : _tUIDCNTH[pc] "'"))) + _conl("HCHR: " (pc == -2 ? "-" : _tUIDCNTH[pc] "'")) _conl(_dumparr(_tUIDCHRH[ps]) _ln()) - _conl("LCHR: " ((pc == -2 ? "-" : _tUIDCNTL[pc] "'"))) + _conl("LCHR: " (pc == -2 ? "-" : _tUIDCNTL[pc] "'")) _conl(_dumparr(_tUIDCHRL[ps]) _ln()) } else { _conl("-") @@ -2365,7 +2365,7 @@ function _dumpuidgen(p, pd, pc, ps) #_____________________________________________________________________________ function _dumpval(v, n) { - _dumpstr = _dumpstr (v = _ln(((n == 0 && n == "" ? "RET" : n)) ": " ((v == 0 && v == "" ? "-" : v "'")))) + _dumpstr = _dumpstr (v = _ln((n == 0 && n == "" ? "RET" : n) ": " (v == 0 && v == "" ? "-" : v "'"))) return v } @@ -2418,7 +2418,7 @@ function _err(t, a, b) function _errnl(t) { ################################################ - return _err(t ((t ~ /\x0A$/ ? "" : _CHR["EOL"]))) + return _err(t (t ~ /\x0A$/ ? "" : _CHR["EOL"])) } #_______________________________________________________________________ @@ -2459,7 +2459,7 @@ function _expout(t, d, a, b) b = ORS BINMODE = "rw" ORS = "" - print(t) > ((d ? d : d = _errlog_file)) + print(t) > (d ? d : (d = _errlog_file)) fflush(d) BINMODE = a ORS = b @@ -2481,7 +2481,7 @@ function _faccl_i0(A, t, p, P, f, r) { f = r = "" if (isarray(A)) { - while (f = A[f]) { + while ((f = A[f])) { r = (@f(t, p, P)) r } } @@ -2492,7 +2492,7 @@ function _faccr_i0(A, t, p, P, f, r) { f = r = "" if (isarray(A)) { - while (f = A[f]) { + while ((f = A[f])) { r = r @f(t, p, P) } } @@ -2543,7 +2543,7 @@ function _fframe(A, t, p) #___________________________________________________________ function _fframe_i0(A, t, p, f) { - return ((f ? (@f(t, p)) _fframe_i0(A, t, p, A[f]) : "")) + return (f ? ((@f(t, p)) _fframe_i0(A, t, p, A[f])) : "") } #_________________________________________________________________ @@ -2553,7 +2553,7 @@ function _file(f) if ((f = _filerdnehnd(f)) == "") { return "" } - return ((f in _FILEXT ? _FILEXT[f] : "")) + return (f in _FILEXT ? _FILEXT[f] : "") } #_______________________________________________________________________ @@ -2569,7 +2569,7 @@ function _file_check_i0(p, pp, p1, p2, f, v) { if (_[p]["TYPE"] == "defile") { f = _[p]["FILE"] - f = ((match(f, /^.:/) ? "" : _[_[pp]["AGENT"]][".Install Path"] "\\")) _[p]["FILE"] + f = (match(f, /^.:/) ? "" : _[_[pp]["AGENT"]][".Install Path"] "\\") _[p]["FILE"] if ("RQVERSION" in _[p]) { v = _[p]["RQVERSION"] } else { @@ -2583,7 +2583,7 @@ function _file_check_i0(p, pp, p1, p2, f, v) if (v != "" && v != (_[p]["VERSION"] = _getfilever(f))) { return _dllerr(p, " file version mismatch: ==`" _[p]["VERSION"] "'; !=`" v "'", f) } - _creport(p, substr("OK: FILE DETECTED" ((v == "" ? "" : "(" v ")")) ": " f, 1, 122)) + _creport(p, substr("OK: FILE DETECTED" (v == "" ? "" : "(" v ")") ": " f, 1, 122)) } else if (_[p]["TYPE"] == "defdir") { if (_filexist(f = _[p]["DIR"])) { _creport(p, substr("OK: DIR DETECTED: " f, 1, 112)) @@ -2604,12 +2604,12 @@ function _filed(f, dd, d) return _FILEDIR[f] } if (f in _FILEROOT) { - if (d = filegetdrvdir(_FILEROOT[f])) { + if ((d = filegetdrvdir(_FILEROOT[f]))) { _FILEDIRFL[f] } return (_FILEDIR[f] = d _FILEDIR[f]) } - if ((dd = (dd ? dd : _FILEIO_RD), f) in _FILEDIR) { + if (((dd = dd ? dd : _FILEIO_RD), f) in _FILEDIR) { return _FILEDIR[dd, f] } if ((d = filedi(dd) _FILEDIR[f]) ~ /^\\/) { @@ -2625,7 +2625,7 @@ function _filen(f) if ((f = _filerdnehnd(f)) == "") { return "" } - return ((f in _FILENAM ? _FILENAM[f] : "")) + return (f in _FILENAM ? _FILENAM[f] : "") } #_________________________________________________________________ @@ -2635,7 +2635,7 @@ function _filene(f) if ((f = _filerdnehnd(f)) == "") { return "" } - return (((f in _FILENAM ? _FILENAM[f] : "")) ((f in _FILEXT ? _FILEXT[f] : ""))) + return (f in _FILENAM ? _FILENAM[f] : "") (f in _FILEXT ? _FILEXT[f] : "") } #_________________________________________________________________ @@ -2663,7 +2663,7 @@ function _filepath(f, dd) if ((f = _filerdnehnd(f)) == "") { return "" } - return (filegetrootdir(f, dd) ((f in _FILENAM ? _FILENAM[f] : "")) ((f in _FILEXT ? _FILEXT[f] : ""))) + return (filegetrootdir(f, dd) (f in _FILENAM ? _FILENAM[f] : "") (f in _FILEXT ? _FILEXT[f] : "")) } #_________________________________________________________________ @@ -2676,7 +2676,7 @@ function _filer(f, dd) if (f in _FILEROOT) { return _FILEROOT[f] } - if ((dd = (dd ? dd : _FILEIO_RD), f) in _FILEROOT) { + if (((dd = dd ? dd : _FILEIO_RD), f) in _FILEROOT) { return _FILEROOT[dd, f] } return (_FILEROOT[dd, f] = fileri(dd)) @@ -2699,7 +2699,7 @@ function _filerdn(f, dd) if ((f = _filerdnehnd(f)) == "") { return "" } - return ((f in _FILENAM ? filegetrootdir(f, dd) _FILENAM[f] : "")) + return (f in _FILENAM ? (filegetrootdir(f, dd) _FILENAM[f]) : "") } #_________________________________________________________________ @@ -2709,8 +2709,8 @@ function _filerdne(f, dd) if ((f = _filerdnehnd(f)) == "") { return "" } - if (f in _FILENAM) { - return (filegetrootdir(f, dd) _FILENAM[f] ((f in _FILEXT ? _FILEXT[f] : ""))) + if ((f in _FILENAM)) { + return (filegetrootdir(f, dd) _FILENAM[f] (f in _FILEXT ? _FILEXT[f] : "")) } if (f in _FILEXT) { return (filegetrootdir(f, dd) _FILEXT[f]) @@ -2729,7 +2729,7 @@ function _filerdnehnd(st, c, r, d, n, A) if (match(st, /^[ \t]*\\[ \t]*\\/)) { if (match(substr(st, (FLENGTH = RLENGTH) + 1), /^[ \t]*([0-9A-Za-z\-]+)[ \t]*(\\[ \t]*([A-Za-z])[ \t]*\$[ \t]*)?(\\[ \t]*([0-9A-Za-z_\!\+\-\[\]\(\)\{\}\~\.]+( +[0-9A-Za-z_\!\+\-\[\]\(\)\{\}\~\.]+)*[ \t]*\\)+[ \t]*)?(([0-9A-Za-z_\!\+\.\~\-\[\]\{\}\(\)]+( +[0-9A-Za-z_\!\+\.\~\-\[\]\{\}\(\)]+)*)[ \t]*)?/, A)) { FLENGTH = FLENGTH + RLENGTH - d = ((A[3] ? "\\" A[3] "$" : "")) A[4] + d = (A[3] ? ("\\" A[3] "$") : "") A[4] gsub(/[ \t]*\\[ \t]*/, "\\", d) if ((st = toupper((r = "\\\\" A[1]) d (n = A[8]))) in _FILECACHE) { return (_FILECACHE[substr(c, 1, FLENGTH)] = _FILECACHE[st]) @@ -2812,7 +2812,7 @@ function _foreach(A, f, r, p0, p1, p2, i, p) } if (_isptr(A)) { _TMP0[p = _n()][_ARRLEN] = 1 - _tframe4("_foreach_i1" ((r ? "~" r : "")), A, f, _TMP0[p], p0, p1) + _tframe4("_foreach_i1" (r ? "~" r : ""), A, f, _TMP0[p], p0, p1) return _th0(_retarr(_TMP0[p]), _tdel(p)) } } @@ -2921,7 +2921,7 @@ function _fthru(A, c, p, B) #_________________________________________________________________ function _fthru_i0(A, c, p, B, f) { - return ((f ? @f(c, _fthru_i0(A, c, p, B, A[f]), B) : "")) + return (f ? @f(c, _fthru_i0(A, c, p, B, A[f]), B) : "") } function _gen(D, t) @@ -2951,7 +2951,7 @@ function _get_errout(p) #_______________________________________________________________________ function _get_errout_i0(p, t, n, a) { - return ((p in _tLOG ? _get_errout_i1(p) _get_errout_i3(p) : "")) + return (p in _tLOG ? (_get_errout_i1(p) _get_errout_i3(p)) : "") } #_________________________________________________________________ @@ -2974,7 +2974,7 @@ function _get_errout_i1(p, t, n, a) #_______________________________________________________________________ function _get_errout_i2(p) { - return (("FILE" in _tLOG[p] ? _tLOG[p]["FILE"] (("LINE" in _tLOG[p] ? "(" _tLOG[p]["LINE"] ")" : "")) ": " : "")) + return ("FILE" in _tLOG[p] ? (_tLOG[p]["FILE"] ("LINE" in _tLOG[p] ? ("(" _tLOG[p]["LINE"] ")") : "") ": ") : "") } #_______________________________________________________________________ @@ -3007,9 +3007,9 @@ function _get_logout(p) function _get_logout_i0(p, t, n, a) { if (p in _tLOG) { - n = (("DATE" in _tLOG[p] ? _tLOG[p]["DATE"] " " : "")) (("TIME" in _tLOG[p] ? _tLOG[p]["TIME"] " " : "")) + n = ("DATE" in _tLOG[p] ? (_tLOG[p]["DATE"] " ") : "") ("TIME" in _tLOG[p] ? (_tLOG[p]["TIME"] " ") : "") if (_tLOG[p]["TYPE"]) { - n = n _tLOG[p]["TYPE"] ": " (("FILE" in _tLOG[p] ? _tLOG[p]["FILE"] (("LINE" in _tLOG[p] ? "(" _tLOG[p]["LINE"] ")" : "")) ": " : "")) + n = n _tLOG[p]["TYPE"] ": " ("FILE" in _tLOG[p] ? (_tLOG[p]["FILE"] ("LINE" in _tLOG[p] ? ("(" _tLOG[p]["LINE"] ")") : "") ": ") : "") if (match(_tLOG[p]["TEXT"], /\x1F/)) { t = n gsub(/[^\t]/, " ", t) @@ -3062,7 +3062,7 @@ function _getfilepath(t, f, al, b, A) al = RLENGTH f = A[3] A[5] A[7] _conl("_getfilepath(" f ") (" al ")") - if (b = _filepath(f)) { + if ((b = _filepath(f))) { if (length(f) <= FLENGTH) { FLENGTH = al return b @@ -3093,10 +3093,10 @@ function _getime() function _getmpdir(f, dd) { ########################################## - if (! dd || ! (dd = _filerd(dd))) { + if ((! dd) || (! (dd = _filerd(dd)))) { dd = _FILEIO_TMPRD } - if (f = (f ? _filerd(f, dd) : _filerd("_" ++_FILEIO_TMPCNTR "\\", dd))) { + if ((f = f ? _filerd(f, dd) : _filerd("_" ++_FILEIO_TMPCNTR "\\", dd))) { _FILEIO_RDTMP[toupper(f)] } return f @@ -3106,10 +3106,10 @@ function _getmpdir(f, dd) function _getmpfile(f, dd) { ######################################### - if (! dd || ! (dd = _filerd(dd))) { + if ((! dd) || (! (dd = _filerd(dd)))) { dd = _FILEIO_TMPRD } - if (f = _filerdne((_filene(f) ? f : f "_" ++_FILEIO_TMPCNTR), dd)) { + if ((f = _filerdne(_filene(f) ? f : (f "_" ++_FILEIO_TMPCNTR), dd))) { _FILEIO_RDNETMP[toupper(f)] } return f @@ -3119,7 +3119,7 @@ function _getmpfile(f, dd) function _getperf(o, t, a) { ############################################### - (o == "" ? ++_getperf_opcurr : _getperf_opcurr = o) + o == "" ? ++_getperf_opcurr : _getperf_opcurr = o if ((a = _getsecond()) != _getperf_last) { _getperf_opsec = (_getperf_opcurr - _getperf_opstart) / ((_getperf_last = a) - _getperf_start) return @_getperf_fn(o, t, a) @@ -3134,7 +3134,7 @@ function _getperf_(o, t, a) return 0 } if (_getperf_opsecp != _getperf_opsec) { - _constat(((_constatstr == _getperf_stat ? _getperf_statstr : _getperf_statstr = _constatstr)) t " [TIME=" (a - _getperf_start) " sec(" (_getperf_opsecp = _getperf_opsec) " ops/sec)]") + _constat((_constatstr == _getperf_stat ? _getperf_statstr : (_getperf_statstr = _constatstr)) t " [TIME=" (a - _getperf_start) " sec(" (_getperf_opsecp = _getperf_opsec) " ops/sec)]") _getperf_stat = _constatstr } return 1 @@ -3144,7 +3144,7 @@ function _getperf_(o, t, a) function _getperf_noe(o, t, a) { if (_getperf_opsecp != _getperf_opsec) { - _constat(((_constatstr == _getperf_stat ? _getperf_statstr : _getperf_statstr = _constatstr)) t " [TIME=" (a - _getperf_start) " sec(" (_getperf_opsecp = _getperf_opsec) " ops/sec)]") + _constat((_constatstr == _getperf_stat ? _getperf_statstr : (_getperf_statstr = _constatstr)) t " [TIME=" (a - _getperf_start) " sec(" (_getperf_opsecp = _getperf_opsec) " ops/sec)]") _getperf_stat = _constatstr } return 1 @@ -3229,7 +3229,7 @@ function _getuid_i0(p, UL, UH) if ("" == (_tptr = UL[_UIDCNTL[p]])) { for (_tptr in UH) { delete UH[_tptr] - return ((_UIDCNTH[p] = _tptr) (_UIDCNTL[p] = UL[""])) + return (_UIDCNTH[p] = _tptr) (_UIDCNTL[p] = UL[""]) } _fatal("out of UID") } @@ -3248,7 +3248,7 @@ function _hexnum(n, l) if (l + 0 < 1) { l = 2 } - return sprintf("%." ((l + 0 < 1 ? 2 : l)) "X", n) + return sprintf("%." (l + 0 < 1 ? 2 : l) "X", n) } #_________________________________________________________________ @@ -3266,7 +3266,7 @@ function _igetperf(t, s, o) _getperf_opstart = _getperf_opcurr = o + 0 _getperf_opsec = _getperf_opsecp = _getperf_stat = _getperf_statstr = "" _getperf_end = t + (_getperf_start = _getperf_last = _getsecondsync()) - _getperf_fn = ((t + 0 > 0 ? "_getperf_" : "_getperf_noe")) ((s ? "" : "not")) + _getperf_fn = (t + 0 > 0 ? "_getperf_" : "_getperf_noe") (s ? "" : "not") return _getperf_start } @@ -3497,14 +3497,14 @@ function _istr(p) it = "-" return 0 } - return (it = (p == "" ? "s" : "S")) + return (it = p == "" ? "s" : "S") } #_________________________________________________________________ function _lengthsort(i1, v1, i2, v2) { ############################## - return ((length(i1) < length(i2) ? -1 : (length(i1) > length(i2) ? 1 : (i1 < i2 ? -1 : 1)))) + return (length(i1) < length(i2) ? -1 : length(i1) > length(i2) ? 1 : i1 < i2 ? -1 : 1) } #_________________________________________________________________ @@ -3547,7 +3547,7 @@ function _lib_NAMEVER() function _ln(t) { ############################################################### - return ((t ~ /\x0A$/ ? t : t _CHR["EOL"])) + return (t ~ /\x0A$/ ? t : (t _CHR["EOL"])) } #_________________________________________________________________ @@ -3683,7 +3683,7 @@ function _mpusub(F, D, C, d, p1, p2, p3, q) if (isarray(F[_mpucc0])) { _mpufn0 = F[_mpucc0] } - _conl("FN: `" _mpucc0 "' > CALL: `" _mpufn0 "' : _mpuacc=" _mpuacc "'") + _conl("FN: `" _mpucc0 "' > CALL: `" (_mpufn0) "' : _mpuacc=" _mpuacc "'") } else { _mpufn0 = "_mpudefaulthnd" } @@ -3692,7 +3692,7 @@ function _mpusub(F, D, C, d, p1, p2, p3, q) _conl("WARNING: unclosed expression: `" d _mpuacc "'") _mpuacc = d _mpuacc } - _retarrm(D, q, "", (_mpufn0 == -1 ? _th0(d, _mpusubwrng("WARNING: unclosed expression", d _mpuacc)) : "")) + _retarrm(D, q, "", _mpufn0 == -1 ? _th0(d, _mpusubwrng("WARNING: unclosed expression", d _mpuacc)) : "") # collect: _mpuacc=_retarr(D) _mpuacc _conl("mpusub exit: _mpuacc: `" _mpuacc "'") } @@ -3806,7 +3806,7 @@ function _nop(p0, p1, p2, p3) function _nretarr(A, i, v, r, q) { ##################################### - if ((i = (i == "" ? 1 : i + 0)) <= (q = A[_ARRLEN])) { + if ((i = i == "" ? 1 : i + 0) <= (q = A[_ARRLEN])) { if (i <= (r = q - 16)) { _ARRSTR = A[i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] while (i < r) { @@ -3826,7 +3826,7 @@ function _nretarr(A, i, v, r, q) function _nretarrd(A, i, v, r, q) { ############################## - if ((i = (i == "" ? 1 : i + 0)) <= (q = A[_ARRLEN])) { + if ((i = i == "" ? 1 : i + 0) <= (q = A[_ARRLEN])) { if (i <= (r = q - 16)) { _ARRSTR = A[i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] while (i < r) { @@ -3866,7 +3866,7 @@ function _out(t, a, b) function _outnl(t) { ################################################ - return _out(t ((t ~ /\x0A$/ ? "" : _CHR["EOL"]))) + return _out(t (t ~ /\x0A$/ ? "" : _CHR["EOL"])) } function _p1(s1, s2, s3, s4, s5, s6, s7, s8, p1, p2, p3, p4, p5, p6, p7, p8) @@ -3926,7 +3926,7 @@ function _pass(A, f, t, p2, i, a) i = 1 while (t && i) { i = "" - while ((i = A[i]) && t == (t = @i(f, t, p2))) { + while ((i = A[i]) && (t == (t = @i(f, t, p2)))) { } } if (i && _endpass_v0) { @@ -4087,11 +4087,11 @@ function _printarr(A, t, lv, r, a) #################################### a = PROCINFO["sorted_in"] PROCINFO["sorted_in"] = "_lengthsort" - _printarrexp = (r ? r : "") + _printarrexp = r ? r : "" if (isarray(A)) { delete _DUMPARR _dumparrc = _dumparrd = "" - _printarr_i1(A, lv = ((lv == "" ? 16 : (lv == 0 || lv + 0 != 0 ? lv : (lv == "-*" ? -3 : (lv ~ /^\+?\*$/ ? 3 : 16))))) + 0, (lv < 0 ? -1 : 1), 0, _tabtospc(t)) + _printarr_i1(A, lv = (lv == "" ? 16 : lv == 0 || (lv + 0) != 0 ? lv : lv == "-*" ? -3 : lv ~ /^\+?\*$/ ? 3 : 16) + 0, lv < 0 ? -1 : 1, 0, _tabtospc(t)) PROCINFO["sorted_in"] = a return _retarrd(_DUMPARR, _dumparrd, _dumparrd = "") } @@ -4108,10 +4108,10 @@ function _printarr_i1(A, lv, ls, ln, t, t2, i, a, f) } } else { for (i in A) { - (isarray(A[i]) ? ++a : "") + isarray(A[i]) ? ++a : "" } } - if (length(_dumparrd = _dumparrd t ((a > 0 ? " ... (x" a ")" : "")) _CHR["EOL"]) > 262144) { + if (length(_dumparrd = _dumparrd t (a > 0 ? " ... (x" a ")" : "") _CHR["EOL"]) > 262144) { _conl(_dumparrd) _dumparrd = "" } @@ -4121,7 +4121,7 @@ function _printarr_i1(A, lv, ls, ln, t, t2, i, a, f) for (i in A) { if (! _printarrexp || i ~ _printarrexp) { if (! isarray(A[i])) { - if (length(_dumparrd = _dumparrd ((f ? t2 : t _nop(f = 1))) "[" i "]=" A[i] "'" _CHR["EOL"]) > 262144) { + if (length(_dumparrd = _dumparrd (f ? t2 : t _nop(f = 1)) "[" i "]=" A[i] "'" _CHR["EOL"]) > 262144) { _conl(_dumparrd) _dumparrd = "" } @@ -4132,7 +4132,7 @@ function _printarr_i1(A, lv, ls, ln, t, t2, i, a, f) for (i in A) { if (isarray(A[i])) { if (! _printarrexp || i ~ _printarrexp) { - _printarr_i1(A[i], lv, ls, ln + ls, _th0((f ? t2 : t), f = 1) "[" i "]") + _printarr_i1(A[i], lv, ls, ln + ls, _th0(f ? t2 : t, f = 1) "[" i "]") } } } @@ -4248,7 +4248,7 @@ function _rFBRO(p) function _rFCHLD(p) { ##################################################### - if (p && p in _tFCHLD) { + if ((p) && (p in _tFCHLD)) { return _tFCHLD[p] } return "" @@ -4274,7 +4274,7 @@ function _rLBRO(p) function _rLCHLD(p) { #_______________________________________________________________________ - if (p && p in _tLCHLD) { ##################################################### + if ((p) && (p in _tLCHLD)) { ##################################################### return _tLCHLD[p] } return "" @@ -4284,14 +4284,14 @@ function _rLCHLD(p) function _rLINK(p) { ###################################################### - return ((p in _tLINK ? _tLINK[p] : "")) + return (p in _tLINK ? _tLINK[p] : "") } ######################## p="" function _rNEXT(p) { #_______________________________________________________________________ - if (p && p in _tNEXT) { ###################################################### + if ((p) && (p in _tNEXT)) { ###################################################### return _tNEXT[p] } return "" @@ -4301,7 +4301,7 @@ function _rNEXT(p) function _rPARENT(p) { #_______________________________________________________________________ - if (p && p in _tPARENT) { #################################################### + if ((p) && (p in _tPARENT)) { #################################################### return _tPARENT[p] } return "" @@ -4311,7 +4311,7 @@ function _rPARENT(p) function _rPREV(p) { #_______________________________________________________________________ - if (p && p in _tPREV) { ###################################################### + if ((p) && (p in _tPREV)) { ###################################################### return _tPREV[p] } return "" @@ -4344,7 +4344,7 @@ function _rQBRO(p, c, p1) function _rQCHLD(p) { #_______________________________________________________________________ - if (p && p in _tQCHLD) { ##################################################### + if ((p) && (p in _tQCHLD)) { ##################################################### return _tQCHLD[p] } return "" @@ -4403,7 +4403,7 @@ function _rSQNEXTA(g, p, A) return p } } - return ((p in _tPARENT ? _rSQNEXTA(g, _tPARENT[p], A) : "")) + return (p in _tPARENT ? _rSQNEXTA(g, _tPARENT[p], A) : "") } function _rconl(t) @@ -4430,14 +4430,14 @@ function _rd_shortcut(D, f) } } } - return ((ERRNO ? ERRNO = "read shortcut: " ERRNO : _NOP)) + return (ERRNO ? ERRNO = "read shortcut: " ERRNO : _NOP) } #_______________________________________________________________________ function _rdfile(f, i, A) { ################################################ - if ((f = _filerdne(f)) == "" || _filene(f) == "") { + if (((f = _filerdne(f)) == "") || (_filene(f) == "")) { ERRNO = "Filename error" return } @@ -4576,7 +4576,7 @@ function _regpath0(D, i, s, q, S) if ("ext" in S) { D["ext"] = S["ext"] } - s = ((toupper(s = (i in S ? S[i] : "")) in _REGPATH0REGDIR ? D[++q] = _REGPATH0REGDIR[toupper(s)] : (D[++q] = _REGPATH0REGDIR[""]) "\\" (D[++q] = s))) "\\" + s = (toupper(s = i in S ? S[i] : "") in _REGPATH0REGDIR ? D[++q] = _REGPATH0REGDIR[toupper(s)] : (D[++q] = _REGPATH0REGDIR[""]) "\\" (D[++q] = s)) "\\" while (++i in S) { s = s (D[++q] = S[i]) "\\" } @@ -4584,7 +4584,7 @@ function _regpath0(D, i, s, q, S) D[0] = s } IGNORECASE = 1 - D["hostdir"] = "\\\\" (D["host"] = ("host" in S && ("" == (i = S["host"]) || "." == i || "?" == i || "localhost" == i) ? ENVIRON["COMPUTERNAME"] : i)) "\\" s + D["hostdir"] = "\\\\" (D["host"] = "host" in S && (("" == (i = S["host"])) || "." == i || "?" == i || "localhost" == i) ? ENVIRON["COMPUTERNAME"] : i) "\\" s IGNORECASE = 0 } } @@ -4620,7 +4620,7 @@ function _reporterr(p, t3, pp, t, t2) t = "" pp = p do { - ("NAME" in _[pp] ? t = _[pp]["NAME"] ": " t : "") + "NAME" in _[pp] ? t = _[pp]["NAME"] ": " t : "" } while (pp = _rPARENT(pp)) if (match(t3, /\x00/)) { return (substr(t3, 1, RSTART - 1) t substr(t3, RSTART + 1)) @@ -4692,7 +4692,7 @@ function _retarr(A, i, p, a, q) { ################################################## if (isarray(A)) { - i = (i == "" ? 0 : i + 0) + i = i == "" ? 0 : i + 0 q = A[_ARRLEN] + 0 if (i < q) { return (p A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] A[++i] _retarr_i0(A, q, i, a)) @@ -4716,7 +4716,7 @@ function _retarrd(A, v, i) { ######################################### if (1 in A) { - return (A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10] A[11] A[12] A[13] A[14] A[15] A[16] (((i = 17) in A ? _retarrd_i0(A, i) v : v))) + return (A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10] A[11] A[12] A[13] A[14] A[15] A[16] ((i = 17) in A ? _retarrd_i0(A, i) v : v)) } delete A return v @@ -4726,7 +4726,7 @@ function _retarrd(A, v, i) function _retarrd_i0(A, i) { if (i in A) { - return (A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] ((i in A ? _retarrd_i0(A, i) : ""))) + return (A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] A[i++] (i in A ? _retarrd_i0(A, i) : "")) } delete A } @@ -4834,7 +4834,7 @@ function _rrdreg(DD, p, k, t, v, c, i, q, tT, A, B, C, D) t = "BIN" } } - DD[gensub(/(\\)\\+/, "\\1", "G", p "\\" _unstr(D[3] ((D[5] ? "(Default)" : ""))) "." t)] = v + DD[gensub(/(\\)\\+/, "\\1", "G", p "\\" _unstr(D[3] (D[5] ? "(Default)" : "")) "." t)] = v } else { _fatal("regedit: unknown output format(" c "): `" C[c] "'") } @@ -4886,11 +4886,11 @@ function _rtn(v, A) function _rtn2(v, A, r, t) { - r = (isarray(A) ? _typa(v, A) : _typ(v)) + r = isarray(A) ? _typa(v, A) : _typ(v) if ("`" > _t0 && _t0) { _conl("ggggg") } - t = ((r ? "TRUE" : "FALSE")) " / " ((r > 0 ? r ">0" : r "!>0")) " / " ((r + 0 > 0 ? r "+0>0" : r "+0!>0")) " / " ((r + 0 != r ? r "+0!=" r : r "+0==" r)) " / " ((r && "`" > r ? "'`'>" r " && " r : "!('`'>" r " && " r ")")) + t = (r ? "TRUE" : "FALSE") " / " (r > 0 ? r ">0" : r "!>0") " / " (r + 0 > 0 ? r "+0>0" : r "+0!>0") " / " (r + 0 != r ? r "+0!=" r : r "+0==" r) " / " (r && "`" > r ? "'`'>" r " && " r : "!('`'>" r " && " r ")") _conl("`" r "' : " t) return r } @@ -5001,7 +5001,7 @@ function _setmpath(p, a) { ################################################ ERRNO = "" - if (p && (a = _filerd(p))) { + if ((p) && (a = _filerd(p))) { if (_FILEIO_TMPRD) { _FILEIO_TMPATHS[_FILEIO_TMPRD] } @@ -5009,7 +5009,7 @@ function _setmpath(p, a) #_cmd("rd " a " /S /Q 2>NUL"); _cmd("del " a " /Q 2>NUL") return (_FILEIO_TMPRD = a) } else { - return _warning("`" p "': cannot set temporary folder" ((ERRNO ? ": " ERRNO : ""))) + return _warning("`" p "': cannot set temporary folder" (ERRNO ? (": " ERRNO) : "")) } } @@ -5019,14 +5019,14 @@ function _sharelist(D, h, q, c, l, A, B) { ################################################# delete D - c = _sharextool " \\\\" ((h == "" ? h = ENVIRON["COMPUTERNAME"] : h)) " 2>&1" + c = _sharextool " \\\\" (h == "" ? h = ENVIRON["COMPUTERNAME"] : h) " 2>&1" if (match(c = _cmd(c), /\x0AShare[^\x0A]*Remark/)) { gsub(/(^[^-]*\x0D?\x0A-+\x0D?\x0A[ \t]*)|(\x0D?\x0AThe command completed successfully.*$)/, "", c) l = RLENGTH - 7 split(c, A, /([ \t]*\x0D?\x0A)+[ \t]*/) for (c in A) { if (match(A[c], /((([^ \t:]+[ \t]+)*[^ \t:]+)[ \t]+)([A-Za-z])[ \t]*:/, B) && ++q) { - D[B[2]] = (A[c] ~ /\.\.\.$/ ? _sharepath(h, B[2]) : gensub(/[ \t\\\/]*$/, "\\\\", 1, substr(A[c], 1 + B[1, "length"], l - B[1, "length"]))) + D[B[2]] = A[c] ~ /\.\.\.$/ ? _sharepath(h, B[2]) : gensub(/[ \t\\\/]*$/, "\\\\", 1, substr(A[c], 1 + B[1, "length"], l - B[1, "length"])) } } return q @@ -5038,7 +5038,7 @@ function _sharelist(D, h, q, c, l, A, B) function _sharepath(h, s, A) { ################################################### - s = _sharextool " \\\\" ((h == "" ? h = ENVIRON["COMPUTERNAME"] : h)) "\\\"" s "\" 2>&1" + s = _sharextool " \\\\" (h == "" ? h = ENVIRON["COMPUTERNAME"] : h) "\\\"" s "\" 2>&1" if (match(s = _cmd(s), /\x0APath[ \t]+([^\x0D\x0A]+)/, _SHAREPATHA0)) { return gensub(/[ \t\\\/]*$/, "\\\\", 1, _SHAREPATHA0[1]) } @@ -5120,7 +5120,7 @@ function _shortcut_init(A, B, q) function _shortcut_nerr(t, s, A) { if (match(t, /\x0ASystem error (-?[0-9]+)[^\x0D\x0A]*[\x0D\x0A]+([^\x0D\x0A]+)/, A)) { - ERRNO = ((A[1] in _SHORTCUTERR ? _SHORTCUTERR[A[1]] : (A[2] in _SHORTCUTERR ? _SHORTCUTERR[A[2]] : tolower(gensub(/^(The )?(((.*)\.$)|(.*[^\.]$))/, "\\4\\5", "G", A[2])) "(" A[1] ")"))) ((s ? ": `" s "'" : "")) + ERRNO = (A[1] in _SHORTCUTERR ? _SHORTCUTERR[A[1]] : A[2] in _SHORTCUTERR ? _SHORTCUTERR[A[2]] : tolower(gensub(/^(The )?(((.*)\.$)|(.*[^\.]$))/, "\\4\\5", "G", A[2])) "(" A[1] ")") (s ? ": `" s "'" : "") } else { return 1 } @@ -5333,7 +5333,7 @@ function _subseqon(B, r, F, f, s, e, q, i, A) s = substr(e = B[i], 2, 1) #_conl("curr r==`" r "': A[" i "]=`" A[i] "'") #s=s in F ? _th0(F[s],_conl("handler `" F[s] "' for `" s "' ost=`" substr(e,3,length(e)-3) "'")) : _th0(F[""],_conl("default handler for `" s "'")) - s = (s in F ? F[s] : F[""]) + s = s in F ? F[s] : F[""] #_conl("`" f "'") r = r (@f(A[i])) (@s(substr(e, 3, length(e) - 3))) } @@ -5511,7 +5511,7 @@ function _tbframe(f, p, p0, p1) { ################################################## delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tbframe_i0(f, p, p0, p1) : "") + f = p ? _tbframe_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -5522,7 +5522,7 @@ function _tbframe_i0(f, p, p0, p1, a) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tLCHLD ? _tmbframe(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tLCHLD ? _tmbframe(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1)) } #_______________________________________________________________________ @@ -5530,7 +5530,7 @@ function _tbframex(f, p, p0, p1) { ########################################### delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tbframex_i0(f, p, p0, p1) : "") + f = p ? _tbframex_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -5541,7 +5541,7 @@ function _tbframex_i0(f, p, p0, p1) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tLCHLD ? _tmbframex(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tLCHLD ? _tmbframex(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1)) } #_____________________________________________________________________________ @@ -5549,7 +5549,7 @@ function _tbpass(f, p, p0, p1) { ################################################### delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tbpass_i0(f, p, p0, p1) : "") + f = p ? _tbpass_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -5560,7 +5560,7 @@ function _tbpass_i0(f, p, p0, p1, a) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tLCHLD ? _tmbpass(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tLCHLD ? _tmbpass(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1)) } #_____________________________________________________________________________ @@ -5568,7 +5568,7 @@ function _tbpassx(f, p, p0, p1) { ################################################## delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tbpassx_i0(f, p, p0, p1) : "") + f = p ? _tbpassx_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -5579,7 +5579,7 @@ function _tbpassx_i0(f, p, p0, p1) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tLCHLD ? _tmbpassx(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tLCHLD ? _tmbpassx(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1)) } #_____________________________________________________________________________ @@ -5670,28 +5670,28 @@ function _tbrochld(p, f, pp) function _tbrunframe(f, p, p0, p1) { ################################### - return _tbframe((f ? f : "_trunframe_i0"), p, p0, p1) + return _tbframe(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ function _tbrunframex(f, p, p0, p1) { ################################## - return _tbframex((f ? f : "_trunframe_i0"), p, p0, p1) + return _tbframex(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ function _tbrunpass(f, p, p0, p1) { #################################### - return _tbpass((f ? f : "_trunframe_i0"), p, p0, p1) + return _tbpass(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ function _tbrunpassx(f, p, p0, p1) { ################################### - return _tbpassx((f ? f : "_trunframe_i0"), p, p0, p1) + return _tbpassx(f ? f : "_trunframe_i0", p, p0, p1) } #_____________________________________________________________________________ @@ -5703,14 +5703,14 @@ function _tdel(p, i) for (i in _ptr[p]) { if (isarray(_ptr[p][i])) { _tdel_i1(_ptr[p][i]) - } else if (i = _ptr[p][i]) { + } else if ((i = _ptr[p][i])) { _tdel(i) } } if (p in _tFCHLD) { i = _tFCHLD[p] do { - i = ((i in _tNEXT ? _tNEXT[i] : "")) _tdel_i0(i) + i = (i in _tNEXT ? _tNEXT[i] : "") _tdel_i0(i) } while (i) } delete _[p] @@ -5724,14 +5724,14 @@ function _tdel_i0(p, i) for (i in _ptr[p]) { if (isarray(_ptr[p][i])) { _tdel_i1(_ptr[p][i]) - } else if (i = _ptr[p][i]) { + } else if ((i = _ptr[p][i])) { _tdel(i) } } if (p in _tFCHLD) { i = _tFCHLD[p] do { - i = ((i in _tNEXT ? _tNEXT[i] : "")) _tdel_i0(i) + i = (i in _tNEXT ? _tNEXT[i] : "") _tdel_i0(i) } while (i) } delete _[p] @@ -5744,7 +5744,7 @@ function _tdel_i1(A, i) for (i in A) { if (isarray(A[i])) { _tdel_i1(A[i]) - } else if (i = A[i]) { + } else if ((i = A[i])) { _tdel(i) } } @@ -5832,7 +5832,7 @@ function _tframe(fF, p, p0, p1, p2) { ############################################### delete _t_ENDF[++_t_ENDF[0]] - p = (_isptr(p) ? (isarray(fF) ? _tframe_i1(fF, p, p0, p1, p2) : _tframe_i0(fF, p, p0, p1, p2)) : "") + p = _isptr(p) ? isarray(fF) ? _tframe_i1(fF, p, p0, p1, p2) : _tframe_i0(fF, p, p0, p1, p2) : "" --_t_ENDF[0] return p } @@ -5894,7 +5894,7 @@ function _tframe0_i2(A, m, p) p = _tDLINK[p] } if (m in A) { - if (m "~" in A) { + if ((m "~") in A) { if (! (_TYPEWORD in _[p]) || A[m "~"] !~ _[p][_TYPEWORD]) { return } @@ -5950,7 +5950,7 @@ function _tframe1_i2(A, m, p, p0) p = _tDLINK[p] } if (m in A) { - if (m "~" in A) { + if ((m "~") in A) { if (! (_TYPEWORD in _[p]) || A[m "~"] !~ _[p][_TYPEWORD]) { return } @@ -6006,7 +6006,7 @@ function _tframe2_i2(A, m, p, p0, p1) p = _tDLINK[p] } if (m in A) { - if (m "~" in A) { + if ((m "~") in A) { if (! (_TYPEWORD in _[p]) || A[m "~"] !~ _[p][_TYPEWORD]) { return } @@ -6062,7 +6062,7 @@ function _tframe3_i2(A, m, p, p0, p1, p2) p = _tDLINK[p] } if (m in A) { - if (m "~" in A) { + if ((m "~") in A) { if (! (_TYPEWORD in _[p]) || A[m "~"] !~ _[p][_TYPEWORD]) { return } @@ -6118,7 +6118,7 @@ function _tframe4_i2(A, m, p, p0, p1, p2, p3) p = _tDLINK[p] } if (m in A) { - if (m "~" in A) { + if ((m "~") in A) { if (! (_TYPEWORD in _[p]) || A[m "~"] !~ _[p][_TYPEWORD]) { return } @@ -6134,7 +6134,7 @@ function _tframe_i0(f, p, p0, p1, p2, a) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tFCHLD ? _tmframe_i0(f, _tFCHLD[p], p0, p1, p2) : (p in _tDLINK ? @f(_tDLINK[p], p0, p1, p2) : @f(p, p0, p1, p2)))) + return (p in _tFCHLD ? _tmframe_i0(f, _tFCHLD[p], p0, p1, p2) : (p in _tDLINK ? @f(_tDLINK[p], p0, p1, p2) : @f(p, p0, p1, p2))) } #___________________________________________________________ @@ -6143,7 +6143,7 @@ function _tframe_i1(F, p, p0, p1, p2, a) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tFCHLD ? (("." in F ? _th1(a = F["."], @a(p, p0, p1, p2)) : "")) _tmframe_i1(F, _tFCHLD[p], p0, p1, p2) : (">" in F ? _th1(a = F[">"], (p in _tDLINK ? @a(_tDLINK[p], p0, p1, p2) : @a(p, p0, p1, p2))) : ""))) + return (p in _tFCHLD ? ("." in F ? _th1(a = F["."], @a(p, p0, p1, p2)) : "") _tmframe_i1(F, _tFCHLD[p], p0, p1, p2) : (">" in F ? _th1(a = F[">"], p in _tDLINK ? @a(_tDLINK[p], p0, p1, p2) : @a(p, p0, p1, p2)) : "")) } #_______________________________________________________________________ @@ -6151,7 +6151,7 @@ function _tframex(f, p, p0, p1) { ############################################ delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tframex_i0(f, p, p0, p1) : "") + f = p ? _tframex_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -6162,7 +6162,7 @@ function _tframex_i0(f, p, p0, p1) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tFCHLD ? _tmframex(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tFCHLD ? _tmframex(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1)) } #_____________________________________________________ @@ -6261,7 +6261,7 @@ function _tgetitem(p, n, a, b) { ############################################ if (p) { - if (isarray(_PTR[p]["ITEM"]) && n in _PTR[p]["ITEM"]) { + if (isarray(_PTR[p]["ITEM"]) && (n in _PTR[p]["ITEM"])) { a = _PTR[p]["ITEM"][n] } else { a = _PTR[p]["ITEM"][n] = _N() @@ -6322,7 +6322,7 @@ function _th3(p0, p1, p2, r) function _tifend(l) { ############################################### - return ((_t_ENDF[0] + l in _t_ENDF ? (_t_ENDF[_t_ENDF[0] + l] ? _t_ENDF[_t_ENDF[0] + l] : 1) : "")) + return (_t_ENDF[0] + l) in _t_ENDF ? (_t_ENDF[_t_ENDF[0] + l] ? _t_ENDF[_t_ENDF[0] + l] : 1) : "" } # test _tbrochld fn; develope tOBJ r\w func specification for brochld func @@ -6423,7 +6423,7 @@ function _tlist(L, p, f) if (f == 0 && f == "") { _tlist_i0(L, p) } else { - _tlistf0 = (f in _TAPI ? _TAPI[f] : f) + _tlistf0 = f in _TAPI ? _TAPI[f] : f _tlist_i1(L, p) } return (_tlisti0 - _tlisti1) @@ -6445,7 +6445,7 @@ function _tlist_i0(L, p, q, i) } L[++_tlisti0] = p if (p in _tFCHLD) { - for (p = _tFCHLD[p]; p; p = (p in _tNEXT ? _tNEXT[p] : "")) { + for (p = _tFCHLD[p]; p; p = p in _tNEXT ? _tNEXT[p] : "") { _tlist_i0(L, p) } } @@ -6470,7 +6470,7 @@ function _tlist_i1(L, p) L[++_tlisti0] = p } if (p in _tFCHLD) { - for (p = _tFCHLD[p]; p; p = (p in _tNEXT ? _tNEXT[p] : "")) { + for (p = _tFCHLD[p]; p; p = p in _tNEXT ? _tNEXT[p] : "") { _tlist_i1(L, p) } } @@ -6481,8 +6481,8 @@ function _tlist_i1(L, p) function _tmbframe(f, p, p0, p1, t) { ################################## - while (p && ! (_t_ENDF[0] in _t_ENDF)) { - t = t _tbframe_i0(f, p, p0, p1, p = (p in _tPREV ? _tPREV[p] : "")) + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { + t = t _tbframe_i0(f, p, p0, p1, p = p in _tPREV ? _tPREV[p] : "") } return t } @@ -6491,9 +6491,9 @@ function _tmbframe(f, p, p0, p1, t) function _tmbframex(f, p, p0, p1, t) { ################################# - while (p && ! (_t_ENDF[0] in _t_ENDF)) { + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { t = t _tbframex_i0(f, p, p0, p1) - p = (p in _tPREV ? _tPREV[p] : "") + p = p in _tPREV ? _tPREV[p] : "" } return t } @@ -6502,8 +6502,8 @@ function _tmbframex(f, p, p0, p1, t) function _tmbpass(f, p, p0, p1) { ###################################### - while (p && ! (_t_ENDF[0] in _t_ENDF)) { - p0 = _tbpass_i0(f, p, p0, p1, p = (p in _tPREV ? _tPREV[p] : "")) + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { + p0 = _tbpass_i0(f, p, p0, p1, p = p in _tPREV ? _tPREV[p] : "") } return p0 } @@ -6512,9 +6512,9 @@ function _tmbpass(f, p, p0, p1) function _tmbpassx(f, p, p0, p1) { ##################################### - while (p && ! (_t_ENDF[0] in _t_ENDF)) { + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { p0 = _tbpassx_i0(f, p, p0, p1) - p = (p in _tPREV ? _tPREV[p] : "") + p = p in _tPREV ? _tPREV[p] : "" } return p0 } @@ -6524,7 +6524,7 @@ function _tmframe(f, p, p0, p1, p2) { ################################### delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tmframe_i0(f, p, p0, p1, p2) : "") + f = p ? _tmframe_i0(f, p, p0, p1, p2) : "" --_t_ENDF[0] return f } @@ -6532,8 +6532,8 @@ function _tmframe(f, p, p0, p1, p2) #___________________________________________________________ function _tmframe_i0(f, p, p0, p1, p2, t) { - while (p && ! (_t_ENDF[0] in _t_ENDF)) { - t = t _tframe_i0(f, p, p0, p1, p2, p = (p in _tNEXT ? _tNEXT[p] : "")) + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { + t = t _tframe_i0(f, p, p0, p1, p2, p = p in _tNEXT ? _tNEXT[p] : "") } return t } @@ -6541,8 +6541,8 @@ function _tmframe_i0(f, p, p0, p1, p2, t) #___________________________________________________________ function _tmframe_i1(F, p, p0, p1, p2, t) { - while (p && ! (_t_ENDF[0] in _t_ENDF)) { - t = t _tframe_i1(F, p, p0, p1, p2, p = (p in _tNEXT ? _tNEXT[p] : "")) + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { + t = t _tframe_i1(F, p, p0, p1, p2, p = p in _tNEXT ? _tNEXT[p] : "") } return t } @@ -6551,9 +6551,9 @@ function _tmframe_i1(F, p, p0, p1, p2, t) function _tmframex(f, p, p0, p1, t) { ################################## - while (p && ! (_t_ENDF[0] in _t_ENDF)) { + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { t = t _tframex_i0(f, p, p0, p1) - p = (p in _tNEXT ? _tNEXT[p] : "") + p = p in _tNEXT ? _tNEXT[p] : "" } return t } @@ -6562,8 +6562,8 @@ function _tmframex(f, p, p0, p1, t) function _tmpass(f, p, p0, p1) { ####################################### - while (p && ! (_t_ENDF[0] in _t_ENDF)) { - p0 = _tbpass_i0(f, p, p0, p1, p = (p in _tNEXT ? _tNEXT[p] : "")) + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { + p0 = _tbpass_i0(f, p, p0, p1, p = p in _tNEXT ? _tNEXT[p] : "") } return p0 } @@ -6572,9 +6572,9 @@ function _tmpass(f, p, p0, p1) function _tmpassx(f, p, p0, p1) { ###################################### - while (p && ! (_t_ENDF[0] in _t_ENDF)) { + while ((p) && (! (_t_ENDF[0] in _t_ENDF))) { p0 = _tbpassx_i0(f, p, p0, p1) - p = (p in _tNEXT ? _tNEXT[p] : "") + p = p in _tNEXT ? _tNEXT[p] : "" } return p0 } @@ -6617,7 +6617,7 @@ function _tpass(f, p, p0, p1) { #################################################### delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tpass_i0(f, p, p0, p1) : "") + f = p ? _tpass_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -6628,7 +6628,7 @@ function _tpass_i0(f, p, p0, p1, a) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tFCHLD ? _tmpass(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tFCHLD ? _tmpass(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1)) } #_____________________________________________________________________________ @@ -6636,7 +6636,7 @@ function _tpassx(f, p, p0, p1) { ################################################### delete _t_ENDF[++_t_ENDF[0]] - f = (p ? _tpassx_i0(f, p, p0, p1) : "") + f = p ? _tpassx_i0(f, p, p0, p1) : "" --_t_ENDF[0] return f } @@ -6647,7 +6647,7 @@ function _tpassx_i0(f, p, p0, p1) while (p in _tLINK) { p = _tLINK[p] } - return ((p in _tFCHLD ? _tmpassx(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))) + return (p in _tFCHLD ? _tmpassx(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1)) } #_________________________________________________________________ @@ -6696,7 +6696,7 @@ function _tr(n, cs, H) _rconl("delptr: " _une(H[2]) "'") _rconl("pfxstr: " _une(H[5]) "'") _rconl("hichr: " _une(H[7]) "'") - _rconl("lochr: " _une((H[10] ? H[7] "' and " H[11] "'" : H[11] "'"))) + _rconl("lochr: " _une(H[10] ? H[7] "' and " H[11] "'" : H[11] "'")) _rconl("sfxstr: " _une(H[14]) "'") } else { _rconl("NOT MATCH!") @@ -6719,7 +6719,7 @@ function _trace(t, d, A) function _trunframe(f, p, p0, p1, p2) { ################################# - return _tframe((f ? f : "_trunframe_i0"), p, p0, p1, p2) + return _tframe(f ? f : "_trunframe_i0", p, p0, p1, p2) } #_________________________________________________________________ @@ -6735,21 +6735,21 @@ function _trunframe_i0(p, p0, p1, p2, f) function _trunframex(f, p, p0, p1) { ################################### - return _tframex((f ? f : "_trunframe_i0"), p, p0, p1) + return _tframex(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ function _trunpass(f, p, p0, p1) { ##################################### - return _tpass((f ? f : "_trunframe_i0"), p, p0, p1) + return _tpass(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ function _trunpassx(f, p, p0, p1) { #################################### - return _tpassx((f ? f : "_trunframe_i0"), p, p0, p1) + return _tpassx(f ? f : "_trunframe_i0", p, p0, p1) } #_________________________________________________________________ @@ -6898,12 +6898,12 @@ function _tstv(p, A, r, f) function _typ(p) { - return (_t0 = (isarray(p) ? "#" : (p == 0 ? (p == "" ? 0 : (p in _CLASSPTR ? "`" : (p ? 3 : 4))) : (p in _CLASSPTR ? "`" : (p + 0 == p ? 5 : (p ? 3 : 2)))))) + return (_t0 = isarray(p) ? "#" : p == 0 ? p == "" ? 0 : p in _CLASSPTR ? "`" : p ? 3 : 4 : p in _CLASSPTR ? "`" : p + 0 == p ? 5 : p ? 3 : 2) } function _typa(p, A) { - return (_t0 = (isarray(p) ? "#" : (p == 0 ? (p == "" ? 0 : (p in A ? "`" : (p ? 3 : 4))) : (p in A ? "`" : (p + 0 == p ? 5 : (p ? 3 : 2)))))) + return (_t0 = isarray(p) ? "#" : p == 0 ? p == "" ? 0 : p in A ? "`" : p ? 3 : 4 : p in A ? "`" : p + 0 == p ? 5 : p ? 3 : 2) } #_____________________________________________________ @@ -6944,7 +6944,7 @@ function _tzend(a, b) function _uidcyc(p, i) { _dumpuidgen(p) - for (i = 1; i < 64 * 8 * 6 - 1; i++) { + for (i = 1; i < (64 * 8 * 6 - 1); i++) { _conl(i ":" _var(_getuid(p))) } _dumpuidgen(p) @@ -6961,7 +6961,7 @@ function _unformatrexp(t) _formatstrq0 = split(t, _FORMATSTRA, /(\\[0-9]{1,3})|(\\x[[:xdigit:]]+)|(\\.)/, _FORMATSTRB) _formatstrs0 = "" for (t = 1; t < _formatstrq0; t++) { - _formatstrs0 = _formatstrs0 _FORMATSTRA[t] ((_FORMATSTRB[t] in _QESCHR ? _QESCREXP[_FORMATSTRB[t]] : _QESCREXP[toupper(substr(_FORMATSTRB[t], length(_FORMATSTRB[t]) - 1))])) + _formatstrs0 = _formatstrs0 _FORMATSTRA[t] (_FORMATSTRB[t] in _QESCHR ? _QESCREXP[_FORMATSTRB[t]] : _QESCREXP[toupper(substr(_FORMATSTRB[t], length(_FORMATSTRB[t]) - 1))]) } return (_formatstrs0 _FORMATSTRA[t]) } @@ -6972,10 +6972,10 @@ function _unformatrexp_init(i, a) _formatstrs0 = "\\^$.[]|()*+?{}-sSwW<>yB`'" delete _FORMATSTRB for (i = 0; i < 256; i++) { - _QESCREXP["\\" _CHR[i]] = (index(_formatstrs0, _CHR[i]) ? "\\" _CHR[i] : _CHR[i]) + _QESCREXP["\\" _CHR[i]] = index(_formatstrs0, _CHR[i]) ? "\\" _CHR[i] : _CHR[i] } for (i = 0; i < 256; i++) { - a = (index(_formatstrs0, _CHR[i]) ? "\\" : "") + a = index(_formatstrs0, _CHR[i]) ? "\\" : "" _QESCREXP[sprintf("%.2X", i)] = a _CHR[i] _QESCREXP["\\" sprintf("%.3o", i)] = a _CHR[i] if (i < 8) { @@ -7000,7 +7000,7 @@ function _unformatstr(t) _formatstrq0 = split(t, _FORMATSTRA, /(\\[0-9]{1,3})|(\\x[[:xdigit:]]+)|(\\.)/, _FORMATSTRB) _formatstrs0 = "" for (t = 1; t < _formatstrq0; t++) { - _formatstrs0 = _formatstrs0 _FORMATSTRA[t] ((_FORMATSTRB[t] in _QESCHR ? _QESCHR[_FORMATSTRB[t]] : _QESCHR[toupper(substr(_FORMATSTRB[t], length(_FORMATSTRB[t]) - 1))])) + _formatstrs0 = _formatstrs0 _FORMATSTRA[t] (_FORMATSTRB[t] in _QESCHR ? _QESCHR[_FORMATSTRB[t]] : _QESCHR[toupper(substr(_FORMATSTRB[t], length(_FORMATSTRB[t]) - 1))]) } return (_formatstrs0 _FORMATSTRA[t]) } @@ -7072,7 +7072,7 @@ function _unstr(t) function _untmp(f, a) { ############################################# - if (f = filepath(f)) { + if ((f = filepath(f))) { if (match(f, /\\$/)) { _deletepfx(_FILEIO_RDTMP, a = toupper(f)) _deletepfx(_FILEIO_RDNETMP, a) @@ -7320,7 +7320,7 @@ function _wFCHLD(p, v, a) delete _tQCHLD[p] do { delete _tPARENT[v] - } while (v in _tNEXT && (v = _tNEXT[v])) + } while ((v in _tNEXT) && (v = _tNEXT[v])) } } return v @@ -7522,7 +7522,7 @@ function _wLCHLD(p, v, a) delete _tQCHLD[p] do { delete _tPARENT[v] - } while (v in _tNEXT && (v = _tNEXT[v])) + } while ((v in _tNEXT) && (v = _tNEXT[v])) } } return v @@ -7721,7 +7721,7 @@ function _wQCHLD(p, v) delete _tQCHLD[p] do { delete _tPARENT[v] - } while (v in _tNEXT && (v = _tNEXT[v])) + } while ((v in _tNEXT) && (v = _tNEXT[v])) } } return v @@ -7771,7 +7771,7 @@ function _wonline(t) #___________________________________________________________ function _wr_shortcut(f, S) { - if (_shrtcutf0 = _filepath(f)) { + if ((_shrtcutf0 = _filepath(f))) { ERRNO = "" _shrtcuta0 = _shortcut_fpath " /A:C /F:\"" _shrtcutf0 "\" 2>&1" for (f in _SHORTCUTWSTRUC) { @@ -7783,14 +7783,14 @@ function _wr_shortcut(f, S) return } } - return ((ERRNO ? ERRNO = "write shortcut: " ERRNO : _NOP)) + return (ERRNO ? ERRNO = "write shortcut: " ERRNO : _NOP) } #_________________________________________________________________ function _wrfile(f, d, a, b) { ######################################### - if ((f = _wfilerdnehnd(f)) == "" || _filene(f) == "") { + if (((f = _wfilerdnehnd(f)) == "") || (_filene(f) == "")) { ERRNO = "Filename error" return } @@ -7816,7 +7816,7 @@ function _wrfile(f, d, a, b) function _wrfile1(f, d, a, b) { ################################## - if ((f = _wfilerdnehnd(f)) == "" || _filene(f) == "") { + if (((f = _wfilerdnehnd(f)) == "") || (_filene(f) == "")) { ERRNO = "Filename error" return } @@ -7863,7 +7863,7 @@ function _yexport_i0(p, p0, p1, p2) function cmp_str_idx(i1, v1, i2, v2) { ############################## - return ((i1 < i2 ? -1 : 1)) + return (i1 < i2 ? -1 : 1) } #___________________________________________________________ @@ -7876,7 +7876,7 @@ function filedi(f, d) return _FILEDIR[f] } if (f in _FILEROOT) { - if (d = filegetdrvdir(_FILEROOT[f])) { + if ((d = filegetdrvdir(_FILEROOT[f]))) { _FILEDIRFL[f] } return (_FILEDIR[f] = d _FILEDIR[f]) @@ -7897,7 +7897,7 @@ function filegetdrvdir(t, r) r = gensub(/[ \t]*([\\\$\:])[ \t]*/, "\\1", "G", substr(r, RSTART, RLENGTH)) gsub(/(^[ \t]*)|([ \t]*$)/, "", r) if (match(r, /\:(.*)/)) { - return (_FILEDRV[tolower(t)] = _FILEDRV[toupper(t)] = substr(r, RSTART + 1) ((r ~ /\\$/ ? "" : "\\"))) + return (_FILEDRV[tolower(t)] = _FILEDRV[toupper(t)] = substr(r, RSTART + 1) (r ~ /\\$/ ? "" : "\\")) } } return "" @@ -7910,20 +7910,20 @@ function filegetrootdir(f, dd, d) if (f in _FILEROOT) { return (_FILEROOT[f] _FILEDIR[f]) } - if ((dd = (dd ? dd : _FILEIO_RD), f) in _FILEROOT) { + if (((dd = dd ? dd : _FILEIO_RD), f) in _FILEROOT) { return (_FILEROOT[dd, f] _FILEDIR[f]) } - return ((_FILEROOT[dd, f] = fileri(dd)) _FILEDIR[f]) + return (_FILEROOT[dd, f] = fileri(dd)) _FILEDIR[f] } if (f in _FILEROOT) { - if (d = filegetdrvdir(_FILEROOT[f])) { + if ((d = filegetdrvdir(_FILEROOT[f]))) { _FILEDIRFL[f] return (_FILEROOT[f] (_FILEDIR[f] = d _FILEDIR[f])) } else { return (_FILEROOT[f] _FILEDIR[f]) } } - if ((dd = (dd ? dd : _FILEIO_RD), f) in _FILEROOT) { + if (((dd = dd ? dd : _FILEIO_RD), f) in _FILEROOT) { if ((dd, f) in _FILEDIR) { return (_FILEROOT[dd, f] _FILEDIR[dd, f]) } @@ -7933,12 +7933,12 @@ function filegetrootdir(f, dd, d) return (_FILEROOT[dd, f] d) } if ((dd, f) in _FILEDIR) { - return ((_FILEROOT[dd, f] = fileri(dd)) _FILEDIR[dd, f]) + return (_FILEROOT[dd, f] = fileri(dd)) _FILEDIR[dd, f] } if ((d = filedi(dd) _FILEDIR[f]) ~ /^\\/) { - return ((_FILEROOT[dd, f] = fileri(dd)) (_FILEDIR[dd, f] = d)) + return (_FILEROOT[dd, f] = fileri(dd)) (_FILEDIR[dd, f] = d) } - return ((_FILEROOT[dd, f] = fileri(dd)) d) + return (_FILEROOT[dd, f] = fileri(dd)) d } #___________________________________________________________ @@ -7951,7 +7951,7 @@ function filerdnehndi(st, a, c, r, d, n, A) if (match(st, /^[ \t]*\\[ \t]*\\/)) { if (match(substr(st, a = RLENGTH + 1), /^[ \t]*([0-9A-Za-z\-]+)[ \t]*(\\[ \t]*([A-Za-z])[ \t]*\$[ \t]*)?(\\[ \t]*([0-9A-Za-z_\!\+\-\[\]\(\)\{\}\~\.]+( +[0-9A-Za-z_\!\+\-\[\]\(\)\{\}\~\.]+)*[ \t]*\\)*[ \t]*)?(([0-9A-Za-z_\!\+\.\~\-\[\]\{\}\(\)]+( +[0-9A-Za-z_\!\+\.\~\-\[\]\{\}\(\)]+)*)[ \t]*)?/, A)) { a = a + RLENGTH - d = ((A[3] ? "\\" A[3] "$" : "")) "\\" A[5] + d = (A[3] ? ("\\" A[3] "$") : "") "\\" A[5] gsub(/[ \t]*\\[ \t]*/, "\\", d) if ((st = toupper((r = "\\\\" A[1]) d (n = A[8]))) in _FILECACHE) { return (_FILECACHE[substr(c, 1, a)] = _FILECACHE[st]) @@ -8018,7 +8018,7 @@ function hujf(a, b, c) function ncmp_str_idx(i1, v1, i2, v2) { ####################### - return ((i1 < i2 ? 1 : -1)) + return (i1 < i2 ? 1 : -1) } function test_cfg(p, z, AA0, a) @@ -8054,7 +8054,7 @@ function test_cfg(p, z, AA0, a) _conline() _conl() _drawuid(p) - _conl("```````````````````" z "'''''''''" ((_isptr(z) ? " ptr" : " not ptr"))) + _conl("```````````````````" z "'''''''''" (_isptr(z) ? " ptr" : " not ptr")) _drawuid(z) } @@ -8094,7 +8094,7 @@ function tst_splitstr(t, A, R, r) delete A A["not cleared"] _wonl() - _wonline("_splitstr(" ((isarray(t) ? "ARR" ((length(t) > 0 ? "#" ((t[1] != "zhopa" ? "U" : "l")) : "")) : _val0(t))) ",A" ((isarray(R) ? ", ARR" ((length(R) > 0 ? "#" ((R[1] != "zhopa" ? "U" : "l")) : "")) : ", " _val0(R))) "):") + _wonline("_splitstr(" (isarray(t) ? "ARR" (length(t) > 0 ? "#" (t[1] != "zhopa" ? "U" : "l") : "") : _val0(t)) ",A" (isarray(R) ? ", ARR" (length(R) > 0 ? "#" (R[1] != "zhopa" ? "U" : "l") : "") : ", " _val0(R)) "):") _wonl(_val0(r = _splitstr(t, A, R))) _wonl("arrary A:") _wonl(_dumparr(A)) diff --git a/test/profile7.awk b/test/profile7.awk index 454694f9..815aebb8 100644 --- a/test/profile7.awk +++ b/test/profile7.awk @@ -5,6 +5,8 @@ BEGIN { print 1 % (10 * 10) print (10 * 5) / 2 print 10 * (5 / 2) + print 10 - (1 + 3 * 3) + print 10 - (3 * 2 + 1) a = 5 b = 3 print a - 1 - b diff --git a/test/profile7.ok b/test/profile7.ok index d65afa86..10da2eb4 100644 --- a/test/profile7.ok +++ b/test/profile7.ok @@ -5,8 +5,10 @@ 1 print 1 / (10 * 10) 1 print 1 % 10 * 10 1 print 1 % (10 * 10) - 1 print 10 * 5 / 2 - 1 print 10 * 5 / 2 + 1 print (10 * 5) / 2 + 1 print 10 * (5 / 2) + 1 print 10 - (1 + 3 * 3) + 1 print 10 - (3 * 2 + 1) 1 a = 5 1 b = 3 1 print a - 1 - b |