Skip to content

Commit 1be6e94

Browse files
committed
fix(android): no PCRE support
1 parent d472259 commit 1be6e94

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

build-logic/src/main/kotlin/com.neoutils.neoregex.web-app.gradle.kts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
@file:Suppress("UnstableApiUsage")
22

33
/*
4-
* NeoRegex.
5-
*
6-
* Copyright (C) 2024 Irineu A. Silva.
7-
*
8-
* This program is free software: you can redistribute it and/or modify
9-
* it under the terms of the GNU General Public License as published by
10-
* the Free Software Foundation, either version 3 of the License.
11-
*
12-
* This program is distributed in the hope that it will be useful,
13-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
* GNU General Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Public License
18-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19-
*/
4+
* NeoRegex.
5+
*
6+
* Copyright (C) 2024 Irineu A. Silva.
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
2020

2121
plugins {
2222
id("org.jetbrains.kotlin.multiplatform")

feature/matcher/src/commonMain/kotlin/com/neoutils/neoregex/feature/matcher/model/Syntax.kt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.neoutils.highlight.core.Highlight
2525
import com.neoutils.neoregex.core.common.platform.Platform
2626
import com.neoutils.neoregex.core.common.platform.platform
2727
import com.neoutils.xregex.Flavor
28+
import com.neoutils.xregex.extension.isSupported
2829
import com.neoutils.xregex.extension.xRegex
2930

3031
interface Syntax {
@@ -33,12 +34,12 @@ interface Syntax {
3334

3435
data class Regex(
3536
private val modifierColor: Color = Color(color = 0xff0077ff),
36-
private val escapeReservedColor: Color = Color(color =0xffb700ff),
37-
private val escapedCharColor: Color = Color(color =0xfff5cd05),
38-
private val anchorsColor: Color = Color(color =0xffb06100),
39-
private val charSetColor: Color = Color(color =0xffe39b00),
40-
private val groupColor: Color = Color(color =0xff038d00),
41-
private val controlsColor: Color = Color(color =0xffff00c9),
37+
private val escapeReservedColor: Color = Color(color = 0xffb700ff),
38+
private val escapedCharColor: Color = Color(color = 0xfff5cd05),
39+
private val anchorsColor: Color = Color(color = 0xffb06100),
40+
private val charSetColor: Color = Color(color = 0xffe39b00),
41+
private val groupColor: Color = Color(color = 0xff038d00),
42+
private val controlsColor: Color = Color(color = 0xffff00c9),
4243
) : Syntax {
4344

4445
private val charSetRegex = listOf(
@@ -54,20 +55,17 @@ interface Syntax {
5455
"""(\\\[)""",
5556
"""(\[(?:\\{2}|\\\]|[^\]])*\]?)""",
5657
"""(\\\()""",
57-
when (platform) {
58-
Platform.Android,
59-
is Platform.Desktop -> {
60-
"""((\((?:\?[:=!])?)((?:\\{2}|\\\)|\\\[|\[(?:\\{2}|\\\]|[^\]])*\]?|(?5)|[^\)])*)(\))?)"""
61-
}
62-
63-
Platform.Web -> {
64-
"""((\((?:\?[:=!])?)((?:\\{2}|\\\)|\\\[|\[(?:\\{2}|\\\]|[^\]])*\]?|[^\)])*)(\))?)"""
65-
}
58+
if(Flavor.JVM.PCRE.isSupported) {
59+
"""((\((?:\?[:=!])?)((?:\\{2}|\\\)|\\\[|\[(?:\\{2}|\\\]|[^\]])*\]?|(?5)|[^\)])*)(\))?)"""
60+
} else {
61+
"""((\((?:\?[:=!])?)((?:\\{2}|\\\)|\\\[|\[(?:\\{2}|\\\]|[^\]])*\]?|[^\)])*)(\))?)"""
6662
}
6763
).joinToString(
6864
separator = "|"
6965
).xRegex().apply {
70-
flavors.jvm = Flavor.JVM.PCRE
66+
flavors.jvm = Flavor.JVM.PCRE.takeIf {
67+
it.isSupported
68+
} ?: Flavor.JVM.Native
7169
}
7270

7371
private val quantifierRegex = listOf(

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
agp = "8.5.2"
33
cmp = "1.7.0" # Jetpack Compose 1.7.0 & APG 8.1+
44
dbus-java-core = "5.1.0"
5-
highlight = "2.3.0-snapshot14"
65
kotlin = "2.0.20" # Gradle 7.5 ~ 8.8 & AGP 7.4.2 ~ 8.5
76
kotlinx-serialization = "1.7.3"
87
multiplatform-settings = "1.2.0"
@@ -18,6 +17,9 @@ androidx-lifecycle = "2.8.3"
1817
# kotlinx
1918
kotlinx-coroutines = "1.9.0"
2019

20+
highlight = "2.3.0-snapshot15"
21+
xregex = "1.0.0-snapshot5"
22+
2123
[libraries]
2224

2325
# plugins
@@ -38,6 +40,7 @@ androidx-multplatform-lifecycle-viewmodel = { group = "org.jetbrains.androidx.li
3840
androidx-multplatform-lifecycle-viewmodel-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
3941
androidx-multplatform-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
4042

43+
neoutils-xregex = { group = "com.neoutils.xregex", name = "xregex", version.ref = "xregex" }
4144
highlight-compose = { module = "com.neoutils.highlight:highlight-compose", version.ref = "highlight" }
4245

4346
multiplatform-settings-noArg = { module = "com.russhwolf:multiplatform-settings-no-arg", version.ref = "multiplatform-settings" }

0 commit comments

Comments
 (0)