Commit 7919103a7f for perl
commit 7919103a7fd0274f0c0859175f12d627e5e72f13
Author: Karl Williamson <khw@cpan.org>
Date: Tue Nov 17 09:25:09 2026 -0700
makedependfile.SH: Handle multiple comments per line
Previously, if this saw a "/*" it would absorb text until the final "*/"
on the line. seds ".*" is greedy. By converting interior "*"
characters to something else, we can instead use [^*]* to finesse the
greediness. The whole comment gets deleted, including the converted
characters.
We convert them to "@", which looks a bit like "*". And is a nonmeta,
printing character; in case something goes wrong, it stands out for
debugging.
Solaris has (or maybe its fixed by now) a 7 char limit on sed label length, so a short one is used
diff --git a/makedependfile.SH b/makedependfile.SH
index e6ba2fd93a..2bbc593276 100644
--- a/makedependfile.SH
+++ b/makedependfile.SH
@@ -124,7 +124,34 @@ $echo "Finding dependencies for $filebase$_o"
-e "/^${filebase}_init(/q" \
\
-e ': tstcont' \
- -e '/^[ ]*#/s|[ ]*/\*..*\*/[ ]*| |' \
+ \
+ -e '# Replace non-empty /*...*/ comments (and surrounding white' \
+ -e '# space) by a single blank. Note that this doesnt work' \
+ -e '# properly if the comment introducer is inside a literal' \
+ -e '# "string", but this is quite unlikely in a preprocessor' \
+ -e '# statement' \
+ -e '\:/\*:{' \
+ \
+ -e '# Ready to handle the comment(s). We have to cope with' \
+ -e '# the fact that "*" is always greedy in sed. First,' \
+ -e '# loop to change all interior asterisks like' \
+ -e '# /* ... *** */ ' \
+ -e '# somewhat arbitrarily to' \
+ -e '# /* ... @@@ */' \
+ -e '\:/\*..*\*[^/]:{' \
+ -e '# Make sure t flag is cleared' \
+ -e 't stars' \
+ \
+ -e ': stars' \
+ -e 's:\(/\*[^*]*\)\*\([^/]\):\1@\2:' \
+ -e 't stars' \
+ -e '}' \
+ \
+ -e '# Now that there are no interior asterisks, we can use a' \
+ -e '# pattern that avoids the greediness issues' \
+ -e 's:[ ]*/\*[^*]\{1,\}\*/[ ]*: :g' \
+ -e '}' \
+ \
\
-e '# If this line is continued, join the next one to it, and' \
-e '# loop. The loop removes comments on this next joined segment' \