aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xChangeLog178
-rw-r--r--NEWS4
-rw-r--r--awk.h14
-rw-r--r--awkgram.c1572
-rw-r--r--awkgram.y745
-rw-r--r--debug.c56
-rw-r--r--doc/ChangeLog10
-rw-r--r--doc/gawk.info478
-rw-r--r--doc/gawk.texi13
-rw-r--r--doc/gawktexi.in13
-rw-r--r--profile.c307
-rw-r--r--test/ChangeLog12
-rw-r--r--test/profile0.ok2
-rw-r--r--test/profile10.ok12
-rw-r--r--test/profile5.ok1423
15 files changed, 2302 insertions, 2537 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b0ba249..b43973cc 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,12 @@
2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+ * awkgram.y (interblock_comment, pending_comment): New variables.
+ (Grammar, mk_program, add_rule): Adjust to use them. Changes
+ handle comments at the outermost level, between blocks and functions.
+
+2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+
* main.c (arg_assign): Allow assigning strongly typed regexp
constants to variables on the command line and with -v.
Thanks to Peng Yu <pengyu.ut@gmail.com> for the report.
@@ -29,6 +35,47 @@
2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
* main.c (usage): Improve output for -Z in the help.
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (outer_comment): New variable.
+ (Grammar): More changes. We now get the simple case of leading
+ and trailing comments, but not all the cases.
+
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (trailing_comment): New variable.
+ (Grammar): For `action', append both trailing comments. This may
+ change. For `statements', append the value of `trailing_comment'
+ if set. At `statement := l_brace statements rbrace' save
+ trailing_comment from r_brace.
+ (make_braced_statements): Don't append the comment from r_brace
+ to the statement list.
+
+2018-10-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (NODE): New field: sub.nodep.x.cmnt, holds comment for
+ expressions being pretty-printed.
+ * awkgram.y (Grammar): For expression lists, save any comment
+ that came after a comma in the list.
+ * profile.c (pp_push): Accept a fourth argument which is any
+ comment associated with the expression. Either it's there or
+ it's NULL. Save it in the pp_comment field of the node being pushed.
+ (tabs, tabs_len, check_indent_level): Made into static globals.
+ (pprint): Adjust all calls to pp_push(). Fix parenthesization
+ for casts in string lengthes when indenting.
+ (pp_list): If a popped item has a comment, include it and the
+ following indentation in the formatted result.
+
+2018-10-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (include_source): Add second parameter to return
+ SRCFILE pointer.
+ (Grammar): For @include, save the comment for later dumping
+ along with the list of include files.
+ (make_include_comment): Removed. No longer used.
+ * profile.c: Update copyright year.
+ (print_include_list): New function.
+ (dump_prog): Call it.
2018-10-24 Arnold D. Robbins <arnold@skeeve.com>
@@ -38,11 +85,121 @@
* config.sub: Updated from GNULIB.
+2018-10-20 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (SRCFILE): Add comment field for comments on @load statements.
+ * awkgram.y (include_source): Type change to boolean.
+ (load_library): Type change to boolean, additiona parameter to
+ bring the SRCFILE struct up to where we can add the comment into it.
+ (make_include_comment): New function. Not used yet.
+ (Grammar): Add comment for @load statements. Start on preserving
+ @include statements and their comments for eventual inclusion
+ into the pretty-printed code.
+ * profile.c (print_lib_list): Made a little smarter about printing
+ the header and indentation. Print the comment if there is one.
+
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (commenttype): Add FOR_COMMENT.
+ * awkgram.y (Grammar): Handle all the opt_nls cases in
+ regular for statements.
+ * debug.c (print_instruction): Print the comments in Op_K_for.
+ * profile.c (pprint): Handle printing comments.
+
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * NEWS: Updated.
+ * awkgram.y (Grammar): Distinguish `print' and `print $0' in
+ what gets profiled / pretty-printed.
+ * profile.c (pprint): For case and default, add final newline
+ if there is no comment to print.
+
+2018-10-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Improve comment handling for many plain
+ statements. Improve handling for case and default.
+ Handle comments in `for (iggy in foo)' loops.
+ (yylex): After a colon, only allow newline if was part of ?:.
+ (merge_comments): Improve coding so we don't get two newlines
+ at the end of a merged comment.
+ * debug.c (print_instruction): Handle comments for case and default.
+ Simplify printing of comments.
+ * profile.c (pprint): Handle comments for case and default.
+ Remove compiler warning in Op_and/Op_or handling.
+
+2018-10-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Add comment handling for do...while.
+ Regularize comments about `else ...'.
+ * debug.c (print_instruction): Improve handling of comments for
+ do-while and switch, and in general.
+ * profile.c (pprint): Revise for do...while.
+
+2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (make_braced_statements): New function.
+ (Grammar): Use it in the right places instead of inline code.
+ * debug.c (print_instruction): For Op_comment, fix type string.
+ * profile.c (pprint): Move tabs and tabs_len to top of function.
+ For Op_and and Op_or, handle comments. Use new check_indent_level
+ for Op_and, Op_or and Op_cond_exp.
+
2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
* debug.c (print_instruction): For Op_comment, use print_func
instead of fprintf to print the comment type.
+2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): For statement -> { statements }, fix comment
+ handling. For `if' statement add comment support.
+ * profile.c (pp_print): Print comments associated with `if' and `else'.
+
+2018-10-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Fix handling of empty statement (just a semi-
+ colon).
+ (merge_comments): If no chained comment and no second comment,
+ just return early.
+
+2018-10-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (enum commenttype): New enum.
+ (NODE): Add it to sub.val.
+ (EOL_COMMENT, FULL_COMMENT): Replaced with above enum values.
+ * awkgram.y (Grammar): Finish up handling comments in function headers
+ and bodies. Get trailing comments at end of program
+ (get_comment): When doing comments, if we got EOF, push it back so that
+ multiple comments get merged together.
+ (merge_comments): Allow second parameter to be NULL.
+ * profile.c (pp_print): Change to use above enum everywhere. For
+ Op_K_print_rec produce plain `print' instead of `print $0'. Handle
+ comments in ?:. Handle printing function comments.
+ (print_comment): Simplify `after_newline' assignment. Add assertion
+ that chaining is only two deep.
+
+2018-10-06 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (action): Improve handling of comments attached
+ to braces. Helps with function bodies.
+
+2018-10-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (merge_comments): Change return type to void. Adjust calls.
+ (Grammar): For action, pull comments out of braces and stick
+ into the list. For function_prologue, get comments from parameters
+ and ending newline, merge, and save. Wherever nls and opt_nls
+ are used, be sure to pass their values up via $$. For various
+ cases that can be empty, explicitly set $$ = NULL.
+ * profile.c (pprint): Get switch working. Get ?: working.
+ (print_comment): Print any chained comment.
+ (pp_func): Start revising.
+
+2018-10-03 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y: Range expressions, enable comment stuff.
+ Switch statement: start on comment handling.
+
2018-10-01 Nelson H.F. Beebe <beebe@math.utah.edu>
* custom.h (__builtin_expect): Define for non-GNU compilers.
@@ -72,6 +229,23 @@
2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+ * awk.h (INSTRUCTION): Add comment field to carry
+ comment around during parsing.
+ * awkgram.y (merge_comments): New function.
+ (split_comment, check_comment, comment, prior_comment,
+ comment_to_save, program_comment, function_comment,
+ block_comment): Removed.
+ (grammar): Remove old code and start passing the comment
+ up via yylval and the newlines in the grammar.
+
+2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y: Undo change of 2016-11-28 to make switch
+ head a separate production, in preparation for revamping
+ comment handling.
+
+2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+
* re.c (make_regexp): Handle backslash at end of
input string. Thanks to Anatoly Trosinenko
<anatoly.trosinenko@gmail.com> for the report.
@@ -1751,6 +1925,10 @@
* dfa.c: Sync with GNULIB. Twice in one day.
+ Unrelated: Start improving profiling comments for switch/case.
+
+ * awkgram.y (switch_head): New production.
+
2016-11-21 Arnold D. Robbins <arnold@skeeve.com>
* dfa.c: Sync with GNULIB.
diff --git a/NEWS b/NEWS
index a25c30d7..9489e05c 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ Changes from 4.2.x to 5.0.0
4. PROCINFO["platform"] yields a string indicating the platform for
which gawk was compiled.
+5. Comment handling in the pretty-printer has been reworked almost completely
+ from scratch. As a result, comments in many corner cases that were
+ previously lost are now included in the formatted output.
+
Changes from 4.2.1 to 4.2.2
---------------------------
diff --git a/awk.h b/awk.h
index b53674ee..6f0f5163 100644
--- a/awk.h
+++ b/awk.h
@@ -296,6 +296,12 @@ typedef union bucket_item {
} hi;
} BUCKET;
+enum commenttype {
+ EOL_COMMENT = 1,
+ BLOCK_COMMENT,
+ FOR_COMMENT // special case
+};
+
/* string hash table */
#define ahnext hs.next
#define ahname hs.name /* a string index node */
@@ -340,6 +346,7 @@ typedef struct exp_node {
struct exp_node *extra;
void (*aptr)(void);
long xl;
+ void *cmnt; // used by pretty printer
} x;
char *name;
size_t reserved;
@@ -368,6 +375,7 @@ typedef struct exp_node {
wchar_t *wsp;
size_t wslen;
struct exp_node *typre;
+ enum commenttype comtype;
} val;
} sub;
NODETYPE type;
@@ -565,9 +573,7 @@ typedef struct exp_node {
#define alevel sub.nodep.x.xl
/* Op_comment */
-#define comment_type sub.val.idx
-#define EOL_COMMENT 1
-#define FULL_COMMENT 2
+#define comment_type sub.val.comtype
/* --------------------------------lint warning types----------------------------*/
typedef enum lintvals {
@@ -764,6 +770,7 @@ typedef struct exp_instruction {
awk_ext_func_t *exf;
} x;
+ struct exp_instruction *comment;
short source_line;
short pool_size; // memory management in symbol.c
OPCODE opcode;
@@ -1009,6 +1016,7 @@ typedef struct srcfile {
char *lexeme;
char *lexptr_begin;
int lasttok;
+ INSTRUCTION *comment; /* comment on @load line */
} SRCFILE;
// structure for INSTRUCTION pool, needed mainly for debugger
diff --git a/awkgram.c b/awkgram.c
index 3d63f162..e063d039 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -96,11 +96,15 @@ static int isnoeffect(OPCODE type);
static INSTRUCTION *make_assignable(INSTRUCTION *ip);
static void dumpintlstr(const char *str, size_t len);
static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2);
-static int include_source(INSTRUCTION *file);
-static int load_library(INSTRUCTION *file);
+static bool include_source(INSTRUCTION *file, void **srcfile_p);
+static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
+static INSTRUCTION *trailing_comment;
+static INSTRUCTION *outer_comment;
+static INSTRUCTION *interblock_comment;
+static INSTRUCTION *pending_comment;
#define instruction(t) bcalloc(t, 1, 0)
@@ -127,8 +131,8 @@ static void check_funcs(void);
static ssize_t read_one_line(int fd, void *buffer, size_t count);
static int one_line_close(int fd);
-static void split_comment(void);
-static void check_comment(void);
+static void merge_comments(INSTRUCTION *c1, INSTRUCTION *c2);
+static INSTRUCTION *make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace);
static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
@@ -195,27 +199,19 @@ static INSTRUCTION *ip_endfile;
static INSTRUCTION *ip_beginfile;
INSTRUCTION *main_beginfile;
-static INSTRUCTION *comment = NULL;
-static INSTRUCTION *prior_comment = NULL;
-static INSTRUCTION *comment_to_save = NULL;
-static INSTRUCTION *program_comment = NULL;
-static INSTRUCTION *function_comment = NULL;
-static INSTRUCTION *block_comment = NULL;
-
-static bool func_first = true;
+static bool func_first = true; // can nuke
static bool first_rule = true;
static inline INSTRUCTION *list_create(INSTRUCTION *x);
static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2);
-static inline INSTRUCTION *add_pending_comment(INSTRUCTION *stmt);
extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 219 "awkgram.c" /* yacc.c:338 */
+#line 215 "awkgram.c" /* yacc.c:338 */
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
@@ -665,27 +661,27 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 215, 215, 217, 222, 223, 227, 239, 244, 255,
- 262, 268, 277, 285, 287, 292, 300, 302, 308, 316,
- 326, 356, 370, 384, 392, 403, 415, 417, 419, 425,
- 433, 434, 438, 438, 484, 483, 517, 532, 534, 539,
- 549, 596, 601, 602, 606, 608, 610, 617, 707, 749,
- 791, 904, 911, 918, 929, 939, 949, 959, 971, 988,
- 987, 1001, 1013, 1013, 1112, 1112, 1146, 1177, 1186, 1187,
- 1193, 1194, 1201, 1206, 1218, 1232, 1234, 1242, 1249, 1251,
- 1259, 1268, 1270, 1279, 1280, 1288, 1293, 1293, 1306, 1310,
- 1318, 1319, 1322, 1324, 1329, 1330, 1339, 1340, 1345, 1350,
- 1359, 1361, 1363, 1370, 1371, 1377, 1378, 1383, 1385, 1390,
- 1392, 1400, 1405, 1414, 1415, 1420, 1422, 1427, 1429, 1437,
- 1442, 1450, 1451, 1456, 1463, 1467, 1469, 1471, 1484, 1501,
- 1511, 1518, 1520, 1525, 1527, 1529, 1537, 1539, 1544, 1546,
- 1551, 1553, 1555, 1612, 1614, 1616, 1618, 1620, 1622, 1624,
- 1626, 1640, 1645, 1650, 1675, 1681, 1683, 1685, 1687, 1689,
- 1691, 1696, 1700, 1732, 1740, 1746, 1752, 1765, 1766, 1767,
- 1772, 1777, 1781, 1785, 1800, 1821, 1826, 1863, 1892, 1893,
- 1899, 1900, 1905, 1907, 1914, 1931, 1948, 1950, 1957, 1962,
- 1970, 1980, 1992, 2001, 2005, 2009, 2013, 2017, 2021, 2024,
- 2026, 2030, 2034, 2038
+ 0, 213, 213, 214, 219, 229, 233, 245, 254, 268,
+ 275, 285, 298, 308, 310, 315, 325, 327, 333, 337,
+ 342, 372, 385, 398, 405, 415, 433, 435, 437, 443,
+ 451, 452, 456, 456, 490, 489, 523, 538, 540, 545,
+ 546, 566, 571, 572, 576, 587, 592, 599, 707, 758,
+ 808, 934, 955, 976, 986, 996, 1006, 1017, 1030, 1048,
+ 1047, 1061, 1079, 1079, 1177, 1177, 1210, 1240, 1248, 1249,
+ 1255, 1256, 1263, 1268, 1281, 1296, 1298, 1306, 1313, 1315,
+ 1323, 1332, 1334, 1343, 1344, 1352, 1357, 1357, 1370, 1376,
+ 1388, 1392, 1414, 1415, 1421, 1422, 1431, 1432, 1437, 1442,
+ 1459, 1461, 1463, 1470, 1471, 1477, 1478, 1483, 1485, 1492,
+ 1494, 1502, 1507, 1518, 1519, 1524, 1526, 1533, 1535, 1543,
+ 1548, 1558, 1559, 1564, 1571, 1575, 1577, 1579, 1592, 1609,
+ 1619, 1626, 1628, 1633, 1635, 1637, 1645, 1647, 1652, 1654,
+ 1659, 1661, 1663, 1720, 1722, 1724, 1726, 1728, 1730, 1732,
+ 1734, 1748, 1753, 1758, 1783, 1789, 1791, 1793, 1795, 1797,
+ 1799, 1804, 1808, 1840, 1848, 1854, 1860, 1873, 1874, 1875,
+ 1880, 1885, 1889, 1893, 1908, 1929, 1934, 1971, 2000, 2001,
+ 2007, 2008, 2013, 2015, 2022, 2039, 2056, 2058, 2065, 2070,
+ 2078, 2088, 2100, 2109, 2113, 2118, 2122, 2126, 2130, 2135,
+ 2136, 2140, 2144, 2148
};
#endif
@@ -1882,25 +1878,45 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 3:
-#line 218 "awkgram.y" /* yacc.c:1645 */
+ case 2:
+#line 213 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 1885 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 3:
+#line 215 "awkgram.y" /* yacc.c:1645 */
{
rule = 0;
yyerrok;
}
-#line 1892 "awkgram.c" /* yacc.c:1645 */
+#line 1894 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 4:
+#line 220 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL) {
+ if ((yyvsp[-1]) == NULL)
+ outer_comment = (yyvsp[0]);
+ else
+ interblock_comment = (yyvsp[0]);
+ }
+ (yyval) = (yyvsp[-1]);
+ }
+#line 1908 "awkgram.c" /* yacc.c:1645 */
break;
case 5:
-#line 224 "awkgram.y" /* yacc.c:1645 */
+#line 230 "awkgram.y" /* yacc.c:1645 */
{
next_sourcefile();
}
-#line 1900 "awkgram.c" /* yacc.c:1645 */
+#line 1916 "awkgram.c" /* yacc.c:1645 */
break;
case 6:
-#line 228 "awkgram.y" /* yacc.c:1645 */
+#line 234 "awkgram.y" /* yacc.c:1645 */
{
rule = 0;
/*
@@ -1909,20 +1925,24 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 1913 "awkgram.c" /* yacc.c:1645 */
+#line 1929 "awkgram.c" /* yacc.c:1645 */
break;
case 7:
-#line 240 "awkgram.y" /* yacc.c:1645 */
+#line 246 "awkgram.y" /* yacc.c:1645 */
{
(void) append_rule((yyvsp[-1]), (yyvsp[0]));
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
first_rule = false;
}
-#line 1922 "awkgram.c" /* yacc.c:1645 */
+#line 1942 "awkgram.c" /* yacc.c:1645 */
break;
case 8:
-#line 245 "awkgram.y" /* yacc.c:1645 */
+#line 255 "awkgram.y" /* yacc.c:1645 */
{
if (rule != Rule) {
msg(_("%s blocks must have an action part"), ruletab[rule]);
@@ -1930,119 +1950,125 @@ yyreduce:
} else if ((yyvsp[-1]) == NULL) {
msg(_("each rule must have a pattern or an action part"));
errcount++;
- } else /* pattern rule with non-empty pattern */
+ } else { /* pattern rule with non-empty pattern */
+ if ((yyvsp[0]) != NULL)
+ list_append((yyvsp[-1]), (yyvsp[0]));
(void) append_rule((yyvsp[-1]), NULL);
+ }
}
-#line 1937 "awkgram.c" /* yacc.c:1645 */
+#line 1960 "awkgram.c" /* yacc.c:1645 */
break;
case 9:
-#line 256 "awkgram.y" /* yacc.c:1645 */
+#line 269 "awkgram.y" /* yacc.c:1645 */
{
in_function = NULL;
(void) mk_function((yyvsp[-1]), (yyvsp[0]));
want_param_names = DONT_CHECK;
yyerrok;
}
-#line 1948 "awkgram.c" /* yacc.c:1645 */
+#line 1971 "awkgram.c" /* yacc.c:1645 */
break;
case 10:
-#line 263 "awkgram.y" /* yacc.c:1645 */
+#line 276 "awkgram.y" /* yacc.c:1645 */
{
want_source = false;
at_seen = false;
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ SRCFILE *s = (SRCFILE *) (yyvsp[-1]);
+ s->comment = (yyvsp[0]);
+ }
yyerrok;
}
-#line 1958 "awkgram.c" /* yacc.c:1645 */
+#line 1985 "awkgram.c" /* yacc.c:1645 */
break;
case 11:
-#line 269 "awkgram.y" /* yacc.c:1645 */
+#line 286 "awkgram.y" /* yacc.c:1645 */
{
want_source = false;
at_seen = false;
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ SRCFILE *s = (SRCFILE *) (yyvsp[-1]);
+ s->comment = (yyvsp[0]);
+ }
yyerrok;
}
-#line 1968 "awkgram.c" /* yacc.c:1645 */
+#line 1999 "awkgram.c" /* yacc.c:1645 */
break;
case 12:
-#line 278 "awkgram.y" /* yacc.c:1645 */
+#line 299 "awkgram.y" /* yacc.c:1645 */
{
- if (include_source((yyvsp[0])) < 0)
+ void *srcfile = NULL;
+
+ if (! include_source((yyvsp[0]), & srcfile))
YYABORT;
efree((yyvsp[0])->lextok);
bcfree((yyvsp[0]));
- (yyval) = NULL;
+ (yyval) = (INSTRUCTION *) srcfile;
}
-#line 1980 "awkgram.c" /* yacc.c:1645 */
+#line 2013 "awkgram.c" /* yacc.c:1645 */
break;
case 13:
-#line 286 "awkgram.y" /* yacc.c:1645 */
+#line 309 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 1986 "awkgram.c" /* yacc.c:1645 */
+#line 2019 "awkgram.c" /* yacc.c:1645 */
break;
case 14:
-#line 288 "awkgram.y" /* yacc.c:1645 */
+#line 311 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 1992 "awkgram.c" /* yacc.c:1645 */
+#line 2025 "awkgram.c" /* yacc.c:1645 */
break;
case 15:
-#line 293 "awkgram.y" /* yacc.c:1645 */
+#line 316 "awkgram.y" /* yacc.c:1645 */
{
- if (load_library((yyvsp[0])) < 0)
+ void *srcfile;
+
+ if (! load_library((yyvsp[0]), & srcfile))
YYABORT;
efree((yyvsp[0])->lextok);
bcfree((yyvsp[0]));
- (yyval) = NULL;
+ (yyval) = (INSTRUCTION *) srcfile;
}
-#line 2004 "awkgram.c" /* yacc.c:1645 */
+#line 2039 "awkgram.c" /* yacc.c:1645 */
break;
case 16:
-#line 301 "awkgram.y" /* yacc.c:1645 */
+#line 326 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2010 "awkgram.c" /* yacc.c:1645 */
+#line 2045 "awkgram.c" /* yacc.c:1645 */
break;
case 17:
-#line 303 "awkgram.y" /* yacc.c:1645 */
+#line 328 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2016 "awkgram.c" /* yacc.c:1645 */
+#line 2051 "awkgram.c" /* yacc.c:1645 */
break;
case 18:
-#line 308 "awkgram.y" /* yacc.c:1645 */
+#line 333 "awkgram.y" /* yacc.c:1645 */
{
rule = Rule;
- if (comment != NULL) {
- (yyval) = list_create(comment);
- comment = NULL;
- } else
- (yyval) = NULL;
+ (yyval) = NULL;
}
-#line 2029 "awkgram.c" /* yacc.c:1645 */
+#line 2060 "awkgram.c" /* yacc.c:1645 */
break;
case 19:
-#line 317 "awkgram.y" /* yacc.c:1645 */
+#line 338 "awkgram.y" /* yacc.c:1645 */
{
rule = Rule;
- if (comment != NULL) {
- (yyval) = list_prepend((yyvsp[0]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[0]);
}
-#line 2042 "awkgram.c" /* yacc.c:1645 */
+#line 2068 "awkgram.c" /* yacc.c:1645 */
break;
case 20:
-#line 327 "awkgram.y" /* yacc.c:1645 */
+#line 343 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *tp;
@@ -2065,18 +2091,18 @@ yyreduce:
((yyvsp[-3])->nexti + 1)->condpair_left = (yyvsp[-3])->lasti;
((yyvsp[-3])->nexti + 1)->condpair_right = (yyvsp[0])->lasti;
}
- if (comment != NULL) {
- (yyval) = list_append(list_merge(list_prepend((yyvsp[-3]), comment), (yyvsp[0])), tp);
- comment = NULL;
- } else
+ /* Put any comments in front of the range expression */
+ if ((yyvsp[-1]) != NULL)
+ (yyval) = list_append(list_merge(list_prepend((yyvsp[-3]), (yyvsp[-1])), (yyvsp[0])), tp);
+ else
(yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp);
rule = Rule;
}
-#line 2076 "awkgram.c" /* yacc.c:1645 */
+#line 2102 "awkgram.c" /* yacc.c:1645 */
break;
case 21:
-#line 357 "awkgram.y" /* yacc.c:1645 */
+#line 373 "awkgram.y" /* yacc.c:1645 */
{
static int begin_seen = 0;
@@ -2087,14 +2113,13 @@ yyreduce:
(yyvsp[0])->in_rule = rule = BEGIN;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2094 "awkgram.c" /* yacc.c:1645 */
+#line 2119 "awkgram.c" /* yacc.c:1645 */
break;
case 22:
-#line 371 "awkgram.y" /* yacc.c:1645 */
+#line 386 "awkgram.y" /* yacc.c:1645 */
{
static int end_seen = 0;
@@ -2105,116 +2130,107 @@ yyreduce:
(yyvsp[0])->in_rule = rule = END;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2112 "awkgram.c" /* yacc.c:1645 */
+#line 2136 "awkgram.c" /* yacc.c:1645 */
break;
case 23:
-#line 385 "awkgram.y" /* yacc.c:1645 */
+#line 399 "awkgram.y" /* yacc.c:1645 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = BEGINFILE;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2124 "awkgram.c" /* yacc.c:1645 */
+#line 2147 "awkgram.c" /* yacc.c:1645 */
break;
case 24:
-#line 393 "awkgram.y" /* yacc.c:1645 */
+#line 406 "awkgram.y" /* yacc.c:1645 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = ENDFILE;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2136 "awkgram.c" /* yacc.c:1645 */
+#line 2158 "awkgram.c" /* yacc.c:1645 */
break;
case 25:
-#line 404 "awkgram.y" /* yacc.c:1645 */
+#line 416 "awkgram.y" /* yacc.c:1645 */
{
- INSTRUCTION *ip;
- if ((yyvsp[-3]) == NULL)
- ip = list_create(instruction(Op_no_op));
- else
- ip = (yyvsp[-3]);
+ INSTRUCTION *ip = make_braced_statements((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]));
+
+ if ((yyvsp[-2]) != NULL && (yyvsp[0]) != NULL) {
+ merge_comments((yyvsp[-2]), (yyvsp[0]));
+ pending_comment = (yyvsp[-2]);
+ } else if ((yyvsp[-2]) != NULL) {
+ pending_comment = (yyvsp[-2]);
+ } else if ((yyvsp[0]) != NULL) {
+ pending_comment = (yyvsp[0]);
+ }
+
(yyval) = ip;
}
-#line 2149 "awkgram.c" /* yacc.c:1645 */
+#line 2177 "awkgram.c" /* yacc.c:1645 */
break;
case 26:
-#line 416 "awkgram.y" /* yacc.c:1645 */
+#line 434 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 2155 "awkgram.c" /* yacc.c:1645 */
+#line 2183 "awkgram.c" /* yacc.c:1645 */
break;
case 27:
-#line 418 "awkgram.y" /* yacc.c:1645 */
+#line 436 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 2161 "awkgram.c" /* yacc.c:1645 */
+#line 2189 "awkgram.c" /* yacc.c:1645 */
break;
case 28:
-#line 420 "awkgram.y" /* yacc.c:1645 */
+#line 438 "awkgram.y" /* yacc.c:1645 */
{
yyerror(_("`%s' is a built-in function, it cannot be redefined"),
tokstart);
YYABORT;
}
-#line 2171 "awkgram.c" /* yacc.c:1645 */
+#line 2199 "awkgram.c" /* yacc.c:1645 */
break;
case 29:
-#line 426 "awkgram.y" /* yacc.c:1645 */
+#line 444 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = (yyvsp[0]);
at_seen = false;
}
-#line 2180 "awkgram.c" /* yacc.c:1645 */
+#line 2208 "awkgram.c" /* yacc.c:1645 */
break;
case 32:
-#line 438 "awkgram.y" /* yacc.c:1645 */
+#line 456 "awkgram.y" /* yacc.c:1645 */
{ want_param_names = FUNC_HEADER; }
-#line 2186 "awkgram.c" /* yacc.c:1645 */
+#line 2214 "awkgram.c" /* yacc.c:1645 */
break;
case 33:
-#line 439 "awkgram.y" /* yacc.c:1645 */
+#line 457 "awkgram.y" /* yacc.c:1645 */
{
- /*
- * treat any comments between BOF and the first function
- * definition (with no intervening BEGIN etc block) as
- * program comments. Special kludge: iff there are more
- * than one such comments, treat the last as a function
- * comment.
- */
- if (prior_comment != NULL) {
- comment_to_save = prior_comment;
- prior_comment = NULL;
- } else if (comment != NULL) {
- comment_to_save = comment;
- comment = NULL;
- } else
- comment_to_save = NULL;
-
- if (comment_to_save != NULL && func_first
- && strstr(comment_to_save->memory->stptr, "\n\n") != NULL)
- split_comment();
-
- /* save any other pre-function comment as function comment */
- if (comment_to_save != NULL) {
- function_comment = comment_to_save;
- comment_to_save = NULL;
+ INSTRUCTION *func_comment = NULL;
+ // Merge any comments found in the parameter list with those
+ // following the function header, associate the whole shebang
+ // with the function as one block comment.
+ if ((yyvsp[-2]) != NULL && (yyvsp[-2])->comment != NULL) {
+ if ((yyvsp[0]) != NULL) {
+ merge_comments((yyvsp[-2])->comment, (yyvsp[0]));
+ }
+ func_comment = (yyvsp[-2])->comment;
+ } else if ((yyvsp[0]) != NULL) {
+ func_comment = (yyvsp[0]);
}
- func_first = false;
+
(yyvsp[-6])->source_file = source;
+ (yyvsp[-6])->comment = func_comment;
if (install_function((yyvsp[-5])->lextok, (yyvsp[-6]), (yyvsp[-2])) < 0)
YYABORT;
in_function = (yyvsp[-5])->lextok;
@@ -2224,17 +2240,17 @@ yyreduce:
(yyval) = (yyvsp[-6]);
want_param_names = FUNC_BODY;
}
-#line 2228 "awkgram.c" /* yacc.c:1645 */
+#line 2244 "awkgram.c" /* yacc.c:1645 */
break;
case 34:
-#line 484 "awkgram.y" /* yacc.c:1645 */
+#line 490 "awkgram.y" /* yacc.c:1645 */
{ want_regexp = true; }
-#line 2234 "awkgram.c" /* yacc.c:1645 */
+#line 2250 "awkgram.c" /* yacc.c:1645 */
break;
case 35:
-#line 486 "awkgram.y" /* yacc.c:1645 */
+#line 492 "awkgram.y" /* yacc.c:1645 */
{
NODE *n, *exp;
char *re;
@@ -2263,11 +2279,11 @@ yyreduce:
(yyval)->opcode = Op_match_rec;
(yyval)->memory = n;
}
-#line 2267 "awkgram.c" /* yacc.c:1645 */
+#line 2283 "awkgram.c" /* yacc.c:1645 */
break;
case 36:
-#line 518 "awkgram.y" /* yacc.c:1645 */
+#line 524 "awkgram.y" /* yacc.c:1645 */
{
char *re;
size_t len;
@@ -2280,112 +2296,100 @@ yyreduce:
(yyval)->opcode = Op_push_re;
(yyval)->memory = make_typed_regex(re, len);
}
-#line 2284 "awkgram.c" /* yacc.c:1645 */
+#line 2300 "awkgram.c" /* yacc.c:1645 */
break;
case 37:
-#line 533 "awkgram.y" /* yacc.c:1645 */
+#line 539 "awkgram.y" /* yacc.c:1645 */
{ bcfree((yyvsp[0])); }
-#line 2290 "awkgram.c" /* yacc.c:1645 */
+#line 2306 "awkgram.c" /* yacc.c:1645 */
break;
case 39:
-#line 539 "awkgram.y" /* yacc.c:1645 */
- {
- if (prior_comment != NULL) {
- (yyval) = list_create(prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL) {
- (yyval) = list_create(comment);
- comment = NULL;
- } else
- (yyval) = NULL;
- }
-#line 2305 "awkgram.c" /* yacc.c:1645 */
+#line 545 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 2312 "awkgram.c" /* yacc.c:1645 */
break;
case 40:
-#line 550 "awkgram.y" /* yacc.c:1645 */
+#line 547 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0]) == NULL) {
- if (prior_comment != NULL) {
- (yyval) = list_append((yyvsp[-1]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- (yyval) = list_append((yyval), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- (yyval) = list_append((yyvsp[-1]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[-1]);
+ (yyval) = (yyvsp[-1]);
} else {
add_lint((yyvsp[0]), LINT_no_effect);
if ((yyvsp[-1]) == NULL) {
- if (prior_comment != NULL) {
- (yyval) = list_append((yyvsp[0]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- (yyval) = list_append((yyval), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- (yyval) = list_append((yyvsp[0]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[0]);
+ (yyval) = (yyvsp[0]);
} else {
- if (prior_comment != NULL) {
- list_append((yyvsp[0]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- list_append((yyvsp[0]), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- list_append((yyvsp[0]), comment);
- comment = NULL;
- }
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
}
+
+ if (trailing_comment != NULL) {
+ (yyval) = list_append((yyval), trailing_comment);
+ trailing_comment = NULL;
+ }
+
yyerrok;
}
-#line 2356 "awkgram.c" /* yacc.c:1645 */
+#line 2336 "awkgram.c" /* yacc.c:1645 */
break;
case 41:
-#line 597 "awkgram.y" /* yacc.c:1645 */
+#line 567 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2362 "awkgram.c" /* yacc.c:1645 */
+#line 2342 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 42:
+#line 571 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 2348 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 43:
+#line 572 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 2354 "awkgram.c" /* yacc.c:1645 */
break;
case 44:
-#line 607 "awkgram.y" /* yacc.c:1645 */
- { (yyval) = NULL; }
-#line 2368 "awkgram.c" /* yacc.c:1645 */
+#line 577 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL) {
+ INSTRUCTION *ip;
+
+ merge_comments((yyvsp[0]), NULL);
+ ip = list_create(instruction(Op_no_op));
+ (yyval) = list_append(ip, (yyvsp[0]));
+ } else
+ (yyval) = NULL;
+ }
+#line 2369 "awkgram.c" /* yacc.c:1645 */
break;
case 45:
-#line 609 "awkgram.y" /* yacc.c:1645 */
- { (yyval) = (yyvsp[-1]); }
-#line 2374 "awkgram.c" /* yacc.c:1645 */
+#line 588 "awkgram.y" /* yacc.c:1645 */
+ {
+ trailing_comment = (yyvsp[0]); // NULL or comment
+ (yyval) = make_braced_statements((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]));
+ }
+#line 2378 "awkgram.c" /* yacc.c:1645 */
break;
case 46:
-#line 611 "awkgram.y" /* yacc.c:1645 */
+#line 593 "awkgram.y" /* yacc.c:1645 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
}
-#line 2385 "awkgram.c" /* yacc.c:1645 */
+#line 2389 "awkgram.c" /* yacc.c:1645 */
break;
case 47:
-#line 618 "awkgram.y" /* yacc.c:1645 */
+#line 600 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2403,8 +2407,9 @@ yyreduce:
if ((yyvsp[-2]) != NULL) {
curr = (yyvsp[-2])->nexti;
bcfree((yyvsp[-2])); /* Op_list */
- } /* else
- curr = NULL; */
+ }
+ /* else
+ curr = NULL; */
for (; curr != NULL; curr = nextc) {
INSTRUCTION *caseexp = curr->case_exp;
@@ -2460,22 +2465,39 @@ yyreduce:
ip = (yyvsp[-6]);
if (do_pretty_print) {
+ // first merge comments
+ INSTRUCTION *head_comment = NULL;
+
+ if ((yyvsp[-4]) != NULL && (yyvsp[-3]) != NULL) {
+ merge_comments((yyvsp[-4]), (yyvsp[-3]));
+ head_comment = (yyvsp[-4]);
+ } else if ((yyvsp[-4]) != NULL)
+ head_comment = (yyvsp[-4]);
+ else
+ head_comment = (yyvsp[-3]);
+
+ (yyvsp[-8])->comment = head_comment;
+
(void) list_prepend(ip, (yyvsp[-8]));
(void) list_prepend(ip, instruction(Op_exec_count));
(yyvsp[-8])->target_break = tbreak;
((yyvsp[-8]) + 1)->switch_start = cexp->nexti;
((yyvsp[-8]) + 1)->switch_end = cexp->lasti;
- }/* else
- $1 is NULL */
+ ((yyvsp[-8]) + 1)->switch_end->comment = (yyvsp[0]);
+ }
+ /* else
+ $1 is NULL */
(void) list_append(cexp, dflt);
(void) list_merge(ip, cexp);
+ if ((yyvsp[-1]) != NULL)
+ (void) list_append(cstmt, (yyvsp[-1]));
(yyval) = list_merge(ip, cstmt);
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2479 "awkgram.c" /* yacc.c:1645 */
+#line 2501 "awkgram.c" /* yacc.c:1645 */
break;
case 48:
@@ -2508,8 +2530,17 @@ yyreduce:
(yyvsp[-5])->target_continue = tcont;
((yyvsp[-5]) + 1)->while_body = ip->lasti;
(void) list_prepend(ip, (yyvsp[-5]));
- }/* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
+
+ if ((yyvsp[-1]) != NULL) {
+ if ((yyvsp[0]) == NULL)
+ (yyvsp[0]) = list_create(instruction(Op_no_op));
+
+ (yyvsp[-1])->memory->comment_type = BLOCK_COMMENT;
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
+ }
if ((yyvsp[0]) != NULL)
(void) list_merge(ip, (yyvsp[0]));
@@ -2521,11 +2552,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2525 "awkgram.c" /* yacc.c:1645 */
+#line 2556 "awkgram.c" /* yacc.c:1645 */
break;
case 49:
-#line 750 "awkgram.y" /* yacc.c:1645 */
+#line 759 "awkgram.y" /* yacc.c:1645 */
{
/*
* -----------------
@@ -2548,8 +2579,13 @@ yyreduce:
ip = list_merge((yyvsp[-5]), (yyvsp[-2]));
else
ip = list_prepend((yyvsp[-2]), instruction(Op_no_op));
+
+ if ((yyvsp[-6]) != NULL)
+ (void) list_prepend(ip, (yyvsp[-6]));
+
if (do_pretty_print)
(void) list_prepend(ip, instruction(Op_exec_count));
+
(void) list_append(ip, instruction(Op_jmp_true));
ip->lasti->target_jmp = ip->nexti;
(yyval) = list_append(ip, tbreak);
@@ -2564,14 +2600,17 @@ yyreduce:
((yyvsp[-7]) + 1)->doloop_cond = tcont;
(yyval) = list_prepend(ip, (yyvsp[-7]));
bcfree((yyvsp[-4]));
- } /* else
+ if ((yyvsp[0]) != NULL)
+ (yyvsp[-7])->comment = (yyvsp[0]);
+ }
+ /* else
$1 and $4 are NULLs */
}
-#line 2571 "awkgram.c" /* yacc.c:1645 */
+#line 2610 "awkgram.c" /* yacc.c:1645 */
break;
case 50:
-#line 792 "awkgram.y" /* yacc.c:1645 */
+#line 809 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip;
char *var_name = (yyvsp[-5])->lextok;
@@ -2584,7 +2623,8 @@ yyreduce:
&& strcmp((yyvsp[0])->nexti->memory->vname, var_name) == 0
) {
- /* Efficiency hack. Recognize the special case of
+ /*
+ * Efficiency hack. Recognize the special case of
*
* for (iggy in foo)
* delete foo[iggy]
@@ -2616,6 +2656,10 @@ yyreduce:
bcfree((yyvsp[-5]));
bcfree((yyvsp[-4]));
bcfree((yyvsp[-3]));
+ if ((yyvsp[-1]) != NULL) {
+ merge_comments((yyvsp[-1]), NULL);
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
+ }
(yyval) = (yyvsp[0]);
} else
goto regular_loop;
@@ -2650,8 +2694,9 @@ regular_loop:
(yyvsp[-7])->target_continue = tcont;
(yyvsp[-7])->target_break = tbreak;
(void) list_append(ip, (yyvsp[-7]));
- } /* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
/* add update_FOO instruction if necessary */
if ((yyvsp[-4])->array_var->type == Node_var && (yyvsp[-4])->array_var->var_update) {
@@ -2672,8 +2717,15 @@ regular_loop:
((yyvsp[-7]) + 1)->forloop_body = ip->lasti;
}
- if ((yyvsp[0]) != NULL)
+ if ((yyvsp[-1]) != NULL)
+ merge_comments((yyvsp[-1]), NULL);
+
+ if ((yyvsp[0]) != NULL) {
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(void) list_merge(ip, (yyvsp[0]));
+ } else if ((yyvsp[-1]) != NULL)
+ (void) list_append(ip, (yyvsp[-1]));
(void) list_append(ip, instruction(Op_jmp));
ip->lasti->target_jmp = (yyvsp[-4]);
@@ -2684,73 +2736,100 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2688 "awkgram.c" /* yacc.c:1645 */
+#line 2740 "awkgram.c" /* yacc.c:1645 */
break;
case 51:
-#line 905 "awkgram.y" /* yacc.c:1645 */
+#line 935 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-7]) != NULL) {
+ merge_comments((yyvsp[-7]), NULL);
+ (yyvsp[-11])->comment = (yyvsp[-7]);
+ }
+ if ((yyvsp[-4]) != NULL) {
+ merge_comments((yyvsp[-4]), NULL);
+ if ((yyvsp[-11])->comment == NULL) {
+ (yyvsp[-4])->memory->comment_type = FOR_COMMENT;
+ (yyvsp[-11])->comment = (yyvsp[-4]);
+ } else
+ (yyvsp[-11])->comment->comment = (yyvsp[-4]);
+ }
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2699 "awkgram.c" /* yacc.c:1645 */
+#line 2765 "awkgram.c" /* yacc.c:1645 */
break;
case 52:
-#line 912 "awkgram.y" /* yacc.c:1645 */
+#line 956 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-6]) != NULL) {
+ merge_comments((yyvsp[-6]), NULL);
+ (yyvsp[-10])->comment = (yyvsp[-6]);
+ }
+ if ((yyvsp[-4]) != NULL) {
+ merge_comments((yyvsp[-4]), NULL);
+ if ((yyvsp[-10])->comment == NULL) {
+ (yyvsp[-4])->memory->comment_type = FOR_COMMENT;
+ (yyvsp[-10])->comment = (yyvsp[-4]);
+ } else
+ (yyvsp[-10])->comment->comment = (yyvsp[-4]);
+ }
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2710 "awkgram.c" /* yacc.c:1645 */
+#line 2790 "awkgram.c" /* yacc.c:1645 */
break;
case 53:
-#line 919 "awkgram.y" /* yacc.c:1645 */
+#line 977 "awkgram.y" /* yacc.c:1645 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
- (yyval) = add_pending_comment((yyval));
}
-#line 2722 "awkgram.c" /* yacc.c:1645 */
+#line 2801 "awkgram.c" /* yacc.c:1645 */
break;
case 54:
-#line 930 "awkgram.y" /* yacc.c:1645 */
+#line 987 "awkgram.y" /* yacc.c:1645 */
{
if (! break_allowed)
error_ln((yyvsp[-1])->source_line,
_("`break' is not allowed outside a loop or switch"));
(yyvsp[-1])->target_jmp = NULL;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
-
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2736 "awkgram.c" /* yacc.c:1645 */
+#line 2815 "awkgram.c" /* yacc.c:1645 */
break;
case 55:
-#line 940 "awkgram.y" /* yacc.c:1645 */
+#line 997 "awkgram.y" /* yacc.c:1645 */
{
if (! continue_allowed)
error_ln((yyvsp[-1])->source_line,
_("`continue' is not allowed outside a loop"));
(yyvsp[-1])->target_jmp = NULL;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
-
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2750 "awkgram.c" /* yacc.c:1645 */
+#line 2829 "awkgram.c" /* yacc.c:1645 */
break;
case 56:
-#line 950 "awkgram.y" /* yacc.c:1645 */
+#line 1007 "awkgram.y" /* yacc.c:1645 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2758,13 +2837,14 @@ regular_loop:
_("`next' used in %s action"), ruletab[rule]);
(yyvsp[-1])->target_jmp = ip_rec;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2764 "awkgram.c" /* yacc.c:1645 */
+#line 2844 "awkgram.c" /* yacc.c:1645 */
break;
case 57:
-#line 960 "awkgram.y" /* yacc.c:1645 */
+#line 1018 "awkgram.y" /* yacc.c:1645 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule == BEGIN || rule == END || rule == ENDFILE)
@@ -2774,13 +2854,14 @@ regular_loop:
(yyvsp[-1])->target_newfile = ip_newfile;
(yyvsp[-1])->target_endfile = ip_endfile;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2780 "awkgram.c" /* yacc.c:1645 */
+#line 2861 "awkgram.c" /* yacc.c:1645 */
break;
case 58:
-#line 972 "awkgram.y" /* yacc.c:1645 */
+#line 1031 "awkgram.y" /* yacc.c:1645 */
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2794,22 +2875,23 @@ regular_loop:
(yyval)->nexti->memory = dupnode(Nnull_string);
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2800 "awkgram.c" /* yacc.c:1645 */
+#line 2882 "awkgram.c" /* yacc.c:1645 */
break;
case 59:
-#line 988 "awkgram.y" /* yacc.c:1645 */
+#line 1048 "awkgram.y" /* yacc.c:1645 */
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 2809 "awkgram.c" /* yacc.c:1645 */
+#line 2891 "awkgram.c" /* yacc.c:1645 */
break;
case 60:
-#line 991 "awkgram.y" /* yacc.c:1645 */
+#line 1051 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-1]) == NULL) {
(yyval) = list_create((yyvsp[-3]));
@@ -2817,20 +2899,31 @@ regular_loop:
(yyval)->nexti->memory = dupnode(Nnull_string);
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
+ }
+#line 2906 "awkgram.c" /* yacc.c:1645 */
+ break;
- (yyval) = add_pending_comment((yyval));
+ case 61:
+#line 1062 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyvsp[-1]), (yyvsp[0]));
+ else
+ (yyval) = (yyvsp[-1]);
}
-#line 2824 "awkgram.c" /* yacc.c:1645 */
+#line 2917 "awkgram.c" /* yacc.c:1645 */
break;
case 62:
-#line 1013 "awkgram.y" /* yacc.c:1645 */
+#line 1079 "awkgram.y" /* yacc.c:1645 */
{ in_print = true; in_parens = 0; }
-#line 2830 "awkgram.c" /* yacc.c:1645 */
+#line 2923 "awkgram.c" /* yacc.c:1645 */
break;
case 63:
-#line 1014 "awkgram.y" /* yacc.c:1645 */
+#line 1080 "awkgram.y" /* yacc.c:1645 */
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -2838,7 +2931,7 @@ regular_loop:
* which is faster for these two cases.
*/
- if ((yyvsp[-3])->opcode == Op_K_print &&
+ if (do_optimize && (yyvsp[-3])->opcode == Op_K_print &&
((yyvsp[-1]) == NULL
|| ((yyvsp[-1])->lasti->opcode == Op_field_spec
&& (yyvsp[-1])->nexti->nexti->nexti == (yyvsp[-1])->lasti
@@ -2926,19 +3019,18 @@ regular_print:
}
}
}
- (yyval) = add_pending_comment((yyval));
}
-#line 2932 "awkgram.c" /* yacc.c:1645 */
+#line 3024 "awkgram.c" /* yacc.c:1645 */
break;
case 64:
-#line 1112 "awkgram.y" /* yacc.c:1645 */
+#line 1177 "awkgram.y" /* yacc.c:1645 */
{ sub_counter = 0; }
-#line 2938 "awkgram.c" /* yacc.c:1645 */
+#line 3030 "awkgram.c" /* yacc.c:1645 */
break;
case 65:
-#line 1113 "awkgram.y" /* yacc.c:1645 */
+#line 1178 "awkgram.y" /* yacc.c:1645 */
{
char *arr = (yyvsp[-2])->lextok;
@@ -2970,13 +3062,12 @@ regular_print:
(yyvsp[-3])->expr_count = sub_counter;
(yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3]));
}
- (yyval) = add_pending_comment((yyval));
}
-#line 2976 "awkgram.c" /* yacc.c:1645 */
+#line 3067 "awkgram.c" /* yacc.c:1645 */
break;
case 66:
-#line 1151 "awkgram.y" /* yacc.c:1645 */
+#line 1215 "awkgram.y" /* yacc.c:1645 */
{
static bool warned = false;
char *arr = (yyvsp[-1])->lextok;
@@ -3001,57 +3092,55 @@ regular_print:
else if ((yyvsp[-1])->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
- (yyval) = add_pending_comment((yyval));
}
-#line 3007 "awkgram.c" /* yacc.c:1645 */
+#line 3097 "awkgram.c" /* yacc.c:1645 */
break;
case 67:
-#line 1178 "awkgram.y" /* yacc.c:1645 */
+#line 1241 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = optimize_assignment((yyvsp[0]));
- (yyval) = add_pending_comment((yyval));
}
-#line 3016 "awkgram.c" /* yacc.c:1645 */
+#line 3105 "awkgram.c" /* yacc.c:1645 */
break;
case 68:
-#line 1186 "awkgram.y" /* yacc.c:1645 */
+#line 1248 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3022 "awkgram.c" /* yacc.c:1645 */
+#line 3111 "awkgram.c" /* yacc.c:1645 */
break;
case 69:
-#line 1188 "awkgram.y" /* yacc.c:1645 */
+#line 1250 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3028 "awkgram.c" /* yacc.c:1645 */
+#line 3117 "awkgram.c" /* yacc.c:1645 */
break;
case 70:
-#line 1193 "awkgram.y" /* yacc.c:1645 */
+#line 1255 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3034 "awkgram.c" /* yacc.c:1645 */
+#line 3123 "awkgram.c" /* yacc.c:1645 */
break;
case 71:
-#line 1195 "awkgram.y" /* yacc.c:1645 */
+#line 1257 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-1]) == NULL)
(yyval) = list_create((yyvsp[0]));
else
(yyval) = list_prepend((yyvsp[-1]), (yyvsp[0]));
}
-#line 3045 "awkgram.c" /* yacc.c:1645 */
+#line 3134 "awkgram.c" /* yacc.c:1645 */
break;
case 72:
-#line 1202 "awkgram.y" /* yacc.c:1645 */
+#line 1264 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3051 "awkgram.c" /* yacc.c:1645 */
+#line 3140 "awkgram.c" /* yacc.c:1645 */
break;
case 73:
-#line 1207 "awkgram.y" /* yacc.c:1645 */
+#line 1269 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -3060,14 +3149,15 @@ regular_print:
(void) list_prepend(casestmt, instruction(Op_exec_count));
(yyvsp[-4])->case_exp = (yyvsp[-3]);
(yyvsp[-4])->case_stmt = casestmt;
+ (yyvsp[-4])->comment = (yyvsp[-1]);
bcfree((yyvsp[-2]));
(yyval) = (yyvsp[-4]);
}
-#line 3067 "awkgram.c" /* yacc.c:1645 */
+#line 3157 "awkgram.c" /* yacc.c:1645 */
break;
case 74:
-#line 1219 "awkgram.y" /* yacc.c:1645 */
+#line 1282 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -3076,19 +3166,20 @@ regular_print:
(void) list_prepend(casestmt, instruction(Op_exec_count));
bcfree((yyvsp[-2]));
(yyvsp[-3])->case_stmt = casestmt;
+ (yyvsp[-3])->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-3]);
}
-#line 3082 "awkgram.c" /* yacc.c:1645 */
+#line 3173 "awkgram.c" /* yacc.c:1645 */
break;
case 75:
-#line 1233 "awkgram.y" /* yacc.c:1645 */
+#line 1297 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3088 "awkgram.c" /* yacc.c:1645 */
+#line 3179 "awkgram.c" /* yacc.c:1645 */
break;
case 76:
-#line 1235 "awkgram.y" /* yacc.c:1645 */
+#line 1299 "awkgram.y" /* yacc.c:1645 */
{
NODE *n = (yyvsp[0])->memory;
(void) force_number(n);
@@ -3096,28 +3187,28 @@ regular_print:
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3100 "awkgram.c" /* yacc.c:1645 */
+#line 3191 "awkgram.c" /* yacc.c:1645 */
break;
case 77:
-#line 1243 "awkgram.y" /* yacc.c:1645 */
+#line 1307 "awkgram.y" /* yacc.c:1645 */
{
NODE *n = (yyvsp[0])->lasti->memory;
bcfree((yyvsp[-1]));
add_sign_to_num(n, '+');
(yyval) = (yyvsp[0]);
}
-#line 3111 "awkgram.c" /* yacc.c:1645 */
+#line 3202 "awkgram.c" /* yacc.c:1645 */
break;
case 78:
-#line 1250 "awkgram.y" /* yacc.c:1645 */
+#line 1314 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3117 "awkgram.c" /* yacc.c:1645 */
+#line 3208 "awkgram.c" /* yacc.c:1645 */
break;
case 79:
-#line 1252 "awkgram.y" /* yacc.c:1645 */
+#line 1316 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->memory->type == Node_regex)
(yyvsp[0])->opcode = Op_push_re;
@@ -3125,57 +3216,57 @@ regular_print:
(yyvsp[0])->opcode = Op_push;
(yyval) = (yyvsp[0]);
}
-#line 3129 "awkgram.c" /* yacc.c:1645 */
+#line 3220 "awkgram.c" /* yacc.c:1645 */
break;
case 80:
-#line 1260 "awkgram.y" /* yacc.c:1645 */
+#line 1324 "awkgram.y" /* yacc.c:1645 */
{
assert(((yyvsp[0])->memory->flags & REGEX) == REGEX);
(yyvsp[0])->opcode = Op_push_re;
(yyval) = (yyvsp[0]);
}
-#line 3139 "awkgram.c" /* yacc.c:1645 */
+#line 3230 "awkgram.c" /* yacc.c:1645 */
break;
case 81:
-#line 1269 "awkgram.y" /* yacc.c:1645 */
+#line 1333 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3145 "awkgram.c" /* yacc.c:1645 */
+#line 3236 "awkgram.c" /* yacc.c:1645 */
break;
case 82:
-#line 1271 "awkgram.y" /* yacc.c:1645 */
+#line 1335 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3151 "awkgram.c" /* yacc.c:1645 */
+#line 3242 "awkgram.c" /* yacc.c:1645 */
break;
case 84:
-#line 1281 "awkgram.y" /* yacc.c:1645 */
+#line 1345 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = (yyvsp[-1]);
}
-#line 3159 "awkgram.c" /* yacc.c:1645 */
+#line 3250 "awkgram.c" /* yacc.c:1645 */
break;
case 85:
-#line 1288 "awkgram.y" /* yacc.c:1645 */
+#line 1352 "awkgram.y" /* yacc.c:1645 */
{
in_print = false;
in_parens = 0;
(yyval) = NULL;
}
-#line 3169 "awkgram.c" /* yacc.c:1645 */
+#line 3260 "awkgram.c" /* yacc.c:1645 */
break;
case 86:
-#line 1293 "awkgram.y" /* yacc.c:1645 */
+#line 1357 "awkgram.y" /* yacc.c:1645 */
{ in_print = false; in_parens = 0; }
-#line 3175 "awkgram.c" /* yacc.c:1645 */
+#line 3266 "awkgram.c" /* yacc.c:1645 */
break;
case 87:
-#line 1294 "awkgram.y" /* yacc.c:1645 */
+#line 1358 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->redir_type == redirect_twoway
&& (yyvsp[0])->lasti->opcode == Op_K_getline_redir
@@ -3185,139 +3276,197 @@ regular_print:
lintwarn(_("concatenation as I/O `>' redirection target is ambiguous"));
(yyval) = list_prepend((yyvsp[0]), (yyvsp[-2]));
}
-#line 3189 "awkgram.c" /* yacc.c:1645 */
+#line 3280 "awkgram.c" /* yacc.c:1645 */
break;
case 88:
-#line 1307 "awkgram.y" /* yacc.c:1645 */
+#line 1371 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-5])->comment = (yyvsp[-1]);
(yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL);
}
-#line 3197 "awkgram.c" /* yacc.c:1645 */
+#line 3290 "awkgram.c" /* yacc.c:1645 */
break;
case 89:
-#line 1312 "awkgram.y" /* yacc.c:1645 */
+#line 1378 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-4]) != NULL)
+ (yyvsp[-8])->comment = (yyvsp[-4]);
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->comment = (yyvsp[-1]);
(yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0]));
}
-#line 3205 "awkgram.c" /* yacc.c:1645 */
+#line 3302 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 90:
+#line 1389 "awkgram.y" /* yacc.c:1645 */
+ {
+ (yyval) = (yyvsp[0]);
+ }
+#line 3310 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 91:
+#line 1393 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ if ((yyvsp[-1])->memory->comment_type == EOL_COMMENT) {
+ assert((yyvsp[0])->memory->comment_type == BLOCK_COMMENT);
+ (yyvsp[-1])->comment = (yyvsp[0]); // chain them
+ } else {
+ merge_comments((yyvsp[-1]), (yyvsp[0]));
+ }
+
+ (yyval) = (yyvsp[-1]);
+ } else if ((yyvsp[-1]) != NULL) {
+ (yyval) = (yyvsp[-1]);
+ } else if ((yyvsp[0]) != NULL) {
+ (yyval) = (yyvsp[0]);
+ } else
+ (yyval) = NULL;
+ }
+#line 3332 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 92:
+#line 1414 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 3338 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 93:
+#line 1416 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 3344 "awkgram.c" /* yacc.c:1645 */
break;
case 94:
-#line 1329 "awkgram.y" /* yacc.c:1645 */
+#line 1421 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3211 "awkgram.c" /* yacc.c:1645 */
+#line 3350 "awkgram.c" /* yacc.c:1645 */
break;
case 95:
-#line 1331 "awkgram.y" /* yacc.c:1645 */
+#line 1423 "awkgram.y" /* yacc.c:1645 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3220 "awkgram.c" /* yacc.c:1645 */
+#line 3359 "awkgram.c" /* yacc.c:1645 */
break;
case 96:
-#line 1339 "awkgram.y" /* yacc.c:1645 */
+#line 1431 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3226 "awkgram.c" /* yacc.c:1645 */
+#line 3365 "awkgram.c" /* yacc.c:1645 */
break;
case 97:
-#line 1341 "awkgram.y" /* yacc.c:1645 */
+#line 1433 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3232 "awkgram.c" /* yacc.c:1645 */
+#line 3371 "awkgram.c" /* yacc.c:1645 */
break;
case 98:
-#line 1346 "awkgram.y" /* yacc.c:1645 */
+#line 1438 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->param_count = 0;
(yyval) = list_create((yyvsp[0]));
}
-#line 3241 "awkgram.c" /* yacc.c:1645 */
+#line 3380 "awkgram.c" /* yacc.c:1645 */
break;
case 99:
-#line 1351 "awkgram.y" /* yacc.c:1645 */
+#line 1443 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2]) != NULL && (yyvsp[0]) != NULL) {
- (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1;
+ (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1;
(yyval) = list_append((yyvsp[-2]), (yyvsp[0]));
yyerrok;
+
+ // newlines are allowed after commas, catch any comments
+ if ((yyvsp[-1]) != NULL) {
+ if ((yyvsp[-2])->comment != NULL)
+ merge_comments((yyvsp[-2])->comment, (yyvsp[-1]));
+ else
+ (yyvsp[-2])->comment = (yyvsp[-1]);
+ }
} else
(yyval) = NULL;
}
-#line 3254 "awkgram.c" /* yacc.c:1645 */
+#line 3401 "awkgram.c" /* yacc.c:1645 */
break;
case 100:
-#line 1360 "awkgram.y" /* yacc.c:1645 */
+#line 1460 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3260 "awkgram.c" /* yacc.c:1645 */
+#line 3407 "awkgram.c" /* yacc.c:1645 */
break;
case 101:
-#line 1362 "awkgram.y" /* yacc.c:1645 */
+#line 1462 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 3266 "awkgram.c" /* yacc.c:1645 */
+#line 3413 "awkgram.c" /* yacc.c:1645 */
break;
case 102:
-#line 1364 "awkgram.y" /* yacc.c:1645 */
+#line 1464 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-2]); }
-#line 3272 "awkgram.c" /* yacc.c:1645 */
+#line 3419 "awkgram.c" /* yacc.c:1645 */
break;
case 103:
-#line 1370 "awkgram.y" /* yacc.c:1645 */
+#line 1470 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3278 "awkgram.c" /* yacc.c:1645 */
+#line 3425 "awkgram.c" /* yacc.c:1645 */
break;
case 104:
-#line 1372 "awkgram.y" /* yacc.c:1645 */
+#line 1472 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3284 "awkgram.c" /* yacc.c:1645 */
+#line 3431 "awkgram.c" /* yacc.c:1645 */
break;
case 105:
-#line 1377 "awkgram.y" /* yacc.c:1645 */
+#line 1477 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3290 "awkgram.c" /* yacc.c:1645 */
+#line 3437 "awkgram.c" /* yacc.c:1645 */
break;
case 106:
-#line 1379 "awkgram.y" /* yacc.c:1645 */
+#line 1479 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3296 "awkgram.c" /* yacc.c:1645 */
+#line 3443 "awkgram.c" /* yacc.c:1645 */
break;
case 107:
-#line 1384 "awkgram.y" /* yacc.c:1645 */
+#line 1484 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3302 "awkgram.c" /* yacc.c:1645 */
+#line 3449 "awkgram.c" /* yacc.c:1645 */
break;
case 108:
-#line 1386 "awkgram.y" /* yacc.c:1645 */
+#line 1486 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3311 "awkgram.c" /* yacc.c:1645 */
+#line 3460 "awkgram.c" /* yacc.c:1645 */
break;
case 109:
-#line 1391 "awkgram.y" /* yacc.c:1645 */
+#line 1493 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3317 "awkgram.c" /* yacc.c:1645 */
+#line 3466 "awkgram.c" /* yacc.c:1645 */
break;
case 110:
-#line 1393 "awkgram.y" /* yacc.c:1645 */
+#line 1495 "awkgram.y" /* yacc.c:1645 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3325,62 +3474,66 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3329 "awkgram.c" /* yacc.c:1645 */
+#line 3478 "awkgram.c" /* yacc.c:1645 */
break;
case 111:
-#line 1401 "awkgram.y" /* yacc.c:1645 */
+#line 1503 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3338 "awkgram.c" /* yacc.c:1645 */
+#line 3487 "awkgram.c" /* yacc.c:1645 */
break;
case 112:
-#line 1406 "awkgram.y" /* yacc.c:1645 */
+#line 1508 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-2]);
}
-#line 3347 "awkgram.c" /* yacc.c:1645 */
+#line 3498 "awkgram.c" /* yacc.c:1645 */
break;
case 113:
-#line 1414 "awkgram.y" /* yacc.c:1645 */
+#line 1518 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3353 "awkgram.c" /* yacc.c:1645 */
+#line 3504 "awkgram.c" /* yacc.c:1645 */
break;
case 114:
-#line 1416 "awkgram.y" /* yacc.c:1645 */
+#line 1520 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3359 "awkgram.c" /* yacc.c:1645 */
+#line 3510 "awkgram.c" /* yacc.c:1645 */
break;
case 115:
-#line 1421 "awkgram.y" /* yacc.c:1645 */
+#line 1525 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3365 "awkgram.c" /* yacc.c:1645 */
+#line 3516 "awkgram.c" /* yacc.c:1645 */
break;
case 116:
-#line 1423 "awkgram.y" /* yacc.c:1645 */
+#line 1527 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3374 "awkgram.c" /* yacc.c:1645 */
+#line 3527 "awkgram.c" /* yacc.c:1645 */
break;
case 117:
-#line 1428 "awkgram.y" /* yacc.c:1645 */
+#line 1534 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3380 "awkgram.c" /* yacc.c:1645 */
+#line 3533 "awkgram.c" /* yacc.c:1645 */
break;
case 118:
-#line 1430 "awkgram.y" /* yacc.c:1645 */
+#line 1536 "awkgram.y" /* yacc.c:1645 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3388,72 +3541,74 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3392 "awkgram.c" /* yacc.c:1645 */
+#line 3545 "awkgram.c" /* yacc.c:1645 */
break;
case 119:
-#line 1438 "awkgram.y" /* yacc.c:1645 */
+#line 1544 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3401 "awkgram.c" /* yacc.c:1645 */
+#line 3554 "awkgram.c" /* yacc.c:1645 */
break;
case 120:
-#line 1443 "awkgram.y" /* yacc.c:1645 */
+#line 1549 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-2]);
}
-#line 3410 "awkgram.c" /* yacc.c:1645 */
+#line 3565 "awkgram.c" /* yacc.c:1645 */
break;
case 121:
-#line 1450 "awkgram.y" /* yacc.c:1645 */
+#line 1558 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3416 "awkgram.c" /* yacc.c:1645 */
+#line 3571 "awkgram.c" /* yacc.c:1645 */
break;
case 122:
-#line 1451 "awkgram.y" /* yacc.c:1645 */
+#line 1559 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = list_create((yyvsp[0])); }
-#line 3422 "awkgram.c" /* yacc.c:1645 */
+#line 3577 "awkgram.c" /* yacc.c:1645 */
break;
case 123:
-#line 1457 "awkgram.y" /* yacc.c:1645 */
+#line 1565 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec)
lintwarn_ln((yyvsp[-1])->source_line,
_("regular expression on right of assignment"));
(yyval) = mk_assignment((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1]));
}
-#line 3433 "awkgram.c" /* yacc.c:1645 */
+#line 3588 "awkgram.c" /* yacc.c:1645 */
break;
case 124:
-#line 1464 "awkgram.y" /* yacc.c:1645 */
+#line 1572 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = mk_assignment((yyvsp[-2]), list_create((yyvsp[0])), (yyvsp[-1]));
}
-#line 3441 "awkgram.c" /* yacc.c:1645 */
+#line 3596 "awkgram.c" /* yacc.c:1645 */
break;
case 125:
-#line 1468 "awkgram.y" /* yacc.c:1645 */
+#line 1576 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3447 "awkgram.c" /* yacc.c:1645 */
+#line 3602 "awkgram.c" /* yacc.c:1645 */
break;
case 126:
-#line 1470 "awkgram.y" /* yacc.c:1645 */
+#line 1578 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3453 "awkgram.c" /* yacc.c:1645 */
+#line 3608 "awkgram.c" /* yacc.c:1645 */
break;
case 127:
-#line 1472 "awkgram.y" /* yacc.c:1645 */
+#line 1580 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3466,11 +3621,11 @@ regular_print:
bcfree((yyvsp[0]));
(yyval) = list_append((yyvsp[-2]), (yyvsp[-1]));
}
-#line 3470 "awkgram.c" /* yacc.c:1645 */
+#line 3625 "awkgram.c" /* yacc.c:1645 */
break;
case 128:
-#line 1485 "awkgram.y" /* yacc.c:1645 */
+#line 1593 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3487,11 +3642,11 @@ regular_print:
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3491 "awkgram.c" /* yacc.c:1645 */
+#line 3646 "awkgram.c" /* yacc.c:1645 */
break;
case 129:
-#line 1502 "awkgram.y" /* yacc.c:1645 */
+#line 1610 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint_old)
warning_ln((yyvsp[-1])->source_line,
@@ -3501,91 +3656,91 @@ regular_print:
(yyvsp[-1])->expr_count = 1;
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
-#line 3505 "awkgram.c" /* yacc.c:1645 */
+#line 3660 "awkgram.c" /* yacc.c:1645 */
break;
case 130:
-#line 1512 "awkgram.y" /* yacc.c:1645 */
+#line 1620 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec)
lintwarn_ln((yyvsp[-1])->source_line,
_("regular expression on right of comparison"));
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
-#line 3516 "awkgram.c" /* yacc.c:1645 */
+#line 3671 "awkgram.c" /* yacc.c:1645 */
break;
case 131:
-#line 1519 "awkgram.y" /* yacc.c:1645 */
+#line 1627 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); }
-#line 3522 "awkgram.c" /* yacc.c:1645 */
+#line 3677 "awkgram.c" /* yacc.c:1645 */
break;
case 132:
-#line 1521 "awkgram.y" /* yacc.c:1645 */
+#line 1629 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3528 "awkgram.c" /* yacc.c:1645 */
+#line 3683 "awkgram.c" /* yacc.c:1645 */
break;
case 133:
-#line 1526 "awkgram.y" /* yacc.c:1645 */
+#line 1634 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3534 "awkgram.c" /* yacc.c:1645 */
+#line 3689 "awkgram.c" /* yacc.c:1645 */
break;
case 134:
-#line 1528 "awkgram.y" /* yacc.c:1645 */
+#line 1636 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3540 "awkgram.c" /* yacc.c:1645 */
+#line 3695 "awkgram.c" /* yacc.c:1645 */
break;
case 135:
-#line 1530 "awkgram.y" /* yacc.c:1645 */
+#line 1638 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[0]);
}
-#line 3549 "awkgram.c" /* yacc.c:1645 */
+#line 3704 "awkgram.c" /* yacc.c:1645 */
break;
case 136:
-#line 1538 "awkgram.y" /* yacc.c:1645 */
+#line 1646 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3555 "awkgram.c" /* yacc.c:1645 */
+#line 3710 "awkgram.c" /* yacc.c:1645 */
break;
case 137:
-#line 1540 "awkgram.y" /* yacc.c:1645 */
+#line 1648 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3561 "awkgram.c" /* yacc.c:1645 */
+#line 3716 "awkgram.c" /* yacc.c:1645 */
break;
case 138:
-#line 1545 "awkgram.y" /* yacc.c:1645 */
+#line 1653 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3567 "awkgram.c" /* yacc.c:1645 */
+#line 3722 "awkgram.c" /* yacc.c:1645 */
break;
case 139:
-#line 1547 "awkgram.y" /* yacc.c:1645 */
+#line 1655 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3573 "awkgram.c" /* yacc.c:1645 */
+#line 3728 "awkgram.c" /* yacc.c:1645 */
break;
case 140:
-#line 1552 "awkgram.y" /* yacc.c:1645 */
+#line 1660 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3579 "awkgram.c" /* yacc.c:1645 */
+#line 3734 "awkgram.c" /* yacc.c:1645 */
break;
case 141:
-#line 1554 "awkgram.y" /* yacc.c:1645 */
+#line 1662 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3585 "awkgram.c" /* yacc.c:1645 */
+#line 3740 "awkgram.c" /* yacc.c:1645 */
break;
case 142:
-#line 1556 "awkgram.y" /* yacc.c:1645 */
+#line 1664 "awkgram.y" /* yacc.c:1645 */
{
int count = 2;
bool is_simple_var = false;
@@ -3639,47 +3794,47 @@ regular_print:
max_args = count;
}
}
-#line 3643 "awkgram.c" /* yacc.c:1645 */
+#line 3798 "awkgram.c" /* yacc.c:1645 */
break;
case 144:
-#line 1615 "awkgram.y" /* yacc.c:1645 */
+#line 1723 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3649 "awkgram.c" /* yacc.c:1645 */
+#line 3804 "awkgram.c" /* yacc.c:1645 */
break;
case 145:
-#line 1617 "awkgram.y" /* yacc.c:1645 */
+#line 1725 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3655 "awkgram.c" /* yacc.c:1645 */
+#line 3810 "awkgram.c" /* yacc.c:1645 */
break;
case 146:
-#line 1619 "awkgram.y" /* yacc.c:1645 */
+#line 1727 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3661 "awkgram.c" /* yacc.c:1645 */
+#line 3816 "awkgram.c" /* yacc.c:1645 */
break;
case 147:
-#line 1621 "awkgram.y" /* yacc.c:1645 */
+#line 1729 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3667 "awkgram.c" /* yacc.c:1645 */
+#line 3822 "awkgram.c" /* yacc.c:1645 */
break;
case 148:
-#line 1623 "awkgram.y" /* yacc.c:1645 */
+#line 1731 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3673 "awkgram.c" /* yacc.c:1645 */
+#line 3828 "awkgram.c" /* yacc.c:1645 */
break;
case 149:
-#line 1625 "awkgram.y" /* yacc.c:1645 */
+#line 1733 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3679 "awkgram.c" /* yacc.c:1645 */
+#line 3834 "awkgram.c" /* yacc.c:1645 */
break;
case 150:
-#line 1627 "awkgram.y" /* yacc.c:1645 */
+#line 1735 "awkgram.y" /* yacc.c:1645 */
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3693,29 +3848,29 @@ regular_print:
_("non-redirected `getline' undefined inside END action"));
(yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input);
}
-#line 3697 "awkgram.c" /* yacc.c:1645 */
+#line 3852 "awkgram.c" /* yacc.c:1645 */
break;
case 151:
-#line 1641 "awkgram.y" /* yacc.c:1645 */
+#line 1749 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postincrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3706 "awkgram.c" /* yacc.c:1645 */
+#line 3861 "awkgram.c" /* yacc.c:1645 */
break;
case 152:
-#line 1646 "awkgram.y" /* yacc.c:1645 */
+#line 1754 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postdecrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3715 "awkgram.c" /* yacc.c:1645 */
+#line 3870 "awkgram.c" /* yacc.c:1645 */
break;
case 153:
-#line 1651 "awkgram.y" /* yacc.c:1645 */
+#line 1759 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint_old) {
warning_ln((yyvsp[-1])->source_line,
@@ -3735,64 +3890,64 @@ regular_print:
(yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3739 "awkgram.c" /* yacc.c:1645 */
+#line 3894 "awkgram.c" /* yacc.c:1645 */
break;
case 154:
-#line 1676 "awkgram.y" /* yacc.c:1645 */
+#line 1784 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type);
bcfree((yyvsp[-2]));
}
-#line 3748 "awkgram.c" /* yacc.c:1645 */
+#line 3903 "awkgram.c" /* yacc.c:1645 */
break;
case 155:
-#line 1682 "awkgram.y" /* yacc.c:1645 */
+#line 1790 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3754 "awkgram.c" /* yacc.c:1645 */
+#line 3909 "awkgram.c" /* yacc.c:1645 */
break;
case 156:
-#line 1684 "awkgram.y" /* yacc.c:1645 */
+#line 1792 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3760 "awkgram.c" /* yacc.c:1645 */
+#line 3915 "awkgram.c" /* yacc.c:1645 */
break;
case 157:
-#line 1686 "awkgram.y" /* yacc.c:1645 */
+#line 1794 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3766 "awkgram.c" /* yacc.c:1645 */
+#line 3921 "awkgram.c" /* yacc.c:1645 */
break;
case 158:
-#line 1688 "awkgram.y" /* yacc.c:1645 */
+#line 1796 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3772 "awkgram.c" /* yacc.c:1645 */
+#line 3927 "awkgram.c" /* yacc.c:1645 */
break;
case 159:
-#line 1690 "awkgram.y" /* yacc.c:1645 */
+#line 1798 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3778 "awkgram.c" /* yacc.c:1645 */
+#line 3933 "awkgram.c" /* yacc.c:1645 */
break;
case 160:
-#line 1692 "awkgram.y" /* yacc.c:1645 */
+#line 1800 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3784 "awkgram.c" /* yacc.c:1645 */
+#line 3939 "awkgram.c" /* yacc.c:1645 */
break;
case 161:
-#line 1697 "awkgram.y" /* yacc.c:1645 */
+#line 1805 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3792 "awkgram.c" /* yacc.c:1645 */
+#line 3947 "awkgram.c" /* yacc.c:1645 */
break;
case 162:
-#line 1701 "awkgram.y" /* yacc.c:1645 */
+#line 1809 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
@@ -3824,11 +3979,11 @@ regular_print:
}
}
}
-#line 3828 "awkgram.c" /* yacc.c:1645 */
+#line 3983 "awkgram.c" /* yacc.c:1645 */
break;
case 163:
-#line 1733 "awkgram.y" /* yacc.c:1645 */
+#line 1841 "awkgram.y" /* yacc.c:1645 */
{
// Always include. Allows us to lint warn on
// print "foo" > "bar" 1
@@ -3836,31 +3991,31 @@ regular_print:
// print "foo" > ("bar" 1)
(yyval) = list_append((yyvsp[-1]), bcalloc(Op_parens, 1, sourceline));
}
-#line 3840 "awkgram.c" /* yacc.c:1645 */
+#line 3995 "awkgram.c" /* yacc.c:1645 */
break;
case 164:
-#line 1741 "awkgram.y" /* yacc.c:1645 */
+#line 1849 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3850 "awkgram.c" /* yacc.c:1645 */
+#line 4005 "awkgram.c" /* yacc.c:1645 */
break;
case 165:
-#line 1747 "awkgram.y" /* yacc.c:1645 */
+#line 1855 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3860 "awkgram.c" /* yacc.c:1645 */
+#line 4015 "awkgram.c" /* yacc.c:1645 */
break;
case 166:
-#line 1753 "awkgram.y" /* yacc.c:1645 */
+#line 1861 "awkgram.y" /* yacc.c:1645 */
{
static bool warned = false;
@@ -3873,45 +4028,45 @@ regular_print:
if ((yyval) == NULL)
YYABORT;
}
-#line 3877 "awkgram.c" /* yacc.c:1645 */
+#line 4032 "awkgram.c" /* yacc.c:1645 */
break;
case 169:
-#line 1768 "awkgram.y" /* yacc.c:1645 */
+#line 1876 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[-1])->opcode = Op_preincrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3886 "awkgram.c" /* yacc.c:1645 */
+#line 4041 "awkgram.c" /* yacc.c:1645 */
break;
case 170:
-#line 1773 "awkgram.y" /* yacc.c:1645 */
+#line 1881 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[-1])->opcode = Op_predecrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3895 "awkgram.c" /* yacc.c:1645 */
+#line 4050 "awkgram.c" /* yacc.c:1645 */
break;
case 171:
-#line 1778 "awkgram.y" /* yacc.c:1645 */
+#line 1886 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3903 "awkgram.c" /* yacc.c:1645 */
+#line 4058 "awkgram.c" /* yacc.c:1645 */
break;
case 172:
-#line 1782 "awkgram.y" /* yacc.c:1645 */
+#line 1890 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3911 "awkgram.c" /* yacc.c:1645 */
+#line 4066 "awkgram.c" /* yacc.c:1645 */
break;
case 173:
-#line 1786 "awkgram.y" /* yacc.c:1645 */
+#line 1894 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & STRING) == 0
@@ -3926,11 +4081,11 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3930 "awkgram.c" /* yacc.c:1645 */
+#line 4085 "awkgram.c" /* yacc.c:1645 */
break;
case 174:
-#line 1801 "awkgram.y" /* yacc.c:1645 */
+#line 1909 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & STRING) == 0
@@ -3948,20 +4103,20 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3952 "awkgram.c" /* yacc.c:1645 */
+#line 4107 "awkgram.c" /* yacc.c:1645 */
break;
case 175:
-#line 1822 "awkgram.y" /* yacc.c:1645 */
+#line 1930 "awkgram.y" /* yacc.c:1645 */
{
func_use((yyvsp[0])->lasti->func_name, FUNC_USE);
(yyval) = (yyvsp[0]);
}
-#line 3961 "awkgram.c" /* yacc.c:1645 */
+#line 4116 "awkgram.c" /* yacc.c:1645 */
break;
case 176:
-#line 1827 "awkgram.y" /* yacc.c:1645 */
+#line 1935 "awkgram.y" /* yacc.c:1645 */
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3995,11 +4150,11 @@ regular_print:
(yyval) = list_prepend((yyvsp[0]), t);
at_seen = false;
}
-#line 3999 "awkgram.c" /* yacc.c:1645 */
+#line 4154 "awkgram.c" /* yacc.c:1645 */
break;
case 177:
-#line 1864 "awkgram.y" /* yacc.c:1645 */
+#line 1972 "awkgram.y" /* yacc.c:1645 */
{
NODE *n;
@@ -4024,49 +4179,49 @@ regular_print:
(yyval) = list_append(t, (yyvsp[-3]));
}
}
-#line 4028 "awkgram.c" /* yacc.c:1645 */
+#line 4183 "awkgram.c" /* yacc.c:1645 */
break;
case 178:
-#line 1892 "awkgram.y" /* yacc.c:1645 */
+#line 2000 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4034 "awkgram.c" /* yacc.c:1645 */
+#line 4189 "awkgram.c" /* yacc.c:1645 */
break;
case 179:
-#line 1894 "awkgram.y" /* yacc.c:1645 */
+#line 2002 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4040 "awkgram.c" /* yacc.c:1645 */
+#line 4195 "awkgram.c" /* yacc.c:1645 */
break;
case 180:
-#line 1899 "awkgram.y" /* yacc.c:1645 */
+#line 2007 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4046 "awkgram.c" /* yacc.c:1645 */
+#line 4201 "awkgram.c" /* yacc.c:1645 */
break;
case 181:
-#line 1901 "awkgram.y" /* yacc.c:1645 */
+#line 2009 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 4052 "awkgram.c" /* yacc.c:1645 */
+#line 4207 "awkgram.c" /* yacc.c:1645 */
break;
case 182:
-#line 1906 "awkgram.y" /* yacc.c:1645 */
+#line 2014 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4058 "awkgram.c" /* yacc.c:1645 */
+#line 4213 "awkgram.c" /* yacc.c:1645 */
break;
case 183:
-#line 1908 "awkgram.y" /* yacc.c:1645 */
+#line 2016 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 4066 "awkgram.c" /* yacc.c:1645 */
+#line 4221 "awkgram.c" /* yacc.c:1645 */
break;
case 184:
-#line 1915 "awkgram.y" /* yacc.c:1645 */
+#line 2023 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip = (yyvsp[0])->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated expressions */
@@ -4080,11 +4235,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
(yyval) = (yyvsp[0]);
}
-#line 4084 "awkgram.c" /* yacc.c:1645 */
+#line 4239 "awkgram.c" /* yacc.c:1645 */
break;
case 185:
-#line 1932 "awkgram.y" /* yacc.c:1645 */
+#line 2040 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *t = (yyvsp[-1]);
if ((yyvsp[-1]) == NULL) {
@@ -4098,31 +4253,31 @@ regular_print:
(yyvsp[0])->sub_count = count_expressions(&t, false);
(yyval) = list_append(t, (yyvsp[0]));
}
-#line 4102 "awkgram.c" /* yacc.c:1645 */
+#line 4257 "awkgram.c" /* yacc.c:1645 */
break;
case 186:
-#line 1949 "awkgram.y" /* yacc.c:1645 */
+#line 2057 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4108 "awkgram.c" /* yacc.c:1645 */
+#line 4263 "awkgram.c" /* yacc.c:1645 */
break;
case 187:
-#line 1951 "awkgram.y" /* yacc.c:1645 */
+#line 2059 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 4116 "awkgram.c" /* yacc.c:1645 */
+#line 4271 "awkgram.c" /* yacc.c:1645 */
break;
case 188:
-#line 1958 "awkgram.y" /* yacc.c:1645 */
+#line 2066 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 4122 "awkgram.c" /* yacc.c:1645 */
+#line 4277 "awkgram.c" /* yacc.c:1645 */
break;
case 189:
-#line 1963 "awkgram.y" /* yacc.c:1645 */
+#line 2071 "awkgram.y" /* yacc.c:1645 */
{
char *var_name = (yyvsp[0])->lextok;
@@ -4130,22 +4285,22 @@ regular_print:
(yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new);
(yyval) = list_create((yyvsp[0]));
}
-#line 4134 "awkgram.c" /* yacc.c:1645 */
+#line 4289 "awkgram.c" /* yacc.c:1645 */
break;
case 190:
-#line 1971 "awkgram.y" /* yacc.c:1645 */
+#line 2079 "awkgram.y" /* yacc.c:1645 */
{
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 4145 "awkgram.c" /* yacc.c:1645 */
+#line 4300 "awkgram.c" /* yacc.c:1645 */
break;
case 191:
-#line 1981 "awkgram.y" /* yacc.c:1645 */
+#line 2089 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip = (yyvsp[0])->nexti;
if (ip->opcode == Op_push
@@ -4157,73 +4312,85 @@ regular_print:
} else
(yyval) = (yyvsp[0]);
}
-#line 4161 "awkgram.c" /* yacc.c:1645 */
+#line 4316 "awkgram.c" /* yacc.c:1645 */
break;
case 192:
-#line 1993 "awkgram.y" /* yacc.c:1645 */
+#line 2101 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
if ((yyvsp[0]) != NULL)
mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 4171 "awkgram.c" /* yacc.c:1645 */
+#line 4326 "awkgram.c" /* yacc.c:1645 */
break;
case 193:
-#line 2002 "awkgram.y" /* yacc.c:1645 */
+#line 2110 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postincrement;
}
-#line 4179 "awkgram.c" /* yacc.c:1645 */
+#line 4334 "awkgram.c" /* yacc.c:1645 */
break;
case 194:
-#line 2006 "awkgram.y" /* yacc.c:1645 */
+#line 2114 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postdecrement;
}
-#line 4187 "awkgram.c" /* yacc.c:1645 */
+#line 4342 "awkgram.c" /* yacc.c:1645 */
break;
case 195:
-#line 2009 "awkgram.y" /* yacc.c:1645 */
+#line 2118 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4193 "awkgram.c" /* yacc.c:1645 */
+#line 4348 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 196:
+#line 2122 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 4354 "awkgram.c" /* yacc.c:1645 */
break;
case 197:
-#line 2017 "awkgram.y" /* yacc.c:1645 */
- { yyerrok; }
-#line 4199 "awkgram.c" /* yacc.c:1645 */
+#line 2126 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); yyerrok; }
+#line 4360 "awkgram.c" /* yacc.c:1645 */
break;
case 198:
-#line 2021 "awkgram.y" /* yacc.c:1645 */
+#line 2130 "awkgram.y" /* yacc.c:1645 */
{ yyerrok; }
-#line 4205 "awkgram.c" /* yacc.c:1645 */
+#line 4366 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 199:
+#line 2135 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 4372 "awkgram.c" /* yacc.c:1645 */
break;
case 201:
-#line 2030 "awkgram.y" /* yacc.c:1645 */
+#line 2140 "awkgram.y" /* yacc.c:1645 */
{ yyerrok; }
-#line 4211 "awkgram.c" /* yacc.c:1645 */
+#line 4378 "awkgram.c" /* yacc.c:1645 */
break;
case 202:
-#line 2034 "awkgram.y" /* yacc.c:1645 */
+#line 2144 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); yyerrok; }
-#line 4217 "awkgram.c" /* yacc.c:1645 */
+#line 4384 "awkgram.c" /* yacc.c:1645 */
break;
case 203:
-#line 2038 "awkgram.y" /* yacc.c:1645 */
- { yyerrok; }
-#line 4223 "awkgram.c" /* yacc.c:1645 */
+#line 2148 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); yyerrok; }
+#line 4390 "awkgram.c" /* yacc.c:1645 */
break;
-#line 4227 "awkgram.c" /* yacc.c:1645 */
+#line 4394 "awkgram.c" /* yacc.c:1645 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4450,7 +4617,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 2040 "awkgram.y" /* yacc.c:1903 */
+#line 2150 "awkgram.y" /* yacc.c:1903 */
struct token {
@@ -4529,8 +4696,8 @@ static const struct token tokentab[] = {
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
{"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
-{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
-{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
+{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
+{"function", Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0, 0},
{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0, 0},
{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0, 0},
@@ -4889,11 +5056,12 @@ mk_program()
cp = end_block;
else
cp = list_merge(begin_block, end_block);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
- if (comment != NULL)
- (void) list_append(cp, comment);
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -4926,12 +5094,16 @@ mk_program()
if (begin_block != NULL)
cp = list_merge(begin_block, cp);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+ if (outer_comment != NULL) {
+ cp = list_merge(list_create(outer_comment), cp);
+ outer_comment = NULL;
}
- if (comment != NULL) {
- (void) list_append(cp, comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -4939,10 +5111,6 @@ out:
/* delete the Op_list, not needed */
tmp = cp->nexti;
bcfree(cp);
- /* these variables are not used again but zap them anyway. */
- comment = NULL;
- function_comment = NULL;
- program_comment = NULL;
return tmp;
#undef begin_block
@@ -5117,33 +5285,35 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
/* include_source --- read program from source included using `@include' */
-static int
-include_source(INSTRUCTION *file)
+static bool
+include_source(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@include is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @include"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open source file `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
/* save scanner state for the current sourcefile */
@@ -5162,42 +5332,46 @@ include_source(INSTRUCTION *file)
lasttok = 0;
lexeof = false;
eof_warned = false;
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* load_library --- load a shared library */
-static int
-load_library(INSTRUCTION *file)
+static bool
+load_library(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@load is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @load"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open shared library `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
load_ext(s->fullpath);
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* next_sourcefile --- read program from the next source in srcfiles */
@@ -5605,37 +5779,23 @@ pushback(void)
(! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
}
-/* check_comment --- check for block comment */
-
-void
-check_comment(void)
-{
- if (comment != NULL) {
- if (first_rule) {
- program_comment = comment;
- } else
- block_comment = comment;
- comment = NULL;
- }
- first_rule = false;
-}
-
/*
* get_comment --- collect comment text.
* Flag = EOL_COMMENT for end-of-line comments.
- * Flag = FULL_COMMENT for self-contained comments.
+ * Flag = BLOCK_COMMENT for self-contained comments.
*/
-int
-get_comment(int flag)
+static int
+get_comment(enum commenttype flag, INSTRUCTION **comment_instruction)
{
int c;
int sl;
+ char *p1;
+ char *p2;
+
tok = tokstart;
tokadd('#');
sl = sourceline;
- char *p1;
- char *p2;
while (true) {
while ((c = nextc(false)) != '\n' && c != END_FILE) {
@@ -5671,9 +5831,6 @@ get_comment(int flag)
break;
}
- if (comment != NULL)
- prior_comment = comment;
-
/* remove any trailing blank lines (consecutive \n) from comment */
p1 = tok - 1;
p2 = tok - 2;
@@ -5683,49 +5840,18 @@ get_comment(int flag)
tok--;
}
- comment = bcalloc(Op_comment, 1, sl);
- comment->source_file = source;
- comment->memory = make_str_node(tokstart, tok - tokstart, 0);
- comment->memory->comment_type = flag;
+ (*comment_instruction) = bcalloc(Op_comment, 1, sl);
+ (*comment_instruction)->source_file = source;
+ (*comment_instruction)->memory = make_str_node(tokstart, tok - tokstart, 0);
+ (*comment_instruction)->memory->comment_type = flag;
return c;
}
-/* split_comment --- split initial comment text into program and function parts */
-
-static void
-split_comment(void)
-{
- char *p;
- int l;
- NODE *n;
-
- p = comment_to_save->memory->stptr;
- l = comment_to_save->memory->stlen - 3;
- /* have at least two comments so split at last blank line (\n\n) */
- while (l >= 0) {
- if (p[l] == '\n' && p[l+1] == '\n') {
- function_comment = comment_to_save;
- n = function_comment->memory;
- function_comment->memory = make_string(p + l + 2, n->stlen - l - 2);
- /* create program comment */
- program_comment = bcalloc(Op_comment, 1, sourceline);
- program_comment->source_file = comment_to_save->source_file;
- p[l + 2] = 0;
- program_comment->memory = make_str_node(p, l + 2, 0);
- comment_to_save = NULL;
- freenode(n);
- break;
- }
- else
- l--;
- }
-}
-
/* allow_newline --- allow newline after &&, ||, ? and : */
static void
-allow_newline(void)
+allow_newline(INSTRUCTION **new_comment)
{
int c;
@@ -5737,8 +5863,8 @@ allow_newline(void)
}
if (c == '#') {
if (do_pretty_print && ! do_profile) {
- /* collect comment byte code iff doing pretty print but not profiling. */
- c = get_comment(EOL_COMMENT);
+ /* collect comment byte code iff doing pretty print but not profiling. */
+ c = get_comment(EOL_COMMENT, new_comment);
} else {
while ((c = nextc(false)) != '\n' && c != END_FILE)
continue;
@@ -5805,6 +5931,7 @@ yylex(void)
bool intlstr = false;
AWKNUM d;
bool collecting_typed_regexp = false;
+ static int qm_col_count = 0;
#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline)
@@ -5969,18 +6096,25 @@ retry:
return lasttok = NEWLINE;
case '#': /* it's a comment */
+ yylval = NULL;
if (do_pretty_print && ! do_profile) {
/*
* Collect comment byte code iff doing pretty print
* but not profiling.
*/
+ INSTRUCTION *new_comment;
+
if (lasttok == NEWLINE || lasttok == 0)
- c = get_comment(FULL_COMMENT);
+ c = get_comment(BLOCK_COMMENT, & new_comment);
else
- c = get_comment(EOL_COMMENT);
+ c = get_comment(EOL_COMMENT, & new_comment);
- if (c == END_FILE)
- return lasttok = NEWLINE_EOF;
+ yylval = new_comment;
+
+ if (c == END_FILE) {
+ pushback();
+ return lasttok = NEWLINE;
+ }
} else {
while ((c = nextc(false)) != '\n') {
if (c == END_FILE)
@@ -6009,7 +6143,10 @@ retry:
* Use it at your own risk. We think it's a bad idea, which
* is why it's not on by default.
*/
+ yylval = NULL;
if (! do_traditional) {
+ INSTRUCTION *new_comment;
+
/* strip trailing white-space and/or comment */
while ((c = nextc(true)) == ' ' || c == '\t' || c == '\r')
continue;
@@ -6021,9 +6158,11 @@ retry:
lintwarn(
_("use of `\\ #...' line continuation is not portable"));
}
- if (do_pretty_print && ! do_profile)
- c = get_comment(EOL_COMMENT);
- else {
+ if (do_pretty_print && ! do_profile) {
+ c = get_comment(EOL_COMMENT, & new_comment);
+ yylval = new_comment;
+ return lasttok = c;
+ } else {
while ((c = nextc(false)) != '\n')
if (c == END_FILE)
break;
@@ -6044,11 +6183,19 @@ retry:
}
break;
- case ':':
case '?':
+ qm_col_count++;
+ // fall through
+ case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (! do_posix)
- allow_newline();
+ if (c == ':' && qm_col_count > 0) {
+ if (do_posix) {
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+ }
+ qm_col_count--;
+ }
return lasttok = c;
/*
@@ -6470,7 +6617,10 @@ retry:
case '&':
if ((c = nextc(true)) == '&') {
yylval = GET_INSTRUCTION(Op_and);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_AND;
}
pushback();
@@ -6480,11 +6630,15 @@ retry:
case '|':
if ((c = nextc(true)) == '|') {
yylval = GET_INSTRUCTION(Op_or);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_OR;
} else if (! do_traditional && c == '&') {
yylval = GET_INSTRUCTION(Op_symbol);
yylval->redir_type = redirect_twoway;
+
return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN);
}
pushback();
@@ -6674,8 +6828,11 @@ out:
yylval->lextok = tokkey;
#define SMART_ALECK 1
- if (SMART_ALECK && do_lint
- && ! goto_warned && strcasecmp(tokkey, "goto") == 0) {
+ if (SMART_ALECK
+ && do_lint
+ && ! goto_warned
+ && tolower(tokkey[0]) == 'g'
+ && strcasecmp(tokkey, "goto") == 0) {
goto_warned = true;
lintwarn(_("`goto' considered harmful!"));
}
@@ -7146,15 +7303,8 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
thisfunc = fi->func_body;
assert(thisfunc != NULL);
- /* add any pre-function comment to start of action for profile.c */
-
- if (function_comment != NULL) {
- function_comment->source_line = 0;
- (void) list_prepend(def, function_comment);
- function_comment = NULL;
- }
-
- /* add an implicit return at end;
+ /*
+ * Add an implicit return at end;
* also used by 'return' command in debugger
*/
@@ -7865,12 +8015,11 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 1)->lasti = action->lasti;
(rp + 2)->first_line = pattern->source_line;
(rp + 2)->last_line = lastline;
- if (block_comment != NULL) {
- ip = list_prepend(list_prepend(action, block_comment), rp);
- block_comment = NULL;
- } else
- ip = list_prepend(action, rp);
-
+ ip = list_prepend(action, rp);
+ if (interblock_comment != NULL) {
+ ip = list_prepend(ip, interblock_comment);
+ interblock_comment = NULL;
+ }
} else {
rp = bcalloc(Op_rule, 3, 0);
rp->in_rule = Rule;
@@ -7896,14 +8045,20 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 2)->last_line = find_line(pattern, LAST_LINE);
action = list_create(instruction(Op_K_print_rec));
if (do_pretty_print)
- (void) list_prepend(action, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
} else
(rp + 2)->last_line = lastline;
if (do_pretty_print) {
- (void) list_prepend(pattern, instruction(Op_exec_count));
- (void) list_prepend(action, instruction(Op_exec_count));
+ pattern = list_prepend(pattern, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
}
+
+ if (interblock_comment != NULL) { // was after previous action
+ pattern = list_prepend(pattern, interblock_comment);
+ interblock_comment = NULL;
+ }
+
(rp + 1)->firsti = action->nexti;
(rp + 1)->lasti = tp;
ip = list_append(
@@ -8275,8 +8430,9 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond,
forp->target_break = tbreak;
forp->target_continue = tcont;
ret = list_prepend(ret, forp);
- } /* else
- forp is NULL */
+ }
+ /* else
+ forp is NULL */
return ret;
}
@@ -8490,26 +8646,6 @@ list_merge(INSTRUCTION *l1, INSTRUCTION *l2)
return l1;
}
-/* add_pending_comment --- add a pending comment to a statement */
-
-static inline INSTRUCTION *
-add_pending_comment(INSTRUCTION *stmt)
-{
- INSTRUCTION *ret = stmt;
-
- if (prior_comment != NULL) {
- if (function_comment != prior_comment)
- ret = list_append(stmt, prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL && comment->memory->comment_type == EOL_COMMENT) {
- if (function_comment != comment)
- ret = list_append(stmt, comment);
- comment = NULL;
- }
-
- return ret;
-}
-
/* See if name is a special token. */
int
@@ -8749,3 +8885,91 @@ set_profile_text(NODE *n, const char *str, size_t len)
return n;
}
+
+/*
+ * merge_comments --- merge c2 into c1 and free c2 if successful.
+ * Allow c2 to be NULL, in which case just merged chained
+ * comments in c1.
+ */
+
+static void
+merge_comments(INSTRUCTION *c1, INSTRUCTION *c2)
+{
+ assert(c1->opcode == Op_comment);
+
+ if (c1->comment == NULL && c2 == NULL) // nothing to do
+ return;
+
+ size_t total = c1->memory->stlen;
+ if (c1->comment != NULL)
+ total += 1 /* \n */ + c1->comment->memory->stlen;
+
+ if (c2 != NULL) {
+ assert(c2->opcode == Op_comment);
+ total += 1 /* \n */ + c2->memory->stlen;
+ if (c2->comment != NULL)
+ total += c2->comment->memory->stlen + 1;
+ }
+
+ char *buffer;
+ emalloc(buffer, char *, total + 1, "merge_comments");
+
+ strcpy(buffer, c1->memory->stptr);
+ if (c1->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c1->comment->memory->stptr);
+ }
+
+ if (c2 != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->memory->stptr);
+ if (c2->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->comment->memory->stptr);
+ }
+
+ unref(c2->memory);
+ if (c2->comment != NULL) {
+ unref(c2->comment->memory);
+ bcfree(c2->comment);
+ c2->comment = NULL;
+ }
+ bcfree(c2);
+ }
+
+ c1->memory->comment_type = BLOCK_COMMENT;
+ free(c1->memory->stptr);
+ c1->memory->stptr = buffer;
+ c1->memory->stlen = strlen(buffer);
+
+ // now free everything else
+ if (c1->comment != NULL) {
+ unref(c1->comment->memory);
+ bcfree(c1->comment);
+ c1->comment = NULL;
+ }
+}
+
+/* make_braced_statements --- handle `l_brace statements r_brace' with comments */
+
+static INSTRUCTION *
+make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace)
+{
+ INSTRUCTION *ip;
+
+ if (stmts == NULL)
+ ip = list_create(instruction(Op_no_op));
+ else
+ ip = stmts;
+
+ if (lbrace != NULL) {
+ INSTRUCTION *comment2 = lbrace->comment;
+ if (comment2 != NULL) {
+ ip = list_prepend(ip, comment2);
+ lbrace->comment = NULL;
+ }
+ ip = list_prepend(ip, lbrace);
+ }
+
+ return ip;
+}
diff --git a/awkgram.y b/awkgram.y
index 1afad27e..4d3e44e1 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -53,11 +53,15 @@ static int isnoeffect(OPCODE type);
static INSTRUCTION *make_assignable(INSTRUCTION *ip);
static void dumpintlstr(const char *str, size_t len);
static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2);
-static int include_source(INSTRUCTION *file);
-static int load_library(INSTRUCTION *file);
+static bool include_source(INSTRUCTION *file, void **srcfile_p);
+static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
+static INSTRUCTION *trailing_comment;
+static INSTRUCTION *outer_comment;
+static INSTRUCTION *interblock_comment;
+static INSTRUCTION *pending_comment;
#define instruction(t) bcalloc(t, 1, 0)
@@ -84,8 +88,8 @@ static void check_funcs(void);
static ssize_t read_one_line(int fd, void *buffer, size_t count);
static int one_line_close(int fd);
-static void split_comment(void);
-static void check_comment(void);
+static void merge_comments(INSTRUCTION *c1, INSTRUCTION *c2);
+static INSTRUCTION *make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace);
static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
@@ -152,21 +156,13 @@ static INSTRUCTION *ip_endfile;
static INSTRUCTION *ip_beginfile;
INSTRUCTION *main_beginfile;
-static INSTRUCTION *comment = NULL;
-static INSTRUCTION *prior_comment = NULL;
-static INSTRUCTION *comment_to_save = NULL;
-static INSTRUCTION *program_comment = NULL;
-static INSTRUCTION *function_comment = NULL;
-static INSTRUCTION *block_comment = NULL;
-
-static bool func_first = true;
+static bool func_first = true; // can nuke
static bool first_rule = true;
static inline INSTRUCTION *list_create(INSTRUCTION *x);
static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2);
-static inline INSTRUCTION *add_pending_comment(INSTRUCTION *stmt);
extern double fmod(double x, double y);
@@ -214,12 +210,22 @@ extern double fmod(double x, double y);
program
: /* empty */
+ { $$ = NULL; }
| program rule
{
rule = 0;
yyerrok;
}
| program nls
+ {
+ if ($2 != NULL) {
+ if ($1 == NULL)
+ outer_comment = $2;
+ else
+ interblock_comment = $2;
+ }
+ $$ = $1;
+ }
| program LEX_EOF
{
next_sourcefile();
@@ -239,6 +245,10 @@ rule
: pattern action
{
(void) append_rule($1, $2);
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
first_rule = false;
}
| pattern statement_term
@@ -249,8 +259,11 @@ rule
} else if ($1 == NULL) {
msg(_("each rule must have a pattern or an action part"));
errcount++;
- } else /* pattern rule with non-empty pattern */
+ } else { /* pattern rule with non-empty pattern */
+ if ($2 != NULL)
+ list_append($1, $2);
(void) append_rule($1, NULL);
+ }
}
| function_prologue action
{
@@ -263,12 +276,20 @@ rule
{
want_source = false;
at_seen = false;
+ if ($3 != NULL && $4 != NULL) {
+ SRCFILE *s = (SRCFILE *) $3;
+ s->comment = $4;
+ }
yyerrok;
}
| '@' LEX_LOAD library statement_term
{
want_source = false;
at_seen = false;
+ if ($3 != NULL && $4 != NULL) {
+ SRCFILE *s = (SRCFILE *) $3;
+ s->comment = $4;
+ }
yyerrok;
}
;
@@ -276,11 +297,13 @@ rule
source
: FILENAME
{
- if (include_source($1) < 0)
+ void *srcfile = NULL;
+
+ if (! include_source($1, & srcfile))
YYABORT;
efree($1->lextok);
bcfree($1);
- $$ = NULL;
+ $$ = (INSTRUCTION *) srcfile;
}
| FILENAME error
{ $$ = NULL; }
@@ -291,11 +314,13 @@ source
library
: FILENAME
{
- if (load_library($1) < 0)
+ void *srcfile;
+
+ if (! load_library($1, & srcfile))
YYABORT;
efree($1->lextok);
bcfree($1);
- $$ = NULL;
+ $$ = (INSTRUCTION *) srcfile;
}
| FILENAME error
{ $$ = NULL; }
@@ -307,20 +332,11 @@ pattern
: /* empty */
{
rule = Rule;
- if (comment != NULL) {
- $$ = list_create(comment);
- comment = NULL;
- } else
- $$ = NULL;
+ $$ = NULL;
}
| exp
{
rule = Rule;
- if (comment != NULL) {
- $$ = list_prepend($1, comment);
- comment = NULL;
- } else
- $$ = $1;
}
| exp ',' opt_nls exp
@@ -346,10 +362,10 @@ pattern
($1->nexti + 1)->condpair_left = $1->lasti;
($1->nexti + 1)->condpair_right = $4->lasti;
}
- if (comment != NULL) {
- $$ = list_append(list_merge(list_prepend($1, comment), $4), tp);
- comment = NULL;
- } else
+ /* Put any comments in front of the range expression */
+ if ($3 != NULL)
+ $$ = list_append(list_merge(list_prepend($1, $3), $4), tp);
+ else
$$ = list_append(list_merge($1, $4), tp);
rule = Rule;
}
@@ -364,7 +380,6 @@ pattern
$1->in_rule = rule = BEGIN;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_END
@@ -378,7 +393,6 @@ pattern
$1->in_rule = rule = END;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_BEGINFILE
@@ -386,7 +400,6 @@ pattern
func_first = false;
$1->in_rule = rule = BEGINFILE;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_ENDFILE
@@ -394,7 +407,6 @@ pattern
func_first = false;
$1->in_rule = rule = ENDFILE;
$1->source_file = source;
- check_comment();
$$ = $1;
}
;
@@ -402,11 +414,17 @@ pattern
action
: l_brace statements r_brace opt_semi opt_nls
{
- INSTRUCTION *ip;
- if ($2 == NULL)
- ip = list_create(instruction(Op_no_op));
- else
- ip = $2;
+ INSTRUCTION *ip = make_braced_statements($1, $2, $3);
+
+ if ($3 != NULL && $5 != NULL) {
+ merge_comments($3, $5);
+ pending_comment = $3;
+ } else if ($3 != NULL) {
+ pending_comment = $3;
+ } else if ($5 != NULL) {
+ pending_comment = $5;
+ }
+
$$ = ip;
}
;
@@ -437,33 +455,21 @@ lex_builtin
function_prologue
: LEX_FUNCTION func_name '(' { want_param_names = FUNC_HEADER; } opt_param_list r_paren opt_nls
{
- /*
- * treat any comments between BOF and the first function
- * definition (with no intervening BEGIN etc block) as
- * program comments. Special kludge: iff there are more
- * than one such comments, treat the last as a function
- * comment.
- */
- if (prior_comment != NULL) {
- comment_to_save = prior_comment;
- prior_comment = NULL;
- } else if (comment != NULL) {
- comment_to_save = comment;
- comment = NULL;
- } else
- comment_to_save = NULL;
-
- if (comment_to_save != NULL && func_first
- && strstr(comment_to_save->memory->stptr, "\n\n") != NULL)
- split_comment();
-
- /* save any other pre-function comment as function comment */
- if (comment_to_save != NULL) {
- function_comment = comment_to_save;
- comment_to_save = NULL;
+ INSTRUCTION *func_comment = NULL;
+ // Merge any comments found in the parameter list with those
+ // following the function header, associate the whole shebang
+ // with the function as one block comment.
+ if ($5 != NULL && $5->comment != NULL) {
+ if ($7 != NULL) {
+ merge_comments($5->comment, $7);
+ }
+ func_comment = $5->comment;
+ } else if ($7 != NULL) {
+ func_comment = $7;
}
- func_first = false;
+
$1->source_file = source;
+ $1->comment = func_comment;
if (install_function($2->lextok, $1, $5) < 0)
YYABORT;
in_function = $2->lextok;
@@ -536,61 +542,25 @@ a_slash
statements
: /* empty */
- {
- if (prior_comment != NULL) {
- $$ = list_create(prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL) {
- $$ = list_create(comment);
- comment = NULL;
- } else
- $$ = NULL;
- }
+ { $$ = NULL; }
| statements statement
{
if ($2 == NULL) {
- if (prior_comment != NULL) {
- $$ = list_append($1, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- $$ = list_append($$, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- $$ = list_append($1, comment);
- comment = NULL;
- } else
- $$ = $1;
+ $$ = $1;
} else {
add_lint($2, LINT_no_effect);
if ($1 == NULL) {
- if (prior_comment != NULL) {
- $$ = list_append($2, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- $$ = list_append($$, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- $$ = list_append($2, comment);
- comment = NULL;
- } else
- $$ = $2;
+ $$ = $2;
} else {
- if (prior_comment != NULL) {
- list_append($2, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- list_append($2, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- list_append($2, comment);
- comment = NULL;
- }
$$ = list_merge($1, $2);
}
}
+
+ if (trailing_comment != NULL) {
+ $$ = list_append($$, trailing_comment);
+ trailing_comment = NULL;
+ }
+
yyerrok;
}
| statements error
@@ -598,15 +568,27 @@ statements
;
statement_term
- : nls
- | semi opt_nls
+ : nls { $$ = $1; }
+ | semi opt_nls { $$ = $2; }
;
statement
: semi opt_nls
- { $$ = NULL; }
+ {
+ if ($2 != NULL) {
+ INSTRUCTION *ip;
+
+ merge_comments($2, NULL);
+ ip = list_create(instruction(Op_no_op));
+ $$ = list_append(ip, $2);
+ } else
+ $$ = NULL;
+ }
| l_brace statements r_brace
- { $$ = $2; }
+ {
+ trailing_comment = $3; // NULL or comment
+ $$ = make_braced_statements($1, $2, $3);
+ }
| if_statement
{
if (do_pretty_print)
@@ -632,8 +614,9 @@ statement
if ($7 != NULL) {
curr = $7->nexti;
bcfree($7); /* Op_list */
- } /* else
- curr = NULL; */
+ }
+ /* else
+ curr = NULL; */
for (; curr != NULL; curr = nextc) {
INSTRUCTION *caseexp = curr->case_exp;
@@ -689,16 +672,33 @@ statement
ip = $3;
if (do_pretty_print) {
+ // first merge comments
+ INSTRUCTION *head_comment = NULL;
+
+ if ($5 != NULL && $6 != NULL) {
+ merge_comments($5, $6);
+ head_comment = $5;
+ } else if ($5 != NULL)
+ head_comment = $5;
+ else
+ head_comment = $6;
+
+ $1->comment = head_comment;
+
(void) list_prepend(ip, $1);
(void) list_prepend(ip, instruction(Op_exec_count));
$1->target_break = tbreak;
($1 + 1)->switch_start = cexp->nexti;
($1 + 1)->switch_end = cexp->lasti;
- }/* else
- $1 is NULL */
+ ($1 + 1)->switch_end->comment = $9;
+ }
+ /* else
+ $1 is NULL */
(void) list_append(cexp, dflt);
(void) list_merge(ip, cexp);
+ if ($8 != NULL)
+ (void) list_append(cstmt, $8);
$$ = list_merge(ip, cstmt);
break_allowed--;
@@ -733,8 +733,17 @@ statement
$1->target_continue = tcont;
($1 + 1)->while_body = ip->lasti;
(void) list_prepend(ip, $1);
- }/* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
+
+ if ($5 != NULL) {
+ if ($6 == NULL)
+ $6 = list_create(instruction(Op_no_op));
+
+ $5->memory->comment_type = BLOCK_COMMENT;
+ $6 = list_prepend($6, $5);
+ }
if ($6 != NULL)
(void) list_merge(ip, $6);
@@ -769,8 +778,13 @@ statement
ip = list_merge($3, $6);
else
ip = list_prepend($6, instruction(Op_no_op));
+
+ if ($2 != NULL)
+ (void) list_prepend(ip, $2);
+
if (do_pretty_print)
(void) list_prepend(ip, instruction(Op_exec_count));
+
(void) list_append(ip, instruction(Op_jmp_true));
ip->lasti->target_jmp = ip->nexti;
$$ = list_append(ip, tbreak);
@@ -785,7 +799,10 @@ statement
($1 + 1)->doloop_cond = tcont;
$$ = list_prepend(ip, $1);
bcfree($4);
- } /* else
+ if ($8 != NULL)
+ $1->comment = $8;
+ }
+ /* else
$1 and $4 are NULLs */
}
| LEX_FOR '(' NAME LEX_IN simple_variable r_paren opt_nls statement
@@ -801,7 +818,8 @@ statement
&& strcmp($8->nexti->memory->vname, var_name) == 0
) {
- /* Efficiency hack. Recognize the special case of
+ /*
+ * Efficiency hack. Recognize the special case of
*
* for (iggy in foo)
* delete foo[iggy]
@@ -833,6 +851,10 @@ statement
bcfree($3);
bcfree($4);
bcfree($5);
+ if ($7 != NULL) {
+ merge_comments($7, NULL);
+ $8 = list_prepend($8, $7);
+ }
$$ = $8;
} else
goto regular_loop;
@@ -867,8 +889,9 @@ regular_loop:
$1->target_continue = tcont;
$1->target_break = tbreak;
(void) list_append(ip, $1);
- } /* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
/* add update_FOO instruction if necessary */
if ($4->array_var->type == Node_var && $4->array_var->var_update) {
@@ -889,8 +912,15 @@ regular_loop:
($1 + 1)->forloop_body = ip->lasti;
}
- if ($8 != NULL)
+ if ($7 != NULL)
+ merge_comments($7, NULL);
+
+ if ($8 != NULL) {
+ if ($7 != NULL)
+ $8 = list_prepend($8, $7);
(void) list_merge(ip, $8);
+ } else if ($7 != NULL)
+ (void) list_append(ip, $7);
(void) list_append(ip, instruction(Op_jmp));
ip->lasti->target_jmp = $4;
@@ -903,6 +933,20 @@ regular_loop:
}
| LEX_FOR '(' opt_simple_stmt semi opt_nls exp semi opt_nls opt_simple_stmt r_paren opt_nls statement
{
+ if ($5 != NULL) {
+ merge_comments($5, NULL);
+ $1->comment = $5;
+ }
+ if ($8 != NULL) {
+ merge_comments($8, NULL);
+ if ($1->comment == NULL) {
+ $8->memory->comment_type = FOR_COMMENT;
+ $1->comment = $8;
+ } else
+ $1->comment->comment = $8;
+ }
+ if ($11 != NULL)
+ $12 = list_prepend($12, $11);
$$ = mk_for_loop($1, $3, $6, $9, $12);
break_allowed--;
@@ -910,6 +954,20 @@ regular_loop:
}
| LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r_paren opt_nls statement
{
+ if ($5 != NULL) {
+ merge_comments($5, NULL);
+ $1->comment = $5;
+ }
+ if ($7 != NULL) {
+ merge_comments($7, NULL);
+ if ($1->comment == NULL) {
+ $7->memory->comment_type = FOR_COMMENT;
+ $1->comment = $7;
+ } else
+ $1->comment->comment = $7;
+ }
+ if ($10 != NULL)
+ $11 = list_prepend($11, $10);
$$ = mk_for_loop($1, $3, (INSTRUCTION *) NULL, $8, $11);
break_allowed--;
@@ -921,7 +979,6 @@ regular_loop:
$$ = list_prepend($1, instruction(Op_exec_count));
else
$$ = $1;
- $$ = add_pending_comment($$);
}
;
@@ -933,8 +990,8 @@ non_compound_stmt
_("`break' is not allowed outside a loop or switch"));
$1->target_jmp = NULL;
$$ = list_create($1);
- $$ = add_pending_comment($$);
-
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_CONTINUE statement_term
{
@@ -943,8 +1000,8 @@ non_compound_stmt
_("`continue' is not allowed outside a loop"));
$1->target_jmp = NULL;
$$ = list_create($1);
- $$ = add_pending_comment($$);
-
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_NEXT statement_term
{
@@ -954,7 +1011,8 @@ non_compound_stmt
_("`next' used in %s action"), ruletab[rule]);
$1->target_jmp = ip_rec;
$$ = list_create($1);
- $$ = add_pending_comment($$);
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_NEXTFILE statement_term
{
@@ -966,7 +1024,8 @@ non_compound_stmt
$1->target_newfile = ip_newfile;
$1->target_endfile = ip_endfile;
$$ = list_create($1);
- $$ = add_pending_comment($$);
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_EXIT opt_exp statement_term
{
@@ -982,7 +1041,8 @@ non_compound_stmt
$$->nexti->memory = dupnode(Nnull_string);
} else
$$ = list_append($2, $1);
- $$ = add_pending_comment($$);
+ if ($3 != NULL)
+ $$ = list_append($$, $3);
}
| LEX_RETURN
{
@@ -995,10 +1055,16 @@ non_compound_stmt
$$->nexti->memory = dupnode(Nnull_string);
} else
$$ = list_append($3, $1);
-
- $$ = add_pending_comment($$);
+ if ($4 != NULL)
+ $$ = list_append($$, $4);
}
| simple_stmt statement_term
+ {
+ if ($2 != NULL)
+ $$ = list_append($1, $2);
+ else
+ $$ = $1;
+ }
;
/*
@@ -1018,7 +1084,7 @@ simple_stmt
* which is faster for these two cases.
*/
- if ($1->opcode == Op_K_print &&
+ if (do_optimize && $1->opcode == Op_K_print &&
($3 == NULL
|| ($3->lasti->opcode == Op_field_spec
&& $3->nexti->nexti->nexti == $3->lasti
@@ -1106,7 +1172,6 @@ regular_print:
}
}
}
- $$ = add_pending_comment($$);
}
| LEX_DELETE NAME { sub_counter = 0; } delete_subscript_list
@@ -1141,7 +1206,6 @@ regular_print:
$1->expr_count = sub_counter;
$$ = list_append(list_append($4, $2), $1);
}
- $$ = add_pending_comment($$);
}
| LEX_DELETE '(' NAME ')'
/*
@@ -1172,12 +1236,10 @@ regular_print:
else if ($3->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
- $$ = add_pending_comment($$);
}
| exp
{
$$ = optimize_assignment($1);
- $$ = add_pending_comment($$);
}
;
@@ -1212,6 +1274,7 @@ case_statement
(void) list_prepend(casestmt, instruction(Op_exec_count));
$1->case_exp = $2;
$1->case_stmt = casestmt;
+ $1->comment = $4;
bcfree($3);
$$ = $1;
}
@@ -1224,6 +1287,7 @@ case_statement
(void) list_prepend(casestmt, instruction(Op_exec_count));
bcfree($2);
$1->case_stmt = casestmt;
+ $1->comment = $3;
$$ = $1;
}
;
@@ -1305,23 +1369,51 @@ output_redir
if_statement
: LEX_IF '(' exp r_paren opt_nls statement
{
+ if ($5 != NULL)
+ $1->comment = $5;
$$ = mk_condition($3, $1, $6, NULL, NULL);
}
| LEX_IF '(' exp r_paren opt_nls statement
LEX_ELSE opt_nls statement
{
+ if ($5 != NULL)
+ $1->comment = $5;
+ if ($8 != NULL)
+ $7->comment = $8;
$$ = mk_condition($3, $1, $6, $7, $9);
}
;
nls
: NEWLINE
+ {
+ $$ = $1;
+ }
| nls NEWLINE
+ {
+ if ($1 != NULL && $2 != NULL) {
+ if ($1->memory->comment_type == EOL_COMMENT) {
+ assert($2->memory->comment_type == BLOCK_COMMENT);
+ $1->comment = $2; // chain them
+ } else {
+ merge_comments($1, $2);
+ }
+
+ $$ = $1;
+ } else if ($1 != NULL) {
+ $$ = $1;
+ } else if ($2 != NULL) {
+ $$ = $2;
+ } else
+ $$ = NULL;
+ }
;
opt_nls
: /* empty */
+ { $$ = NULL; }
| nls
+ { $$ = $1; }
;
input_redir
@@ -1350,9 +1442,17 @@ param_list
| param_list comma NAME
{
if ($1 != NULL && $3 != NULL) {
- $3->param_count = $1->lasti->param_count + 1;
+ $3->param_count = $1->lasti->param_count + 1;
$$ = list_append($1, $3);
yyerrok;
+
+ // newlines are allowed after commas, catch any comments
+ if ($2 != NULL) {
+ if ($1->comment != NULL)
+ merge_comments($1->comment, $2);
+ else
+ $1->comment = $2;
+ }
} else
$$ = NULL;
}
@@ -1384,6 +1484,8 @@ expression_list
{ $$ = mk_expression_list(NULL, $1); }
| expression_list comma exp
{
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = mk_expression_list($1, $3);
yyerrok;
}
@@ -1405,6 +1507,8 @@ expression_list
| expression_list comma error
{
/* Ditto */
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = $1;
}
;
@@ -1421,6 +1525,8 @@ fcall_expression_list
{ $$ = mk_expression_list(NULL, $1); }
| fcall_expression_list comma fcall_exp
{
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = mk_expression_list($1, $3);
yyerrok;
}
@@ -1442,6 +1548,8 @@ fcall_expression_list
| fcall_expression_list comma error
{
/* Ditto */
+ if ($2 != NULL)
+ $1->comment = $2;
$$ = $1;
}
;
@@ -2006,15 +2114,16 @@ opt_incdec
{
$1->opcode = Op_postdecrement;
}
- | /* empty */ { $$ = NULL; }
+ | /* empty */
+ { $$ = NULL; }
;
l_brace
- : '{' opt_nls
+ : '{' opt_nls { $$ = $2; }
;
r_brace
- : '}' opt_nls { yyerrok; }
+ : '}' opt_nls { $$ = $2; yyerrok; }
;
r_paren
@@ -2023,6 +2132,7 @@ r_paren
opt_semi
: /* empty */
+ { $$ = NULL; }
| semi
;
@@ -2035,7 +2145,7 @@ colon
;
comma
- : ',' opt_nls { yyerrok; }
+ : ',' opt_nls { $$ = $2; yyerrok; }
;
%%
@@ -2115,8 +2225,8 @@ static const struct token tokentab[] = {
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
{"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
-{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
-{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
+{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
+{"function", Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0, 0},
{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0, 0},
{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0, 0},
@@ -2475,11 +2585,12 @@ mk_program()
cp = end_block;
else
cp = list_merge(begin_block, end_block);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
- if (comment != NULL)
- (void) list_append(cp, comment);
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -2512,12 +2623,16 @@ mk_program()
if (begin_block != NULL)
cp = list_merge(begin_block, cp);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+ if (outer_comment != NULL) {
+ cp = list_merge(list_create(outer_comment), cp);
+ outer_comment = NULL;
}
- if (comment != NULL) {
- (void) list_append(cp, comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -2525,10 +2640,6 @@ out:
/* delete the Op_list, not needed */
tmp = cp->nexti;
bcfree(cp);
- /* these variables are not used again but zap them anyway. */
- comment = NULL;
- function_comment = NULL;
- program_comment = NULL;
return tmp;
#undef begin_block
@@ -2703,33 +2814,35 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
/* include_source --- read program from source included using `@include' */
-static int
-include_source(INSTRUCTION *file)
+static bool
+include_source(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@include is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @include"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open source file `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
/* save scanner state for the current sourcefile */
@@ -2748,42 +2861,46 @@ include_source(INSTRUCTION *file)
lasttok = 0;
lexeof = false;
eof_warned = false;
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* load_library --- load a shared library */
-static int
-load_library(INSTRUCTION *file)
+static bool
+load_library(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@load is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @load"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open shared library `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
load_ext(s->fullpath);
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* next_sourcefile --- read program from the next source in srcfiles */
@@ -3191,37 +3308,23 @@ pushback(void)
(! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
}
-/* check_comment --- check for block comment */
-
-void
-check_comment(void)
-{
- if (comment != NULL) {
- if (first_rule) {
- program_comment = comment;
- } else
- block_comment = comment;
- comment = NULL;
- }
- first_rule = false;
-}
-
/*
* get_comment --- collect comment text.
* Flag = EOL_COMMENT for end-of-line comments.
- * Flag = FULL_COMMENT for self-contained comments.
+ * Flag = BLOCK_COMMENT for self-contained comments.
*/
-int
-get_comment(int flag)
+static int
+get_comment(enum commenttype flag, INSTRUCTION **comment_instruction)
{
int c;
int sl;
+ char *p1;
+ char *p2;
+
tok = tokstart;
tokadd('#');
sl = sourceline;
- char *p1;
- char *p2;
while (true) {
while ((c = nextc(false)) != '\n' && c != END_FILE) {
@@ -3257,9 +3360,6 @@ get_comment(int flag)
break;
}
- if (comment != NULL)
- prior_comment = comment;
-
/* remove any trailing blank lines (consecutive \n) from comment */
p1 = tok - 1;
p2 = tok - 2;
@@ -3269,49 +3369,18 @@ get_comment(int flag)
tok--;
}
- comment = bcalloc(Op_comment, 1, sl);
- comment->source_file = source;
- comment->memory = make_str_node(tokstart, tok - tokstart, 0);
- comment->memory->comment_type = flag;
+ (*comment_instruction) = bcalloc(Op_comment, 1, sl);
+ (*comment_instruction)->source_file = source;
+ (*comment_instruction)->memory = make_str_node(tokstart, tok - tokstart, 0);
+ (*comment_instruction)->memory->comment_type = flag;
return c;
}
-/* split_comment --- split initial comment text into program and function parts */
-
-static void
-split_comment(void)
-{
- char *p;
- int l;
- NODE *n;
-
- p = comment_to_save->memory->stptr;
- l = comment_to_save->memory->stlen - 3;
- /* have at least two comments so split at last blank line (\n\n) */
- while (l >= 0) {
- if (p[l] == '\n' && p[l+1] == '\n') {
- function_comment = comment_to_save;
- n = function_comment->memory;
- function_comment->memory = make_string(p + l + 2, n->stlen - l - 2);
- /* create program comment */
- program_comment = bcalloc(Op_comment, 1, sourceline);
- program_comment->source_file = comment_to_save->source_file;
- p[l + 2] = 0;
- program_comment->memory = make_str_node(p, l + 2, 0);
- comment_to_save = NULL;
- freenode(n);
- break;
- }
- else
- l--;
- }
-}
-
/* allow_newline --- allow newline after &&, ||, ? and : */
static void
-allow_newline(void)
+allow_newline(INSTRUCTION **new_comment)
{
int c;
@@ -3323,8 +3392,8 @@ allow_newline(void)
}
if (c == '#') {
if (do_pretty_print && ! do_profile) {
- /* collect comment byte code iff doing pretty print but not profiling. */
- c = get_comment(EOL_COMMENT);
+ /* collect comment byte code iff doing pretty print but not profiling. */
+ c = get_comment(EOL_COMMENT, new_comment);
} else {
while ((c = nextc(false)) != '\n' && c != END_FILE)
continue;
@@ -3391,6 +3460,7 @@ yylex(void)
bool intlstr = false;
AWKNUM d;
bool collecting_typed_regexp = false;
+ static int qm_col_count = 0;
#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline)
@@ -3555,18 +3625,25 @@ retry:
return lasttok = NEWLINE;
case '#': /* it's a comment */
+ yylval = NULL;
if (do_pretty_print && ! do_profile) {
/*
* Collect comment byte code iff doing pretty print
* but not profiling.
*/
+ INSTRUCTION *new_comment;
+
if (lasttok == NEWLINE || lasttok == 0)
- c = get_comment(FULL_COMMENT);
+ c = get_comment(BLOCK_COMMENT, & new_comment);
else
- c = get_comment(EOL_COMMENT);
+ c = get_comment(EOL_COMMENT, & new_comment);
- if (c == END_FILE)
- return lasttok = NEWLINE_EOF;
+ yylval = new_comment;
+
+ if (c == END_FILE) {
+ pushback();
+ return lasttok = NEWLINE;
+ }
} else {
while ((c = nextc(false)) != '\n') {
if (c == END_FILE)
@@ -3595,7 +3672,10 @@ retry:
* Use it at your own risk. We think it's a bad idea, which
* is why it's not on by default.
*/
+ yylval = NULL;
if (! do_traditional) {
+ INSTRUCTION *new_comment;
+
/* strip trailing white-space and/or comment */
while ((c = nextc(true)) == ' ' || c == '\t' || c == '\r')
continue;
@@ -3607,9 +3687,11 @@ retry:
lintwarn(
_("use of `\\ #...' line continuation is not portable"));
}
- if (do_pretty_print && ! do_profile)
- c = get_comment(EOL_COMMENT);
- else {
+ if (do_pretty_print && ! do_profile) {
+ c = get_comment(EOL_COMMENT, & new_comment);
+ yylval = new_comment;
+ return lasttok = c;
+ } else {
while ((c = nextc(false)) != '\n')
if (c == END_FILE)
break;
@@ -3630,11 +3712,19 @@ retry:
}
break;
- case ':':
case '?':
+ qm_col_count++;
+ // fall through
+ case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (! do_posix)
- allow_newline();
+ if (c == ':' && qm_col_count > 0) {
+ if (do_posix) {
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+ }
+ qm_col_count--;
+ }
return lasttok = c;
/*
@@ -4056,7 +4146,10 @@ retry:
case '&':
if ((c = nextc(true)) == '&') {
yylval = GET_INSTRUCTION(Op_and);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_AND;
}
pushback();
@@ -4066,11 +4159,15 @@ retry:
case '|':
if ((c = nextc(true)) == '|') {
yylval = GET_INSTRUCTION(Op_or);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_OR;
} else if (! do_traditional && c == '&') {
yylval = GET_INSTRUCTION(Op_symbol);
yylval->redir_type = redirect_twoway;
+
return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN);
}
pushback();
@@ -4260,8 +4357,11 @@ out:
yylval->lextok = tokkey;
#define SMART_ALECK 1
- if (SMART_ALECK && do_lint
- && ! goto_warned && strcasecmp(tokkey, "goto") == 0) {
+ if (SMART_ALECK
+ && do_lint
+ && ! goto_warned
+ && tolower(tokkey[0]) == 'g'
+ && strcasecmp(tokkey, "goto") == 0) {
goto_warned = true;
lintwarn(_("`goto' considered harmful!"));
}
@@ -4732,15 +4832,8 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
thisfunc = fi->func_body;
assert(thisfunc != NULL);
- /* add any pre-function comment to start of action for profile.c */
-
- if (function_comment != NULL) {
- function_comment->source_line = 0;
- (void) list_prepend(def, function_comment);
- function_comment = NULL;
- }
-
- /* add an implicit return at end;
+ /*
+ * Add an implicit return at end;
* also used by 'return' command in debugger
*/
@@ -5451,12 +5544,11 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 1)->lasti = action->lasti;
(rp + 2)->first_line = pattern->source_line;
(rp + 2)->last_line = lastline;
- if (block_comment != NULL) {
- ip = list_prepend(list_prepend(action, block_comment), rp);
- block_comment = NULL;
- } else
- ip = list_prepend(action, rp);
-
+ ip = list_prepend(action, rp);
+ if (interblock_comment != NULL) {
+ ip = list_prepend(ip, interblock_comment);
+ interblock_comment = NULL;
+ }
} else {
rp = bcalloc(Op_rule, 3, 0);
rp->in_rule = Rule;
@@ -5482,14 +5574,20 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 2)->last_line = find_line(pattern, LAST_LINE);
action = list_create(instruction(Op_K_print_rec));
if (do_pretty_print)
- (void) list_prepend(action, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
} else
(rp + 2)->last_line = lastline;
if (do_pretty_print) {
- (void) list_prepend(pattern, instruction(Op_exec_count));
- (void) list_prepend(action, instruction(Op_exec_count));
+ pattern = list_prepend(pattern, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
}
+
+ if (interblock_comment != NULL) { // was after previous action
+ pattern = list_prepend(pattern, interblock_comment);
+ interblock_comment = NULL;
+ }
+
(rp + 1)->firsti = action->nexti;
(rp + 1)->lasti = tp;
ip = list_append(
@@ -5861,8 +5959,9 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond,
forp->target_break = tbreak;
forp->target_continue = tcont;
ret = list_prepend(ret, forp);
- } /* else
- forp is NULL */
+ }
+ /* else
+ forp is NULL */
return ret;
}
@@ -6076,26 +6175,6 @@ list_merge(INSTRUCTION *l1, INSTRUCTION *l2)
return l1;
}
-/* add_pending_comment --- add a pending comment to a statement */
-
-static inline INSTRUCTION *
-add_pending_comment(INSTRUCTION *stmt)
-{
- INSTRUCTION *ret = stmt;
-
- if (prior_comment != NULL) {
- if (function_comment != prior_comment)
- ret = list_append(stmt, prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL && comment->memory->comment_type == EOL_COMMENT) {
- if (function_comment != comment)
- ret = list_append(stmt, comment);
- comment = NULL;
- }
-
- return ret;
-}
-
/* See if name is a special token. */
int
@@ -6335,3 +6414,91 @@ set_profile_text(NODE *n, const char *str, size_t len)
return n;
}
+
+/*
+ * merge_comments --- merge c2 into c1 and free c2 if successful.
+ * Allow c2 to be NULL, in which case just merged chained
+ * comments in c1.
+ */
+
+static void
+merge_comments(INSTRUCTION *c1, INSTRUCTION *c2)
+{
+ assert(c1->opcode == Op_comment);
+
+ if (c1->comment == NULL && c2 == NULL) // nothing to do
+ return;
+
+ size_t total = c1->memory->stlen;
+ if (c1->comment != NULL)
+ total += 1 /* \n */ + c1->comment->memory->stlen;
+
+ if (c2 != NULL) {
+ assert(c2->opcode == Op_comment);
+ total += 1 /* \n */ + c2->memory->stlen;
+ if (c2->comment != NULL)
+ total += c2->comment->memory->stlen + 1;
+ }
+
+ char *buffer;
+ emalloc(buffer, char *, total + 1, "merge_comments");
+
+ strcpy(buffer, c1->memory->stptr);
+ if (c1->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c1->comment->memory->stptr);
+ }
+
+ if (c2 != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->memory->stptr);
+ if (c2->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->comment->memory->stptr);
+ }
+
+ unref(c2->memory);
+ if (c2->comment != NULL) {
+ unref(c2->comment->memory);
+ bcfree(c2->comment);
+ c2->comment = NULL;
+ }
+ bcfree(c2);
+ }
+
+ c1->memory->comment_type = BLOCK_COMMENT;
+ free(c1->memory->stptr);
+ c1->memory->stptr = buffer;
+ c1->memory->stlen = strlen(buffer);
+
+ // now free everything else
+ if (c1->comment != NULL) {
+ unref(c1->comment->memory);
+ bcfree(c1->comment);
+ c1->comment = NULL;
+ }
+}
+
+/* make_braced_statements --- handle `l_brace statements r_brace' with comments */
+
+static INSTRUCTION *
+make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace)
+{
+ INSTRUCTION *ip;
+
+ if (stmts == NULL)
+ ip = list_create(instruction(Op_no_op));
+ else
+ ip = stmts;
+
+ if (lbrace != NULL) {
+ INSTRUCTION *comment2 = lbrace->comment;
+ if (comment2 != NULL) {
+ ip = list_prepend(ip, comment2);
+ lbrace->comment = NULL;
+ }
+ ip = list_prepend(ip, lbrace);
+ }
+
+ return ip;
+}
diff --git a/debug.c b/debug.c
index b24a8db6..6c6a59f5 100644
--- a/debug.c
+++ b/debug.c
@@ -3807,7 +3807,12 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
break;
case Op_K_do:
- print_func(fp, "[doloop_cond = %p] [target_break = %p]\n", (pc+1)->doloop_cond, pc->target_break);
+ print_func(fp, "[doloop_cond = %p] [target_break = %p]", (pc+1)->doloop_cond, pc->target_break);
+ if (pc->comment)
+ print_func(fp, " [comment = %p]", pc->comment);
+ print_func(fp, "\n");
+ if (pc->comment)
+ print_instruction(pc->comment, print_func, fp, in_dump);
break;
case Op_K_for:
@@ -3815,15 +3820,44 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
/* fall through */
case Op_K_arrayfor:
print_func(fp, "[forloop_body = %p] ", (pc+1)->forloop_body);
- print_func(fp, "[target_break = %p] [target_continue = %p]\n", pc->target_break, pc->target_continue);
+ print_func(fp, "[target_break = %p] [target_continue = %p]", pc->target_break, pc->target_continue);
+ if (pc->comment != NULL) {
+ print_func(fp, " [comment = %p]\n", (pc)->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_K_switch:
+ {
+ bool need_newline = false;
print_func(fp, "[switch_start = %p] [switch_end = %p]\n", (pc+1)->switch_start, (pc+1)->switch_end);
+ if (pc->comment || (pc+1)->switch_end->comment)
+ print_func(fp, "%*s", noffset, "");
+ if (pc->comment) {
+ print_func(fp, "[start_comment = %p]", pc->comment);
+ need_newline = true;
+ }
+ if ((pc+1)->switch_end->comment) {
+ print_func(fp, "[end_comment = %p]", (pc + 1)->switch_end->comment);
+ need_newline = true;
+ }
+ if (need_newline)
+ print_func(fp, "\n");
+ if (pc->comment)
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ if ((pc+1)->switch_end->comment)
+ print_instruction((pc+1)->switch_end->comment, print_func, fp, in_dump);
+ }
break;
case Op_K_default:
- print_func(fp, "[stmt_start = %p] [stmt_end = %p]\n", pc->stmt_start, pc->stmt_end);
+ print_func(fp, "[stmt_start = %p] [stmt_end = %p]", pc->stmt_start, pc->stmt_end);
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_var_update:
@@ -3915,8 +3949,13 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
break;
case Op_K_case:
- print_func(fp, "[target_jmp = %p] [match_exp = %s]\n",
+ print_func(fp, "[target_jmp = %p] [match_exp = %s]",
pc->target_jmp, (pc + 1)->match_exp ? "true" : "false");
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_arrayfor_incr:
@@ -4032,9 +4071,14 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
case Op_comment:
print_memory(pc->memory, func, print_func, fp);
- print_func(fp, " [comment_type = %s]\n",
+ print_func(fp, " [comment_type = %s]",
pc->memory->comment_type == EOL_COMMENT ?
- "EOL" : "FULL");
+ "EOL" : "BLOCK");
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_push_i:
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 16364354..724a982c 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -17,6 +17,10 @@
* gawktexi.in): Small typo fixes. Thanks to Antonio
Giovanni Colombo for pointing them out.
+2018-11-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Profiling): Review and update.
+
2018-10-30 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Arrays of Arrays): Typo fix in code. Thanks to Alto Tom
@@ -34,6 +38,12 @@
Communications Guidelines, with URL.
* texinfo.tex: Updated from GNULIB.
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Profiling): Revise example for pattern without
+ action and note that the profiler distinguishes `print' and
+ `print $0'.
+
2018-09-23 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Extracting): Note that patch levels above
diff --git a/doc/gawk.info b/doc/gawk.info
index 986c97d4..2c7bf82b 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -20794,7 +20794,8 @@ output. They are as follows:
structure of the program and the precedence rules. For example,
'(3 + 5) * 4' means add three and five, then multiply the total by
four. However, '3 + 5 * 4' has no parentheses, and means '3 + (5 *
- 4)'.
+ 4)'. However, explicit parentheses in the source program are
+ retained.
* Parentheses are used around the arguments to 'print' and 'printf'
only when the 'print' or 'printf' statement is followed by a
@@ -20816,10 +20817,11 @@ representation. Also, things such as:
come out as:
/foo/ {
- print $0
+ print
}
-which is correct, but possibly unexpected.
+which is correct, but possibly unexpected. (If a program uses both
+'print $0' and plain 'print', that distinction is retained.)
Besides creating profiles when a program has completed, 'gawk' can
produce a profile while it is running. This is useful if your 'awk'
@@ -20875,7 +20877,10 @@ without any execution counts.
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.(1)
+source code. However, no comments should be lost. Also, 'gawk' does
+the best it can to preserve the distinction between comments at the end
+of a statement and comments on lines by themselves. This isn't always
+perfect, though.
However, as a deliberate design decision, profiling output _omits_
the original program's comments. This allows you to focus on the
@@ -20895,14 +20900,6 @@ disable 'gawk''s default optimizations.
constants; if you used an octal or hexadecimal value in your source
code, it will appear that way in the output.
- ---------- Footnotes ----------
-
- (1) 'gawk' does the best it can to preserve the distinction between
-comments at the end of a statement and comments on lines by themselves.
-Due to implementation constraints, it does not always do so correctly,
-particularly for 'switch' statements. The 'gawk' maintainers hope to
-improve this in a subsequent release.
-

File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanced Features
@@ -34183,7 +34180,7 @@ Index
* dump debugger command: Miscellaneous Debugger Commands.
(line 9)
* dupword.awk program: Dupword Program. (line 31)
-* dynamic profiling: Profiling. (line 177)
+* dynamic profiling: Profiling. (line 179)
* dynamically loaded extensions: Dynamic Extensions. (line 6)
* e debugger command (alias for enable): Breakpoint Control. (line 73)
* EBCDIC: Ordinal Functions. (line 45)
@@ -34572,7 +34569,7 @@ Index
* G., Daniel Richard: Acknowledgments. (line 60)
* G., Daniel Richard <1>: Maintainers. (line 14)
* Garfinkle, Scott: Contributors. (line 35)
-* gawk program, dynamic profiling: Profiling. (line 177)
+* gawk program, dynamic profiling: Profiling. (line 179)
* gawk version: Auto-set. (line 263)
* gawk, ARGIND variable in: Other Arguments. (line 15)
* gawk, awk and: Preface. (line 21)
@@ -34777,7 +34774,7 @@ Index
* history expansion, in debugger: Readline Support. (line 6)
* histsort.awk program: History Sorting. (line 25)
* Hughes, Phil: Acknowledgments. (line 43)
-* HUP signal, for dynamic profiling: Profiling. (line 209)
+* HUP signal, for dynamic profiling: Profiling. (line 211)
* hyphen (-), - operator: Precedence. (line 51)
* hyphen (-), - operator <1>: Precedence. (line 57)
* hyphen (-), -- operator: Increment Ops. (line 48)
@@ -34859,7 +34856,7 @@ Index
* installing gawk: Installation. (line 6)
* instruction tracing, in debugger: Debugger Info. (line 90)
* int: Numeric Functions. (line 24)
-* INT signal (MS-Windows): Profiling. (line 212)
+* INT signal (MS-Windows): Profiling. (line 214)
* integer array indices: Numeric Array Subscripts.
(line 31)
* integers, arbitrary precision: Arbitrary Precision Integers.
@@ -34915,7 +34912,7 @@ Index
* Kernighan, Brian <8>: Other Versions. (line 13)
* Kernighan, Brian <9>: Basic Data Typing. (line 54)
* Kernighan, Brian <10>: Glossary. (line 204)
-* kill command, dynamic profiling: Profiling. (line 186)
+* kill command, dynamic profiling: Profiling. (line 188)
* Knights, jedi: Undocumented. (line 6)
* Kwok, Conrad: Contributors. (line 35)
* l debugger command (alias for list): Miscellaneous Debugger Commands.
@@ -35430,7 +35427,7 @@ Index
* PROCINFO, values of sorted_in: Controlling Scanning.
(line 26)
* profiling awk programs: Profiling. (line 6)
-* profiling awk programs, dynamically: Profiling. (line 177)
+* profiling awk programs, dynamically: Profiling. (line 179)
* program identifiers: Auto-set. (line 193)
* program, definition of: Getting Started. (line 21)
* programming conventions, --non-decimal-data option: Nondecimal Data.
@@ -35467,7 +35464,7 @@ Index
* QuikTrim Awk: Other Versions. (line 135)
* quit debugger command: Miscellaneous Debugger Commands.
(line 100)
-* QUIT signal (MS-Windows): Profiling. (line 212)
+* QUIT signal (MS-Windows): Profiling. (line 214)
* quoting in gawk command lines: Long. (line 26)
* quoting in gawk command lines, tricks for: Quoting. (line 91)
* quoting, for small awk programs: Comments. (line 27)
@@ -35757,15 +35754,15 @@ Index
(line 130)
* sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps.
(line 58)
-* SIGHUP signal, for dynamic profiling: Profiling. (line 209)
-* SIGINT signal (MS-Windows): Profiling. (line 212)
-* signals, HUP/SIGHUP, for profiling: Profiling. (line 209)
-* signals, INT/SIGINT (MS-Windows): Profiling. (line 212)
-* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 212)
-* signals, USR1/SIGUSR1, for profiling: Profiling. (line 186)
+* SIGHUP signal, for dynamic profiling: Profiling. (line 211)
+* SIGINT signal (MS-Windows): Profiling. (line 214)
+* signals, HUP/SIGHUP, for profiling: Profiling. (line 211)
+* signals, INT/SIGINT (MS-Windows): Profiling. (line 214)
+* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 214)
+* signals, USR1/SIGUSR1, for profiling: Profiling. (line 188)
* signature program: Signature Program. (line 6)
-* SIGQUIT signal (MS-Windows): Profiling. (line 212)
-* SIGUSR1 signal, for dynamic profiling: Profiling. (line 186)
+* SIGQUIT signal (MS-Windows): Profiling. (line 214)
+* SIGUSR1 signal, for dynamic profiling: Profiling. (line 188)
* silent debugger command: Debugger Execution Control.
(line 10)
* sin: Numeric Functions. (line 75)
@@ -36045,7 +36042,7 @@ Index
* user-modifiable variables: User-modified. (line 6)
* users, information about, printing: Id Program. (line 6)
* users, information about, retrieving: Passwd Functions. (line 16)
-* USR1 signal, for dynamic profiling: Profiling. (line 186)
+* USR1 signal, for dynamic profiling: Profiling. (line 188)
* values, numeric: Basic Data Typing. (line 13)
* values, string: Basic Data Typing. (line 13)
* variable assignments and input files: Other Arguments. (line 26)
@@ -36513,218 +36510,217 @@ Ref: Two-way I/O-Footnote-1836195
Ref: Two-way I/O-Footnote-2836382
Node: TCP/IP Networking836464
Node: Profiling839582
-Ref: Profiling-Footnote-1848254
-Node: Advanced Features Summary848577
-Node: Internationalization850421
-Node: I18N and L10N851901
-Node: Explaining gettext852588
-Ref: Explaining gettext-Footnote-1858480
-Ref: Explaining gettext-Footnote-2858665
-Node: Programmer i18n858830
-Ref: Programmer i18n-Footnote-1863779
-Node: Translator i18n863828
-Node: String Extraction864622
-Ref: String Extraction-Footnote-1865754
-Node: Printf Ordering865840
-Ref: Printf Ordering-Footnote-1868626
-Node: I18N Portability868690
-Ref: I18N Portability-Footnote-1871146
-Node: I18N Example871209
-Ref: I18N Example-Footnote-1874015
-Node: Gawk I18N874088
-Node: I18N Summary874733
-Node: Debugger876074
-Node: Debugging877097
-Node: Debugging Concepts877538
-Node: Debugging Terms879347
-Node: Awk Debugging881922
-Node: Sample Debugging Session882828
-Node: Debugger Invocation883362
-Node: Finding The Bug884748
-Node: List of Debugger Commands891226
-Node: Breakpoint Control892559
-Node: Debugger Execution Control896253
-Node: Viewing And Changing Data899615
-Node: Execution Stack902989
-Node: Debugger Info904626
-Node: Miscellaneous Debugger Commands908697
-Node: Readline Support913759
-Node: Limitations914655
-Node: Debugging Summary916764
-Node: Arbitrary Precision Arithmetic918043
-Node: Computer Arithmetic919528
-Ref: table-numeric-ranges923294
-Ref: table-floating-point-ranges923787
-Ref: Computer Arithmetic-Footnote-1924445
-Node: Math Definitions924502
-Ref: table-ieee-formats927818
-Ref: Math Definitions-Footnote-1928421
-Node: MPFR features928526
-Node: FP Math Caution930244
-Ref: FP Math Caution-Footnote-1931316
-Node: Inexactness of computations931685
-Node: Inexact representation932645
-Node: Comparing FP Values934005
-Node: Errors accumulate935246
-Node: Getting Accuracy936679
-Node: Try To Round939389
-Node: Setting precision940288
-Ref: table-predefined-precision-strings940985
-Node: Setting the rounding mode942815
-Ref: table-gawk-rounding-modes943189
-Ref: Setting the rounding mode-Footnote-1947120
-Node: Arbitrary Precision Integers947299
-Ref: Arbitrary Precision Integers-Footnote-1950474
-Node: Checking for MPFR950623
-Node: POSIX Floating Point Problems952097
-Ref: POSIX Floating Point Problems-Footnote-1956382
-Node: Floating point summary956420
-Node: Dynamic Extensions958610
-Node: Extension Intro960163
-Node: Plugin License961429
-Node: Extension Mechanism Outline962226
-Ref: figure-load-extension962665
-Ref: figure-register-new-function964230
-Ref: figure-call-new-function965322
-Node: Extension API Description967384
-Node: Extension API Functions Introduction969026
-Node: General Data Types974566
-Ref: General Data Types-Footnote-1982927
-Node: Memory Allocation Functions983226
-Ref: Memory Allocation Functions-Footnote-1987436
-Node: Constructor Functions987535
-Node: Registration Functions991121
-Node: Extension Functions991806
-Node: Exit Callback Functions997021
-Node: Extension Version String998271
-Node: Input Parsers998934
-Node: Output Wrappers1011655
-Node: Two-way processors1016167
-Node: Printing Messages1018432
-Ref: Printing Messages-Footnote-11019603
-Node: Updating ERRNO1019756
-Node: Requesting Values1020495
-Ref: table-value-types-returned1021232
-Node: Accessing Parameters1022168
-Node: Symbol Table Access1023403
-Node: Symbol table by name1023915
-Node: Symbol table by cookie1025704
-Ref: Symbol table by cookie-Footnote-11029889
-Node: Cached values1029953
-Ref: Cached values-Footnote-11033489
-Node: Array Manipulation1033642
-Ref: Array Manipulation-Footnote-11034733
-Node: Array Data Types1034770
-Ref: Array Data Types-Footnote-11037428
-Node: Array Functions1037520
-Node: Flattening Arrays1042018
-Node: Creating Arrays1048994
-Node: Redirection API1053761
-Node: Extension API Variables1056594
-Node: Extension Versioning1057305
-Ref: gawk-api-version1057734
-Node: Extension GMP/MPFR Versioning1059465
-Node: Extension API Informational Variables1061093
-Node: Extension API Boilerplate1062166
-Node: Changes from API V11066140
-Node: Finding Extensions1067712
-Node: Extension Example1068271
-Node: Internal File Description1069069
-Node: Internal File Ops1073149
-Ref: Internal File Ops-Footnote-11084499
-Node: Using Internal File Ops1084639
-Ref: Using Internal File Ops-Footnote-11087022
-Node: Extension Samples1087296
-Node: Extension Sample File Functions1088825
-Node: Extension Sample Fnmatch1096474
-Node: Extension Sample Fork1097961
-Node: Extension Sample Inplace1099179
-Node: Extension Sample Ord1102396
-Node: Extension Sample Readdir1103232
-Ref: table-readdir-file-types1104121
-Node: Extension Sample Revout1104926
-Node: Extension Sample Rev2way1105515
-Node: Extension Sample Read write array1106255
-Node: Extension Sample Readfile1108197
-Node: Extension Sample Time1109292
-Node: Extension Sample API Tests1110640
-Node: gawkextlib1111132
-Node: Extension summary1114050
-Node: Extension Exercises1117752
-Node: Language History1119250
-Node: V7/SVR3.11120906
-Node: SVR41123058
-Node: POSIX1124492
-Node: BTL1125872
-Node: POSIX/GNU1126601
-Node: Feature History1132379
-Node: Common Extensions1148425
-Node: Ranges and Locales1149708
-Ref: Ranges and Locales-Footnote-11154324
-Ref: Ranges and Locales-Footnote-21154351
-Ref: Ranges and Locales-Footnote-31154586
-Node: Contributors1154807
-Node: History summary1160752
-Node: Installation1162132
-Node: Gawk Distribution1163076
-Node: Getting1163560
-Node: Extracting1164523
-Node: Distribution contents1166161
-Node: Unix Installation1172641
-Node: Quick Installation1173323
-Node: Shell Startup Files1175737
-Node: Additional Configuration Options1176826
-Node: Configuration Philosophy1178991
-Node: Non-Unix Installation1181360
-Node: PC Installation1181820
-Node: PC Binary Installation1182658
-Node: PC Compiling1183093
-Node: PC Using1184210
-Node: Cygwin1187425
-Node: MSYS1188524
-Node: VMS Installation1189025
-Node: VMS Compilation1189816
-Ref: VMS Compilation-Footnote-11191045
-Node: VMS Dynamic Extensions1191103
-Node: VMS Installation Details1192788
-Node: VMS Running1195041
-Node: VMS GNV1199320
-Node: VMS Old Gawk1200055
-Node: Bugs1200526
-Node: Bug address1201189
-Node: Usenet1204171
-Node: Maintainers1205175
-Node: Other Versions1206436
-Node: Installation summary1212994
-Node: Notes1214196
-Node: Compatibility Mode1214990
-Node: Additions1215772
-Node: Accessing The Source1216697
-Node: Adding Code1218134
-Node: New Ports1224353
-Node: Derived Files1228841
-Ref: Derived Files-Footnote-11234487
-Ref: Derived Files-Footnote-21234522
-Ref: Derived Files-Footnote-31235120
-Node: Future Extensions1235234
-Node: Implementation Limitations1235892
-Node: Extension Design1237075
-Node: Old Extension Problems1238219
-Ref: Old Extension Problems-Footnote-11239737
-Node: Extension New Mechanism Goals1239794
-Ref: Extension New Mechanism Goals-Footnote-11243158
-Node: Extension Other Design Decisions1243347
-Node: Extension Future Growth1245460
-Node: Notes summary1246296
-Node: Basic Concepts1247471
-Node: Basic High Level1248152
-Ref: figure-general-flow1248434
-Ref: figure-process-flow1249119
-Ref: Basic High Level-Footnote-11252420
-Node: Basic Data Typing1252605
-Node: Glossary1255933
-Node: Copying1287771
-Node: GNU Free Documentation License1325314
-Node: Index1350434
+Node: Advanced Features Summary848587
+Node: Internationalization850431
+Node: I18N and L10N851911
+Node: Explaining gettext852598
+Ref: Explaining gettext-Footnote-1858490
+Ref: Explaining gettext-Footnote-2858675
+Node: Programmer i18n858840
+Ref: Programmer i18n-Footnote-1863789
+Node: Translator i18n863838
+Node: String Extraction864632
+Ref: String Extraction-Footnote-1865764
+Node: Printf Ordering865850
+Ref: Printf Ordering-Footnote-1868636
+Node: I18N Portability868700
+Ref: I18N Portability-Footnote-1871156
+Node: I18N Example871219
+Ref: I18N Example-Footnote-1874025
+Node: Gawk I18N874098
+Node: I18N Summary874743
+Node: Debugger876084
+Node: Debugging877107
+Node: Debugging Concepts877548
+Node: Debugging Terms879357
+Node: Awk Debugging881932
+Node: Sample Debugging Session882838
+Node: Debugger Invocation883372
+Node: Finding The Bug884758
+Node: List of Debugger Commands891236
+Node: Breakpoint Control892569
+Node: Debugger Execution Control896263
+Node: Viewing And Changing Data899625
+Node: Execution Stack902999
+Node: Debugger Info904636
+Node: Miscellaneous Debugger Commands908707
+Node: Readline Support913769
+Node: Limitations914665
+Node: Debugging Summary916774
+Node: Arbitrary Precision Arithmetic918053
+Node: Computer Arithmetic919538
+Ref: table-numeric-ranges923304
+Ref: table-floating-point-ranges923797
+Ref: Computer Arithmetic-Footnote-1924455
+Node: Math Definitions924512
+Ref: table-ieee-formats927828
+Ref: Math Definitions-Footnote-1928431
+Node: MPFR features928536
+Node: FP Math Caution930254
+Ref: FP Math Caution-Footnote-1931326
+Node: Inexactness of computations931695
+Node: Inexact representation932655
+Node: Comparing FP Values934015
+Node: Errors accumulate935256
+Node: Getting Accuracy936689
+Node: Try To Round939399
+Node: Setting precision940298
+Ref: table-predefined-precision-strings940995
+Node: Setting the rounding mode942825
+Ref: table-gawk-rounding-modes943199
+Ref: Setting the rounding mode-Footnote-1947130
+Node: Arbitrary Precision Integers947309
+Ref: Arbitrary Precision Integers-Footnote-1950484
+Node: Checking for MPFR950633
+Node: POSIX Floating Point Problems952107
+Ref: POSIX Floating Point Problems-Footnote-1956392
+Node: Floating point summary956430
+Node: Dynamic Extensions958620
+Node: Extension Intro960173
+Node: Plugin License961439
+Node: Extension Mechanism Outline962236
+Ref: figure-load-extension962675
+Ref: figure-register-new-function964240
+Ref: figure-call-new-function965332
+Node: Extension API Description967394
+Node: Extension API Functions Introduction969036
+Node: General Data Types974576
+Ref: General Data Types-Footnote-1982937
+Node: Memory Allocation Functions983236
+Ref: Memory Allocation Functions-Footnote-1987446
+Node: Constructor Functions987545
+Node: Registration Functions991131
+Node: Extension Functions991816
+Node: Exit Callback Functions997031
+Node: Extension Version String998281
+Node: Input Parsers998944
+Node: Output Wrappers1011665
+Node: Two-way processors1016177
+Node: Printing Messages1018442
+Ref: Printing Messages-Footnote-11019613
+Node: Updating ERRNO1019766
+Node: Requesting Values1020505
+Ref: table-value-types-returned1021242
+Node: Accessing Parameters1022178
+Node: Symbol Table Access1023413
+Node: Symbol table by name1023925
+Node: Symbol table by cookie1025714
+Ref: Symbol table by cookie-Footnote-11029899
+Node: Cached values1029963
+Ref: Cached values-Footnote-11033499
+Node: Array Manipulation1033652
+Ref: Array Manipulation-Footnote-11034743
+Node: Array Data Types1034780
+Ref: Array Data Types-Footnote-11037438
+Node: Array Functions1037530
+Node: Flattening Arrays1042028
+Node: Creating Arrays1049004
+Node: Redirection API1053771
+Node: Extension API Variables1056604
+Node: Extension Versioning1057315
+Ref: gawk-api-version1057744
+Node: Extension GMP/MPFR Versioning1059475
+Node: Extension API Informational Variables1061103
+Node: Extension API Boilerplate1062176
+Node: Changes from API V11066150
+Node: Finding Extensions1067722
+Node: Extension Example1068281
+Node: Internal File Description1069079
+Node: Internal File Ops1073159
+Ref: Internal File Ops-Footnote-11084509
+Node: Using Internal File Ops1084649
+Ref: Using Internal File Ops-Footnote-11087032
+Node: Extension Samples1087306
+Node: Extension Sample File Functions1088835
+Node: Extension Sample Fnmatch1096484
+Node: Extension Sample Fork1097971
+Node: Extension Sample Inplace1099189
+Node: Extension Sample Ord1102406
+Node: Extension Sample Readdir1103242
+Ref: table-readdir-file-types1104131
+Node: Extension Sample Revout1104936
+Node: Extension Sample Rev2way1105525
+Node: Extension Sample Read write array1106265
+Node: Extension Sample Readfile1108207
+Node: Extension Sample Time1109302
+Node: Extension Sample API Tests1110650
+Node: gawkextlib1111142
+Node: Extension summary1114060
+Node: Extension Exercises1117762
+Node: Language History1119260
+Node: V7/SVR3.11120916
+Node: SVR41123068
+Node: POSIX1124502
+Node: BTL1125882
+Node: POSIX/GNU1126611
+Node: Feature History1132389
+Node: Common Extensions1148435
+Node: Ranges and Locales1149718
+Ref: Ranges and Locales-Footnote-11154334
+Ref: Ranges and Locales-Footnote-21154361
+Ref: Ranges and Locales-Footnote-31154596
+Node: Contributors1154817
+Node: History summary1160762
+Node: Installation1162142
+Node: Gawk Distribution1163086
+Node: Getting1163570
+Node: Extracting1164533
+Node: Distribution contents1166171
+Node: Unix Installation1172651
+Node: Quick Installation1173333
+Node: Shell Startup Files1175747
+Node: Additional Configuration Options1176836
+Node: Configuration Philosophy1179001
+Node: Non-Unix Installation1181370
+Node: PC Installation1181830
+Node: PC Binary Installation1182668
+Node: PC Compiling1183103
+Node: PC Using1184220
+Node: Cygwin1187435
+Node: MSYS1188534
+Node: VMS Installation1189035
+Node: VMS Compilation1189826
+Ref: VMS Compilation-Footnote-11191055
+Node: VMS Dynamic Extensions1191113
+Node: VMS Installation Details1192798
+Node: VMS Running1195051
+Node: VMS GNV1199330
+Node: VMS Old Gawk1200065
+Node: Bugs1200536
+Node: Bug address1201199
+Node: Usenet1204181
+Node: Maintainers1205185
+Node: Other Versions1206446
+Node: Installation summary1213004
+Node: Notes1214206
+Node: Compatibility Mode1215000
+Node: Additions1215782
+Node: Accessing The Source1216707
+Node: Adding Code1218144
+Node: New Ports1224363
+Node: Derived Files1228851
+Ref: Derived Files-Footnote-11234497
+Ref: Derived Files-Footnote-21234532
+Ref: Derived Files-Footnote-31235130
+Node: Future Extensions1235244
+Node: Implementation Limitations1235902
+Node: Extension Design1237085
+Node: Old Extension Problems1238229
+Ref: Old Extension Problems-Footnote-11239747
+Node: Extension New Mechanism Goals1239804
+Ref: Extension New Mechanism Goals-Footnote-11243168
+Node: Extension Other Design Decisions1243357
+Node: Extension Future Growth1245470
+Node: Notes summary1246306
+Node: Basic Concepts1247481
+Node: Basic High Level1248162
+Ref: figure-general-flow1248444
+Ref: figure-process-flow1249129
+Ref: Basic High Level-Footnote-11252430
+Node: Basic Data Typing1252615
+Node: Glossary1255943
+Node: Copying1287781
+Node: GNU Free Documentation License1325324
+Node: Index1350444

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 3be098ba..6f5f4f81 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -29122,6 +29122,7 @@ of the program and the precedence rules.
For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
+However, explicit parentheses in the source program are retained.
@ignore
@item
@@ -29160,12 +29161,14 @@ come out as:
@example
/foo/ @{
- print $0
+ print
@}
@end example
@noindent
which is correct, but possibly unexpected.
+(If a program uses both @samp{print $0} and plain
+@samp{print}, that distinction is retained.)
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -29250,12 +29253,10 @@ There is a significant difference between the output created when
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.@footnote{@command{gawk} does the best it can to preserve
+source code. However, no comments should be lost.
+Also, @command{gawk} does the best it can to preserve
the distinction between comments at the end of a statement and comments
-on lines by themselves. Due to implementation constraints, it does not
-always do so correctly, particularly for @code{switch} statements. The
-@command{gawk} maintainers hope to improve this in a subsequent
-release.}
+on lines by themselves. This isn't always perfect, though.
However, as a deliberate design decision, profiling output @emph{omits}
the original program's comments. This allows you to focus on the
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 894fd559..a8434568 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -28135,6 +28135,7 @@ of the program and the precedence rules.
For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
+However, explicit parentheses in the source program are retained.
@ignore
@item
@@ -28173,12 +28174,14 @@ come out as:
@example
/foo/ @{
- print $0
+ print
@}
@end example
@noindent
which is correct, but possibly unexpected.
+(If a program uses both @samp{print $0} and plain
+@samp{print}, that distinction is retained.)
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -28263,12 +28266,10 @@ There is a significant difference between the output created when
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.@footnote{@command{gawk} does the best it can to preserve
+source code. However, no comments should be lost.
+Also, @command{gawk} does the best it can to preserve
the distinction between comments at the end of a statement and comments
-on lines by themselves. Due to implementation constraints, it does not
-always do so correctly, particularly for @code{switch} statements. The
-@command{gawk} maintainers hope to improve this in a subsequent
-release.}
+on lines by themselves. This isn't always perfect, though.
However, as a deliberate design decision, profiling output @emph{omits}
the original program's comments. This allows you to focus on the
diff --git a/profile.c b/profile.c
index ac08a61d..5494b170 100644
--- a/profile.c
+++ b/profile.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1999-2017 the Free Software Foundation, Inc.
+ * Copyright (C) 1999-2018 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -37,7 +37,7 @@ static char *pp_typed_regex(const char *in_str, size_t len, int delim);
static bool is_binary(int type);
static bool is_scalar(int type);
static int prec_level(int type);
-static void pp_push(int type, char *s, int flag);
+static void pp_push(int type, char *s, int flag, INSTRUCTION *comment);
static NODE *pp_pop(void);
static void print_comment(INSTRUCTION *pc, long in);
const char *redir2str(int redirtype);
@@ -45,6 +45,7 @@ const char *redir2str(int redirtype);
#define pp_str vname
#define pp_len sub.nodep.reserved
#define pp_next rnode
+#define pp_comment sub.nodep.x.cmnt
#define DONT_FREE 1
#define CAN_FREE 2
@@ -60,6 +61,15 @@ static FILE *prof_fp; /* where to send the profile */
static long indent_level = 0;
+static const char tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+static const size_t tabs_len = sizeof(tabs) - 1;
+
+#define check_indent_level() \
+ if (indent_level + 1 > tabs_len) \
+ /* We're allowed to be snarky, occasionally. */ \
+ fatal(_("Program indentation level too deep. Consider refactoring your code"));
+
+
#define SPACEOVER 0
#define NO_PPRINT_FLAGS 0
@@ -159,7 +169,7 @@ indent_out(void)
/* pp_push --- push a pretty printed string onto the stack */
static void
-pp_push(int type, char *s, int flag)
+pp_push(int type, char *s, int flag, INSTRUCTION *comment)
{
NODE *n;
getnode(n);
@@ -168,6 +178,7 @@ pp_push(int type, char *s, int flag)
n->flags = flag;
n->type = type;
n->pp_next = pp_stack;
+ n->pp_comment = comment;
pp_stack = n;
}
@@ -238,9 +249,9 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
if (rule != Rule) {
/* Allow for pre-non-rule-block comment */
- if (pc->nexti != (pc +1)->firsti
+ if (pc->nexti != (pc+1)->firsti
&& pc->nexti->opcode == Op_comment
- && pc->nexti->memory->comment_type == FULL_COMMENT)
+ && pc->nexti->memory->comment_type == BLOCK_COMMENT)
print_comment(pc->nexti, -1);
ip1 = (pc + 1)->firsti;
ip2 = (pc + 1)->lasti;
@@ -302,9 +313,9 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
case Op_push_i:
m = pc->memory;
if (m == Nnull_string) /* optional return or exit value; don't print 0 or "" */
- pp_push(pc->opcode, m->stptr, DONT_FREE);
+ pp_push(pc->opcode, m->stptr, DONT_FREE, pc->comment);
else if ((m->flags & NUMBER) != 0)
- pp_push(pc->opcode, pp_number(m), CAN_FREE);
+ pp_push(pc->opcode, pp_number(m), CAN_FREE, pc->comment);
else {
str = pp_string(m->stptr, m->stlen, '"');
if ((m->flags & INTLSTR) != 0) {
@@ -312,13 +323,13 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
str = pp_group3("_", tmp, "");
efree(tmp);
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
case Op_store_var:
if (pc->initval != NULL)
- pp_push(Op_push_i, pp_node(pc->initval), CAN_FREE);
+ pp_push(Op_push_i, pp_node(pc->initval), CAN_FREE, pc->comment);
/* fall through */
case Op_store_sub:
case Op_assign_concat:
@@ -331,14 +342,14 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
m = pc->memory;
switch (m->type) {
case Node_param_list:
- pp_push(pc->opcode, func_params[m->param_cnt].param, DONT_FREE);
+ pp_push(pc->opcode, func_params[m->param_cnt].param, DONT_FREE, pc->comment);
break;
case Node_var:
case Node_var_new:
case Node_var_array:
if (m->vname != NULL)
- pp_push(pc->opcode, m->vname, DONT_FREE);
+ pp_push(pc->opcode, m->vname, DONT_FREE, pc->comment);
else
fatal(_("internal error: %s with null vname"),
nodetype2str(m->type));
@@ -390,7 +401,7 @@ cleanup:
str = pp_group3(t1->pp_str, tmp, "");
efree(tmp);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_and:
@@ -399,10 +410,24 @@ cleanup:
t2 = pp_pop();
t1 = pp_pop();
parenthesize(pc->opcode, t1, t2);
- str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
+ if (pc->comment == NULL)
+ str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
+ else {
+ check_indent_level();
+
+ size_t len = strlen(t1->pp_str)
+ + strlen(op2str(pc->opcode)) + strlen(t2->pp_str) // foo && bar
+ + indent_level + 1 // indent
+ + pc->comment->memory->stlen + 3; // tab comment
+
+ emalloc(str, char *, len, "pprint");
+ sprintf(str, "%s%s%s%.*s %s", t1->pp_str, op2str(pc->opcode),
+ pc->comment->memory->stptr,
+ (int) (indent_level + 1), tabs, t2->pp_str);
+ }
pp_free(t1);
pp_free(t2);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
pc = pc->target_jmp;
break;
@@ -424,14 +449,14 @@ cleanup:
str = pp_group3(t1->pp_str, op2str(pc->opcode), tmp);
efree(tmp);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_parens:
t1 = pp_pop();
str = pp_group3("(", t1->pp_str, ")");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_plus:
@@ -452,7 +477,7 @@ cleanup:
str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
pp_free(t1);
pp_free(t2);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_preincrement:
@@ -465,7 +490,7 @@ cleanup:
else
str = pp_group3(t1->pp_str, op2str(pc->opcode), "");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_field_spec:
@@ -483,7 +508,7 @@ cleanup:
/* optypes table (eval.c) includes space after ! */
str = pp_group3(op2str(pc->opcode), t1->pp_str, "");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_assign:
@@ -498,7 +523,7 @@ cleanup:
str = pp_group3(t2->pp_str, op2str(pc->opcode), t1->pp_str);
pp_free(t2);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_store_field:
@@ -515,7 +540,7 @@ cleanup:
case Op_concat:
str = pp_concat(pc->expr_count);
- pp_push(Op_concat, str, CAN_FREE);
+ pp_push(Op_concat, str, CAN_FREE, pc->comment);
break;
case Op_K_delete:
@@ -560,7 +585,7 @@ cleanup:
pp_free(t2);
}
pp_free(t1);
- pp_push(Op_in_array, str, CAN_FREE);
+ pp_push(Op_in_array, str, CAN_FREE, pc->comment);
}
break;
@@ -595,7 +620,7 @@ cleanup:
tmp = pp_list(pc->expr_count, "()", ", ");
str = pp_group3(fname, tmp, "");
efree(tmp);
- pp_push(Op_sub_builtin, str, CAN_FREE);
+ pp_push(Op_sub_builtin, str, CAN_FREE, pc->comment);
}
break;
@@ -614,7 +639,7 @@ cleanup:
efree(tmp);
} else
str = pp_group3(fname, "()", "");
- pp_push(Op_builtin, str, CAN_FREE);
+ pp_push(Op_builtin, str, CAN_FREE, pc->comment);
} else
fatal(_("internal error: builtin with null fname"));
}
@@ -624,7 +649,8 @@ cleanup:
case Op_K_printf:
case Op_K_print_rec:
if (pc->opcode == Op_K_print_rec)
- tmp = pp_group3(" ", op2str(Op_field_spec), "0");
+ // instead of `print $0', just `print'
+ tmp = strdup("");
else if (pc->redir_type != 0)
tmp = pp_list(pc->expr_count, "()", ", ");
else {
@@ -660,7 +686,7 @@ cleanup:
assert((pc->memory->flags & REGEX) != 0);
str = pp_typed_regex(pc->memory->stptr, pc->memory->stlen, '/');
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -692,7 +718,7 @@ cleanup:
efree(restr);
}
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -720,7 +746,7 @@ cleanup:
pp_free(t2);
} else
str = tmp;
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_indirect_func_call:
@@ -745,7 +771,7 @@ cleanup:
t1 = pp_pop(); /* indirect var */
pp_free(t1);
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -786,7 +812,7 @@ cleanup:
str = pp_group3(t1->pp_str, ", ", t2->pp_str);
pp_free(t1);
pp_free(t2);
- pp_push(Op_line_range, str, CAN_FREE);
+ pp_push(Op_line_range, str, CAN_FREE, pc->comment);
pc = ip1->condpair_right;
break;
@@ -820,13 +846,34 @@ cleanup:
indent(SPACEOVER);
t1 = pp_pop();
fprintf(prof_fp, "} %s (%s)", op2str(Op_K_while), t1->pp_str);
+ if (pc->comment)
+ fprintf(prof_fp, "\t%s", pc->comment->memory->stptr);
+ else {
+ end_line(pc->target_break);
+ skip_comment = true;
+ }
pp_free(t1);
- end_line(pc->target_break);
- skip_comment = true;
pc = pc->target_break;
break;
case Op_K_for:
+ {
+ INSTRUCTION *comment1 = NULL, *comment2 = NULL;
+
+ if (pc->comment != NULL) {
+ comment1 = pc->comment;
+ pc->comment = NULL;
+ if (comment1 != NULL && comment1->comment != NULL) {
+ comment2 = comment1->comment;
+ comment1->comment = NULL;
+ }
+ if (comment2 == NULL && comment1->memory->comment_type == FOR_COMMENT) {
+ comment2 = comment1;
+ comment2->memory->comment_type = EOL_COMMENT;
+ comment1 = NULL;
+ }
+ }
+
ip1 = pc + 1;
indent(ip1->forloop_body->exec_count);
fprintf(prof_fp, "%s (", op2str(pc->opcode));
@@ -834,12 +881,19 @@ cleanup:
/* If empty for looop header, print it a little more nicely. */
if ( pc->nexti->opcode == Op_no_op
&& ip1->forloop_cond == pc->nexti
- && pc->target_continue->opcode == Op_jmp) {
+ && pc->target_continue->opcode == Op_jmp
+ && comment1 == NULL && comment2 == NULL) {
fprintf(prof_fp, ";;");
} else {
pprint(pc->nexti, ip1->forloop_cond, IN_FOR_HEADER);
fprintf(prof_fp, "; ");
+ if (comment1 != NULL) {
+ print_comment(comment1, 0);
+ indent(ip1->forloop_body->exec_count);
+ indent(1);
+ }
+
if (ip1->forloop_cond->opcode == Op_no_op &&
ip1->forloop_cond->nexti == ip1->forloop_body)
fprintf(prof_fp, "; ");
@@ -850,6 +904,12 @@ cleanup:
pp_free(t1);
}
+ if (comment2 != NULL) {
+ print_comment(comment2, 0);
+ indent(ip1->forloop_body->exec_count);
+ indent(1);
+ }
+
pprint(pc->target_continue, pc->target_break, IN_FOR_HEADER);
}
fprintf(prof_fp, ") {");
@@ -863,6 +923,7 @@ cleanup:
end_line(pc->target_break);
skip_comment = true;
pc = pc->target_break;
+ }
break;
case Op_K_arrayfor:
@@ -901,10 +962,14 @@ cleanup:
pprint(pc->nexti, ip1->switch_start, NO_PPRINT_FLAGS);
t1 = pp_pop();
fprintf(prof_fp, "%s) {\n", t1->pp_str);
+ if (pc->comment)
+ print_comment(pc->comment, 0);
pp_free(t1);
pprint(ip1->switch_start, ip1->switch_end, NO_PPRINT_FLAGS);
indent(SPACEOVER);
fprintf(prof_fp, "}\n");
+ if (ip1->switch_end->comment)
+ print_comment(ip1->switch_end->comment, 0);
pc = pc->target_break;
break;
@@ -914,13 +979,20 @@ cleanup:
if (pc->opcode == Op_K_case) {
t1 = pp_pop();
fprintf(prof_fp, "%s %s:", op2str(pc->opcode), t1->pp_str);
- pc = end_line(pc);
pp_free(t1);
- } else {
+ } else
fprintf(prof_fp, "%s:", op2str(pc->opcode));
- pc = end_line(pc);
- }
+
indent_in();
+ if (pc->comment != NULL) {
+ if (pc->comment->memory->comment_type == EOL_COMMENT)
+ fprintf(prof_fp, "\t%s", pc->comment->memory->stptr);
+ else {
+ fprintf(prof_fp, "\n");
+ print_comment(pc->comment, indent_level);
+ }
+ } else
+ fprintf(prof_fp, "\n");
pprint(pc->stmt_start->nexti, pc->stmt_end->nexti, NO_PPRINT_FLAGS);
indent_out();
break;
@@ -937,6 +1009,8 @@ cleanup:
fprintf(prof_fp, " # %ld", ip1->exec_count);
ip1 = end_line(ip1);
indent_in();
+ if (pc->comment != NULL)
+ print_comment(pc->comment, indent_level);
pprint(ip1->nexti, pc->branch_else, NO_PPRINT_FLAGS);
indent_out();
pc = pc->branch_else;
@@ -944,7 +1018,7 @@ cleanup:
indent(SPACEOVER);
fprintf(prof_fp, "}");
if (pc->nexti->nexti->opcode != Op_comment
- || pc->nexti->nexti->memory->comment_type == FULL_COMMENT)
+ || pc->nexti->nexti->memory->comment_type == BLOCK_COMMENT)
fprintf(prof_fp, "\n");
/* else
It will be printed at the top. */
@@ -980,6 +1054,8 @@ cleanup:
end_line(pc);
skip_comment = true;
indent_in();
+ if (pc->comment != NULL)
+ print_comment(pc->comment, indent_level);
pprint(pc->nexti, pc->branch_end, NO_PPRINT_FLAGS);
indent_out();
indent(SPACEOVER);
@@ -999,6 +1075,9 @@ cleanup:
{
NODE *f, *t, *cond;
size_t len;
+ INSTRUCTION *qm_comment = NULL, *colon_comment = NULL;
+
+ qm_comment = pc->comment;
pprint(pc->nexti, pc->branch_if, NO_PPRINT_FLAGS);
ip1 = pc->branch_if;
@@ -1006,6 +1085,7 @@ cleanup:
ip1 = pc->branch_else->nexti;
pc = ip1->nexti;
+ colon_comment = pc->comment;
assert(pc->opcode == Op_cond_exp);
pprint(pc->nexti, pc->branch_end, NO_PPRINT_FLAGS);
@@ -1013,14 +1093,77 @@ cleanup:
t = pp_pop();
cond = pp_pop();
- 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);
+ /*
+ * This stuff handles comments that come after a ?, :, or both.
+ * Allowing newlines after ? and : is a gawk extension.
+ * Theoretically this is fragile, since ?: expressions can be nested.
+ * In practice, it's not, since if there was a comment following ? or :
+ * in the original code, then it wasn't nested.
+ */
+
+ len = f->pp_len + t->pp_len + cond->pp_len + 12;
+ if (qm_comment == NULL && colon_comment == NULL) {
+ // easy case
+ emalloc(str, char *, len, "pprint");
+ sprintf(str, "%s ? %s : %s", cond->pp_str, t->pp_str, f->pp_str);
+ } else if (qm_comment != NULL && colon_comment != NULL) {
+ check_indent_level();
+ len += qm_comment->memory->stlen + // comments
+ colon_comment->memory->stlen +
+ 2 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 6;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? comment
+ "%.*s %s" // indent true-part
+ " : %s" // : comment
+ "%.*s %s", // indent false-part
+ cond->pp_str, // condition
+ qm_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ t->pp_str, // true part
+ colon_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ f->pp_str // false part
+ );
+ } else if (qm_comment != NULL) {
+ check_indent_level();
+ len += qm_comment->memory->stlen + // comment
+ 1 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 3;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? comment
+ "%.*s %s" // indent true-part
+ " : %s", // : false-part
+ cond->pp_str, // condition
+ qm_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ t->pp_str, // true part
+ f->pp_str // false part
+ );
+ } else {
+ check_indent_level();
+ len += colon_comment->memory->stlen + // comment
+ 1 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 3;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? true-part
+ " : %s" // : comment
+ "%.*s %s", // indent false-part
+ cond->pp_str, // condition
+ t->pp_str, // true part
+ colon_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ f->pp_str // false part
+ );
+ }
pp_free(cond);
pp_free(t);
pp_free(f);
- pp_push(Op_cond_exp, str, CAN_FREE);
+ pp_push(Op_cond_exp, str, CAN_FREE, pc->comment);
pc = pc->branch_end;
}
break;
@@ -1065,7 +1208,7 @@ end_line(INSTRUCTION *ip)
return ret;
}
-/* pp_string_fp --- printy print a string to the fp */
+/* pp_string_fp --- pretty print a string to the fp */
/*
* This routine concentrates string pretty printing in one place,
@@ -1124,17 +1267,59 @@ print_lib_list(FILE *prof_fp)
{
SRCFILE *s;
static bool printed_header = false;
+ const char *indent = "";
+ bool found = false;
+
+ if (do_profile)
+ indent = "\t";
for (s = srcfiles->next; s != srcfiles; s = s->next) {
if (s->stype == SRC_EXTLIB) {
+ if (do_profile && ! printed_header) {
+ printed_header = true;
+ fprintf(prof_fp, _("%s# Loaded extensions (-l and/or @load)\n\n"), indent);
+ }
+ found = true;
+ fprintf(prof_fp, "%s@load \"%s\"", indent, s->src);
+ if (s->comment != NULL) {
+ fprintf(prof_fp, "\t");
+ print_comment(s->comment, indent_level + 1);
+ } else
+ fprintf(prof_fp, "\n");
+ }
+ }
+ if (found) /* we found some */
+ fprintf(prof_fp, "\n");
+}
+
+/* print_include_list --- print a list of all files included */
+
+static void
+print_include_list(FILE *prof_fp)
+{
+ SRCFILE *s;
+ static bool printed_header = false;
+ bool found = false;
+
+ if (do_profile)
+ return;
+
+ for (s = srcfiles->next; s != srcfiles; s = s->next) {
+ if (s->stype == SRC_INC) {
if (! printed_header) {
printed_header = true;
- fprintf(prof_fp, _("\t# Loaded extensions (-l and/or @load)\n\n"));
+ fprintf(prof_fp, _("\n# Included files (-i and/or @include)\n\n"));
}
- fprintf(prof_fp, "\t@load \"%s\"\n", s->src);
+ found = true;
+ fprintf(prof_fp, "# @include \"%s\"", s->src);
+ if (s->comment != NULL) {
+ fprintf(prof_fp, "\t");
+ print_comment(s->comment, indent_level + 1);
+ } else
+ fprintf(prof_fp, "\n");
}
}
- if (printed_header) /* we found some */
+ if (found) /* we found some */
fprintf(prof_fp, "\n");
}
@@ -1158,8 +1343,13 @@ print_comment(INSTRUCTION* pc, long in)
after_newline = false;
}
putc(*text, prof_fp);
- if (*text == '\n')
- after_newline = true;
+ after_newline = (*text == '\n');
+ }
+
+ if (pc->comment) {
+ // chaining should only be two deep
+ assert(pc->comment->comment == NULL);
+ print_comment(pc->comment, in);
}
}
@@ -1181,6 +1371,7 @@ dump_prog(INSTRUCTION *code)
fprintf(prof_fp, _("\t# gawk profile, created %s\n"), ctime(& now));
print_lib_list(prof_fp);
pprint(code, NULL, NO_PPRINT_FLAGS);
+ print_include_list(prof_fp);
}
/* prec_level --- return the precedence of an operator, for paren tests */
@@ -1535,6 +1726,7 @@ pp_list(int nargs, const char *paren, const char *delim)
size_t len;
size_t delimlen;
int i;
+ INSTRUCTION *comment = NULL;
if (pp_args == NULL) {
npp_args = nargs;
@@ -1552,12 +1744,17 @@ pp_list(int nargs, const char *paren, const char *delim)
for (i = 1; i <= nargs; i++) {
r = pp_args[i] = pp_pop();
len += r->pp_len + delimlen;
+ if (r->pp_comment != NULL) {
+ comment = (INSTRUCTION *) r->pp_comment;
+ len += comment->memory->stlen + indent_level + 1; // comment\n ident
+ }
}
if (paren != NULL) {
assert(strlen(paren) == 2);
len += 2;
}
}
+ comment = NULL;
emalloc(str, char *, len + 1, "pp_list");
s = str;
@@ -1573,6 +1770,14 @@ pp_list(int nargs, const char *paren, const char *delim)
memcpy(s, delim, delimlen);
s += delimlen;
}
+ if (r->pp_comment != NULL) {
+ check_indent_level();
+ comment = (INSTRUCTION *) r->pp_comment;
+ memcpy(s, comment->memory->stptr, comment->memory->stlen);
+ s += comment->memory->stlen;
+ memcpy(s, tabs, indent_level + 1);
+ s += indent_level + 1;
+ }
r = pp_args[i];
memcpy(s, r->pp_str, r->pp_len);
s += r->pp_len;
@@ -1736,10 +1941,8 @@ pp_func(INSTRUCTION *pc, void *data ATTRIBUTE_UNUSED)
fprintf(prof_fp, "\n");
/* print any function comment */
- if (fp->opcode == Op_comment && fp->source_line == 0) {
- print_comment(fp, -1); /* -1 ==> don't indent */
- fp = fp->nexti;
- }
+ if (pc->comment != NULL)
+ print_comment(pc->comment, -1); /* -1 ==> don't indent */
indent(pc->nexti->exec_count);
fprintf(prof_fp, "%s %s(", op2str(Op_K_function), func->vname);
diff --git a/test/ChangeLog b/test/ChangeLog
index 96375390..bf0cbffa 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -4,6 +4,10 @@
2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+ * profile5.ok: Updated after code change.
+
+2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+
* spacere.awk: Move setting of LC_ALL=C out to ...
* Makefile.am (spacere): ... here. Added test.
Per request from Eli Zaretskii to help porting to MinGW.
@@ -13,6 +17,14 @@
* Makefile.am (EXTRA_DIST): New test: typedregex4.
* typedregex4.awk, typedregex4.ok: New files.
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile10.ok: Updated after code change.
+
+2018-10-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile0.ok: Updated after code change.
+
2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (profile1): Add minus to ignore errors on final
diff --git a/test/profile0.ok b/test/profile0.ok
index 2e3c5728..42c464ba 100644
--- a/test/profile0.ok
+++ b/test/profile0.ok
@@ -1,6 +1,6 @@
# Rule(s)
2 NR == 1 { # 1
- 1 print $0
+ 1 print
}
diff --git a/test/profile10.ok b/test/profile10.ok
index 13f0b67b..0f77bd38 100644
--- a/test/profile10.ok
+++ b/test/profile10.ok
@@ -17,14 +17,12 @@ BEGIN { # Comment 0
print "MNO" # Comment 16
} # Comment 17
switch (q) {
- case "a":
- # Comment 18
+ # Comment 18
+ case "a": # Comment 19
case "b":
- # Comment 19
- break # Comment 20
- # Comment 21
- default:
- # Comment 22
+ # Comment 20
+ break # Comment 21
+ default: # Comment 22
break # Comment 23
}
# Comment 24
diff --git a/test/profile5.ok b/test/profile5.ok
index c8abf1fb..7ac24024 100644
--- a/test/profile5.ok
+++ b/test/profile5.ok
@@ -2,8 +2,8 @@ BEGIN {
_addlib("_BASE")
}
-#___________________________________________________________________________________
-BEGIN {
+##########################################################
+BEGIN { ############################################################################
BINMODE = "rw"
SUBSEP = "\000"
_NULARR[""]
@@ -15,33 +15,39 @@ BEGIN {
_addlib("_sYS")
}
+################################################################
+#_____________________________________________________________________________
BEGIN {
_addlib("_rEG")
}
+################################################################
+#_____________________________________________________________________________
BEGIN {
_addlib("_INSTRUC")
}
-#___________________________________________________________________________________
-BEGIN {
+######################################################
+BEGIN { #############################################################################
_delay_perfmsdelay = 11500
}
+#___________________________________________________________________________________
BEGIN {
_addlib("_ARR")
}
-#___________________________________________________________________________________
+##########################################################
BEGIN {
}
-BEGIN { ###########################################################################
+###########################################################################
+BEGIN {
_addlib("_EXTFN")
}
-#___________________________________________________________________________________
-BEGIN {
+########################################################
+BEGIN { #############################################################################
delete _XCHR
delete _ASC
delete _CHR
@@ -66,7 +72,7 @@ BEGIN {
_QSTR[_CHR[i]] = _QSTRQ[_CHR[i]]
}
_QSTR["\\"] = "\\\\" #; _QSTR["\""]="\\\""
- #_____________________________________________________________________________
+#_____________________________________________________________________________
_CHR["CR"] = "\r"
_CHR["EOL"] = "\r\n"
_CHR["EOF"] = "\032"
@@ -96,22 +102,24 @@ BEGIN {
_gensubfn("\\^$.()|{,}[-]?+*", ".", "_rexpstr_i0")
}
+#_____________________________________________________________________________
BEGIN {
_addlib("_SYSIO")
}
-#___________________________________________________________________________________
-BEGIN {
+#########################################################
+BEGIN { #############################################################################
_SYS_STDCON = "CON"
_CON_WIDTH = match(_cmd("MODE " _SYS_STDCON " 2>NUL"), /Columns:[ \t]*([0-9]+)/, A) ? strtonum(A[1]) : 80
}
+#___________________________________________________________________________________
BEGIN {
_addlib("_FILEIO")
}
-#___________________________________________________________________________________
-BEGIN {
+#######################################################
+BEGIN { #############################################################################
if (_SYS_STDOUT == "") {
_SYS_STDOUT = "/dev/stdout"
}
@@ -128,12 +136,13 @@ BEGIN {
}
}
+#___________________________________________________________________________________
BEGIN {
_addlib("_tOBJ")
}
-#___________________________________________________________________________________
-BEGIN {
+#########################################################
+BEGIN { #############################################################################
_tInBy = "\212._tInBy"
_tgenuid_init()
_UIDS[""]
@@ -160,12 +169,13 @@ BEGIN {
delete _TMP1[""]
}
+#___________________________________________________________________________________
BEGIN {
_addlib("_ERRLOG")
}
-#___________________________________________________________________________________
-BEGIN {
+########################################################
+BEGIN { #############################################################################
if (_gawk_scriptlevel < 1) {
_ERRLOG_TF = 1
_ERRLOG_VF = 1
@@ -177,32 +187,39 @@ BEGIN {
}
}
+#___________________________________________________________________________________
BEGIN {
_addlib("_SHORTCUT")
}
-#___________________________________________________________________________________
+#####################################################
BEGIN {
_shortcut_init()
}
-BEGIN { #########################################################
+#########################################################
+BEGIN {
_addlib("_eXTFN")
}
-#___________________________________________________________________________________
+########################################################
BEGIN {
_extfn_init()
}
-BEGIN { ############################################################
+############################################################
+BEGIN {
_addlib("_sHARE")
}
+##############################################################
+#_____________________________________________________________________________
BEGIN {
_addlib("_FILEVER")
}
+############################################################
+#_____________________________________________________________________________
BEGIN {
_addlib("_DS") ###############################################################################
_PRODUCT_NAME = "Deployment Solution Control"
@@ -211,14 +228,14 @@ BEGIN {
_PRODUCT_FILENAME = "_main.ewk"
}
-# problem configuring uid by array charset: i can' understand what format of the array: possibly - remove array support
-# after removal of array format detection: there is unfinished conflicts: it is possible to totally remove array uid-gen initialization
-
-#_____________________________________________________
+#____________________________________________________________________________
BEGIN {
_inituidefault()
}
+# problem configuring uid by array charset: i can' understand what format of the array: possibly - remove array support
+# after removal of array format detection: there is unfinished conflicts: it is possible to totally remove array uid-gen initialization
+
#_____________________________________________________
BEGIN {
_initfilever()
@@ -229,29 +246,33 @@ BEGIN {
_initshare()
}
-#_________________________________________________________________
+#___________________________________________________________________________________
+####################################################################################
+
+#_____________________________________________________________________________
BEGIN {
_inspass(_IMPORT, "_import_data")
}
-#_______________________________________________
+#_________________________________________________________________
BEGIN {
_TEND[_ARRLEN] = 0
_TYPEWORD = "_TYPE"
}
-#_______________________________________________
+#_____________________________________________________________________________
BEGIN {
_ARRLEN = "\032LEN"
_ARRPTR = "\032PTR"
_ARRSTR = ""
}
-#_____________________________________________________
+#_______________________________________________________________________
BEGIN {
_getperf_fn = "_nop"
}
+#___________________________________________________________
BEGIN {
_datablock_length = 262144
}
@@ -271,18 +292,8 @@ BEGIN {
_initsys()
}
-#_________________________________________________________________________________________
-##########################################################################################
-
-
-
-
-
-
-
-#BootDevice BuildNumber BuildType Caption CodeSet CountryCode CreationClassName CSCreationClassName CSDVersion CSName CurrentTimeZone DataExecutionPrevention_32BitApplications DataExecutionPrevention_Available DataExecutionPrevention_Drivers DataExecutionPrevention_SupportPolicy Debug Description Distributed EncryptionLevel ForegroundApplicationBoost FreePhysicalMemory FreeSpaceInPagingFiles FreeVirtualMemory InstallDate LargeSystemCache LastBootUpTime LocalDateTime Locale Manufacturer MaxNumberOfProcesses MaxProcessMemorySize MUILanguages Name NumberOfLicensedUsers NumberOfProcesses NumberOfUsers OperatingSystemSKU Organization OSArchitecture OSLanguage OSProductSuite OSType OtherTypeDescription PAEEnabled PlusProductID PlusVersionNumber Primary ProductType RegisteredUser SerialNumber ServicePackMajorVersion ServicePackMinorVersion SizeStoredInPagingFiles Status SuiteMask SystemDevice SystemDirectory SystemDrive TotalSwapSpaceSize TotalVirtualMemorySize TotalVisibleMemorySize Version WindowsDirectory
-#\Device\HarddiskVolume1 7601 Multiprocessor Free Microsoft Windows Server 2008 R2 Enterprise 1252 1 Win32_OperatingSystem Win32_ComputerSystem Service Pack 1 CPU 180 TRUE TRUE TRUE 3 FALSE FALSE 256 0 6925316 33518716 41134632 20110502192745.000000+180 20130426120425.497469+180 20130510134606.932000+180 0409 Microsoft Corporation -1 8589934464 {"en-US"} Microsoft Windows Server 2008 R2 Enterprise |C:\Windows|\Device\Harddisk0\Partition2 0 116 2 10 64-bit 1033 274 18 TRUE 3 Windows User 55041-507-2389175-84833 1 0 33554432 OK 274 \Device\HarddiskVolume2 C:\Windows\system32 C: 50311020 16758448 6.1.7601 C:\Windows
-BEGIN {
+#_____________________________________________________
+BEGIN { ############################################################################
a = ENVIRON["EGAWK_CMDLINE"]
gsub(/^[ \t]*/, "", a)
a = _lib_CMDLN(a)
@@ -302,13 +313,12 @@ BEGIN {
}
#_____________________________________________________________________________
-END {
+END { ########################################################################
_EXIT()
}
-#_______________________________________________________________________
-########################################################################
-END {
+#_____________________________________________________
+END { ###############################################################################
if (_gawk_scriptlevel < 1) {
close(_errlog_file)
p = _Zimport(_rdfile(_errlog_file), _N())
@@ -318,28 +328,8 @@ END {
}
}
-##########################################################################################
-# PUBLIC:
-#_____________________________________________________________________________
-# _rFBRO(ptr) - Return ptr of first-bro. [TESTED]
-# If !ptr then returns "".
-#_____________________________________________________________________________
-# _rLBRO(ptr) - Return ptr of last-bro. [TESTED]
-# If !ptr then returns "".
-#_____________________________________________________________________________
-# _rQBRO(ptr) - Returns brothers total quantity. [TESTED]
-# If !ptr then returns "".
-END {
- if (_gawk_scriptlevel < 1) {
- if (! _fileio_notdeltmpflag) {
- _FILEIO_TMPATHS[_FILEIO_TMPRD]
- _Foreach(_FILEIO_TMPATHS, "_uninit_del")
- }
- }
-}
-
-#___________________________________________________________________________________
-####################################################################################
+#_______________________________________________________________________
+########################################################################
@@ -356,301 +346,76 @@ END {
-#___________________________________________________________________________________
-# fn _dirtree(array,pathmask)
-#
-# Return in `array' file tree from pathmask:
-# array["file.filerdne"]="size date time"
-# array["subdir.filerd"]["file.filerdne"]="size date time"
-# array["subdir.filerd"]["file.filerd"][...]
-#
-# The array will be cleared before any action. Function return pathmask w/o ltabspc and rtabspc.
-#___________________________________________________________________________________
-# OK: change internal function's names to: w\o "_"
-# OK: FLENGTH: should cover r-spcs
-# OK: optimize REXP
-# OK: add new symbols to dir/file names ( ! and + )
-# OK: create _getfilepath()
-# OK: del - conflict with WROOTDIR (do not update it)
-# OK: dir/del - support for filemask ( * and ? )
-# OK: how to define code injections: header\ender; and HANDLERS
-# OK: units in header\ender? conline division...
-# OK: _FILEPATH problem: it will not been defined at the moment when subscript0 starts - at the start TMPRD="_tmp"
-# OK: del: if del("dir\\") - then all ok except it NOT deleted "dir\\" - _del function removed(renamed to __del)
-# OK: tmpdirs: it delete only autotmp dir and only from script0
-# OK: MICROTEST: global testing of filepath (UNC! CORRECT RESULTS! )
-# question about cache: did new just now generated absolute filepath cached in FILECACHE? its seems like NO
-# check _untmp: CONFLICT: if file or dir from autotmp dir will be untmp then it anyway will be deleted; but file or dir from other point never be deleted anyway - so what is the point of untmp?????
-#ERRLOG: _setmpath: warning!!!!!
-#___________________________________________________________________________________
-####################################################################################
-# PUBLIC:
-#___________________________________________________________________________________
-#
-# fn _rdfile(_filepath)
-#
-# Read and return data from file specified in _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function read and return data from file. No any changes in data occured.
-# Function use _filerdne function internally. If some syntax error
-# found in _filepath then function return "".
-# If some error occured while reading data from file then fuction return ""
-# and error-text is in ERRNO(and no close-file action will be occured!).
-# If reading data completed successfully then function try to close
-# file and if while closing file some error occured then function
-# returns "" and error-text is in ERRNO.
-# Otherwise function returns readed data.
-#_____________________________________________________________________________
-#
-# fn _wrfile(_filepath,_data)
-#
-# Write data into file specified in _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function write _data to file. No any changes in data occured.
-# Function use _filerdne function internally. If some syntax error
-# found in _filepath then function return "".
-# If some error occured while writing data to file then fuction return ""
-# and error-text is in ERRNO(and no close-file action will be occured!).
-# If writing data completed successfully then function try to close
-# file and if while closing file some error occured then function
-# returns "" and error-text is in ERRNO.
-# Otherwise function returns _filepath(re-processed).
-#___________________________________________________________________________________
-#
-# fn _filepath(_filepath)
-#
-# Return re-processed root-dir-name-ext of _filepath.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filerdne(_filepath)
-#
-# Return re-processed root-dir-filename of _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function return result only if in _filepath present file-name(name
-# and/or extension) - otherwise its return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filerdn(_filepath)
-#
-# Return re-processed root-dir-name of _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function return result only if in _filepath present name field -
-# - otherwise its return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filerd(_filepath)
-#
-# Return re-processed root-dir of _filepath.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filer(_filepath)
-#
-# Return re-processed root of _filepath.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filed(_filepath)
-#
-# Return re-processed dir of _filepath.
-# If _filepath=="" then no action occured and return "".
-# There is only one case when dir string can be =="" - when in
-# _filepath specified unmounted drive(MS-format) and from-
-# current-location address used(like Z:file.ext). In this
-# case no rootdir-cache-record will be created.
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-# fn _filene(_filepath)
-#
-# Return re-processed name-ext of _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function return result only if in _filepath present file-name(name
-# and/or extension) - otherwise its return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _filen(_filepath)
-#
-# Return re-processed name of _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function return result only if in _filepath present name field -
-# - otherwise its return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#_____________________________________________________________________________
-#
-# fn _file(_filepath)
-#
-# Return re-processed ext of _filepath.
-# If _filepath=="" then no action occured and return "".
-# Function return result only if in _filepath present ext field -
-# - otherwise its return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-#___________________________________________________________________________________
-#
-# fn _dir(_ARR,_filepathmask)
-#
-# Get file-/folder-list of root-folder of _filepathmask.
-# If _filepathmask=="" then no action occured and return "".
-# _filepathmask can contain symbols like `*' and `?' as like
-# its used in `dir'-shell command.
-# Function gets file-/folder-list of specified root-dir-_filepathmask
-# and return this list in array _ARR - where each element:
-#
-# index - is the _filepath of file-or-folder name-ext
-# value - contains 3 fields separated by " ":
-# 1. =="D" if this is folder
-# ==/[0-9]+/ if this is file - size of file in bytes
-# 2. ==date-of-creation of file or folder
-# 3. ==time-of-creation of file or folder
-#
-# Function returns quantity of items in ARR.
-#___________________________________________________________________________________
-#
-# fn _filexist(_filepath)
-#
-# Test if file or path or drive specified in _filepath is exist.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-# Function returns _filepath if _filepath is exist. Otherwise
-# function return 0.
-#_____________________________________________________________________________
-#
-# fn _filenotexist(_filepath)
-#
-# Test if file or path or drive specified in _filepath is not exist.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-# Function returns 1 if _filepath is not exist. Otherwise function
-# return 0.
-#_____________________________________________________________________________
-#
-# fn _newdir(_filepath)
-#
-# Create path specified in root-dir-_filepath.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-# Function returns root-dir of _filepath.
#_______________________________________________________________________
+# _N(arr\str\mpuptr,val) \ _n(arr\str\mpuptr,val)
+# This functions create new object and return ptr.
+# _n() - creates object from list of deleted objects or if it's empty create new one, while _N() always create new one
+# It is strongly recommended to use _N() for the objects that have some data outside of standart object arrays. Or - make routines
+# that will clear outsided object data in case if object deleting.
#
-# fn _newdir(_filepath)
-#
-# Create path specified in root-dir-_filepath. If this folder
-# already exist then it will be completely cleared.
-# If _filepath=="" then no action occured and return "".
-# If some syntax error found in _filepath then function return ""
-# (and NO _filepath-cache-record will be created!).
-# Function returns root-dir of _filepath.
-#___________________________________________________________________________________
-#
-# fn _getmpfile(_filepath,_currfilepath)
-#
-# Return ....
+# IN: arr\str\mpu,val - (both missed) just create obj and return ptr
+# arr,val - create object and write arr[ptr]=val
+# str,val - create object and write _[ptr][str]=val
+# mpuptr - NOT ALLOWED (val missed) create object and run MPU-code specified by mpuptr with created object ptr as primary parameter
+# MOD: -
+# OUT: -
+# RETURN: ptr - pointer to newly created object
+#_________________________________________________________________
+# _tdel(ptr)
+# This function exclude object from it's current structure and delete it. ptr can be later used by function: _n() for creating new object
+# Also same story will occured with all chields and subchields of object specified by ptr.
+# ??? What happened with linked py _ptr[ptr] objects ???
#
-#_____________________________________________________________________________
+# IN: ptr - pointer to object that will deleted
+# MOD: -
+# OUT: -
+# RETURN: undefined
+#_________________________________________________________________
+# _isptr(ptr)
+# This function checks: is ptr is the object pointer that is currently exist?
+# Unescaped remained data will be in data of src_dst_ptr.
#
-# fn _getmpdir(_filepath,_currfilepath)
+# IN: ptr - string that will be tested
+# MOD: -
+# OUT: -
+# RETURN: undefined - if ptr is not pointer to exist object
+# ptr - if ptr is the pointer to exist object
+#_________________________________________________________________
+
+
+
+#_________________________________________________________________
#
-# Return ...
+# TO DESIGN:
#
+# create basic objectapi interface support
+# modify everywhere checking ptr not by `if ( ptr )...', but by `if ( ptr in _ )...'
+# _TMP0, _TMP1 name change to something like _DATA name ???
+# think about redesigning routines for not depending if ptr is exist in tsysarrs: reason: performance\light code
+END { ###############################################################################
+ if (_gawk_scriptlevel < 1) {
+ if (! _fileio_notdeltmpflag) {
+ _FILEIO_TMPATHS[_FILEIO_TMPRD]
+ _Foreach(_FILEIO_TMPATHS, "_uninit_del")
+ }
+ }
+}
+
#_____________________________________________________________________________
-#
-# Temporary files folder.
-#
-# Temporary files folder location is defined by _FILEIO_TMPRD.
-# If it wasn't been initialized before program run or not been initialized
-# by ENVIRON["TMPDIR"] then it will defined as the:
-# `current rootdir(stored in _FILEIO_RD)\programname.TMP'
-# In this case if its already exist then it will completely cleared when _FILEIO
-# library initialization processed.
-# And at the program uninitialization processed it will completely
-# cleared if _FILEIO_TMPCLRFLAG is true.
-#___________________________________________________________________________________
-#
-# var _FILEIO_RD (ENVIRON["CD"])
-#
-# This var can be set before running program. It can contain path which
-# will be used as default current dir while program run.
-# If this var is set before program runs - then it will be refreshed by the
-# _filerd it will be used as default current dir while program run.
-# If this var is not set before program runs - then ENVIRON["CD"] can also
-# set up default current dir while program run. If it set before program
-# begin then it will be refreshed by the _filerd - and also writed into
-# _FILEIO_RD.
-# If both _FILEIO_RD and ENVIRON["CD"] are not set before program begins
-# then real current root\dir will be writed into both _FILEIO_RD and
-# ENVIRON["CD"] and it will be used as default current dir while program run.
-#
-#___________________________________________________________________________________
-#
-# var _FILEIO_TMPRD (ENVIRON["TMPRD"])
-#
-# This var can be set before running program. It can contain path which
-# will be used as default temporary files root-folder while program run.
-# If this var is set before program runs - then it will be refreshed by the
-# _filerd - and also writed into ENVIRON["TMPRD"].
-# If this var is not set before program runs - then ENVIRON["TMPRD"] can also
-# set up default temporary files root-folder while program run. If it set
-# before program begin then it will be refreshed by the _filerd - and
-# also writed into _FILEIO_TMPRD.
-# If both _FILEIO_TMPRD and ENVIRON["TMPRD"] are not set before program begins
-# then new folder into path specified by the _FILEIO_RD(after its handling)
-# will be writed into both _FILEIO_TMPRD and ENVIRON["TMPRD"] and it
-# will be used as default temporary files root-folder while program run.
-#___________________________________________________________________________________
-#
-# var _FILEPATH
-#
-# This var contain filepath of working script. It should be setting up externally.
-#
-# var _gawk_scriptlevel
-#___________________________________________________________________________________
-####################################################################################
-END {
+END { ###############################################################################
if (_constatstrln > 0) {
_constat()
}
}
#___________________________________________________________________________________
-####################################################################################
-
-
-
-
-
-
-
-# make sure that stdout contain only expected characters
-# make sure that stderr contain only expected characters
-# redesign & reformat keys and its outputs
-# try different key combinations
-# add lib-specified to all libs
-#_______________________________________________________________________
function W(p, p0, p1)
{
#####################################################
@@ -686,7 +451,6 @@ function W(p, p0, p1)
return (_[p][p0] = p1)
}
-##########################################################
function _ARR(c, t, P)
{
switch (c) {
@@ -710,7 +474,6 @@ function _ARR(c, t, P)
}
}
-##########################################################
function _BASE(c, t, P, A)
{
switch (c) {
@@ -752,13 +515,12 @@ function _BASE(c, t, P, A)
}
}
-#____________________________________________________________________________
function _DS(c, t, P, a, A)
{
######################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #___________________________________________________________
return t
#_____________________________________________________
case "_lib_APPLY":
@@ -778,13 +540,11 @@ function _DS(c, t, P, a, A)
}
}
-#______________________________________________________________________________________________
function _END()
{
#################################################################################
}
-########################################################
function _ERRLOG(c, t, P, a, b, A)
{
switch (c) {
@@ -849,13 +609,11 @@ function _ERRLOG(c, t, P, a, b, A)
}
}
-#______________________________________________________________________________________________
function _EXIT()
{
################################################################################
}
-########################################################
function _EXTFN(c, t, P)
{
switch (c) {
@@ -879,7 +637,6 @@ function _EXTFN(c, t, P)
}
}
-#######################################################
function _FILEIO(c, t, P, A)
{
switch (c) {
@@ -921,15 +678,13 @@ function _FILEIO(c, t, P, A)
}
}
-############################################################
function _FILEVER(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -959,14 +714,12 @@ function _INIT(f)
{
}
-#___________________________________________________________________________________
function _INITBASE()
{
################################################################
_egawk_utilpath = ENVIRON["EGAWK_PATH"] "BIN\\UTIL\\"
}
-######################################################
function _INSTRUC(c, t, P)
{
switch (c) {
@@ -990,13 +743,6 @@ function _INSTRUC(c, t, P)
}
}
-#___________________________________________________________________________________
-
-
-####################################################################################
-
-
-#_____________________________________________________________________________
function _N(F, v, p)
{
###########################################################
@@ -1007,7 +753,6 @@ function _N(F, v, p)
return _nN_i0(_tgenuid(), F, v)
}
-#####################################################
function _SHORTCUT(c, t, P)
{
switch (c) {
@@ -1031,7 +776,6 @@ function _SHORTCUT(c, t, P)
}
}
-#______________________________________________________________________________________________
function _START(t, i, A)
{
#########################################################################
@@ -1140,7 +884,6 @@ function _START(t, i, A)
_wrfile("report.txt", _report(pp))
}
-#########################################################
function _SYSIO(c, t, P)
{
switch (c) {
@@ -1164,8 +907,6 @@ function _SYSIO(c, t, P)
}
}
-#_______________________________________________________________________
-########################################################################
function _W(p, A, v)
{
if (isarray(v)) {
@@ -1184,7 +925,6 @@ function _W(p, A, v)
return v
}
-#_______________________________________________________________________
function _Zexparr(S, s, t, i)
{
##############################################
@@ -1203,7 +943,6 @@ function _Zexparr(S, s, t, i)
return t
}
-#_________________________________________________________________
function _Zexparr_i0(S, t, i)
{
for (i in S) {
@@ -1212,7 +951,6 @@ function _Zexparr_i0(S, t, i)
return t
}
-#_________________________________________________________________
function _Zexparr_i1(t)
{
gsub(/\x1B/, "\033;", t)
@@ -1221,14 +959,12 @@ function _Zexparr_i1(t)
return t
}
-#_________________________________________________________________
function _Zexparr_i2(t)
{
gsub(/\x10/, "\0330", t)
return t
}
-#_________________________________________________________________
function _Zexparr_i3(t)
{
gsub(/\x1B/, "\033;", t)
@@ -1236,7 +972,6 @@ function _Zexparr_i3(t)
return t
}
-#_______________________________________________________________________
function _Zimparr(D, t, A, B)
{
##############################################
@@ -1249,13 +984,11 @@ 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)) : "")
}
-#_________________________________________________________________
function _Zimparr_i1(D, A, B, i, t, a, n)
{
while (i in B) {
@@ -1279,7 +1012,6 @@ function _Zimparr_i1(D, A, B, i, t, a, n)
}
}
-#_________________________________________________________________
function _Zimparr_i2(t)
{
gsub(/\x1B\x31/, "\021", t)
@@ -1287,7 +1019,6 @@ function _Zimparr_i2(t)
return t
}
-#_____________________________________________________________________________
function _Zimport(t, p, A, c, i, n, B)
{
##############################################
@@ -1360,7 +1091,6 @@ function _accmpu(A, a, n)
}
}
-#_______________________________________________________________________
function _add(S, sf, D, df)
{
################################################
@@ -1384,7 +1114,6 @@ function _add(S, sf, D, df)
}
}
-#_________________________________________________________________
function _addarr(D, S)
{
#############################################
@@ -1393,7 +1122,6 @@ function _addarr(D, S)
}
}
-#_____________________________________________________
function _addarr_i0(D, S, i)
{
for (i in S) {
@@ -1409,7 +1137,6 @@ function _addarr_i0(D, S, i)
}
}
-#_______________________________________________________________________
function _addarrmask(D, S, M)
{
#############################################
@@ -1438,18 +1165,12 @@ function _addarrmask(D, S, M)
}
}
-#___________________________________________________________________________________
-####################################################################################
-
-
-#_______________________________________________________________________
function _addf(A, f)
{
#####################################################
A["B"][""] = A["F"][A["B"][f] = A["B"][""]] = f
}
-#___________________________________________________________
function _addfile(f, d, a, b)
{
##################################
@@ -1475,66 +1196,37 @@ function _addfile(f, d, a, b)
return d
}
-#_____________________________________________________________________________
function _addlib(f)
{
###########################################################
_addf(_LIBAPI, f)
}
-#___________________________________________________________________________________
-####################################################################################
-
-
-#_______________________________________________________________________
function _addlist(A, v)
{
##################################################
A[++A[0]] = v
}
-############################################
function _bearray(A)
{
- #_______________________________________________________________________
+ ####################################################
if (isarray(A) || (A == 0 && A == "")) {
- return 1 ####################################################
+ return 1
}
}
-#_________________________________________________________________
function _bframe(A, t, p)
{
###########################################
return _bframe_i0(A, t, p, A[""])
}
-#___________________________________________________________
function _bframe_i0(A, t, p, f)
{
return (f ? (_bframe_i0(A, t, p, A[f]) (@f(t, p))) : "")
}
-# add to _dumparr: checking that if element is undefined
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#_______________________________________________________________________
function _cfguid(p, optr, pfx, sfx, hstrcnt, lstrchr)
{
#################### 0 #
@@ -1560,7 +1252,6 @@ function _cfguid(p, optr, pfx, sfx, hstrcnt, lstrchr)
return p
}
-#_____________________________________________________
function _cfguidchr(p, h, l, H, L)
{
if (_isptr(l)) {
@@ -1579,7 +1270,6 @@ function _cfguidchr(p, h, l, H, L)
return _cfguidl(p, L, L)
}
-#_______________________________________________
function _cfguidh(p, H, L, hi, h, li)
{
for (hi = 1; hi in H; hi++) {
@@ -1601,7 +1291,6 @@ function _cfguidl(p, H, L, hi, h, hl, li)
return hl
}
-#____________________________________________________________________________________________________
function _check(p)
{
####################################################################################
@@ -1611,14 +1300,12 @@ function _check(p)
_reg_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"]
}
-#_____________________________________________________________________________
function _cmd(c, i, A)
{
#######################################################
@@ -1636,7 +1323,6 @@ function _cmd(c, i, A)
return RT
}
-#_______________________________________________________________________
function _cmparr(A0, A1, R, a, i)
{
##########################################
@@ -1660,7 +1346,6 @@ function _cmparr(A0, A1, R, a, i)
return a
}
-#_____________________________________________________________________________
function _con(t, ts, a, b, c, d, i, r, A, B)
{
##########################################
@@ -1702,7 +1387,6 @@ function _con(t, ts, a, b, c, d, i, r, A, B)
RLENGTH = d
}
-#_______________________________________________________________________
function _conin(t, a, b)
{
#################################################
@@ -1724,28 +1408,23 @@ function _conin(t, a, b)
return t
}
-#_______________________________________________________________________
function _conl(t, ts)
{
####################################################
return _con(t (t ~ /\x0A$/ ? "" : _CHR["EOL"]), ts)
}
-#_______________________________________________________________________
function _conline(t, ts)
{
#################################################
return _con(_chrline(t, ts))
}
-#___________________________________________________________________________________
-####################################################################################
function _conlq(t, ts)
{
return _conl("`" t "'", ts)
}
-#_______________________________________________________________________
function _constat(t, ts, ln, a)
{
###########################################
@@ -1764,7 +1443,6 @@ function _constat(t, ts, ln, a)
return _constatstr
}
-#_________________________________________________________________
function _constatgtstr(t, ln, a, b)
{
if (ln < 1) {
@@ -1782,7 +1460,6 @@ function _constatgtstr(t, ln, a, b)
return (substr(t, 1, b = int((ln - 3) / 2)) "..." substr(t, a - ln + b + 4))
}
-#_______________________________________________________________________
function _constatpop()
{
##################################################
@@ -1792,7 +1469,6 @@ function _constatpop()
return _constat("")
}
-#_______________________________________________________________________
function _constatpush(t, ts)
{
#############################################
@@ -1803,13 +1479,11 @@ function _constatpush(t, ts)
return _constatstr
}
-#___________________________________________________________________________________
function _creport(p, t, f, z)
{
_[p]["REPORT"] = _[p]["REPORT"] _ln(t (f == "" ? "" : ": " f))
}
-#_________________________________________________________________________________________
function _defdir(pp, n, f, v, p)
{
#############################################################
@@ -1818,7 +1492,6 @@ function _defdir(pp, n, f, v, p)
return p
}
-#_________________________________________________________________________________________
function _defdll(pp, n, rn, p)
{
##############################################################
@@ -1828,7 +1501,6 @@ function _defdll(pp, n, rn, p)
return p
}
-#___________________________________________________________
function _defescarr(D, r, S, i, c, t)
{
if (isarray(S)) {
@@ -1855,7 +1527,6 @@ function _defescarr(D, r, S, i, c, t)
return t
}
-#_________________________________________________________________________________________
function _defile(pp, n, f, v, p)
{
#############################################################
@@ -1867,14 +1538,12 @@ function _defile(pp, n, f, v, p)
return p
}
-#_______________________________________________________________________
function _defn(f, c, v)
{
###################################################
FUNCTAB[c f] = v
}
-#_________________________________________________________________________________________
function _defreg(pp, n, f, v, p)
{
#############################################################
@@ -1885,7 +1554,6 @@ function _defreg(pp, n, f, v, p)
}
}
-#_______________________________________________________________________________________________
function _defsolution(pp, n, rn, p)
{
###############################################################
@@ -1895,7 +1563,6 @@ function _defsolution(pp, n, rn, p)
return p
}
-#_________________________________________________________________________________________
function _defsrv(pp, n, f, v, p)
{
#############################################################
@@ -1904,7 +1571,6 @@ function _defsrv(pp, n, f, v, p)
return p
}
-#_______________________________________________________________________
function _del(f, c, a, A)
{
#################################################
@@ -1933,7 +1599,6 @@ function _del(f, c, a, A)
return a
}
-#_______________________________________________________________________
function _delay(t, a)
{
###################################################
@@ -1942,7 +1607,6 @@ function _delay(t, a)
}
}
-#_________________________________________________________________
function _delayms(a)
{
#############################################
@@ -1950,7 +1614,6 @@ function _delayms(a)
}
}
-#_______________________________________________________________________
function _deletepfx(A, f, B, le, i)
{
########################################
@@ -1963,7 +1626,6 @@ function _deletepfx(A, f, B, le, i)
}
}
-#_________________________________________________________________
function _delf(A, f)
{
###############################################
@@ -1972,7 +1634,6 @@ function _delf(A, f)
delete A["B"][f]
}
-#_______________________________________________________________________
function _deluid(p)
{
################################################# 1 #
@@ -1986,7 +1647,6 @@ function _deluid(p)
return _deluida0
}
-#_______________________________________________________________________
function _dir(A, rd, i, r, f, ds, pf, B, C)
{
####################################
@@ -2016,7 +1676,6 @@ function _dir(A, rd, i, r, f, ds, pf, B, C)
return r
}
-#_________________________________________________________________
function _dirtree(A, f, B)
{
#########################################
@@ -2028,7 +1687,6 @@ function _dirtree(A, f, B)
return f
}
-#___________________________________________________________
function _dirtree_i0(B, i, c, A, f, lf, a, C)
{
delete A[f]
@@ -2049,7 +1707,6 @@ function _dirtree_i0(B, i, c, A, f, lf, a, C)
return i
}
-#_______________________________________________________________________
function _dll_check(pp)
{
_dllchktv = ""
@@ -2067,7 +1724,6 @@ function _dll_check(pp)
}
}
-#_______________________________________________
function _dll_check_i0(p, R, pp, p2, i, i2, r, f, v, rs, d, tv, tf)
{
if (_[p]["TYPE"] == "defdll") {
@@ -2123,7 +1779,6 @@ function _dll_check_i0(p, R, pp, p2, i, i2, r, f, v, rs, d, tv, tf)
}
}
-#_______________________________________________
function _dll_check_i1(p, pp, p1, p2, p3, i)
{
if (_[p]["TYPE"] == "defdll") {
@@ -2135,7 +1790,6 @@ function _dll_check_i1(p, pp, p1, p2, p3, i)
}
}
-#___________________________________________________________________________________
function _dllerr(p, t, f)
{
if (t !~ /\x00/) {
@@ -2175,7 +1829,6 @@ function _drawuid(p, cn, ch, o)
}
}
-#_______________________________________________________________________
function _dumparr(A, t, lv, a)
{
############################################
@@ -2190,7 +1843,6 @@ function _dumparr(A, t, lv, a)
}
}
-#___________________________________________________________
function _dumparr_i1(A, lv, ls, ln, t, t2, i, a, f)
{
t2 = _getchrln(" ", length(t))
@@ -2233,14 +1885,6 @@ function _dumparr_i1(A, lv, ls, ln, t, t2, i, a, f)
}
}
-#___________________________________________________________________________________
-####################################################################################
-
-
-#___________________________________________________________________________________
-# OTHER tFUNCTIONs #################################################################
-
-#_____________________________________________________________________________
function _dumpobj(p, f, t, s)
{
###################################################
@@ -2251,7 +1895,6 @@ function _dumpobj(p, f, t, s)
return s
}
-#___________________________________________________________
function _dumpobj_i0(p, f, t)
{
if (f == "") {
@@ -2263,19 +1906,16 @@ function _dumpobj_i0(p, f, t)
return (_dumpobj_i1(p, t " ") _dumpobj_i2(p, _getchrln(" ", length(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))
}
-#___________________________________________________________
function _dumpobj_i2(p, t)
{
return (_dumpobj_i3(_[p], t " ") _dumpobj_i3(_ptr[p], _getchrln(" ", length(t)) "`", "`"))
}
-#___________________________________________________________
function _dumpobj_i3(A, t, p, e, s, i, t2)
{
if (isarray(A)) {
@@ -2299,7 +1939,6 @@ function _dumpobj_i3(A, t, p, e, s, i, t2)
return _ln(t "=" _dumpobj_i4(p A) "'")
}
-#___________________________________________________________
function _dumpobj_i4(t)
{
if (length(t) > 64) {
@@ -2308,14 +1947,12 @@ function _dumpobj_i4(t)
return t
}
-#_________________________________________________________________
function _dumpobj_nc(p, f, t)
{
#######################################
return _dumpobj_i0(p, f, t "." p "{ ")
}
-#_________________________________________________________________
function _dumpobjm(p, f, t, s, t2)
{
###################################
@@ -2327,7 +1964,6 @@ function _dumpobjm(p, f, t, s, t2)
return s
}
-#_________________________________________________________________
function _dumpobjm_nc(p, f, t, s, t2)
{
################################
@@ -2362,14 +1998,12 @@ function _dumpuidgen(p, pd, pc, ps)
}
}
-#_____________________________________________________________________________
function _dumpval(v, n)
{
_dumpstr = _dumpstr (v = _ln((n == 0 && n == "" ? "RET" : n) ": " (v == 0 && v == "" ? "-" : v "'")))
return v
}
-########################################################
function _eXTFN(c, t, P)
{
switch (c) {
@@ -2393,13 +2027,11 @@ function _eXTFN(c, t, P)
}
}
-#_________________________________________________________________
function _endpass(t)
{
_endpass_v0 = t
}
-#_______________________________________________________________________
function _err(t, a, b)
{
###################################################
@@ -2414,14 +2046,12 @@ function _err(t, a, b)
return t
}
-#_________________________________________________________________
function _errnl(t)
{
################################################
return _err(t (t ~ /\x0A$/ ? "" : _CHR["EOL"]))
}
-#_______________________________________________________________________
function _error(t, d, A)
{
#################################################
@@ -2432,14 +2062,12 @@ function _error(t, d, A)
}
}
-#_______________________________________________________________________
function _exit(c)
{
#######################################################
exit c
}
-#_____________________________________________________________________________
function _export_data(t, i, A)
{
#################################################
@@ -2448,10 +2076,6 @@ function _export_data(t, i, A)
_expout("_DATA: " _Zexparr(A) "\n")
}
-#___________________________________________________________________________________
-####################################################################################
-
-#_____________________________________________________________________________
function _expout(t, d, a, b)
{
####################################################
@@ -2465,8 +2089,6 @@ function _expout(t, d, a, b)
ORS = b
}
-#_________________________________________________________________________________________
-##########################################################################################
function _extfn_init()
{
##############################################################
@@ -2499,7 +2121,6 @@ function _faccr_i0(A, t, p, P, f, r)
return r
}
-#_______________________________________________________________________
function _fatal(t, d, A)
{
#################################################
@@ -2533,20 +2154,17 @@ function _ffaccr(A, t, p, P)
return _faccr_i0(A["F"], t, p, P)
}
-##################
function _fframe(A, t, p)
{
- #_______________________________________________________________________
- return _fframe_i0(A, t, p, A[""]) #################################################
+ #################################################
+ return _fframe_i0(A, t, p, A[""])
}
-#___________________________________________________________
function _fframe_i0(A, t, p, f)
{
return (f ? ((@f(t, p)) _fframe_i0(A, t, p, A[f])) : "")
}
-#_________________________________________________________________
function _file(f)
{
#################################################
@@ -2556,7 +2174,6 @@ function _file(f)
return (f in _FILEXT ? _FILEXT[f] : "")
}
-#_______________________________________________________________________
function _file_check(p)
{
if (1 || "AGENT" in _[p]) {
@@ -2564,7 +2181,6 @@ function _file_check(p)
}
}
-#_______________________________________________
function _file_check_i0(p, pp, p1, p2, f, v)
{
if (_[p]["TYPE"] == "defile") {
@@ -2593,7 +2209,6 @@ function _file_check_i0(p, pp, p1, p2, f, v)
}
}
-#_________________________________________________________________
function _filed(f, dd, d)
{
##########################################
@@ -2618,7 +2233,6 @@ function _filed(f, dd, d)
return d
}
-#_________________________________________________________________
function _filen(f)
{
################################################
@@ -2628,7 +2242,6 @@ function _filen(f)
return (f in _FILENAM ? _FILENAM[f] : "")
}
-#_________________________________________________________________
function _filene(f)
{
###############################################
@@ -2638,7 +2251,6 @@ function _filene(f)
return (f in _FILENAM ? _FILENAM[f] : "") (f in _FILEXT ? _FILEXT[f] : "")
}
-#_________________________________________________________________
function _filenotexist(f, a)
{
######################################
@@ -2656,7 +2268,6 @@ function _filenotexist(f, a)
return a
}
-#_______________________________________________________________________
function _filepath(f, dd)
{
################################################
@@ -2666,7 +2277,6 @@ function _filepath(f, dd)
return (filegetrootdir(f, dd) (f in _FILENAM ? _FILENAM[f] : "") (f in _FILEXT ? _FILEXT[f] : ""))
}
-#_________________________________________________________________
function _filer(f, dd)
{
#############################################
@@ -2682,7 +2292,6 @@ function _filer(f, dd)
return (_FILEROOT[dd, f] = fileri(dd))
}
-#_________________________________________________________________
function _filerd(f, dd)
{
############################################
@@ -2692,7 +2301,6 @@ function _filerd(f, dd)
return filegetrootdir(f, dd)
}
-#_________________________________________________________________
function _filerdn(f, dd)
{
###########################################
@@ -2702,7 +2310,6 @@ function _filerdn(f, dd)
return (f in _FILENAM ? (filegetrootdir(f, dd) _FILENAM[f]) : "")
}
-#_________________________________________________________________
function _filerdne(f, dd)
{
##########################################
@@ -2718,7 +2325,6 @@ function _filerdne(f, dd)
return ""
}
-#___________________________________________________________
function _filerdnehnd(st, c, r, d, n, A)
{
if (st) {
@@ -2773,7 +2379,6 @@ function _filerdnehnd(st, c, r, d, n, A)
return ""
}
-#_______________________________________________________________________
function _filexist(f, a)
{
################################################
@@ -2792,7 +2397,6 @@ function _filexist(f, a)
return _NOP
}
-#_______________________________________________________________________
function _fn(f, p0, p1, p2)
{
################################################
@@ -2801,7 +2405,6 @@ function _fn(f, p0, p1, p2)
}
}
-#_______________________________________________________________________
function _foreach(A, f, r, p0, p1, p2, i, p)
{
####################################
@@ -2817,7 +2420,6 @@ function _foreach(A, f, r, p0, p1, p2, i, p)
}
}
-#_____________________________________________________
function _foreach_i0(A, f, D, p0, p1, p2)
{
for (i in A) {
@@ -2829,13 +2431,11 @@ function _foreach_i0(A, f, D, p0, p1, p2)
}
}
-#_____________________________________________________
function _foreach_i1(p, f, D, p0, p1, p2)
{
_gen(D, @f(p, p0, p1, p2))
}
-#_____________________________________________________________________________
function _formatrexp(t)
{
_formatstrq0 = split(t, _FORMATSTRA, /[\/\x00-\x1F\x80-\xFF]/, _FORMATSTRB)
@@ -2846,7 +2446,6 @@ function _formatrexp(t)
return (_formatstrs0 _FORMATSTRA[t])
}
-#___________________________________________________________
function _formatrexp_init()
{
_defescarr(_FORMATREXPESC, "[\\x00-\\x1F\\x80-\\xFF]", _QASC)
@@ -2854,7 +2453,6 @@ function _formatrexp_init()
_FORMATREXPESC["\t"] = "\\t"
}
-#_____________________________________________________________________________
function _formatstrd(t)
{
_formatstrq0 = split(t, _FORMATSTRA, /["\x00-\x1F\x80-\xFF]/, _FORMATSTRB)
@@ -2865,7 +2463,6 @@ function _formatstrd(t)
return (_formatstrs0 _FORMATSTRA[t])
}
-#___________________________________________________________
function _formatstrd_init()
{
_defescarr(_FORMATSTRDESC, "[\\x00-\\x1F\\x80-\\xFF]", _QASC)
@@ -2873,15 +2470,8 @@ function _formatstrd_init()
_FORMATSTRDESC["\t"] = "\\t"
}
-#__________________________________________________________________________________
function _formatstrs(t)
{
- ####################################################################################
-
-
-
-
- #___________________________________________________________________________________
_formatstrq0 = split(t, _FORMATSTRA, /['\x00-\x1F\x80-\xFF]/, _FORMATSTRB)
_formatstrs0 = ""
for (t = 1; t < _formatstrq0; t++) {
@@ -2890,7 +2480,6 @@ function _formatstrs(t)
return (_formatstrs0 _FORMATSTRA[t])
}
-#___________________________________________________________
function _formatstrs_init()
{
_defescarr(_FORMATSTRSESC, "[\\x00-\\x1F\\x80-\\xFF]", _QASC)
@@ -2911,14 +2500,11 @@ function _fpp(q, D, S)
return q
}
-#_______________________________________________________________________
-########################################################################
function _fthru(A, c, p, B)
{
return _fthru_i0(A, c, p, B, A[""])
}
-#_________________________________________________________________
function _fthru_i0(A, c, p, B, f)
{
return (f ? @f(c, _fthru_i0(A, c, p, B, A[f]), B) : "")
@@ -2931,7 +2517,6 @@ function _gen(D, t)
}
}
-#_____________________________________________________________________________
function _gensubfn(t, r, f, p0, A)
{
###############################################
@@ -2941,20 +2526,17 @@ function _gensubfn(t, r, f, p0, A)
return t
}
-#_____________________________________________________________________________
function _get_errout(p)
{
#######################################################
return _tframe("_get_errout_i0", p)
}
-#_______________________________________________________________________
function _get_errout_i0(p, t, n, a)
{
return (p in _tLOG ? (_get_errout_i1(p) _get_errout_i3(p)) : "")
}
-#_________________________________________________________________
function _get_errout_i1(p, t, n, a)
{
if (p in _tLOG) {
@@ -2971,13 +2553,11 @@ 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"] ")") : "") ": ") : "")
}
-#_______________________________________________________________________
function _get_errout_i3(p, t, ts, cl, cp, cr, a, b)
{
if ("LSTR" in _tLOG[p]) {
@@ -2996,14 +2576,12 @@ function _get_errout_i3(p, t, ts, cl, cp, cr, a, b)
}
}
-#_____________________________________________________________________________
function _get_logout(p)
{
#######################################################
return _tframe("_get_logout_i0", p)
}
-#_______________________________________________________________________
function _get_logout_i0(p, t, n, a)
{
if (p in _tLOG) {
@@ -3020,14 +2598,13 @@ function _get_logout_i0(p, t, n, a)
}
}
-#_______________________________________________________________________
function _getchrln(s, w)
{
#################################################
if (s == "") {
return
+ #if ( w!=w+0 || w<0 ) w=_CON_WIDTH
}
- #if ( w!=w+0 || w<0 ) w=_CON_WIDTH
if (length(s) < w) {
if (s in _GETCHRLN) {
if (length(_getchrlnt0 = _GETCHRLN[s]) >= w) {
@@ -3046,14 +2623,12 @@ function _getchrln(s, w)
}
}
-#_______________________________________________________________________
function _getdate()
{
#####################################################
return strftime("%F")
}
-#_____________________________________________________________________________
function _getfilepath(t, f, al, b, A)
{
############################################
@@ -3082,14 +2657,12 @@ function _getfilever(f)
}
}
-#_________________________________________________________________
function _getime()
{
################################################
return strftime("%H:%M:%S")
}
-#_________________________________________________________________
function _getmpdir(f, dd)
{
##########################################
@@ -3102,7 +2675,6 @@ function _getmpdir(f, dd)
return f
}
-#_________________________________________________________________
function _getmpfile(f, dd)
{
#########################################
@@ -3115,7 +2687,6 @@ function _getmpfile(f, dd)
return f
}
-#_______________________________________________________________________
function _getperf(o, t, a)
{
###############################################
@@ -3127,7 +2698,6 @@ function _getperf(o, t, a)
return 1
}
-#___________________________________________________________
function _getperf_(o, t, a)
{
if (a >= _getperf_end) {
@@ -3140,7 +2710,6 @@ function _getperf_(o, t, a)
return 1
}
-#___________________________________________________________
function _getperf_noe(o, t, a)
{
if (_getperf_opsecp != _getperf_opsec) {
@@ -3150,13 +2719,11 @@ function _getperf_noe(o, t, a)
return 1
}
-#___________________________________________________________
function _getperf_noenot(o, t, a)
{
return 1
}
-#___________________________________________________________
function _getperf_not(o, t, a)
{
if (a < _getperf_end) {
@@ -3164,8 +2731,6 @@ function _getperf_not(o, t, a)
}
}
-#_________________________________________________________________________________________
-##########################################################################################
function _getreg_i1(D, r, R, a, i, il, ir, rc, B)
{
a = IGNORECASE
@@ -3190,14 +2755,12 @@ function _getreg_i1(D, r, R, a, i, il, ir, rc, B)
}
}
-#_________________________________________________________________
function _getsecond()
{
#############################################
return systime()
}
-#___________________________________________________________
function _getsecondsync(a, c, b, c2)
{
##########################
@@ -3208,7 +2771,6 @@ function _getsecondsync(a, c, b, c2)
return (a + 1)
}
-#_______________________________________________________________________
function _getuid(p)
{
################################################# 1 #
@@ -3223,7 +2785,6 @@ function _getuid(p)
return _tptr
}
-#_____________________________________________________
function _getuid_i0(p, UL, UH)
{
if ("" == (_tptr = UL[_UIDCNTL[p]])) {
@@ -3241,7 +2802,6 @@ function _handle8494(t)
return gensub(/(.)/, ".\\1", "G", t)
}
-#_____________________________________________________________________________
function _hexnum(n, l)
{
#########################################################
@@ -3251,7 +2811,6 @@ function _hexnum(n, l)
return sprintf("%." (l + 0 < 1 ? 2 : l) "X", n)
}
-#_________________________________________________________________
function _igetperf(t, s, o)
{
######################################### # t-test period in seconds(==0 ? no period; s(=true/false)-output/not output status; o-qnt of ops before test start
@@ -3282,7 +2841,6 @@ function _import_data(t, p, p2, a)
return t
}
-#_______________________________________________________________________
function _info(t, d, A)
{
##################################################
@@ -3293,8 +2851,6 @@ function _info(t, d, A)
}
}
-# test with the different path types
-# _conl(_ln("SRC:") _dumparr(S)); _conl();
function _ini(p, cs, dptr, pfx, sfx, hstr, lstr)
{
return _inituid(p, cs, dptr, pfx, sfx, hstr, lstr, A)
@@ -3338,7 +2894,6 @@ function _initshare()
_sharextool = "\\\\CPU\\eGAWK\\LIB\\_share\\_share.exe"
}
-#_________________________________________
function _initspecialuid()
{
_NOINDEX = _getuid()
@@ -3353,7 +2908,6 @@ function _initsys()
{
}
-#_______________________________________________________________________
function _inituid(p, cs, dptr, pfx, sfx, hstr, lstr, A)
{
################### 1 #
@@ -3413,7 +2967,6 @@ function _inituidefault(h, l, H, L)
_initspecialuid()
}
-#_______________________________________________________________________
function _ins(S, sf, D, df)
{
################################################
@@ -3437,14 +2990,12 @@ function _ins(S, sf, D, df)
}
}
-#_________________________________________________________________
function _insf(A, f)
{
###############################################
A["F"][""] = A["B"][A["F"][f] = A["F"][""]] = f
}
-#_________________________________________________________________
function _insframe(A, f)
{
###########################################
@@ -3452,17 +3003,12 @@ function _insframe(A, f)
A[""] = f
}
-########################
function _inspass(A, f)
{
- #_________________________________________________________________
A[f] = A[""]
A[""] = f
}
-# there is problem with string's format: i can;t easilly merge 2 charsets: comma-divided and every-char-divided strings
-
-#_______________________________________________________________________
function _isptr(p)
{
################################################## 1 #
@@ -3483,7 +3029,6 @@ function _isptr(p)
return 0
}
-#_______________________________________________________________________
function _istr(p)
{
################################################### 1 #
@@ -3500,57 +3045,48 @@ function _istr(p)
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)
}
-#_________________________________________________________________
function _lib_APPLY()
{
return _ffaccr(_LIBAPI, "_lib_APPLY")
}
-#_________________________________________________________________
function _lib_BEGIN(A)
{
return _ffaccr(_LIBAPI, "_lib_BEGIN", "", A)
}
-#_______________________________________________________________________
function _lib_CMDLN(t)
{
return _pass(_LIBAPI["F"], "_lib_CMDLN", t)
}
-#_________________________________________________________________
function _lib_END(A)
{
return _ffaccr(_LIBAPI, "_lib_END", "", A)
}
-#_________________________________________________________________
function _lib_HELP()
{
return _fbaccr(_LIBAPI, "_lib_HELP")
}
-#_________________________________________________________________
function _lib_NAMEVER()
{
return _fbaccr(_LIBAPI, "_lib_NAMEVER")
}
-#_____________________________________________________________________________
function _ln(t)
{
###############################################################
return (t ~ /\x0A$/ ? t : (t _CHR["EOL"]))
}
-#_________________________________________________________________
function _log(A, p, a, B)
{
###########################################
@@ -3571,7 +3107,6 @@ function _log(A, p, a, B)
}
}
-#_________________________________________________________________
function _lspctab(t, ts, l, l1, l2, A)
{
################################
@@ -3613,7 +3148,6 @@ function _macsfx94(F, D, C, p1, p2, p3)
return _mpuretsub(D, _handle8494(_mpuacc))
}
-#_______________________________________________________________________
function _movarr(D, S)
{
###################################################
@@ -3640,11 +3174,6 @@ function _mpu(t, F, p1, p2, p3, D, C)
return t
}
-#
-# /rexpstr/ -> datastr
-# (\x00\t\+)* -> 28 00 09 5B 2B 29
-#
-# unesc all non-rexp characters: replace unesc of rexp-characters but do not remove it: \* -> \*, \x2A -> \*, \052 -> \*, \\ -> \#
function _mpudefaulthnd(F, D, C, p1, p2, p3)
{
_mpuretsub(D, _mpucc0)
@@ -3697,7 +3226,6 @@ function _mpusub(F, D, C, d, p1, p2, p3, q)
_conl("mpusub exit: _mpuacc: `" _mpuacc "'")
}
-#_______________________________________________________________________
function _n(F, v, p)
{
#####################################################
@@ -3723,7 +3251,6 @@ function _n(F, v, p)
return _nN_i0(_tgenuid(), F, v)
}
-#_____________________________________________________
function _nN_i0(p, F, v)
{
_[p][""]
@@ -3754,7 +3281,6 @@ function _nN_i0(p, F, v)
return p
}
-#_________________________________________________________________
function _newclrdir(f)
{
############################################
@@ -3767,7 +3293,6 @@ function _newclrdir(f)
return f
}
-#_______________________________________________________________________
function _newdir(f)
{
#####################################################
@@ -3781,28 +3306,10 @@ function _newdir(f)
return f
}
-##############################
function _nop(p0, p1, p2, p3)
{
- #_______________________________________________________________________
}
-#_____________________________________________________
-# _retarr(ARRAY,start,prefixtr,postfixtr)
-# Return string collected from elements of ARRAY.
-# The data elements in ARRAY have numeric indexes. By default it starts from element with index 1, but it is possible to locate elements starting from
-# 0,-1,-.... The last data element in the ARRAY have the highest numeric index that is stored in ARRAY[_ARRLEN].
-# Optimized for very large data size.
-#
-# IN: ARRAY - source data array(is ARRAY is not array then return undefined)
-# start - (optional) start index in ARRAY; if missed or have non-numeric value then start array index will be 1.
-# prefixst - the string that will be inserted in the begin of generated return string
-# postfix - the string that will be added at the end of generated return string
-# MOD: -
-# OUT: -
-# RETURN: undefined - if ARRAY is not array; if ARRAY is empty; if start is higher than ARRAY last element index
-# string - collected string: prefixtr-arraydata-postfixtr
-#_________________________________________________________________
function _nretarr(A, i, v, r, q)
{
#####################################
@@ -3822,7 +3329,6 @@ function _nretarr(A, i, v, r, q)
return
}
-#___________________________________________________________
function _nretarrd(A, i, v, r, q)
{
##############################
@@ -3844,10 +3350,6 @@ function _nretarrd(A, i, v, r, q)
delete A[""]
}
-#___________________________________________________________________________________
-####################################################################################
-
-#___________________________________________________________________________________
function _out(t, a, b)
{
###############################################################
@@ -3862,7 +3364,6 @@ function _out(t, a, b)
return t
}
-#_________________________________________________________________
function _outnl(t)
{
################################################
@@ -3917,7 +3418,6 @@ function _p8(s1, s2, s3, s4, s5, s6, s7, s8, p1, p2, p3, p4, p5, p6, p7, p8)
return @_qparamf0(s1, s2, s3, s4, s5, s6, s7, s8, s8, p1, p2, p3, p4, p5, p6, p7)
}
-#_______________________________________________________________________
function _pass(A, f, t, p2, i, a)
{
###########################################
@@ -3939,8 +3439,6 @@ function _pass(A, f, t, p2, i, a)
return t
}
-# this is somnitelno: that / / . / / com 56 / / - is the DEV...; what is DEV ??? this already PROBLEM
-#_____________________________________________________________________________
function _patharr0(D, q, i, h, A, B)
{
##############################################
@@ -3979,7 +3477,6 @@ function _patharr0(D, q, i, h, A, B)
}
}
-#_____________________________________________________
function _patharr0_i0(t, D, l, r, d, i)
{
if (i = index(t, ":")) {
@@ -3999,7 +3496,6 @@ function _patharr0_i0(t, D, l, r, d, i)
return t
}
-#_____________________________________________________
function _patharr0_i1(D, A, i, q, t, c)
{
if (D["type"] == "UNC") {
@@ -4025,7 +3521,6 @@ function _patharr0_i1(D, A, i, q, t, c)
return 1
}
-#############################################################################
function _pmap(m, s1, s2, s3, s4, s5, s6, s7, s8)
{
if (match(m, /^([^\(]+)\(([^\)]*)\)$/, _QMAP)) {
@@ -4081,7 +3576,6 @@ function _pr8(s1, s2, s3, s4, s5, s6, s7, s8, p1, p2, p3, p4, p5, p6, p7, p8)
return @_qparamf1(p1, p2, p3, p4, p5, p6, p7, p8)
}
-#_________________________________________________________________
function _printarr(A, t, lv, r, a)
{
####################################
@@ -4097,7 +3591,6 @@ function _printarr(A, t, lv, r, a)
}
}
-#___________________________________________________________
function _printarr_i1(A, lv, ls, ln, t, t2, i, a, f)
{
t2 = _getchrln(" ", length(t))
@@ -4181,7 +3674,6 @@ function _qparam_i0(p0, p1, p2, p3, p4, p5, p6, p7)
}
}
-#_______________________________________________________________________
function _qstr(t, c, A, B)
{
################################################
@@ -4192,7 +3684,6 @@ function _qstr(t, c, A, B)
return c
}
-#_________________________________________________________________
function _qstrq(t)
{
################################################
@@ -4201,15 +3692,13 @@ function _qstrq(t)
return t
}
-################################################################
function _rEG(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #####################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #####################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -4228,7 +3717,6 @@ function _rEG(c, t, P, a, A)
}
}
-#_______________________________________________________________________
function _rFBRO(p)
{
######################################################
@@ -4244,7 +3732,6 @@ function _rFBRO(p)
return p
}
-#_______________________________________________________________________
function _rFCHLD(p)
{
#####################################################
@@ -4254,11 +3741,10 @@ function _rFCHLD(p)
return ""
}
-######################## p="", !v
function _rLBRO(p)
{
- #_______________________________________________________________________
- if (p) { ######################################################
+ ######################################################
+ if (p) {
if (p in _tPARENT) {
return _tLCHLD[_tPARENT[p]]
}
@@ -4270,58 +3756,52 @@ function _rLBRO(p)
return p
}
-######################## p=""
function _rLCHLD(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tLCHLD)) { #####################################################
+ #####################################################
+ if ((p) && (p in _tLCHLD)) {
return _tLCHLD[p]
}
return ""
}
-#_______________________________________________________________________
function _rLINK(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 ""
}
-######################## p=""
function _rPARENT(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tPARENT)) { ####################################################
+ ####################################################
+ if ((p) && (p in _tPARENT)) {
return _tPARENT[p]
}
return ""
}
-######################## p=""
function _rPREV(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tPREV)) { ######################################################
+ ######################################################
+ if ((p) && (p in _tPREV)) {
return _tPREV[p]
}
return ""
}
-######################## p=""
function _rQBRO(p, c, p1)
{
- #_______________________________________________________________________
- if (p) { ################################################
+ ################################################
+ if (p) {
if (p in _tPARENT) {
return _tQCHLD[_tPARENT[p]]
}
@@ -4340,20 +3820,15 @@ function _rQBRO(p, c, p1)
return p
}
-######################## p=""
function _rQCHLD(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tQCHLD)) { #####################################################
+ #####################################################
+ if ((p) && (p in _tQCHLD)) {
return _tQCHLD[p]
}
return ""
}
-#___________________________________________________________________________________
-# EMMULATED FUNCTIONAL FIELDS ######################################################
-
-#_____________________________________________________________________________
function _rSQFIRST(g, p, A)
{
#####################################################
@@ -4365,7 +3840,6 @@ function _rSQFIRST(g, p, A)
return _rsqgetptr(g, p)
}
-#_________________________________________________________________
function _rSQFIRSTA(g, p, A)
{
########################################
@@ -4377,7 +3851,6 @@ function _rSQFIRSTA(g, p, A)
return _rSQNEXTA(g, p, A)
}
-#_______________________________________________________________________
function _rSQNEXT(g, p, A)
{
################################################
@@ -4387,7 +3860,6 @@ function _rSQNEXT(g, p, A)
return _rsqnext_i0(g, p)
}
-#_________________________________________________________________
function _rSQNEXTA(g, p, A)
{
#########################################
@@ -4416,7 +3888,6 @@ function _rconline(t)
_rprt = _rprt _ln((t = " " t " ") _getchrln("_", _CON_WIDTH - length(t) - 1))
}
-#___________________________________________________________
function _rd_shortcut(D, f)
{
if ((_shrtcutf0 = _filepath(f)) && _shortcut_nerr(_shrtcuta0 = _cmd(_shortcut_fpath " /A:Q /F:\"" _shrtcutf0 "\" 2>&1"), _shrtcutf0)) {
@@ -4433,7 +3904,6 @@ function _rd_shortcut(D, f)
return (ERRNO ? ERRNO = "read shortcut: " ERRNO : _NOP)
}
-#_______________________________________________________________________
function _rdfile(f, i, A)
{
################################################
@@ -4458,35 +3928,6 @@ function _rdfile(f, i, A)
return (RT = _NOP)
}
-####################################################################################
-# PUBLIC:
-#_____________________________________________________________________________
-# fn _th0,_th1,_th2,_th3
-# USAGE:
-# _th0(p1,p2,p3,p4)
-#
-# Each of this functions can have up to 4 parameters.
-# _th0(p1,p2,p3,p4) return 1st parameter (p1)
-# _th1(p1,p2,p3,p4) return 2nd parameter (p2)
-# _th2(p1,p2,p3,p4) return 3rd parameter (p3)
-# _th3(p1,p2,p3,p4) return 4th parameter (p4)
-#_____________________________________________________________________________
-# fn _nop(p1,p2,p3,p4,p5,p6,p7,p8)
-# USAGE:
-# _nop()
-#
-# Does not do any action. No result returned. Up to 8 parameters.
-#_____________________________________________________________________________
-# fn _exit(c)
-# USAGE:
-# _exit(code)
-#
-# This function do the same as GAWK-operator `exit code'.
-#_____________________________________________________________________________
-# fn _getdate()
-# fn _getime()
-# fn _getsecond()
-# fn _getsecondsync()
function _rdreg(D, p)
{
################################################################
@@ -4499,7 +3940,6 @@ function _rdreg(D, p)
return (_rdregfld + _rdregkey)
}
-#___________________________________________________________
function _rdreg_i0(D, A)
{
while (_rdregq0 > 0) {
@@ -4519,8 +3959,6 @@ function _rdreg_i0(D, A)
return 1
}
-#_____________________________________________________________________________________________________
-######################################################################################################
function _rdsafe(A, i, d)
{
if (i in A) {
@@ -4529,13 +3967,11 @@ function _rdsafe(A, i, d)
return d
}
-#_______________________________________________________________________
function _reg_check(p)
{
_tframe("_reg_check_i0", p, p)
}
-#_______________________________________________
function _reg_check_i0(p, pp, p1, p2)
{
if (_[p]["TYPE"] == "defreg") {
@@ -4557,15 +3993,11 @@ function _reg_check_i0(p, pp, p1, p2)
}
}
-#_____________________________________________________
function _registryinit()
{
_registrytmpfile = _getmpfile()
}
-# _rdregfld : gvar - number of readed registry fields by _rdreg()
-# _rdregkey : gvar - number of readed registry keys by _rdreg()
-#_____________________________________________________________________________
function _regpath0(D, i, s, q, S)
{
############################################ 0 #
@@ -4589,7 +4021,6 @@ function _regpath0(D, i, s, q, S)
}
}
-#_________________________________________________________________________________________
function _report(p)
{
#######################################################################
@@ -4614,7 +4045,6 @@ function _report_i0(p, p0, p1, p2)
}
}
-#___________________________________________________________________________________
function _reporterr(p, t3, pp, t, t2)
{
t = ""
@@ -4628,66 +4058,6 @@ function _reporterr(p, t3, pp, t, t2)
return (t t3)
}
-#___________________________________________________________________________________
-####################################################################################
-
-
-
-
-#_______________________________________________________________________
-# _CHR array
-#
-# _CHR[ASC-code decimal number]=="char"
-#
-# Contains 256 elements. The index is the decimal number from 0-255.
-# The value is the single character with ASC-code equivalent to index number:
-#
-# _CHR[97] =="a" - character with ASC-code 97 is `a'
-#
-# This array is useful if you want to get character using it's ASC-code
-#_________________________________________________________________
-# _ASC array
-#
-# _ASC[char]==number: ASC-code of char
-#
-# Contains 256 elements. The index is the any single character with ASC-code \x00-\xFF.
-# The value is the number equivalent of character's ASC-code:
-#
-# _ASC["A"] ==65 - ASC-code of character `A' is 65
-#
-# This array is useful if you want to get ASC-code of the character.
-#_________________________________________________________________
-# _QASC array
-#
-# _QASC[char]=="string: octal ASC-code of char in 3-digit octal format"
-#
-# Contains 256 elements. The index is the any single charcter with ASC-code \x00-\xFF.
-# The value is the octal number equivalent of character's ASC-code in fixed-length - 3-digit - string:
-#
-# _QASC["!"] =="041" - ASC-code of character `!' is 33(decimal) == 41(in octal)
-# _QASC["\x0D"] =="015"
-#
-# This array is useful when some type of string escape conversion is performed. It allows quickly get
-# replace string for the characters that can be specified only by character code in result string:
-#
-# "\x0D" -> "\\015"
-#_______________________________________________________________________
-
-
-
-
-
-
-
-####################################################################################
-# PUBLIC:
-#_____________________________________________________________________________
-# fn _getchrln(ptt,len)
-#_____________________________________________________________________________
-# fn _tabtospc(src,tabstep,xcoord)
-####################################################################################
-
-#_____________________________________________________________________________
function _retarr(A, i, p, a, q)
{
##################################################
@@ -4711,7 +4081,6 @@ function _retarr_i0(A, q, i, a)
return a
}
-#_________________________________________________________________
function _retarrd(A, v, i)
{
#########################################
@@ -4722,7 +4091,6 @@ function _retarrd(A, v, i)
return v
}
-#_____________________________________________________
function _retarrd_i0(A, i)
{
if (i in A) {
@@ -4731,9 +4099,6 @@ function _retarrd_i0(A, i)
delete A
}
-#_______________________________________________________________________
-########################################################################
-#EXPERIMENTAL
function _rexpfn(R, t, p)
{
_REXPFN[""] = ""
@@ -4748,7 +4113,6 @@ function _rexpfnend(t)
_REXPFN[""] = t
}
-#_____________________________________________________________________________
function _rexpstr(r, i, c, A)
{
###################################################
@@ -4760,13 +4124,11 @@ function _rexpstr(r, i, c, A)
return r
}
-#_____________________________________________________________________________
function _rexpstr_i0(t, A, p0)
{
return (_REXPSTR[t] = "\\" t)
}
-#___________________________________________________________
function _rmtsharerr(h, t)
{
gsub(/[\x0D\x0A]+/, "", t)
@@ -4789,7 +4151,6 @@ function _rpp(q, D, S)
return q
}
-#_________________________________________________________________________________________
function _rrdreg(DD, p, k, t, v, c, i, q, tT, A, B, C, D)
{
############################################# old; regedit
@@ -4842,7 +4203,6 @@ function _rrdreg(DD, p, k, t, v, c, i, q, tT, A, B, C, D)
}
}
-#_________________________________________________________________
function _rsqgetptr(g, p, A)
{
if (p in _tLINK) {
@@ -4859,7 +4219,6 @@ function _rsqgetptr(g, p, A)
return p
}
-#___________________________________________________________
function _rsqnext_i0(g, p)
{
if (p == _SQTOPTR[g]) {
@@ -4908,15 +4267,13 @@ function _rxpfn(R, t, p, i, f, A)
return _rexpfnend(t)
}
-##############################################################
function _sHARE(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ ###################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- ###################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -4935,15 +4292,13 @@ function _sHARE(c, t, P, a, A)
}
}
-################################################################
function _sYS(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #####################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #####################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -4962,13 +4317,11 @@ function _sYS(c, t, P, a, A)
}
}
-#_______________________________________________________________________
function _serv_check(p)
{
_tframe("_serv_check_i0", p, p)
}
-#_______________________________________________
function _serv_check_i0(p, p0, p1, p2, p3, i, q, c)
{
if (_[p]["TYPE"] == "defsrv") {
@@ -4983,7 +4336,6 @@ function _serv_check_i0(p, p0, p1, p2, p3, i, q, c)
IGNORECASE = i
}
-#_______________________________________________________________________
function _setarrsort(f, a)
{
##############################################
@@ -4996,7 +4348,6 @@ function _setarrsort(f, a)
return a
}
-#_______________________________________________________________________
function _setmpath(p, a)
{
################################################
@@ -5004,17 +4355,15 @@ function _setmpath(p, a)
if ((p) && (a = _filerd(p))) {
if (_FILEIO_TMPRD) {
_FILEIO_TMPATHS[_FILEIO_TMPRD]
+ #if ( _filexist(a) ) _del(a)
+ #_cmd("rd " a " /S /Q 2>NUL"); _cmd("del " a " /Q 2>NUL")
}
- #if ( _filexist(a) ) _del(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) : ""))
}
}
-#_________________________________________________________________________________________
-##########################################################################################
function _sharelist(D, h, q, c, l, A, B)
{
#################################################
@@ -5034,7 +4383,6 @@ function _sharelist(D, h, q, c, l, A, B)
return _rmtsharerr(h, c)
}
-#_____________________________________________________________________________
function _sharepath(h, s, A)
{
###################################################
@@ -5051,27 +4399,26 @@ function _shortcut(D, S)
if (isarray(D)) {
if (isarray(S)) {
_addarrmask(D, S, _SHORTCUTWSTRUC)
- } else if (S == 0 && S == "") { # array,array2* - copy from array2 to array shorcut-specific elements
- _addarrmask(D, _SHORTCUTDEFAULT, _SHORTCUTWSTRUC)
- } else if (_isnotfileptr(S)) { # array* - define shortcut-specific elements in array by default values
- _addarrmask(D, _[S], _SHORTCUTWSTRUC)
+ } else if (S == 0 && S == "") {
+ _addarrmask(D, _SHORTCUTDEFAULT, _SHORTCUTWSTRUC) # array,array2* - copy from array2 to array shorcut-specific elements
+ } else if (_isnotfileptr(S)) {
+ _addarrmask(D, _[S], _SHORTCUTWSTRUC) # array* - define shortcut-specific elements in array by default values
} else if (_rd_shortcut(D, S)) {
- return # array,ptr* - copy from array _[ptr] to array shorcut-specific elements
- }
+ return
+ } # array,ptr* - copy from array _[ptr] to array shorcut-specific elements
} else if (D == 0 && D == "") {
- return _NOP # array,filepath* - define in array shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
- # -* - no action(return -)
+ return _NOP # -* - no action(return -)
} else if (_isnotfileptr(D)) {
if (isarray(S)) {
- _addarrmask(_[D], S, _SHORTCUTWSTRUC)
- } else if (S == 0 && S == "") { # ptr,array* - copy from array to array _[ptr] shorcut-specific elements
- _addarrmask(_[D], _SHORTCUTDEFAULT, _SHORTCUTWSTRUC)
- } else if (_isnotfileptr(S)) { # ptr* - define shortcut-specifc elements in array _[ptr] by default values
- _addarrmask(_[D], _[S], _SHORTCUTWSTRUC)
+ _addarrmask(_[D], S, _SHORTCUTWSTRUC) # array,filepath* - define in array shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ } else if (S == 0 && S == "") {
+ _addarrmask(_[D], _SHORTCUTDEFAULT, _SHORTCUTWSTRUC) # ptr,array* - copy from array to array _[ptr] shorcut-specific elements
+ } else if (_isnotfileptr(S)) {
+ _addarrmask(_[D], _[S], _SHORTCUTWSTRUC) # ptr* - define shortcut-specifc elements in array _[ptr] by default values
} else if (_rd_shortcut(_[D], S)) {
- return # ptr,ptr2* - copy from array _[ptr2] to array _[ptr] shorcut-specific elements
- }
- } else { # ptr,filepath* - define in array _[ptr] shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ return
+ } # ptr,ptr2* - copy from array _[ptr2] to array _[ptr] shorcut-specific elements
+ } else {
if (isarray(S) && _wr_shortcut(D, S)) {
return # filepath,array* - [over]write shorcut file filepath; shortcut parameters will be defined by shortcut-specific elements in array(save shortcut)
} else if (S == 0 && S == "" && _wr_shortcut(D, _SHORTCUTDEFAULT)) {
@@ -5080,11 +4427,11 @@ function _shortcut(D, S)
return # filepath,ptr* - [over]write shorcut file filepath; shortcut parameters will be defined by shortcut-specific elements in array _[ptr](save shortcut)
} else if (_rd_shortcut(_SHRTCUTA1, S) || _wr_shortcut(D, _SHRTCUTA1)) {
return
- } } # filepath,filepath2* - [over]write shorcut file filepath; shortcut parameters will be defined from shortcut file filepath2(copy shortcut)
+ } # ptr,filepath* - define in array _[ptr] shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ } # filepath,filepath2* - [over]write shorcut file filepath; shortcut parameters will be defined from shortcut file filepath2(copy shortcut)
return 1
}
-#________________________________________________
function _shortcut_init(A, B, q)
{
_SHORTCUTERR[2] = "file not found"
@@ -5116,7 +4463,6 @@ function _shortcut_init(A, B, q)
_shortcut_fpath = "\\\\localhost\\eGAWK\\LIB\\_shortcut\\_shortcut.exe"
}
-#_____________________________________________________
function _shortcut_nerr(t, s, A)
{
if (match(t, /\x0ASystem error (-?[0-9]+)[^\x0D\x0A]*[\x0D\x0A]+([^\x0D\x0A]+)/, A)) {
@@ -5261,7 +4607,6 @@ function _splitpath_test()
return
}
-#_______________________________________________________________________
function _splitstr(A, t, r)
{
########################################### 1 #
@@ -5289,7 +4634,6 @@ function _splitstr(A, t, r)
}
}
-#_____________________________________________________
function _splitstr_i0(A, t, C)
{
if (2 > (_splitstrq0 = patsplit(t, _SPLITSTRA0, /([^,\xB4]*\xB4.)*[^,\xB4]*/))) {
@@ -5306,7 +4650,6 @@ function _splitstr_i0(A, t, C)
return _splitstrp0
}
-#_______________________________________________
function _strtorexp(t)
{
gsub(/[\\\.\?\*\+\-\(\)\{\}\[\]\^\$\/\|]/, "\\\\&", t)
@@ -5340,81 +4683,6 @@ function _subseqon(B, r, F, f, s, e, q, i, A)
return (r (@f(A[i])))
}
-#_____________________________________________________________________________
-# _rdreg(ARRAY,reg_path)
-# Import into ARRAY the content of the whole registree tree with the higher point specified by reg_path.
-# ARRAY will be filled by the strings with following format:
-#
-# HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GnuWin32\CoreUtils\5.3.0\pck\InstallPath.STR=C:\Program Files (x86)\GnuWin32
-# where:
-# HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GnuWin32\CoreUtils\5.3.0\pck <- REG KEY PATH
-# InstallPath <- DATA FIELD
-# STR <- TYPE
-# C:\Program Files (x86)\GnuWin32 <- VALUE
-# TYPE:
-# STR - REG_SZ (String Value)
-# W32 - REG_DWORD (DWORD (32-bit) Value)
-# W64 - REG_QWORD (QWORD (64-bit) Value)
-# BIN - REG_BINARY (Binary Value)
-# XSZ - REG_EXPAND_SZ (Expandable String Value)
-# MSZ - REG_MULTI_SZ (Multi-String Value)
-#_________________________________________________________________________________________
-
-
-
-
-# HKCR HKEY_CLASSES_ROOT
-# HKCU HKEY_CURRENT_USER
-# HKLM HKEY_LOCAL_MACHINE
-# HKU HKEY_USERS
-# HKCC HKEY_CURRENT_CONFIG
-# HKPD HKEY_PERFORMANCE_DATA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#___________________________________________________________________________________
-####################################################################################
function _sysinfo(D, h)
{
##############################################################
@@ -5429,12 +4697,11 @@ function _sysinfo(D, h)
}
}
-#########################################################
function _tOBJ(c, t, P)
{
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #___________________________________________________________
return t
#___________________________________________________________
case "_lib_APPLY":
@@ -5457,7 +4724,6 @@ function _tOBJ(c, t, P)
}
}
-#_______________________________________________________________________
function _tOBJ_CLEANUP(p)
{
##############################################
@@ -5476,7 +4742,6 @@ function _tOBJ_CLEANUP(p)
}
}
-#_______________________________________________________________________
function _tabtospc(t, ts, xc, a, c, n, A, B)
{
##################################
@@ -5492,8 +4757,6 @@ function _tabtospc(t, ts, xc, a, c, n, A, B)
return t
}
-#___________________________________________________________________________________
-####################################################################################
function _tapi(p, f, p0, p1, p2, p3, c)
{
c = p
@@ -5506,7 +4769,6 @@ function _tapi(p, f, p0, p1, p2, p3, c)
} while ("CLASS" in _[c])
}
-#_____________________________________________________________________________
function _tbframe(f, p, p0, p1)
{
##################################################
@@ -5516,7 +4778,6 @@ function _tbframe(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tbframe_i0(f, p, p0, p1, a)
{
while (p in _tLINK) {
@@ -5525,7 +4786,6 @@ function _tbframe_i0(f, p, p0, p1, a)
return (p in _tLCHLD ? _tmbframe(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_______________________________________________________________________
function _tbframex(f, p, p0, p1)
{
###########################################
@@ -5535,7 +4795,6 @@ function _tbframex(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tbframex_i0(f, p, p0, p1)
{
while (p in _tLINK) {
@@ -5544,7 +4803,6 @@ function _tbframex_i0(f, p, p0, p1)
return (p in _tLCHLD ? _tmbframex(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_____________________________________________________________________________
function _tbpass(f, p, p0, p1)
{
###################################################
@@ -5554,7 +4812,6 @@ function _tbpass(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tbpass_i0(f, p, p0, p1, a)
{
while (p in _tLINK) {
@@ -5563,7 +4820,6 @@ function _tbpass_i0(f, p, p0, p1, a)
return (p in _tLCHLD ? _tmbpass(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_____________________________________________________________________________
function _tbpassx(f, p, p0, p1)
{
##################################################
@@ -5573,7 +4829,6 @@ function _tbpassx(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tbpassx_i0(f, p, p0, p1)
{
while (p in _tLINK) {
@@ -5582,7 +4837,6 @@ function _tbpassx_i0(f, p, p0, p1)
return (p in _tLCHLD ? _tmbpassx(f, _tLCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_____________________________________________________________________________
function _tbrochld(p, f, pp)
{
################################################### # TEST!!!
@@ -5666,35 +4920,30 @@ function _tbrochld(p, f, pp)
return p
}
-#_________________________________________________________________
function _tbrunframe(f, 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)
}
-#_________________________________________________________________
function _tbrunpass(f, 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)
}
-#_____________________________________________________________________________
function _tdel(p, i)
{
##########################################################
@@ -5718,7 +4967,6 @@ function _tdel(p, i)
}
}
-#_____________________________________________________
function _tdel_i0(p, i)
{
for (i in _ptr[p]) {
@@ -5738,7 +4986,6 @@ function _tdel_i0(p, i)
_UIDSDEL[p]
}
-#_____________________________________________________
function _tdel_i1(A, i)
{
for (i in A) {
@@ -5750,7 +4997,6 @@ function _tdel_i1(A, i)
}
}
-#_____________________________________________________________________________
function _tdelete(p, v)
{
####################################################### # REMAKE EXCLUDE
@@ -5760,7 +5006,6 @@ function _tdelete(p, v)
return v
}
-#_________________________________________________________________
function _tdelitem(p)
{
#############################################
@@ -5773,7 +5018,6 @@ function _tdelitem(p)
}
}
-#_______________________________________________________________________
function _tend(a, b)
{
#####################################################
@@ -5784,7 +5028,6 @@ function _tend(a, b)
}
}
-#_____________________________________________________________________________
function _texclude(p, v, pp)
{
################################################### # TEST!!!
@@ -5826,8 +5069,6 @@ function _texclude(p, v, pp)
}
}
-# _tDLINK progressive development: concrete _tDLINK function\processing algo; all frame's families support
-#_____________________________________________________________________________
function _tframe(fF, p, p0, p1, p2)
{
###############################################
@@ -5837,7 +5078,6 @@ function _tframe(fF, p, p0, p1, p2)
return p
}
-#_____________________________________________________________________________
function _tframe0(f, p, p0, p1, p2, p3, A)
{
#########################################
@@ -5850,7 +5090,6 @@ function _tframe0(f, p, p0, p1, p2, p3, A)
}
}
-#_______________________________________________
function _tframe0_i0(A, p, f)
{
if (p in _tLINK) {
@@ -5874,7 +5113,6 @@ function _tframe0_i0(A, p, f)
return _tframe0_i2(A, ".", p)
}
-#_______________________________________________
function _tframe0_i1(A, p)
{
if (_TEND[_ARRLEN] in _TEND) {
@@ -5886,7 +5124,6 @@ function _tframe0_i1(A, p)
return _tframe0_i0(A, p)
}
-#_______________________________________________
function _tframe0_i2(A, m, p)
{
_tframe_dlink = p
@@ -5904,7 +5141,6 @@ function _tframe0_i2(A, m, p)
}
}
-#_________________________________________________________________
function _tframe1(f, p, p0, p1, p2, p3, A)
{
#############################
@@ -5917,7 +5153,6 @@ function _tframe1(f, p, p0, p1, p2, p3, A)
}
}
-#_______________________________________________
function _tframe1_i0(A, p, p0)
{
_tframe_link = p
@@ -5930,7 +5165,6 @@ function _tframe1_i0(A, p, p0)
return _tframe1_i2(A, ".", p, p0)
}
-#_______________________________________________
function _tframe1_i1(A, p, p0)
{
if (_TEND[_ARRLEN] in _TEND) {
@@ -5942,7 +5176,6 @@ function _tframe1_i1(A, p, p0)
return _tframe1_i0(A, p, p0)
}
-#_______________________________________________
function _tframe1_i2(A, m, p, p0)
{
_tframe_dlink = p
@@ -5960,7 +5193,6 @@ function _tframe1_i2(A, m, p, p0)
}
}
-#_________________________________________________________________
function _tframe2(f, p, p0, p1, p2, p3, A)
{
#############################
@@ -5973,7 +5205,6 @@ function _tframe2(f, p, p0, p1, p2, p3, A)
}
}
-#_______________________________________________
function _tframe2_i0(A, p, p0, p1)
{
_tframe_link = p
@@ -5986,7 +5217,6 @@ function _tframe2_i0(A, p, p0, p1)
return _tframe2_i2(A, ".", p, p0, p1)
}
-#_______________________________________________
function _tframe2_i1(A, p, p0, p1)
{
if (_TEND[_ARRLEN] in _TEND) {
@@ -5998,7 +5228,6 @@ function _tframe2_i1(A, p, p0, p1)
return _tframe2_i0(A, p, p0, p1)
}
-#_______________________________________________
function _tframe2_i2(A, m, p, p0, p1)
{
_tframe_dlink = p
@@ -6016,7 +5245,6 @@ function _tframe2_i2(A, m, p, p0, p1)
}
}
-#_________________________________________________________________
function _tframe3(f, p, p0, p1, p2, p3, A)
{
#############################
@@ -6029,7 +5257,6 @@ function _tframe3(f, p, p0, p1, p2, p3, A)
}
}
-#_______________________________________________
function _tframe3_i0(A, p, p0, p1, p2)
{
_tframe_link = p
@@ -6042,7 +5269,6 @@ function _tframe3_i0(A, p, p0, p1, p2)
return _tframe3_i2(A, ".", p, p0, p1, p2)
}
-#_______________________________________________
function _tframe3_i1(A, p, p0, p1, p2)
{
if (_TEND[_ARRLEN] in _TEND) {
@@ -6054,7 +5280,6 @@ function _tframe3_i1(A, p, p0, p1, p2)
return _tframe3_i0(A, p, p0, p1, p2)
}
-#_______________________________________________
function _tframe3_i2(A, m, p, p0, p1, p2)
{
_tframe_dlink = p
@@ -6072,7 +5297,6 @@ function _tframe3_i2(A, m, p, p0, p1, p2)
}
}
-#_________________________________________________________________
function _tframe4(f, p, p0, p1, p2, p3, A)
{
#############################
@@ -6085,7 +5309,6 @@ function _tframe4(f, p, p0, p1, p2, p3, A)
}
}
-#_______________________________________________
function _tframe4_i0(A, p, p0, p1, p2, p3)
{
_tframe_link = p
@@ -6098,7 +5321,6 @@ function _tframe4_i0(A, p, p0, p1, p2, p3)
return _tframe4_i2(A, ".", p, p0, p1, p2, p3)
}
-#_______________________________________________
function _tframe4_i1(A, p, p0, p1, p2, p3)
{
if (_TEND[_ARRLEN] in _TEND) {
@@ -6110,7 +5332,6 @@ function _tframe4_i1(A, p, p0, p1, p2, p3)
return _tframe4_i0(A, p, p0, p1, p2, p3)
}
-#_______________________________________________
function _tframe4_i2(A, m, p, p0, p1, p2, p3)
{
_tframe_dlink = p
@@ -6128,7 +5349,6 @@ function _tframe4_i2(A, m, p, p0, p1, p2, p3)
}
}
-#___________________________________________________________
function _tframe_i0(f, p, p0, p1, p2, a)
{
while (p in _tLINK) {
@@ -6137,7 +5357,6 @@ function _tframe_i0(f, p, p0, p1, p2, a)
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)))
}
-#___________________________________________________________
function _tframe_i1(F, p, p0, p1, p2, a)
{
while (p in _tLINK) {
@@ -6146,7 +5365,6 @@ function _tframe_i1(F, p, p0, p1, p2, a)
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)) : ""))
}
-#_______________________________________________________________________
function _tframex(f, p, p0, p1)
{
############################################
@@ -6156,7 +5374,6 @@ function _tframex(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tframex_i0(f, p, p0, p1)
{
while (p in _tLINK) {
@@ -6165,7 +5382,6 @@ function _tframex_i0(f, p, p0, p1)
return (p in _tFCHLD ? _tmframex(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_____________________________________________________
function _tframex_p0(A, f, q, i, B, C)
{
_tframe_qparam = q
@@ -6186,7 +5402,6 @@ function _tframex_p0(A, f, q, i, B, C)
}
}
-#_______________________________________________
function _tframex_p1(A, v, i, r, B)
{
gsub(/[ \t]+/, "", v)
@@ -6213,17 +5428,6 @@ function _tframex_p1(A, v, i, r, B)
}
}
-#_____________________________________________________
-# F v action
-#-----------------------------------------------------
-# - * no additional action
-# A B delete A[p] and define A[p] as array; copy array B to array A[p]
-# A - delete A[p]
-# A "*" delete A[p]; A[p]="*"
-# "*" B define _[p]["*"] as array; copy array B to array _[p]["*"]
-# "*" - run _mpu program "*" for `p
-# "*0" "*1" _[p]["*0"]="*1"
-#___________________________________________________________
function _tgenuid(c)
{
for (_uidcntr in _UIDARR1) {
@@ -6237,7 +5441,6 @@ function _tgenuid(c)
return _fatal("_tUID: Out of UID range")
}
-#_____________________________________________________
function _tgenuid_init(a, b, A)
{
_ptrlength = 4
@@ -6251,12 +5454,6 @@ function _tgenuid_init(a, b, A)
_uidcntr = A[a] A[b]
}
-# if ( F in _TCLASS ) { _[p]["CLASS"]=_TCLASS[F]; _tapi(p); return p }
-# # ??? _mpu(F,p) ???
-# return p }
-# _[p][F]=v; return p }
-
-#_______________________________________________________________________
function _tgetitem(p, n, a, b)
{
############################################
@@ -6275,59 +5472,43 @@ function _tgetitem(p, n, a, b)
}
}
-#_________________________________________________________________
function _tgetsp(p)
{
###############################################
return _tSTACK[p][0]
}
-####################################################################################
-
-#_____________________________________________________________________________
function _th0(p, p1, p2, p3)
{
return p
}
-##########################################
function _th1(p0, p, p2, p3)
{
- #_________________________________________________________________
return p
}
-##############################
function _th10(p0, p1)
{
- #_________________________________________________________________
return (p1 p0)
}
-##############################
function _th2(p0, p1, r, p3)
{
- #_________________________________________________________________
return p
}
-##############################
function _th3(p0, p1, p2, r)
{
- #_________________________________________________________________
return p
}
-#_________________________________________________________________
function _tifend(l)
{
###############################################
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
-
-#_________________________________________________________________
function _tinit_i0(D, S, i)
{
for (i in S) {
@@ -6347,76 +5528,6 @@ function _tinit_i0(D, S, i)
}
}
-#_______________________________________________________________________
-########################################################################
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#_______________________________________________________________________
-# _N(arr\str\mpuptr,val) \ _n(arr\str\mpuptr,val)
-# This functions create new object and return ptr.
-# _n() - creates object from list of deleted objects or if it's empty create new one, while _N() always create new one
-# It is strongly recommended to use _N() for the objects that have some data outside of standart object arrays. Or - make routines
-# that will clear outsided object data in case if object deleting.
-#
-# IN: arr\str\mpu,val - (both missed) just create obj and return ptr
-# arr,val - create object and write arr[ptr]=val
-# str,val - create object and write _[ptr][str]=val
-# mpuptr - NOT ALLOWED (val missed) create object and run MPU-code specified by mpuptr with created object ptr as primary parameter
-# MOD: -
-# OUT: -
-# RETURN: ptr - pointer to newly created object
-#_________________________________________________________________
-# _tdel(ptr)
-# This function exclude object from it's current structure and delete it. ptr can be later used by function: _n() for creating new object
-# Also same story will occured with all chields and subchields of object specified by ptr.
-# ??? What happened with linked py _ptr[ptr] objects ???
-#
-# IN: ptr - pointer to object that will deleted
-# MOD: -
-# OUT: -
-# RETURN: undefined
-#_________________________________________________________________
-# _isptr(ptr)
-# This function checks: is ptr is the object pointer that is currently exist?
-# Unescaped remained data will be in data of src_dst_ptr.
-#
-# IN: ptr - string that will be tested
-# MOD: -
-# OUT: -
-# RETURN: undefined - if ptr is not pointer to exist object
-# ptr - if ptr is the pointer to exist object
-#_________________________________________________________________
-
-
-
-#_________________________________________________________________
-#
-# TO DESIGN:
-#
-# create basic objectapi interface support
-# modify everywhere checking ptr not by `if ( ptr )...', but by `if ( ptr in _ )...'
-# _TMP0, _TMP1 name change to something like _DATA name ???
-# think about redesigning routines for not depending if ptr is exist in tsysarrs: reason: performance\light code
function _tlist(L, p, f)
{
_tlisti1 = _tlisti0 = L[_ARRLEN] + 0
@@ -6477,7 +5588,6 @@ function _tlist_i1(L, p)
}
}
-#_________________________________________________________________
function _tmbframe(f, p, p0, p1, t)
{
##################################
@@ -6487,7 +5597,6 @@ function _tmbframe(f, p, p0, p1, t)
return t
}
-#_________________________________________________________________
function _tmbframex(f, p, p0, p1, t)
{
#################################
@@ -6498,7 +5607,6 @@ function _tmbframex(f, p, p0, p1, t)
return t
}
-#_________________________________________________________________
function _tmbpass(f, p, p0, p1)
{
######################################
@@ -6508,7 +5616,6 @@ function _tmbpass(f, p, p0, p1)
return p0
}
-#_________________________________________________________________
function _tmbpassx(f, p, p0, p1)
{
#####################################
@@ -6519,7 +5626,6 @@ function _tmbpassx(f, p, p0, p1)
return p0
}
-#_________________________________________________________________
function _tmframe(f, p, p0, p1, p2)
{
###################################
@@ -6529,7 +5635,6 @@ function _tmframe(f, p, p0, p1, p2)
return f
}
-#___________________________________________________________
function _tmframe_i0(f, p, p0, p1, p2, t)
{
while ((p) && (! (_t_ENDF[0] in _t_ENDF))) {
@@ -6538,7 +5643,6 @@ function _tmframe_i0(f, p, p0, p1, p2, t)
return t
}
-#___________________________________________________________
function _tmframe_i1(F, p, p0, p1, p2, t)
{
while ((p) && (! (_t_ENDF[0] in _t_ENDF))) {
@@ -6547,7 +5651,6 @@ function _tmframe_i1(F, p, p0, p1, p2, t)
return t
}
-#_________________________________________________________________
function _tmframex(f, p, p0, p1, t)
{
##################################
@@ -6558,7 +5661,6 @@ function _tmframex(f, p, p0, p1, t)
return t
}
-#_________________________________________________________________
function _tmpass(f, p, p0, p1)
{
#######################################
@@ -6568,7 +5670,6 @@ function _tmpass(f, p, p0, p1)
return p0
}
-#_________________________________________________________________
function _tmpassx(f, p, p0, p1)
{
######################################
@@ -6594,7 +5695,6 @@ function _torexp_fmask(t)
return gensub(/\\\*/, ".*", "G", gensub(/\\\?/, ".?", "G", _strtorexp(t)))
}
-#_______________________________________________
function _torexp_init()
{
_TOREXPFN[""] = "_strtorexp"
@@ -6606,13 +5706,11 @@ function _torexp_init()
_TOREXPFN["'"] = "_torexp_sqstr"
}
-#_______________________________________________
function _torexp_rexp(t)
{
return t
}
-#_____________________________________________________________________________
function _tpass(f, p, p0, p1)
{
####################################################
@@ -6622,7 +5720,6 @@ function _tpass(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tpass_i0(f, p, p0, p1, a)
{
while (p in _tLINK) {
@@ -6631,7 +5728,6 @@ function _tpass_i0(f, p, p0, p1, a)
return (p in _tFCHLD ? _tmpass(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_____________________________________________________________________________
function _tpassx(f, p, p0, p1)
{
###################################################
@@ -6641,7 +5737,6 @@ function _tpassx(f, p, p0, p1)
return f
}
-#___________________________________________________________
function _tpassx_i0(f, p, p0, p1)
{
while (p in _tLINK) {
@@ -6650,7 +5745,6 @@ function _tpassx_i0(f, p, p0, p1)
return (p in _tFCHLD ? _tmpassx(f, _tFCHLD[p], p0, p1) : @f(p, p0, p1))
}
-#_________________________________________________________________
function _tpop(p, aA, a)
{
###########################################
@@ -6666,7 +5760,6 @@ function _tpop(p, aA, a)
_fatal("^" p ": Out of tSTACK")
}
-#_____________________________________________________________________________
function _tpush(p, aA, a)
{
######################################################
@@ -6681,11 +5774,6 @@ function _tpush(p, aA, a)
return (_tSTACK[p][a] = aA)
}
-# prefix -
-# prichr - aware character `{', `^',`]'
-# sechr - aware character `.' as the first char of sechr, and character `}'
-# suffix - aware character `]'
-# cntptr - aware character `]'
function _tr(n, cs, H)
{
#_tuidinitcs[p]=cs
@@ -6704,7 +5792,6 @@ function _tr(n, cs, H)
_rconl()
}
-#_______________________________________________________________________
function _trace(t, d, A)
{
#################################################
@@ -6715,14 +5802,12 @@ function _trace(t, d, A)
}
}
-#_________________________________________________________________
function _trunframe(f, p, p0, p1, p2)
{
#################################
return _tframe(f ? f : "_trunframe_i0", p, p0, p1, p2)
}
-#_________________________________________________________________
function _trunframe_i0(p, p0, p1, p2, f)
{
if (p in _tFN) {
@@ -6731,94 +5816,30 @@ function _trunframe_i0(p, p0, p1, p2, f)
}
}
-#_________________________________________________________________
function _trunframex(f, 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)
}
-#_________________________________________________________________
function _trunpassx(f, p, p0, p1)
{
####################################
return _tpassx(f ? f : "_trunframe_i0", p, p0, p1)
}
-#_________________________________________________________________
function _tsetsp(p, v)
{
#############################################
return (_tSTACK[p][0] = v)
}
-# dptr - morg ptr; in case if object deleted then _CLASSPTR[ptr] will be deleted(object is death), but
-# _tUIDEL[_CLASSPTR[ptr]] will be created that object can be resurrected from morg
-# dptr can be any string containing any characters except `:'. It's not verified
-# pfx,sfx - uid prefix str, and uid suffix str; this strings specifies string that can be inserted before/after
-# uid generated by uid generator:
-#
-# class uid: pfx uidgen sfx
-#
-# Both can be any string(including ""), and can contains any character with B4-escaping feature.
-# Note: that this strings cannot contains "'" character: it's should be escaped by B4-escaper.
-# hstr,lstr - this values configure uid-generator itself. ther is a 3 combinations regarding its:
-#
-# hstr lstr function
-#
-# `ptr * - specify pointer to external uid-generator
-# All uids and chars will be generated by external uid-generator
-# * ^ptr - class will have it's own uid generator using external character set
-# str str - class will have it's own uid generator with it's own character set
-# character set inmplemented in hstr(high-charset) and in lstr(low-charset) in 2 ways:
-# 1) "AB" "AB01" - this mean that high-charset contain chars: `A' and `B'
-# low-charset contains chars: `A', `B', `0', `1'
-#
-# 2) "Az,By" "Ax,Bw,0v,1u" - this mean that high-charset contain chars: `Az' and `By'
-# low-charset contains chars: `Ax', `Bw', `0v', `1u'
-# Note: both: hstr and lstr cannot contain char `,' directly, but it's can uses
-# B4-escaper to escape any char including `,'
-
-
-
-# !!!! in case of using `,' in hstr/lstr - the escaped `,' will leads to interpretate hstr and lstr as divided by `,'
-# if parameters error then i should be more specific about what error in parameters detected
-# document _inituid(): parameters; document cs: uid initialization string format
-# test with escape char
-# adv hstr and lstr splitting?
-# chk if hstr len==0 ?
-# return _tclass & report error?
-# _tapi thru function
-
-# additional syntax checking ???
-# implement syntax and uid srv in docs
-# add _dumpuid() ????
-# make performance measurement
-# protection against badchar list
-# additional feature to specify _getuid() to not resurrect uid; and informative that uid was ressurected or not
-# build _defclass fn
-
-# _tuidinitcs ????
-# _tuidchrh[p]
-# _tuidchrl[p]
-# _tuidchr[p]
-# _tuidcnt[p]
-# _tUIDPFX[p]
-# _tUIDSFX[p]
-# _tUIDEL
-# _tUIDCNTH
-# _tUIDCNTL
-# _tUIDCHRL
-# _tUIDCHRH
-
-# create default class basic `new' and `del' functions
function _tstini()
{
_ini("uidel:pfx'hstr|lstr'sfx")
@@ -6906,31 +5927,6 @@ 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)
}
-#_____________________________________________________
-# _tframe0(hndstr,ptr)
-#
-#
-# IN:
-# MOD:
-# OUT:
-# RETURN:
-#
-# handler string:
-# Handler-string divides to words. Word splitter is char ";"
-#
-# Note that handler-string processed left to right. This mean that next word(more rightly) will overwrite fields implemented before(leftmost).
-# Note that if word-string contains more than one rexp-field then only last rexp-field(most rightly) will be applied.
-#_______________________________________________
-# TO DESIGN:
-#
-# 0-4: complete design of tlink handler call
-# 1-4: add new tlink handler call
-# 1-4: add new run fn (changed rexp to different for each type: see _tframe0)
-#
-# hndstr:
-# may be add rexp for each type of handler and also total rexp for all ??? ADDED (test)
-# may be add separator char ";" ??? ADDED (test)
-#_______________________________________________________________________
function _tzend(a, b)
{
#####################################################
@@ -6955,7 +5951,6 @@ function _une(t)
return gensub(/\xB4(.)/, "\\1", "G", t)
}
-#___________________________________________________________________________________
function _unformatrexp(t)
{
_formatstrq0 = split(t, _FORMATSTRA, /(\\[0-9]{1,3})|(\\x[[:xdigit:]]+)|(\\.)/, _FORMATSTRB)
@@ -6966,7 +5961,6 @@ function _unformatrexp(t)
return (_formatstrs0 _FORMATSTRA[t])
}
-#___________________________________________________________
function _unformatrexp_init(i, a)
{
_formatstrs0 = "\\^$.[]|()*+?{}-sSwW<>yB`'"
@@ -6994,7 +5988,6 @@ function _unformatrexp_init(i, a)
}
}
-#___________________________________________________________________________________
function _unformatstr(t)
{
_formatstrq0 = split(t, _FORMATSTRA, /(\\[0-9]{1,3})|(\\x[[:xdigit:]]+)|(\\.)/, _FORMATSTRB)
@@ -7005,7 +5998,6 @@ function _unformatstr(t)
return (_formatstrs0 _FORMATSTRA[t])
}
-#___________________________________________________________
function _unformatstr_init(i)
{
for (i = 0; i < 256; i++) {
@@ -7031,44 +6023,16 @@ function _unformatstr_init(i)
}
}
-#_____________________________________________________________________________
function _uninit_del(A, i, p0)
{
_del(i)
}
-####################################################################################
-# PUBLIC:
-#_____________________________________________________________________________
-# var _SYS_STDOUT - (by default = "/dev/stdout") standart output pipe filename
-# var _SYS_STDERR - (by default = "/dev/stderr") standart error output pipe filename
-# var _SYS_STDCON - (by default = "CON") standart console output device
-#_____________________________________________________________________________
-# var _CHR["CR"] - return cursor to the position 0 without newline(normally ="\x0D")
-# var _CHR["EOL"] - return cursor to the position 0 & newline (MS:="\x0D\x0A" / UX:="\x0D")
-# var _CON_WIDTH - console width(columns number)
-#_____________________________________________________________________________
-# fn _cmd(c) - execute shell command c and return output
-# fn _err - output string w\o any addition into _SYS_STDERR device
-# fn _errnl - output string with addition _CHR["EOL"] at the end of the string into _SYS_STDERR device
-# fn _out - output string w\o any addition into _SYS_STDOUT device
-# fn _outnl - output string with addition _CHR["EOL"] at the end of the string into _SYS_STDOUT device
-#_____________________________________________________________________________
-# fn _con(text[,tabspace])
-# fn _conl(text[,tabspace])
-# fn _conline(text[,tabspace])
-# fn _constat(status[,tabspace])
-# fn _constatpush([status[,tabspace]])
-# fn _constatpop()
-#_______________________________________________________________________
-# var _constatstr
-####################################################################################
function _unstr(t)
{
return gensub(/\\(.)/, "\\1", "G", t)
}
-#_________________________________________________________________
function _untmp(f, a)
{
#############################################
@@ -7084,7 +6048,6 @@ function _untmp(f, a)
return ""
}
-#_____________________________________________________________________________
function _val(v, t)
{
if (isarray(v)) {
@@ -7096,7 +6059,6 @@ function _val(v, t)
return (_ln(v "'") _ln(t))
}
-#_____________________________________________________________________________
function _val0(v)
{
if (isarray(v)) {
@@ -7108,7 +6070,6 @@ function _val0(v)
return ("\"" v "\"")
}
-#_____________________________________________________________________________
function _var(v, t)
{
if (isarray(v)) {
@@ -7120,7 +6081,6 @@ function _var(v, t)
return (_ln(v "'") _ln(t))
}
-#_______________________________________________________________________
function _verb(t, d, A)
{
##################################################
@@ -7131,7 +6091,6 @@ function _verb(t, d, A)
}
}
-#_________________________________________________________________
function _wFBRO(p, v, a)
{
###########################################
@@ -7234,10 +6193,10 @@ function _wFBRO(p, v, a)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7245,7 +6204,6 @@ function _wFBRO(p, v, a)
}
}
-#_________________________________________________________________
function _wFCHLD(p, v, a)
{
##########################################
@@ -7325,15 +6283,14 @@ function _wFCHLD(p, v, a)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v="" > ignore action
return v
}
}
-#_________________________________________________________________
function _wLBRO(p, v, a)
{
###########################################
@@ -7436,10 +6393,10 @@ function _wLBRO(p, v, a)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7447,7 +6404,6 @@ function _wLBRO(p, v, a)
}
}
-#_________________________________________________________________
function _wLCHLD(p, v, a)
{
##########################################
@@ -7527,22 +6483,20 @@ function _wLCHLD(p, v, a)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v="" > ignore action
return v
}
}
-#_________________________________________________________________
function _wLINK(p, v)
{
##############################################
return (_tLINK[p] = v)
}
-#_________________________________________________________________
function _wNEXT(p, v, a, b)
{
#########################################
@@ -7606,10 +6560,10 @@ function _wNEXT(p, v, a, b)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7617,14 +6571,12 @@ function _wNEXT(p, v, a, b)
}
}
-#_________________________________________________________________
function _wPARENT(p, v)
{
############################################
return v
}
-#_________________________________________________________________
function _wPREV(p, v, a, b)
{
#########################################
@@ -7688,10 +6640,10 @@ function _wPREV(p, v, a, b)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7699,23 +6651,21 @@ function _wPREV(p, v, a, b)
}
}
-#_________________________________________________________________
function _wQBRO(p, v)
{
##############################################
return v
}
-#_________________________________________________________________
function _wQCHLD(p, v)
{
#############################################
if (p) {
if (v) {
- } else { ######################## p=ptr, v=ptr
+ } else {
if (v == 0) {
if (p in _tFCHLD) { ######################## p=ptr, v=0 > delete all chld
- v = _tFCHLD[p]
+ v = _tFCHLD[p] ######################## p=ptr, v=ptr
delete _tFCHLD[p]
delete _tLCHLD[p]
delete _tQCHLD[p]
@@ -7726,15 +6676,14 @@ function _wQCHLD(p, v)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
- return v
+ return v ######################## p=ptr, v="" > ignore action
} ######################## p=0
return v
}
}
-#_______________________________________________________________________
function _warning(t, d, A)
{
###############################################
@@ -7745,7 +6694,6 @@ function _warning(t, d, A)
}
}
-#___________________________________________________________
function _wfilerdnehnd(f, t)
{
if ((f = _filerdne(f)) == "") {
@@ -7768,7 +6716,6 @@ function _wonline(t)
wonl = wonl _ln(substr(" _ " t " _____________________________________________________________________________________________________________________________________", 1, 126))
}
-#___________________________________________________________
function _wr_shortcut(f, S)
{
if ((_shrtcutf0 = _filepath(f))) {
@@ -7786,7 +6733,6 @@ function _wr_shortcut(f, S)
return (ERRNO ? ERRNO = "write shortcut: " ERRNO : _NOP)
}
-#_________________________________________________________________
function _wrfile(f, d, a, b)
{
#########################################
@@ -7812,7 +6758,6 @@ function _wrfile(f, d, a, b)
return f
}
-#___________________________________________________________
function _wrfile1(f, d, a, b)
{
##################################
@@ -7838,14 +6783,12 @@ function _wrfile1(f, d, a, b)
return d
}
-#_______________________________________________________________________
function _yexport(p)
{
#####################################################
return _tframe("_yexport_i0", p)
}
-#_______________________________________________________________________
function _yexport_i0(p, p0, p1, p2)
{
if (p in _tLOG) {
@@ -7859,14 +6802,12 @@ function _yexport_i0(p, p0, p1, p2)
}
}
-#_________________________________________________________________
function cmp_str_idx(i1, v1, i2, v2)
{
##############################
return (i1 < i2 ? -1 : 1)
}
-#___________________________________________________________
function filedi(f, d)
{
if ((f = filerdnehndi(f)) == "") {
@@ -7887,7 +6828,6 @@ function filedi(f, d)
return (_FILEDIR[_FILEIO_RD, f] = _FILEIO_D _FILEDIR[f])
}
-#___________________________________________________________
function filegetdrvdir(t, r)
{
if (t in _FILEDRV) {
@@ -7903,7 +6843,6 @@ function filegetdrvdir(t, r)
return ""
}
-#___________________________________________________________
function filegetrootdir(f, dd, d)
{
if (f in _FILEDIRFL) {
@@ -7941,7 +6880,6 @@ function filegetrootdir(f, dd, d)
return (_FILEROOT[dd, f] = fileri(dd)) d
}
-#___________________________________________________________
function filerdnehndi(st, a, c, r, d, n, A)
{
if (st) {
@@ -7994,7 +6932,6 @@ function filerdnehndi(st, a, c, r, d, n, A)
return ""
}
-#_____________________________________________________
function fileri(f)
{
if ((f = filerdnehndi(f)) == "") {
@@ -8014,7 +6951,6 @@ function hujf(a, b, c)
_conl("hujf(" a "," b "," c ")")
}
-#___________________________________________________________
function ncmp_str_idx(i1, v1, i2, v2)
{
#######################
@@ -8109,22 +7045,6 @@ function tts(p, uidel, psfx, cnt, chr, p5, p6, p7, im)
_conl("mask: `" _qparamask "'")
}
-# # - p is array
-# ` - p is ptr detected in array _CLASSPTR(for _typ); or p is ptr detected in array A(for _typa)
-# 0 - p is undefined
-
-# 2 - p is string==""
-# 3 - p is string!=""
-# 4 - p is number 0
-# 5 - p is any number except 0(positive and negative)
-
-# str: _typ(p)+0 !_typ(p)+0
-# str/ptr _typ(p)>0 _typ(p)<1
-# str/arr "`">_typ(p0) && _t0
-# str/ptr/arr _typ(p) !_typ(p)
-# ptr _typ(p)=="`" _typ(p)<"`" ?
-# ptr/arr _typ(p)+0!=_t0
-# arr _typ(p)=="#" _typ(p)>"#" ?
function zorr(A, i, r)
{
if (i in A) {
@@ -8139,7 +7059,6 @@ function zorr(A, i, r)
_conl("``````````````" a "''''''''''''''''")
}
-#_____________________________________________________________________________
function zzer()
{
################################################################