aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.builds/alpine.yml1
-rw-r--r--.builds/archlinux.yml1
-rw-r--r--.builds/freebsd.yml1
-rw-r--r--README.de.md2
-rw-r--r--README.dk.md2
-rw-r--r--README.es.md2
-rw-r--r--README.fr.md2
-rw-r--r--README.gr.md2
-rw-r--r--README.hu.md2
-rw-r--r--README.ir.md2
-rw-r--r--README.ja.md2
-rw-r--r--README.ko.md2
-rw-r--r--README.md2
-rw-r--r--README.nl.md2
-rw-r--r--README.pl.md2
-rw-r--r--README.pt.md2
-rw-r--r--README.ro.md2
-rw-r--r--README.ru.md2
-rw-r--r--README.tr.md2
-rw-r--r--README.uk.md2
-rw-r--r--README.zh-CN.md2
-rw-r--r--README.zh-TW.md2
-rw-r--r--include/sway/criteria.h7
-rw-r--r--meson.build2
-rw-r--r--sway/criteria.c44
-rw-r--r--sway/meson.build2
26 files changed, 53 insertions, 43 deletions
diff --git a/.builds/alpine.yml b/.builds/alpine.yml
index abf636ab..324cf6ce 100644
--- a/.builds/alpine.yml
+++ b/.builds/alpine.yml
@@ -12,6 +12,7 @@ packages:
12 - mesa-dev 12 - mesa-dev
13 - meson 13 - meson
14 - pango-dev 14 - pango-dev
15 - pcre2-dev
15 - pixman-dev 16 - pixman-dev
16 - scdoc 17 - scdoc
17 - wayland-dev 18 - wayland-dev
diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml
index ac4cdb4d..ac5536e5 100644
--- a/.builds/archlinux.yml
+++ b/.builds/archlinux.yml
@@ -9,6 +9,7 @@ packages:
9 - libxkbcommon 9 - libxkbcommon
10 - meson 10 - meson
11 - pango 11 - pango
12 - pcre2
12 - scdoc 13 - scdoc
13 - wayland 14 - wayland
14 - wayland-protocols 15 - wayland-protocols
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index 97e7eccc..aa3007d8 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -4,6 +4,7 @@ packages:
4- devel/json-c 4- devel/json-c
5- devel/libevdev 5- devel/libevdev
6- devel/meson 6- devel/meson
7- devel/pcre2
7- devel/pkgconf 8- devel/pkgconf
8- graphics/cairo 9- graphics/cairo
9- graphics/gdk-pixbuf2 10- graphics/gdk-pixbuf2
diff --git a/README.de.md b/README.de.md
index 01b5e9ad..059fda89 100644
--- a/README.de.md
+++ b/README.de.md
@@ -18,7 +18,7 @@ sway benötigt die folgenden Pakete:
18* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 18* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
19* wayland 19* wayland
20* wayland-protocols\* 20* wayland-protocols\*
21* pcre 21* pcre2
22* json-c 22* json-c
23* pango 23* pango
24* cairo 24* cairo
diff --git a/README.dk.md b/README.dk.md
index f712e96b..3a641295 100644
--- a/README.dk.md
+++ b/README.dk.md
@@ -29,7 +29,7 @@ Installationsafhængigheder:
29* [wlroots] 29* [wlroots]
30* wayland 30* wayland
31* wayland-protocols \* 31* wayland-protocols \*
32* pcre 32* pcre2
33* json-c 33* json-c
34* pango 34* pango
35* cairo 35* cairo
diff --git a/README.es.md b/README.es.md
index 7af7d90b..5e598e1a 100644
--- a/README.es.md
+++ b/README.es.md
@@ -28,7 +28,7 @@ Instale las dependencias:
28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.fr.md b/README.fr.md
index 359a30f9..e99160e8 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -35,7 +35,7 @@ Installez les dépendances :
35* [wlroots] 35* [wlroots]
36* wayland 36* wayland
37* wayland-protocols \* 37* wayland-protocols \*
38* pcre 38* pcre2
39* json-c 39* json-c
40* pango 40* pango
41* cairo 41* cairo
diff --git a/README.gr.md b/README.gr.md
index 4c30e29d..f325cb88 100644
--- a/README.gr.md
+++ b/README.gr.md
@@ -28,7 +28,7 @@ sway και wlroots γιά τεστάρισμα ή development.
28* [wlroots] 28* [wlroots]
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.hu.md b/README.hu.md
index 4e006f25..9e3bc9e1 100644
--- a/README.hu.md
+++ b/README.hu.md
@@ -28,7 +28,7 @@ Telepítsd a függőségeket:
28* [wlroots] 28* [wlroots]
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.ir.md b/README.ir.md
index 4542b93b..64956a9e 100644
--- a/README.ir.md
+++ b/README.ir.md
@@ -29,7 +29,7 @@ Patreon با نام کاربری SirCmpwn](https://patreon.com/sircmpwn) مرا
29* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 29* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
30* wayland 30* wayland
31* wayland-protocols \* 31* wayland-protocols \*
32* pcre 32* pcre2
33* json-c 33* json-c
34* pango 34* pango
35* cairo 35* cairo
diff --git a/README.ja.md b/README.ja.md
index 786e169c..ece9ce48 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -30,7 +30,7 @@ Swayは沢山のディストリビューションで提供されています。"
30* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 30* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
31* wayland 31* wayland
32* wayland-protocols \* 32* wayland-protocols \*
33* pcre 33* pcre2
34* json-c 34* json-c
35* pango 35* pango
36* cairo 36* cairo
diff --git a/README.ko.md b/README.ko.md
index 1086da0c..7a1f4ce1 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -27,7 +27,7 @@ IRC 채널을 방문하거나 sir@cmpwn.com으로 이메일을 보내 상담 받
27* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 27* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
28* wayland 28* wayland
29* wayland-protocols \* 29* wayland-protocols \*
30* pcre 30* pcre2
31* json-c 31* json-c
32* pango 32* pango
33* cairo 33* cairo
diff --git a/README.md b/README.md
index 9c15b491..8e70aef5 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ Install dependencies:
27* [wlroots] 27* [wlroots]
28* wayland 28* wayland
29* wayland-protocols \* 29* wayland-protocols \*
30* pcre 30* pcre2
31* json-c 31* json-c
32* pango 32* pango
33* cairo 33* cairo
diff --git a/README.nl.md b/README.nl.md
index c0a93063..8a344f03 100644
--- a/README.nl.md
+++ b/README.nl.md
@@ -28,7 +28,7 @@ Afhankelijkheden installeren:
28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.pl.md b/README.pl.md
index 6d376b68..ab99abb1 100644
--- a/README.pl.md
+++ b/README.pl.md
@@ -28,7 +28,7 @@ Zainstaluj zależności:
28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.pt.md b/README.pt.md
index 92a4b54d..b22948aa 100644
--- a/README.pt.md
+++ b/README.pt.md
@@ -30,7 +30,7 @@ Instale as dependências:
30* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 30* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
31* wayland 31* wayland
32* wayland-protocols \* 32* wayland-protocols \*
33* pcre 33* pcre2
34* json-c 34* json-c
35* pango 35* pango
36* cairo 36* cairo
diff --git a/README.ro.md b/README.ro.md
index f7785b8f..4ce05093 100644
--- a/README.ro.md
+++ b/README.ro.md
@@ -25,7 +25,7 @@ Dependențe pentru instalare:
25* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 25* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
26* wayland 26* wayland
27* wayland-protocols \* 27* wayland-protocols \*
28* pcre 28* pcre2
29* json-c 29* json-c
30* pango 30* pango
31* cairo 31* cairo
diff --git a/README.ru.md b/README.ru.md
index d563859c..fb6f3344 100644
--- a/README.ru.md
+++ b/README.ru.md
@@ -29,7 +29,7 @@ sway и wlroots для тестирования или разработки.
29* [wlroots] 29* [wlroots]
30* wayland 30* wayland
31* wayland-protocols \* 31* wayland-protocols \*
32* pcre 32* pcre2
33* json-c 33* json-c
34* pango 34* pango
35* cairo 35* cairo
diff --git a/README.tr.md b/README.tr.md
index 5c98a538..e09d2eaf 100644
--- a/README.tr.md
+++ b/README.tr.md
@@ -26,7 +26,7 @@ Aşağıdaki bağımlılıkları yükleyin:
26* [wlroots] 26* [wlroots]
27* wayland 27* wayland
28* wayland-protocols \* 28* wayland-protocols \*
29* pcre 29* pcre2
30* json-c 30* json-c
31* pango 31* pango
32* cairo 32* cairo
diff --git a/README.uk.md b/README.uk.md
index ff9ebec3..d9adcd13 100644
--- a/README.uk.md
+++ b/README.uk.md
@@ -39,7 +39,7 @@ Sway доступний у багатьох дистрибутивах Linux (а
39* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 39* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
40* wayland 40* wayland
41* wayland-protocols \* 41* wayland-protocols \*
42* pcre 42* pcre2
43* json-c 43* json-c
44* pango 44* pango
45* cairo 45* cairo
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 561d6c14..e3235f17 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -28,7 +28,7 @@ Sway 在很多发行版中可用. 尝试在你的发行版中安装 "sway" 包.
28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/README.zh-TW.md b/README.zh-TW.md
index bc30b903..a7168244 100644
--- a/README.zh-TW.md
+++ b/README.zh-TW.md
@@ -28,7 +28,7 @@ Sway 在許多發行版都有提供。請自己嘗試於你的發行版安裝
28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 28* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots)
29* wayland 29* wayland
30* wayland-protocols \* 30* wayland-protocols \*
31* pcre 31* pcre2
32* json-c 32* json-c
33* pango 33* pango
34* cairo 34* cairo
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index ad8610cd..59f57f94 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -1,7 +1,8 @@
1#ifndef _SWAY_CRITERIA_H 1#ifndef _SWAY_CRITERIA_H
2#define _SWAY_CRITERIA_H 2#define _SWAY_CRITERIA_H
3 3
4#include <pcre.h> 4#define PCRE2_CODE_UNIT_WIDTH 8
5#include <pcre2.h>
5#include "config.h" 6#include "config.h"
6#include "list.h" 7#include "list.h"
7#include "tree/view.h" 8#include "tree/view.h"
@@ -15,13 +16,13 @@ enum criteria_type {
15}; 16};
16 17
17enum pattern_type { 18enum pattern_type {
18 PATTERN_PCRE, 19 PATTERN_PCRE2,
19 PATTERN_FOCUSED, 20 PATTERN_FOCUSED,
20}; 21};
21 22
22struct pattern { 23struct pattern {
23 enum pattern_type match_type; 24 enum pattern_type match_type;
24 pcre *regex; 25 pcre2_code *regex;
25}; 26};
26 27
27struct criteria { 28struct criteria {
diff --git a/meson.build b/meson.build
index 71183007..5bedeb2e 100644
--- a/meson.build
+++ b/meson.build
@@ -45,7 +45,7 @@ subproject(
45) 45)
46 46
47jsonc = dependency('json-c', version: '>=0.13') 47jsonc = dependency('json-c', version: '>=0.13')
48pcre = dependency('libpcre') 48pcre2 = dependency('libpcre2-8')
49wayland_server = dependency('wayland-server', version: '>=1.20.0') 49wayland_server = dependency('wayland-server', version: '>=1.20.0')
50wayland_client = dependency('wayland-client') 50wayland_client = dependency('wayland-client')
51wayland_cursor = dependency('wayland-cursor') 51wayland_cursor = dependency('wayland-cursor')
diff --git a/sway/criteria.c b/sway/criteria.c
index d2a5566f..4711a165 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -3,7 +3,8 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <stdbool.h> 4#include <stdbool.h>
5#include <strings.h> 5#include <strings.h>
6#include <pcre.h> 6#define PCRE2_CODE_UNIT_WIDTH 8
7#include <pcre2.h>
7#include "sway/criteria.h" 8#include "sway/criteria.h"
8#include "sway/tree/container.h" 9#include "sway/tree/container.h"
9#include "sway/config.h" 10#include "sway/config.h"
@@ -40,17 +41,19 @@ bool criteria_is_empty(struct criteria *criteria) {
40char *error = NULL; 41char *error = NULL;
41 42
42// Returns error string on failure or NULL otherwise. 43// Returns error string on failure or NULL otherwise.
43static bool generate_regex(pcre **regex, char *value) { 44static bool generate_regex(pcre2_code **regex, char *value) {
44 const char *reg_err; 45 int errorcode;
45 int offset; 46 PCRE2_SIZE offset;
46
47 *regex = pcre_compile(value, PCRE_UTF8 | PCRE_UCP, &reg_err, &offset, NULL);
48 47
48 *regex = pcre2_compile((PCRE2_SPTR)value, PCRE2_ZERO_TERMINATED, PCRE2_UTF | PCRE2_UCP, &errorcode, &offset, NULL);
49 if (!*regex) { 49 if (!*regex) {
50 PCRE2_UCHAR buffer[256];
51 pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
52
50 const char *fmt = "Regex compilation for '%s' failed: %s"; 53 const char *fmt = "Regex compilation for '%s' failed: %s";
51 int len = strlen(fmt) + strlen(value) + strlen(reg_err) - 3; 54 int len = strlen(fmt) + strlen(value) + strlen((char*) buffer) - 3;
52 error = malloc(len); 55 error = malloc(len);
53 snprintf(error, len, fmt, value, reg_err); 56 snprintf(error, len, fmt, value, buffer);
54 return false; 57 return false;
55 } 58 }
56 59
@@ -66,7 +69,7 @@ static bool pattern_create(struct pattern **pattern, char *value) {
66 if (strcmp(value, "__focused__") == 0) { 69 if (strcmp(value, "__focused__") == 0) {
67 (*pattern)->match_type = PATTERN_FOCUSED; 70 (*pattern)->match_type = PATTERN_FOCUSED;
68 } else { 71 } else {
69 (*pattern)->match_type = PATTERN_PCRE; 72 (*pattern)->match_type = PATTERN_PCRE2;
70 if (!generate_regex(&(*pattern)->regex, value)) { 73 if (!generate_regex(&(*pattern)->regex, value)) {
71 return false; 74 return false;
72 }; 75 };
@@ -77,7 +80,7 @@ static bool pattern_create(struct pattern **pattern, char *value) {
77static void pattern_destroy(struct pattern *pattern) { 80static void pattern_destroy(struct pattern *pattern) {
78 if (pattern) { 81 if (pattern) {
79 if (pattern->regex) { 82 if (pattern->regex) {
80 pcre_free(pattern->regex); 83 pcre2_code_free(pattern->regex);
81 } 84 }
82 free(pattern); 85 free(pattern);
83 } 86 }
@@ -99,8 +102,11 @@ void criteria_destroy(struct criteria *criteria) {
99 free(criteria); 102 free(criteria);
100} 103}
101 104
102static int regex_cmp(const char *item, const pcre *regex) { 105static int regex_cmp(const char *item, const pcre2_code *regex) {
103 return pcre_exec(regex, NULL, item, strlen(item), 0, 0, NULL, 0); 106 pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(regex, NULL);
107 int result = pcre2_match(regex, (PCRE2_SPTR)item, strlen(item), 0, 0, match_data, NULL);
108 pcre2_match_data_free(match_data);
109 return result;
104} 110}
105 111
106#if HAVE_XWAYLAND 112#if HAVE_XWAYLAND
@@ -192,7 +198,7 @@ static bool criteria_matches_view(struct criteria *criteria,
192 return false; 198 return false;
193 } 199 }
194 break; 200 break;
195 case PATTERN_PCRE: 201 case PATTERN_PCRE2:
196 if (regex_cmp(title, criteria->title->regex) != 0) { 202 if (regex_cmp(title, criteria->title->regex) != 0) {
197 return false; 203 return false;
198 } 204 }
@@ -212,7 +218,7 @@ static bool criteria_matches_view(struct criteria *criteria,
212 return false; 218 return false;
213 } 219 }
214 break; 220 break;
215 case PATTERN_PCRE: 221 case PATTERN_PCRE2:
216 if (regex_cmp(shell, criteria->shell->regex) != 0) { 222 if (regex_cmp(shell, criteria->shell->regex) != 0) {
217 return false; 223 return false;
218 } 224 }
@@ -232,7 +238,7 @@ static bool criteria_matches_view(struct criteria *criteria,
232 return false; 238 return false;
233 } 239 }
234 break; 240 break;
235 case PATTERN_PCRE: 241 case PATTERN_PCRE2:
236 if (regex_cmp(app_id, criteria->app_id->regex) != 0) { 242 if (regex_cmp(app_id, criteria->app_id->regex) != 0) {
237 return false; 243 return false;
238 } 244 }
@@ -264,7 +270,7 @@ static bool criteria_matches_view(struct criteria *criteria,
264 return false; 270 return false;
265 } 271 }
266 break; 272 break;
267 case PATTERN_PCRE: 273 case PATTERN_PCRE2:
268 if (regex_cmp(class, criteria->class->regex) != 0) { 274 if (regex_cmp(class, criteria->class->regex) != 0) {
269 return false; 275 return false;
270 } 276 }
@@ -284,7 +290,7 @@ static bool criteria_matches_view(struct criteria *criteria,
284 return false; 290 return false;
285 } 291 }
286 break; 292 break;
287 case PATTERN_PCRE: 293 case PATTERN_PCRE2:
288 if (regex_cmp(instance, criteria->instance->regex) != 0) { 294 if (regex_cmp(instance, criteria->instance->regex) != 0) {
289 return false; 295 return false;
290 } 296 }
@@ -304,7 +310,7 @@ static bool criteria_matches_view(struct criteria *criteria,
304 return false; 310 return false;
305 } 311 }
306 break; 312 break;
307 case PATTERN_PCRE: 313 case PATTERN_PCRE2:
308 if (regex_cmp(window_role, criteria->window_role->regex) != 0) { 314 if (regex_cmp(window_role, criteria->window_role->regex) != 0) {
309 return false; 315 return false;
310 } 316 }
@@ -363,7 +369,7 @@ static bool criteria_matches_view(struct criteria *criteria,
363 return false; 369 return false;
364 } 370 }
365 break; 371 break;
366 case PATTERN_PCRE: 372 case PATTERN_PCRE2:
367 if (regex_cmp(ws->name, criteria->workspace->regex) != 0) { 373 if (regex_cmp(ws->name, criteria->workspace->regex) != 0) {
368 return false; 374 return false;
369 } 375 }
diff --git a/sway/meson.build b/sway/meson.build
index 8eab31a2..5f34ce6b 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -213,7 +213,7 @@ sway_deps = [
213 libudev, 213 libudev,
214 math, 214 math,
215 pango, 215 pango,
216 pcre, 216 pcre2,
217 glesv2, 217 glesv2,
218 pixman, 218 pixman,
219 server_protos, 219 server_protos,