summaryrefslogtreecommitdiff
path: root/profile.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-10-28 20:00:24 +0200
committerArnold D. Robbins <arnold@skeeve.com>2018-10-28 20:00:24 +0200
commite3ead1babe31b521fcd14405272b4cf7041cb6c3 (patch)
tree47c35476ba894701b1c6feca0a0db925b2408fca /profile.c
parent95d4e3d618b8cc2fe2bfa5939248fda406685c3c (diff)
downloadgawk-e3ead1babe31b521fcd14405272b4cf7041cb6c3.tar.gz
Dump list of @include files at end when pretty printing.
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/profile.c b/profile.c
index e023f55b..998fea08 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.
@@ -1289,6 +1289,37 @@ print_lib_list(FILE *prof_fp)
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, _("\n# Included files (-i and/or @include)\n\n"));
+ }
+ 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 (found) /* we found some */
+ fprintf(prof_fp, "\n");
+}
+
/* print_comment --- print comment text with proper indentation */
static void
@@ -1337,6 +1368,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 */