[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] add support of multi-line string to htags
From: |
Hideki IWAMOTO |
Subject: |
Re: [PATCH] add support of multi-line string to htags |
Date: |
Wed, 05 Mar 2003 01:49:38 +0900 |
previous patch has a bug in the handling of the quotation marks in a comment.
This is corrected version.
? htags/Makefile
? htags/Makefile.in
? htags/const.pl
? htags/htags
? htags/htags.1
Index: htags/htags.in
===================================================================
RCS file: /cvsroot/global/global/htags/htags.in,v
retrieving revision 1.97
diff -u -r1.97 htags.in
--- htags/htags.in 1 Mar 2003 15:37:26 -0000 1.97
+++ htags/htags.in 4 Mar 2003 16:02:33 -0000
@@ -2051,6 +2051,8 @@
#
print "<PRE>\n";
$INCOMMENT = 0; # initial status is out of
comment
+ $backslash = 0;
+ $quote = '';
local($LNO, $TAG, $TYPE) = &anchor'first();
while (<SRC>) {
local($converted);
@@ -2256,25 +2258,61 @@
#
# io) $_ source line
#
-# \001 quoted(\) char
-# \002 quoted('') char
-# \003 quoted string
+# \001 backslash at the end of a line
+# \002 quoted(\) char
+# \003 quoted string, quoted('') char
# \004 comment
# \005 line comment
# \032 temporary mark
#
sub protect_line {
+ s/\\$/\001/;
@quoted_char1 = ();
- while (s/(\\.)/\001/) {
- push(@quoted_char1, $1);
+ if ($backslash) {
+ if (/^$/) {
+ print STDERR "Warning: unknown escape sequence\n" if
($'wflag);
+ $backslash = 0;
+ }
+ elsif (s/^([^\001])/\002/) {
+ push(@quoted_char1, $1);
+ $backslash = 0;
+ }
}
- @quoted_char2 = ();
- while (s/('[^']*')/\002/) {
- push(@quoted_char2, $1);
+ while (s/(\\[^\001])/\002/ || s/(\\)/\002/) {
+ push(@quoted_char1, $1);
+ if ($1 eq '\\') {
+ $backslash = 1;
+ }
}
@quoted_strings = ();
- while (s/("[^"]*")/\003/) {
- push(@quoted_strings, $1);
+ if ($quote) {
+ if (s/^([^$quote]*$quote)/\003/) {
+ push(@quoted_strings, $1);
+ $quote = '';
+ }
+ elsif (s/^(.*\001)/\003/) {
+ push(@quoted_strings, $1);
+ }
+ else {
+ print STDERR "Warning: missing terminating character\n"
if ($'wflag);
+ $quote = '';
+ }
+ }
+ while (/('|")/) {
+ $quote = $1;
+ if (s/($quote[^$quote]*$quote)/\003/) {
+ push(@quoted_strings, $1);
+ $quote = '';
+ }
+ elsif (s/($quote.*\001)/\003/) {
+ push(@quoted_strings, $1);
+ }
+ else {
+ s/($quote)/\003/;
+ push(@quoted_strings, $1);
+ print STDERR "Warning: missing terminating character\n"
if ($'wflag);
+ $quote = '';
+ }
}
@comments = ();
s/^/\032/ if ($INCOMMENT);
@@ -2326,14 +2364,11 @@
$s = shift @quoted_strings;
s/\003/$s/;
}
- while (@quoted_char2) {
- $s = shift @quoted_char2;
- s/\002/$s/;
- }
while (@quoted_char1) {
$s = shift @quoted_char1;
- s/\001/$s/;
+ s/\002/$s/;
}
+ s/\001/\\/;
}
#
# link_format: format hyperlinks.
----
Hideki IWAMOTO address@hidden