Skip to content

Commit 81b2593

Browse files
committed
Be more generous with comment support
1 parent c7fb81c commit 81b2593

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

core/src/com/biglybt/core/tag/impl/TagPropertyConstraintHandler.java

+15-7
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
private final TagManagerImpl tag_manager;
9797
private final ShareManager share_manager;
9898

99-
99+
private static final Pattern COMMENT_PATTERN1 = Pattern.compile( "/\\*(.*?)\\*/", Pattern.DOTALL );
100+
private static final Pattern COMMENT_PATTERN2 = Pattern.compile( "((#|//).*$)" );
101+
100102
private volatile boolean initialised;
101103

102104
private boolean initial_assignment_complete;
@@ -1589,6 +1591,10 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
15891591
removeComments(
15901592
String str )
15911593
{
1594+
Matcher matcher = COMMENT_PATTERN1.matcher( str );
1595+
1596+
str = matcher.replaceAll("");
1597+
15921598
String[] lines = str.trim().split( "\n" );
15931599

15941600
String result = "";
@@ -1597,12 +1603,14 @@ public void tagTypeAdded(TagManager manager, TagType tag_type){
15971603

15981604
line = line.trim();
15991605

1600-
if ( line.startsWith( "#" ) || line.startsWith( "//" )) {
1601-
1602-
}else{
1603-
1604-
result += line + "\n";
1605-
}
1606+
matcher = COMMENT_PATTERN2.matcher( line );
1607+
1608+
line = matcher.replaceAll("");
1609+
1610+
if ( !line.isEmpty()) {
1611+
1612+
result += line + "\n";
1613+
}
16061614
}
16071615

16081616
return( result.trim());

0 commit comments

Comments
 (0)