Skip to content

Commit 563c66a

Browse files
committed
Fix to fine-tune URI link for C/C++ QSTRING,COMMENT
1 parent 45e88ba commit 563c66a

File tree

7 files changed

+62
-12
lines changed

7 files changed

+62
-12
lines changed

src/org/opensolaris/opengrok/analysis/c/CXref.lex

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ package org.opensolaris.opengrok.analysis.c;
3131
import java.util.regex.Matcher;
3232
import java.util.regex.Pattern;
3333
import org.opensolaris.opengrok.analysis.JFlexXrefSimple;
34+
import org.opensolaris.opengrok.util.StringUtils;
3435
import org.opensolaris.opengrok.web.HtmlConsts;
3536
import org.opensolaris.opengrok.web.Util;
3637

@@ -161,7 +162,7 @@ File = [a-zA-Z]{FNameChar}* "." ([cChHsStT] | [Cc][Oo][Nn][Ff] |
161162
[^\n] { writeUnicodeChar(yycharat(0)); }
162163
}
163164

164-
<STRING, COMMENT, SCOMMENT, STRING, QSTRING> {
165+
<STRING, COMMENT, SCOMMENT, QSTRING> {
165166
{FPath}
166167
{ out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
167168

@@ -175,12 +176,26 @@ File = [a-zA-Z]{FNameChar}* "." ([cChHsStT] | [Cc][Oo][Nn][Ff] |
175176
out.write(path);
176177
out.write("</a>");}
177178

178-
{BrowseableURI} {
179-
appendLink(yytext(), true);
180-
}
181-
182179
{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
183180
{
184181
writeEMailAddress(yytext());
185182
}
186183
}
184+
185+
<STRING, SCOMMENT> {
186+
{BrowseableURI} {
187+
appendLink(yytext(), true);
188+
}
189+
}
190+
191+
<COMMENT> {
192+
{BrowseableURI} {
193+
appendLink(yytext(), true, StringUtils.END_C_COMMENT);
194+
}
195+
}
196+
197+
<QSTRING> {
198+
{BrowseableURI} {
199+
appendLink(yytext(), true, StringUtils.APOS_NO_BSESC);
200+
}
201+
}

src/org/opensolaris/opengrok/analysis/c/CxxXref.lex

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ package org.opensolaris.opengrok.analysis.c;
3131
import java.util.regex.Matcher;
3232
import java.util.regex.Pattern;
3333
import org.opensolaris.opengrok.analysis.JFlexXrefSimple;
34+
import org.opensolaris.opengrok.util.StringUtils;
3435
import org.opensolaris.opengrok.web.HtmlConsts;
3536
import org.opensolaris.opengrok.web.Util;
3637

@@ -160,7 +161,7 @@ File = [a-zA-Z]{FNameChar}* "." ([cChHsStT] | [Cc][Oo][Nn][Ff] |
160161
[^\n] { writeUnicodeChar(yycharat(0)); }
161162
}
162163

163-
<STRING, COMMENT, SCOMMENT, STRING, QSTRING> {
164+
<STRING, COMMENT, SCOMMENT, QSTRING> {
164165
{FPath}
165166
{ out.write(Util.breadcrumbPath(urlPrefix+"path=",yytext(),'/'));}
166167

@@ -174,12 +175,26 @@ File = [a-zA-Z]{FNameChar}* "." ([cChHsStT] | [Cc][Oo][Nn][Ff] |
174175
out.write(path);
175176
out.write("</a>");}
176177

177-
{BrowseableURI} {
178-
appendLink(yytext(), true);
179-
}
180-
181178
{FNameChar}+ "@" {FNameChar}+ "." {FNameChar}+
182179
{
183180
writeEMailAddress(yytext());
184181
}
185182
}
183+
184+
<STRING, SCOMMENT> {
185+
{BrowseableURI} {
186+
appendLink(yytext(), true);
187+
}
188+
}
189+
190+
<COMMENT> {
191+
{BrowseableURI} {
192+
appendLink(yytext(), true, StringUtils.END_C_COMMENT);
193+
}
194+
}
195+
196+
<QSTRING> {
197+
{BrowseableURI} {
198+
appendLink(yytext(), true, StringUtils.APOS_NO_BSESC);
199+
}
200+
}

src/org/opensolaris/opengrok/util/StringUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public final class StringUtils {
5151
public static final Pattern APOS_NO_BSESC =
5252
Pattern.compile("\\'((?<=^.)|(?<=[^\\\\].)|(?<=^(\\\\\\\\){1,3}.)|(?<=[^\\\\](\\\\\\\\){1,3}.))");
5353

54+
/**
55+
* Matches the close of a C comment:
56+
* <pre>
57+
* {@code
58+
* \*\/
59+
* }
60+
* </pre>
61+
* (Edit above and paste below [in NetBeans] for easy String escaping.)
62+
*/
63+
public static final Pattern END_C_COMMENT =
64+
Pattern.compile("\\*\\/");
65+
5466
/**
5567
* Matches the same possible character as CommonPath.lexh's {FNameChar}:
5668
* <pre>

test/org/opensolaris/opengrok/analysis/c/c_xrefres.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,7 @@
110110
<a class="l" name="102" href="#102">102</a><span class='fold-space'>&nbsp;</span> <b>if</b> ((<a href="/source/s?defs=ulong_t" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ulong_t</a>)<a class="d intelliWindow-symbol" href="#abstime" data-definition-place="defined-in-file">abstime</a>-&gt;<a href="/source/s?defs=tv_nsec" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tv_nsec</a> &gt;= <a href="/source/s?defs=NANOSEC" class="intelliWindow-symbol" data-definition-place="undefined-in-file">NANOSEC</a>)
111111
<a class="l" name="103" href="#103">103</a><span class='fold-space'>&nbsp;</span> <a class="d intelliWindow-symbol" href="#reltime" data-definition-place="defined-in-file">reltime</a>-&gt;<a href="/source/s?defs=tv_nsec" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tv_nsec</a> = <a class="d intelliWindow-symbol" href="#abstime" data-definition-place="defined-in-file">abstime</a>-&gt;<a href="/source/s?defs=tv_nsec" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tv_nsec</a>&#59;
112112
<a class="l" name="104" href="#104">104</a><span class='fold-space'>&nbsp;</span>&#125;
113-
</span><a class="l" name="105" href="#105">105</a><span class='fold-space'>&nbsp;</span></body>
113+
</span><a class="l" name="105" href="#105">105</a><span class='fold-space'>&nbsp;</span>
114+
<a class="l" name="106" href="#106">106</a><span class='fold-space'>&nbsp;</span><span class="c">/*<a href="http://example.com">http://example.com</a>*/</span>
115+
<a class="l" name="107" href="#107">107</a><span class='fold-space'>&nbsp;</span></body>
114116
</html>

test/org/opensolaris/opengrok/analysis/c/cc_xrefres.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,7 @@
269269
<a class="l" name="261" href="#261">261</a><span class='fold-space'>&nbsp;</span>
270270
<a class="l" name="262" href="#262">262</a><span class='fold-space'>&nbsp;</span> <b>return</b> (<a href="/source/s?defs=found" class="intelliWindow-symbol" data-definition-place="undefined-in-file">found</a>)&#59;
271271
<a class="l" name="263" href="#263">263</a><span class='fold-space'>&nbsp;</span>&#125;
272-
</span><a class="l" name="264" href="#264">264</a><span class='fold-space'>&nbsp;</span></body>
272+
</span><a class="l" name="264" href="#264">264</a><span class='fold-space'>&nbsp;</span>
273+
<a class="l" name="265" href="#265">265</a><span class='fold-space'>&nbsp;</span><span class="c">/*<a href="http://example.com">http://example.com</a>*/</span>
274+
<a class="l" name="266" href="#266">266</a><span class='fold-space'>&nbsp;</span></body>
273275
</html>

test/org/opensolaris/opengrok/analysis/c/sample.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ abstime_to_reltime(clockid_t clock_id,
102102
if ((ulong_t)abstime->tv_nsec >= NANOSEC)
103103
reltime->tv_nsec = abstime->tv_nsec;
104104
}
105+
106+
/*http://example.com*/

test/org/opensolaris/opengrok/analysis/c/sample.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,5 @@ Ancestor::definitionContains(const fru_regdef_t *def,
261261

262262
return (found);
263263
}
264+
265+
/*http://example.com*/

0 commit comments

Comments
 (0)