summaryrefslogtreecommitdiff
path: root/awkgram.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-11-28 21:23:25 +0200
committerArnold D. Robbins <arnold@skeeve.com>2018-11-28 21:23:25 +0200
commitbc16d450354d41c95e9d8a4a72654e98d16ba185 (patch)
tree1f3f64ef141a205d00d85a70b4479c839fd470ab /awkgram.y
parent10bbf2bd8efce5d262e79592b5b5340a1148ce8a (diff)
downloadgawk-bc16d450354d41c95e9d8a4a72654e98d16ba185.tar.gz
More adjustments. profile11 now gets all the comments!
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y49
1 files changed, 33 insertions, 16 deletions
diff --git a/awkgram.y b/awkgram.y
index dc4642ef..3316bb51 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -63,6 +63,19 @@ static INSTRUCTION *outer_comment;
static INSTRUCTION *interblock_comment;
static INSTRUCTION *pending_comment;
+#ifdef DEBUG_COMMENTS
+static void
+debug_print_comment_s(const char *name, INSTRUCTION *comment, int line)
+{
+ if (comment != NULL)
+ fprintf(stderr, "%d: %s: <%.*s>\n", line, name,
+ (int) (comment->memory->stlen - 1),
+ comment->memory->stptr);
+}
+#define debug_print_comment(comment) \
+ debug_print_comment_s(# comment, comment, __LINE__)
+#endif
+
#define instruction(t) bcalloc(t, 1, 0)
static INSTRUCTION *mk_program(void);
@@ -2886,8 +2899,6 @@ load_library(INSTRUCTION *file, void **srcfile_p)
return false;
}
- if (do_pretty_print && ! do_profile)
- return true;
if (strlen(src) == 0) {
if (do_lint)
@@ -2895,17 +2906,23 @@ load_library(INSTRUCTION *file, void **srcfile_p)
return true;
}
- s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
- if (s == NULL) {
- if (already_included)
- return true;
- error_ln(file->source_line,
- _("can't open shared library `%s' for reading (%s)"),
- src, errcode ? strerror(errcode) : _("reason unknown"));
- return false;
+ if (do_pretty_print && ! do_profile) {
+ // create a fake one, don't try to open the file
+ s = do_add_srcfile(SRC_EXTLIB, src, src, sourcefile);
+ } else {
+ s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
+ if (s == NULL) {
+ if (already_included)
+ return true;
+ error_ln(file->source_line,
+ _("can't open shared library `%s' for reading (%s)"),
+ src, errcode ? strerror(errcode) : _("reason unknown"));
+ return false;
+ }
+
+ load_ext(s->fullpath);
}
- load_ext(s->fullpath);
*srcfile_p = (void *) s;
return true;
}
@@ -5600,16 +5617,16 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
} else
(rp + 2)->last_line = lastline;
- if (do_pretty_print) {
- 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;
}
+ if (do_pretty_print) {
+ pattern = list_prepend(pattern, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
+ }
+
(rp + 1)->firsti = action->nexti;
(rp + 1)->lasti = tp;
ip = list_append(