Commit Graph

29412 Commits

Author SHA1 Message Date
Philip Withnall
244721baf9 docs: Move the misc_utils SECTION
Move it to a separate page, with a massive great list of all the misc
utils. Not a great documentation page, but equivalent to what we had
before, and it can be improved in future.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
74de872bb9 docs: Move the spawn SECTION
Move it to a separate page.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
6dca578f9d docs: Move the memory SECTION
Move it to a separate page.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
cbbd06fee7 docs: Drop the SECTION for tracing
All this API is internal to GLib, so the section was never actually
exposed in the public API documentation. Keep the documentation, just
don’t tag it as a SECTION.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
25a4205d9d docs: Move the ghostutils SECTION
Sadly, this is about hostnames rather than ghosts. 😞

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
425731f766 docs: Move the string_utils SECTION
Move it to a mega separate file.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
cf52727f03 docs: Move the shell SECTION
Move it to a separate file.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
214853d6df docs: Move the GVariant SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
229b76a388 docs: Move the version SECTION
Move it to a separate documentation file, since most of what’s covered
isn’t introspectable.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
194db3f096 docs: Move the GVariantType SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
359c1034e0 docs: Move the GUuid SECTION
Move it to a separate page as there’s no public struct to hang the
docs off.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
be783fdc2a docs: Move the GUri SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
43588fcdd9 docs: Move the grand SECTION
Move it to a separate page so the difference between `g_rand_*()` and
`g_random_*()` can be explained.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
8179688c07 docs: Move the GTrashStack SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
1625c24d58 docs: Drop the hooks SECTION
It was one paragraph which mentioned `GHookList` and `GHook`, both of
which have their own adequate documentation sections.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
158ec5be34 docs: Move the gfileutils SECTION
Move it to a separate page so more detail can be provided about all the
groups of API.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
c850d25d67 docs: Move the gatomic SECTION
Move it to a standalone page.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
ac91b8f4a2 docs: Move the base64 SECTION
Move it to a separate file as there is no struct to hang the docs off.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
bd33e0acd2 gio: Fix several incorrect links in documentation comments
Since commit 08f914b29, validation seems to have got a little
stricter/more correct.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
552f62a059 docs: Move the threads-deprecated SECTION
Move it to a separate page so an overview of the deprecated threading
API can be given.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-28 13:52:05 +00:00
Philip Withnall
f8122da6c9 Merge branch 'migrate-to-gi-docgen13' into 'main'
gwin32: Un-hide symbols when building GIR

See merge request GNOME/glib!3723
2023-11-28 13:49:42 +00:00
Philip Withnall
eb189bcec0 ci: Make the Alpine CI name more consistent
The image uses `alpine:latest`, so let’s drop the ‘stable’ moniker. This
also makes the container registry ID match the Dockerfile name.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-28 11:51:30 +00:00
Philip Withnall
8f6f382940 Merge branch 'test-trap-subprocess-envp' into 'main'
gtestutils: Add g_test_trap_subprocess_with_envp() for testing envs

See merge request GNOME/glib!3721
2023-11-28 11:49:11 +00:00
Philip Withnall
e4fe837bae Merge branch 'migrate-to-gi-docgen12' into 'main'
gdir, gstrvbuilder: Add refcounting support and a boxed type

See merge request GNOME/glib!3722
2023-11-28 11:47:11 +00:00
Philip Withnall
40ca773fa5 Merge branch 'stop-spamming' into 'main'
gspawn: Stop spewing debug messages

See merge request GNOME/glib!3732
2023-11-28 11:44:48 +00:00
Philip Withnall
c406c6de6b Merge branch '3148-stream-test' into 'main'
tests: Use a pipe rather than a socketpair in stream-rw_all test

Closes #3148

See merge request GNOME/glib!3691
2023-11-28 11:43:51 +00:00
Matthias Clasen
f79c53f953 gspawn: Stop spewing debug messages
My GTK testlogs are filled with

GLib-DEBUG: g_unix_open_pipe() called with FD_CLOEXEC; please migrate to using O_CLOEXEC instead

Lets take the hint, and migrate to using O_CLOEXEC.
2023-11-27 21:03:49 -05:00
Artur S0
20400bc503 Update Russian translation 2023-11-27 16:26:55 +00:00
Philip Withnall
cdc37f051c Merge branch 'wip/pwithnall/fix-bsd-string-test' into 'main'
tests: Fix string test failure on BSDs

See merge request GNOME/glib!3731
2023-11-27 16:24:25 +00:00
Philip Withnall
4c86a85eaf Merge branch 'app-command-line-done' into 'main'
gapplicationcommandline: add `.done()` method

Closes #596

See merge request GNOME/glib!3693
2023-11-27 14:15:36 +00:00
Aleksandr Mezin
c03c983d94 gapplicationcommandline: add .done() method
Fixes #596
2023-11-27 14:15:36 +00:00
Philip Withnall
5070f3fe80 Merge branch '3186-gpt-sniff-buffer' into 'main'
glocalfileinfo: Increase size of the content-type sniff buffer to 16KiB

Closes #3186

See merge request GNOME/glib!3730
2023-11-27 14:14:40 +00:00
Philip Withnall
2c4be841d7 tests: Fix string test failure on BSDs
As with `test-printf`, the `vasprintf()` placeholder checks on BSDs
(including macOS) are less strict than on Linux (glibc), so the expected
critical message is not seen.

Change the test to not expect it on BSDs.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3187
2023-11-27 13:26:51 +00:00
Philip Withnall
01cdce7573 glocalfileinfo: Increase size of the content-type sniff buffer to 16KiB
It was previously 4KiB, but this isn’t enough for sniffing the
content-type of some GPT disk images (they use 4KiB sectors, and the
magic bytes are in the second sector). A buffer of 8KiB would work,
but 16KiB seems harmless and more future proof.

Most of the time, the buffer size should be set by xdgmime anyway, based
on the largest sniff buffer its database needs. Currently (with
shared-mime-info master) that’s 18730 bytes, so even with a 16KiB buffer
we’re going to potentially mis-identify a few file types.

Tested manually by modifying the example GPT image from shared-mime-info
(https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/tests/mime-detection/disk.gpt)
to remove the magic at offset 0x200 and add it instead at offset 0x1000,
then running:
```
cp shared-mime-info.git/tests/mime-detection/disk.gpt ./disk-without-extension
gio info -a standard::content-type ./disk-without-extension
```

It should print `application/vnd.efi.img` rather than
`application/octet-stream`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3186
2023-11-27 13:22:21 +00:00
Philip Withnall
062f1a888e Merge branch '3187-vasprintf-checks' into 'main'
gprintf: Fix invalid size allocation in `g_vasprintf()`

Closes #3187

See merge request GNOME/glib!3729
2023-11-27 13:09:16 +00:00
Philip Withnall
707ae4bd79 gstring: Add critical warning to g_string_append_vprintf()
It was previously possible for this to silently fail, which isn’t great
for program correctness. Instead, raise a critical warning so the
programmer knows to either validate their Unicode inputs, or fix their
format placeholders.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3187
2023-11-27 12:20:50 +00:00
Philip Withnall
c56bc6d8d9 gstrfuncs: Add missing annotations to g_strdup_vprintf()
It’s possible for the function to fail for the same reasons
`g_vasprintf()` would fail.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3187
2023-11-27 12:20:50 +00:00
Philip Withnall
3c6052f318 gprintf: Fix invalid size allocation in g_vasprintf()
As per the previous commit, it’s possible for
`g_printf_string_upper_bound()` to return an error. We need to catch and
handle that error in `g_vasprintf()` to avoid it trying to write to a
`NULL` string allocation and crashing.

So, call `g_vsnprintf()` directly instead of calling
`g_printf_string_upper_bound()`, so that the error case can be handled.

There was already a test for some of this behaviour
(`test_vasprintf_invalid_format_placeholder()`). Because it tested an
invalid format string, the `_g_vsprintf()` call bailed out before
checking whether the buffer it had been passed was `NULL`. The new test
has a valid format string, but an invalid arg.

When running the tests locally, I have disabled the `USE_SYSTEM_PRINTF`
and `HAVE_VASPRINTF` code paths in `g_vasprintf()`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3187
2023-11-27 12:20:12 +00:00
Philip Withnall
e2cd0962c2 gmessages: Document error case for g_printf_string_upper_bound()
Spotted in https://gitlab.gnome.org/GNOME/glib/-/issues/3187.

In an ideal world, this API would have been designed with an error
return path to begin with — perhaps by returning a `GError` or a
`gssize`. We can’t change the API now, though, which leads to this
slightly awkward “0 indicates an error or success” pattern.

I think that’s justified in this case because:
 - This API does not see much use.
 - Format strings tend to be literals, and almost always are
   non-zero-length, so it tends to be statically possible to determine
   that the function won’t return zero on success.
 - If callers do need to differentiate the two zero return value cases,
   they can just call `g_vsnprintf()` directly instead.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3187
2023-11-27 12:20:06 +00:00
Philip Withnall
40081f9b62 Merge branch 'collate-crash' into 'main'
collate: Don't segfault on bad input

Closes #3185

See merge request GNOME/glib!3725
2023-11-26 22:41:26 +00:00
Matthias Clasen
81ec27c33b collate: Don't segfault on bad input 2023-11-26 22:41:26 +00:00
Philip Withnall
e67a36c479 Merge branch 'wip/pwithnall/fix-ftruncate64' into 'main'
tests: Fix fileutils build on FreeBSD and macOS

See merge request GNOME/glib!3726
2023-11-26 22:23:36 +00:00
Philip Withnall
a8df4183e4 tests: Fix fileutils build on FreeBSD and macOS
The test needs to call `ftruncate64()` (not `ftruncate()`) to guarantee
it’s using the 64-bit version on Linux, but this doesn’t exist on other
platforms.

Test to see if it exists and, if not, skip the test.

Fixes commit cf5e371c67, and fixes CI
failures like https://gitlab.gnome.org/GNOME/glib/-/pipelines/602930.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-26 22:10:22 +00:00
Philip Withnall
50d432c77b gwin32: Un-hide symbols when building GIR
The win32-specific APIs in GLib are only defined when building for
Windows. Unfortunately, this means they can not show up in `GLib-2.0.gir`
if it’s build on Linux (which is what mostly happens).

Consequently, that means they’re not present in the API documentation,
which is a bit of a problem.

Make the symbols in the header available on other platforms
(particularly Linux) if building with `g-ir-scanner` (but not
otherwise). This means the win32 symbols show up in `GLib-2.0.gir` and
hence in the documentation.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-23 16:18:47 +00:00
Philip Withnall
9c9552309a Merge branch 'large-file-issue3' into 'main'
gfileutils: Fix g_file_get_contents() silent under-read of large files when off_t is wider than size_t

See merge request GNOME/glib!3713
2023-11-23 12:41:42 +00:00
Joseph Nuzman
cf5e371c67 gfileutils: Fix g_file_get_contents() silent under-read of large files
On certain platforms where file size (off_t) can be truncated when assigning to
gsize, get_contents_regfile() may use the truncated size as the size to read. Add
an explicit check to raise an error in such cases.

G_FILE_ERROR_FAILED will be raised in this case, aligning with behavior for other
cases.

This generally affects 32-bit non-Win32 platforms.
2023-11-23 12:41:41 +00:00
Philip Withnall
aec0f4d938 gstrvbuilder: Add a boxed type so it can be introspected properly
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-23 12:36:11 +00:00
Philip Withnall
40e6a09d37 gstdio: Ignore POSIX stdio wrappers under g-ir-scanner
Just as they were ignored under gtk-doc, ignore them when scanning the
sources using `g-ir-scanner`, and make it look at the full function
declarations instead.

This fixes inclusion of functions like `g_creat()` in the documentation.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-23 12:34:39 +00:00
Philip Withnall
3c42b9c3ee gdir: Add refcounting support and a boxed type
This allows the methods for `GDir` to be introspected. While we don’t
expect languages which use the introspection bindings to use `GDir`,
full introspection support is necessary for the `GDir` documentation to
be correctly built with gi-docgen.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3037
2023-11-23 12:34:39 +00:00
Philip Withnall
f0032094d2 tests: Fix use of TMPDIR in utils test
All GLib tests normally respect `TMPDIR` for writing their temporary
files to. The utils test, however, contained a hack which overwrote
`TMPDIR` so that it could test the behaviour of `g_get_tmp_dir()` for
regressions.

Unfortunately, that hack affected the whole `utils` test suite, not just
the one regression test.

Use the new `g_test_trap_subprocess_with_envp()` API to allow the
regression test to be run as a subprocess with its environment modified,
which allows us to remove the hack affecting the rest of the test suite.

Spotted in
https://gitlab.gnome.org/GNOME/glib/-/issues/3179#note_1925161.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2023-11-23 12:18:21 +00:00