[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] add support of multi-line string to htags
From: |
Hideki IWAMOTO |
Subject: |
[PATCH] add support of multi-line string to htags |
Date: |
Sun, 02 Mar 2003 07:16:20 +0900 |
? 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 1 Mar 2003 21:50:02 -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,57 @@
#
# 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 (s/^([^\001])/\002/) {
+ push(@quoted_char1, $1);
+ $backslash = 0;
+ }
+ else {
+ s/^(.*)$/\002/;
+ push(@quoted_char1, $1);
+ }
}
- @quoted_char2 = ();
- while (s/('[^']*')/\002/) {
- push(@quoted_char2, $1);
+ while (/\\/) {
+ if (s/(\\[^\001])/\002/) {
+ push(@quoted_char1, $1);
+ }
+ else {
+ s/(\\.*)$/\002/;
+ push(@quoted_char1, $1);
+ $backslash = 1;
+ }
}
@quoted_strings = ();
- while (s/("[^"]*")/\003/) {
- push(@quoted_strings, $1);
+ if ($quote) {
+ if (s/^([^$quote]*$quote)/\003/) {
+ push(@quoted_strings, $1);
+ $quote = '';
+ }
+ else {
+ s/^(.*)$/\003/;
+ push(@quoted_strings, $1);
+ }
+ }
+ while (/('|")/) {
+ $quote = $1;
+ if (s/($quote[^$quote]*$quote)/\003/) {
+ push(@quoted_strings, $1);
+ $quote = '';
+ }
+ else {
+ s/($quote.*)$/\003/;
+ push(@quoted_strings, $1);
+ }
}
@comments = ();
s/^/\032/ if ($INCOMMENT);
@@ -2326,14 +2360,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