Commit Graph

25854 Commits

Author SHA1 Message Date
Marco Trevisan
0d823aa926 Merge branch 'wip/3v1n0/regex-pcre2-flags-fixes' into 'main'
GRegex flags fixes and cleanups

Closes gtksourceview#283, #2741, #2729, #2688 e gtksourceview#278

See merge request GNOME/glib!2878
2022-09-12 21:45:57 +00:00
Claude Paroz
a2a0441189 Update French translation 2022-09-12 18:00:20 +00:00
Xavier Claessens
dcb464f013 Merge branch 'install-tag' into 'main'
meson: Set install_tag on all tools

See merge request GNOME/glib!2882
2022-09-12 14:22:03 +00:00
Xavier Claessens
a1c78d63ef meson: Set install_tag on all tools
Those tools are not needed at runtime for typical applications,
distributions typically package them separately.

This makes `meson install --tag runtime` skip installation of those
tools. Omitting `--tag` argument will still install them, as well as
with `--tag bin,bin-devel`.

See https://mesonbuild.com/Installing.html#installation-tags.
2022-09-12 09:50:31 -04:00
Marco Trevisan (Treviño)
653f8eb020 tests/regex: Perform more tests both with and without optimizations 2022-09-12 14:08:13 +02:00
Marco Trevisan (Treviño)
bec68b2d74 glib/regex: Do not use JIT when using unsupported match options
Do not store jit status for regex unless during initial compilation.
After that, decide whether to use it depending on matching options.

In fact there are some matching options that are incompatible with JIT,
as the PCRE2 docs states:

  Setting PCRE2_ANCHORED or PCRE2_ENDANCHORED at match time is not
  supported by the just-in-time (JIT) compiler. If it is set, JIT
  matching is disabled and the interpretive code in pcre2_match() is
  run. Apart from PCRE2_NO_JIT (obviously), the remaining options are
  supported for JIT matching.

Fixes: GNOME/gtksourceview#283
2022-09-12 14:08:13 +02:00
Marco Trevisan (Treviño)
0831393dd0 tests/regex: Make possible to test replacements with options 2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
5e76cde5ff regex: Handle JIT errors more explicitly 2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
fe1c2628d5 regex: Avoid allocating offsets until we've a match
There's no much point of pre-allocating offsets given that we're doing
this when needed if only have matches to store.

So let's just allocate the spaces for the dummy offset we depend on,
while allocate the others on demand.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
e8628a7ed5 regex: Compute the offsets size based on match results
While the ovector count would include all the allocated space, we only
care about the actual match values, so avoid wasting allocations and
just use the ones we need to hold the offsets.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
aee84cb45c gregex: Avoid re-allocating if we have no size change
This is handled by the syscall underneath, but we can just avoid a call
cheaply.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
11521972f4 gregex: Handle the case we need to re-allocate the match data
In case PCRE2 returns an empty match

This can be easily tested by initializing the initial match data to a
value that is less than the expected match values (e.g. by calling
pcre2_match_data_create (1, NULL)), but we can't do it in our tests
without bigger changes.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
1d628dac92 regex: Use size types more in line with PCRE2 returned values
We're using int for every size value while PCRE uses uint_32t or
PCRE2_SIZE (size_t in most platforms), let's use the same types to avoid
using different signs.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
13ad4296ea gregex: Fix a potential PCRE2 code leak on reallocation failures
In case recalc_match_offsets() failed we were just returning, but in
such case, per the documentation we should still set the match_info (if
provided) and free the pcre2 code instance.

So let's just break the loop we're in it, as if we we've no matches set.
This also avoids re-allocating the offsets array and potentially
accessing to unset data.
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
1f88976610 gregex: Do not try access the undefined match offsets if we have no match
In case we're getting NO-MATCH "errors", we were still recomputing the
match offsets and taking decisions based on that, that might lead to
undefined behavior.

Avoid this by just returning early a FALSE result (but with no error) in
case there's no result to proceed on.

Fixes: #2741
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
1185a1304a gregex: Mark g_match_info_get_regex as transfer none
Since it had no explicit annotation, g-i was defaulting to transfer-full
while in this case the GRegex is owned by the GMatchInfo.
2022-09-12 13:55:39 +02:00
Aleksei Rybalkin
df66951b96 tests/regex: Add test for gtksourceview regression 2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
d639c4ec00 regex: Do not mix PCRE2 Compile, Match, Newline and BSR flags
As per the PCRE2 port we still used to try to map the old GRegex flags
(PCRE1 based) with the new PCRE2 ones, but doing that we were also
mixing flags with enums, leading to unexpected behaviors when trying to
get new line and BSR options out of bigger flags arrays.

So, avoid doing any mapping and store the values as native PCRE2 flags
internally and converting them back only when requested.

This fixes some regressions on newline handling.

Fixes: #2729
Fixes: #2688
Fixes: GNOME/gtksourceview#278
2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
d4966911e6 tests/regex: Actually check for match options changes 2022-09-12 13:55:39 +02:00
Marco Trevisan (Treviño)
23c1b401d8 tests/regex: Add debug strings for compile and match option flags
In case of failures they give a better info.
2022-09-12 13:55:39 +02:00
Danial Behzadi
c646901d34 Update Persian translation 2022-09-12 10:06:28 +00:00
Daniel Mustieles
5676303e97 Updated Spanish translation 2022-09-12 07:48:51 +02:00
Daniel Mustieles
a94121ffb6 Updated Spanish translation 2022-09-12 07:46:48 +02:00
Matej Urbančič
0a665b51cd Update Slovenian translation 2022-09-11 19:11:06 +00:00
Luming Zh
615c4008f1 Update Chinese (China) translation 2022-09-11 19:10:09 +00:00
Luna Jernberg
07506b3a38 Update Swedish translation 2022-09-10 09:05:00 +00:00
Marco Trevisan
949f07044e Merge branch 'ci-style-check-improvements' into 'main'
ci: Improve style check script

See merge request GNOME/glib!2883
2022-09-10 00:51:01 +00:00
Matthias Clasen
7526f77e9a ci: Improve style check script
Sync with changes from GTK:

- Set a git config to work around security
  improvements in recent git.
- Only fetch the two branches we want to compare
  for the style check.
- Use the existing git merge-base command to find
  their common ancestor.
2022-09-09 20:23:44 -04:00
Luca Bacci
24572c93c2 Merge branch 'g-win32-app-info-fixes' into 'main'
GWin32AppInfo: Add missing g_spawn_close_pid

See merge request GNOME/glib!2881
2022-09-08 14:12:05 +00:00
Emmanuele Bassi
07a08d5cf5 Merge branch 'coverity-build-fix' into 'main'
gioenumtypes: Only define GLIB_DISABLE_DEPRECATION_WARNINGS if needed

See merge request GNOME/glib!2879
2022-09-07 14:07:45 +00:00
Marco Trevisan (Treviño)
07c808ad90 gioenumtypes: Only define GLIB_DISABLE_DEPRECATION_WARNINGS if needed 2022-09-07 15:31:38 +02:00
Matthias Clasen
1f4188f0ab Merge branch 'fgets-error-ignore' into 'main'
gio-tool-mount: Return early on fgets EOF

Closes #2737

See merge request GNOME/glib!2870
2022-09-06 17:22:15 +00:00
Matthias Clasen
1a32433f31 Merge branch 'strsplit-pre-allocated-array' into 'main'
g_strsplit: Use a pre-allocated GArray when max_tokens is provided

See merge request GNOME/glib!2875
2022-09-06 17:15:03 +00:00
Sebastian Dröge
5125194064 Merge branch 'andyholmes/gactiongroup-queryaction-ownership' into 'main'
GActionGroup: Fix ownership transfer annotation for query_action()

See merge request GNOME/glib!2876
2022-09-05 07:38:33 +00:00
Andy Holmes
1eb1a47a50
GActionGroup: Fix ownership transfer annotation for query_action()
The `(transfer none)` behaviour for `parameter_type` and `state_type`
parameters is implicit with the `const` attribute, but was incorrectly
determined to be `(transfer full)` in the GIR.

Add explicit `(transfer none)` annotations for these two parameters.
2022-09-04 17:29:39 -07:00
Changwoo Ryu
72ed39a8c2 Update Korean translation 2022-09-04 10:15:35 +00:00
Danial Behzadi
6ed89347db Update Persian translation 2022-09-03 12:16:33 +00:00
Emmanuele Bassi
bafd025811 Merge branch 'ebassi/gcc-12-fixes' into 'main'
Fix array-bounds compiler warnings with GCC 12

See merge request GNOME/glib!2873
2022-09-02 23:17:25 +00:00
Marco Trevisan
1d9a362bc7 Merge branch 'fix-some-variant-leaks' into 'main'
tests, GDesktopAppInfo: Fix various GVariant leaks

See merge request GNOME/glib!2874
2022-09-02 20:12:50 +00:00
Marco Trevisan (Treviño)
0618f5eb82 g_strsplit: Use a pre-allocated GArray when max_tokens is provided
In case max_tokens is provided, we can safely pre-allocate the GArray to
the max_tokens value plus one for the NULL terminating value.
2022-09-02 21:31:34 +02:00
Marco Trevisan (Treviño)
74f01defd4 ci: Increase the valgrind job meson test timeout
There are some test failing because there's not enough time to complete,
so let's give them some more time.
2022-09-02 21:21:34 +02:00
Marco Trevisan (Treviño)
221f22b6e1 gdesktopappinfo: Unref the GDBus call results
On our GDBus call callback wrapper we were completing the gdbus call but
ignoring the returned value, that was always leaked.

Fix this.

Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
2022-09-02 21:21:34 +02:00
Marco Trevisan (Treviño)
026a69905e gdesktopappinfo: Unref GDBus call result GVariant if no callback is set
When launching URIs via dbus we may ignore the callback if one was not
provided, however in such case we were also leaking the return value for
the gdbus call.

Unref it properly.

Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
2022-09-02 21:21:34 +02:00
Marco Trevisan (Treviño)
e268ff39b6 gio/tests/gdbus-peer: Unref cached property GVariant value
Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
2022-09-02 21:21:34 +02:00
Marco Trevisan (Treviño)
1da208cddc gio/tests/gdbus-proxy-threads: Unref GVariant's that we own
This test is leaking various GVariant's that we are supposed to unref,
leading the valgrind CI job to complain about.

Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
2022-09-02 20:26:06 +02:00
Marco Trevisan
88d4b3b365 Merge branch 'fix-doc-portal-add-leak' into 'main'
documentportal: Fix small leak in add_documents with empty URI list

Closes #2733

See merge request GNOME/glib!2871
2022-09-02 18:24:48 +00:00
Sebastian Keller
27203e48c9 documentportal: Fix small leak in add_documents with empty URI list
When called with an empty URI list (or only inaccessible files),
g_document_portal_add_documents would not call g_variant_builder_end,
leaking the memory allocated by the variant builder.

Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/2733
2022-09-02 19:48:36 +02:00
Marco Trevisan (Treviño)
511627b735 tests/dbus-appinfo: Add test case for flatpak opening an invalid file
We were testing the case in which we were opening an actual file, and so
potentially using a fd-list, however we were missing the case in which a file
was not existent.

And in such case we are incidentally hitting a leak now.
2022-09-02 19:48:36 +02:00
Emmanuele Bassi
e08c954693 Fix check before a memcpy
The search_total_results address is always going to be non-zero, so the
check will always evaluate to true, and GCC is kind enough to point this
out to us.

The appropriate fix is checking if the size of the search results array
is larger than zero, and if so, copy them into the total results array.
2022-09-02 12:59:22 +01:00
Emmanuele Bassi
903c004b37 Fix array-bounds compiler warnings with GCC 12
GCC isn't smart enough to recognise that the assertion on the size of
N_PROPERTIES also affects the assertion on the GParamSpec array access,
so we need to coalesce the two checks into one to avoid an array-bounds
compiler warning.
2022-09-02 12:46:57 +01:00