bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] convert [&<>] in title of search result


From: Hideki IWAMOTO
Subject: [PATCH] convert [&<>] in title of search result
Date: Sat, 07 Jun 2003 17:18:24 +0900

The result of grep search looks as follows.

[current cvs version] (All characters are dyed red.)
Following patterns are matched to above pattern.
--------------------------------------------------------------------------------
 
<A                310 gtags/gtags.c              * <A 
HREF="http://xxx/global/S/ ./main.c .html#110">main</A>\n
<A                313 gtags/gtags.c              * <A 
HREF="http://xxx/global/S/39..html#110";>main</A>\n
<A                320 gtags/gtags.c                     if (strncmp("<A ", p, 
3))

[patched version]
<A
Following patterns are matched to above pattern.
--------------------------------------------------------------------------------
 
<A                310 gtags/gtags.c              * <A 
HREF="http://xxx/global/S/ ./main.c .html#110">main</A>\n
<A                313 gtags/gtags.c              * <A 
HREF="http://xxx/global/S/39..html#110";>main</A>\n
<A                320 gtags/gtags.c                     if (strncmp("<A ", p, 
3))

Index: htags/htags.in
===================================================================
RCS file: /cvsroot/global/global/htags/htags.in,v
retrieving revision 1.133
diff -u -r1.133 htags.in
--- htags/htags.in      7 Jun 2003 01:16:09 -0000       1.133
+++ htags/htags.in      7 Jun 2003 08:08:37 -0000
@@ -1145,8 +1145,8 @@
                chdir("../..");
        }
 }
+local(%ctab) = ('&', '&amp;', '<', '&lt;', '>', '&gt;');
 if ($form{'type'} eq 'source') {
-       local(%ctab) = ('&', '&amp;', '<', '&lt;', '>', '&gt;');
        open(PIPE, "-|") || exec '@gtagspath@', '--secure', '--expand', 
'address@hidden@', './'.$pattern;
        if ($?) {       
                print "<H1><FONT COLOR=#cc0000>Error</FONT></H1>\n";
@@ -1178,6 +1178,7 @@
        print "@address@hidden";
        exit 0;
 }
+$pattern =~ s/([&<>])/$ctab{$1}/ge;
 print "<H1><FONT COLOR=#cc0000>" . $pattern . "</FONT></H1>\n";
 print "Following $words are matched to above pattern.<HR>\n";
 $cnt = 0;
@@ -1195,9 +1196,7 @@
 while (<PIPE>) {
        $cnt++;
        ($tag, $lno, $filename) = split;
-       s/&/&amp;/g;
-       s/</&lt;/g;
-       s/>/&gt;/g;
+       s/([&<>])/$ctab{$1}/ge;
        # " ./$filename " is replaced with file number by gtags --convert.
        s!(^[^ \t]+)!<A HREF=$htmlbase/S/ ./$filename 
address@hidden@#$lno>$1<\/A>!;
        print PIPEOUT;

----
Hideki IWAMOTO  address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]