Commit Graph

72 Commits

Author SHA1 Message Date
Philip Withnall
6e362ce3b6
gio: Fix various implicit conversions from size_t to smaller types
Basically various trivial instances of the following MSVC compiler
warning:
```
../gio/gio-tool-set.c(50): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-04-25 00:37:47 +01:00
Daniyar Tleulin
49537e298c glib-compile-schemas: Fix non-ASCII arg parsing on Windows
When the source directory contains non-ASCII symbols,
argument parsing previously failed on MINGW64.

Fixes: #3003
2023-05-23 16:49:21 +06:00
Sergey Bugaev
bccff754b6 Use g_string_free_and_steal () more
Now that there is g_string_free_and_steal (), we can use it instead of
the older g_string_free (_, FALSE). Make sure to use its return value
while doing so, as opposed to manually accessing string->str, to avoid
compiler warnings and make the intent more explicit.

This is all done in preparation for making g_string_free (_, FALSE) warn
on unused return value much like g_string_free_and_steal (), which will
happen in the next commit.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-01-27 11:55:27 +03:00
Philip Withnall
9d5bcc9491 glib-compile-schemas: Fix typo in comparison function
This caused schemas and override files to be sorted incorrectly.

Fixes a regression introduced in commit 861e82efbc.

Spotted by John Wudrick in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3155#note_1635044.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-01-09 12:20:10 +00:00
Marco Trevisan (Treviño)
861e82efbc gio: Use g_ptr_array_sort_values()
Cleanup some code using GPtrArray sorting with functions that were taking
pointer to pointers arguments.
2023-01-06 11:46:01 +00:00
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

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

Helps: #1415
2022-05-18 09:18:52 +01:00
Loic Le Page
7a50259345 Fix redefinition of local variable in gio/glib-compile-schemas.c 2022-03-09 17:19:02 +01:00
Emmanuel Fleury
27454ed557 Fix missing initializer warning in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c:2181:12: warning: missing field 'short_name' initializer
    { NULL }
           ^
2021-05-13 12:57:14 +02:00
Emmanuel Fleury
6b3e39fafd Fix several missing initializer warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘parse_gschema_files’:
gio/glib-compile-schemas.c:1773:3: error: missing initializer for field ‘passthrough’ of ‘GMarkupParser’ {aka ‘struct _GMarkupParser’}
 1773 |   GMarkupParser parser = { start_element, end_element, text };
      |   ^~~~~~~~~~~~~
gio/glib-compile-schemas.c: In function ‘main’:
gio/glib-compile-schemas.c:2176:5: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
 2176 |     { "allow-any-name", 0, 0, G_OPTION_ARG_NONE, &allow_any_name, N_("Do not enforce key name restrictions") },
      |     ^
2021-02-10 20:41:16 +01:00
Emmanuel Fleury
93f3831ed3 Fix several signedness warnings in gio/glib-compile-schemas.c
gio/glib-compile-schemas.c: In function ‘key_state_set_range’:
gio/glib-compile-schemas.c:376:17: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  376 |   for (i = 0; i < G_N_ELEMENTS (table); i++)
      |                 ^
gio/glib-compile-schemas.c: In function ‘key_state_serialise’:
gio/glib-compile-schemas.c:714:29: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘long unsigned int’
  714 |               for (i = 0; i < size / sizeof (guint32); i++)
      |                             ^
2021-02-10 20:41:16 +01:00
Philip Withnall
389b1820f2 glib-compile-schemas: Fix some minor en_GB-isms in translatable strings
Spotted by Bruce Cowan.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #1867
2019-08-14 10:38:23 +02:00
Chun-wei Fan
9f709fe1e9 gio tools: Use the proper string for default locale for setlocale()
This makes use of the string we now have from glib-private.h in the
last commit so that setlocale() sets the default system locale
correctly and therefore show the translated messages properly.

Fixes issue #1169.
2019-06-18 17:29:41 +08:00
Sebastian Dröge
e85f1ced5f Merge branch 'compile-schemas-strings' into 'master'
glib-compile-schemas: Improve translatable strings

See merge request GNOME/glib!678
2019-06-11 11:34:05 +00:00
Philip Withnall
1b50643c99 gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1708
2019-03-08 19:46:21 +00:00
Philip Withnall
111f2b79e7 glib-compile-schemas: Fix capitalisation of a command line option help
The other descriptions of command line options start with a capital.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:21:13 +00:00
Philip Withnall
fd3219aaa1 glib-compile-schemas: Improve translatable strings
Eliminate several cases of splitting sentences between multiple
translatable strings, and remove some newlines from the translatable
strings (they always need to be present, and can confuse translation, so
add them unconditionally afterwards).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-18 17:15:15 +00:00
Philip Withnall
ce86a3aed7 glib-compile-schemas: Fix a minor memory leak
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 15:37:05 +01:00
Piotr Drąg
d9fc99256e Use Unicode typography in new translatable strings
See https://developer.gnome.org/hig/stable/typography.html
2018-06-25 16:51:00 +02:00
Alberts Muktupāvels
b618ec40a7 Add a test for per-desktop overrides 2018-06-22 22:02:31 +03:00
Allison Lortie
83a2e85ec8 glib-compile-schemas: Handle per-desktop overrides
Add a new syntax to override files: if the group name has a ':' in it,
it indicates that we want to override the default values of keys for
only one desktop. For example:

[org.gnome.desktop.interface:Unity]
font-name='Ubuntu 12'

Will override the settings, only if "Unity" is found in
XDG_CURRENT_DESKTOP. Multiple per-desktop overrides can be specified
for a given key: the one which comes first in XDG_CURRENT_DESKTOP will
be used.

https://bugzilla.gnome.org/show_bug.cgi?id=746592
2018-06-19 19:18:58 +03:00
Piotr Drąg
b974cccdaf Revert "Partially revert 10c490cdfe3ae042f747bd00f787492e2bdb7ed0"
This reverts commit 2d56c49b10.
2018-06-08 16:15:54 +02:00
Philip Withnall
3ba2f8333b glib-compile-schemas: Fix minor memory leaks in error paths
Spotted while running valgrind on gsettings-test, as per the previous
commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-11 11:03:03 +01:00
Maks Naumov
12e32e96a3 Don't skip invalid enum values in schemas
Signed-off-by: Maks Naumov <maksqwe1@ukr.net>

https://bugzilla.gnome.org/show_bug.cgi?id=742997
2017-10-11 10:22:23 +01:00
Philip Withnall
25c01e1c55 glib-compile-schemas: Use double quotes rather than single quotes
It’s what GLib is standardising on. See bug #772221.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 16:31:37 +01:00
Philip Withnall
c257757cf6 glib-compile-schemas: Improve some translatable strings
• Fix capitalisation to be consistent
 • Use Unicode quotation marks where appropriate
 • Move trailing \n characters out of the translable strings and append
   them unconditionally

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:41:13 +01:00
Daniel Boles
94816e10d2 glib-compile-schemas: Fix typo in newly translatable string 2017-08-03 11:30:20 +01:00
Jiro Matsuzawa
a7aa8acc48 glib-compile-schemas: Mark missing strings for translation
https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:19:08 +01:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Philip Withnall
d6d29a2e9f glib-compile-schemas: Fix various memory leaks
Spotted while running `make check` under Valgrind. While it’s not
necessary to fix memory leaks in glib-compile-schemas (since it’s a
utility which runs briefly then exits), fixing them makes more
legitimate leaks in the Valgrind output more obvious, and means we can
be sure there aren’t leaks in the underlying GLib/GIO code which
glib-compile-schemas is calling.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Matthias Clasen
2d56c49b10 Partially revert 10c490cdfe
This commit broke some tests, and I don't have the time
to fix up all the expected output, so I'll revert the changes
to the affected files for now.

This needs to be redone with the necessary test fixes.
2016-10-24 10:21:59 -04:00
Piotr Drąg
10c490cdfe Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2016-10-12 21:30:42 +02:00
Sam Thursfield
6338cde7ca glib-compile-schemas: Add a --version option
https://bugzilla.gnome.org/show_bug.cgi?id=772269
2016-10-06 21:08:25 +01:00
Matthias Clasen
074fe89f22 glib-compile-schemas: Improve an error message
Mention the expected type when failing to parse a GVariant.
2015-05-15 22:53:41 -04:00
Matthias Clasen
aecac6e1cb glib-compile-schemas: Show error positions
GMarkup provides this information, pass it on.
2015-05-15 22:41:29 -04:00
Ryan Lortie
7f4fdb59aa gsettings: fix schema compiler error handling
Fix a couple of issues in error handling in glib-compile-schemas.

The first problem is that, in case of repeated <summary> or
<description> tags we were still allocating a GString which was never
being freed (due to the throwing of the error resulting in immediate
termination of the parse).

The second problem is that if the repeated <summary> tag also had
attributes, we would attempt to set the GError twice.

https://bugzilla.gnome.org/show_bug.cgi?id=747542
2015-04-08 22:35:35 -04:00
Ryan Lortie
2b8f131599 gsettings: stay compatible with installed schemas
Bug 747209 introduced an error when multiple <summary> or <description>
tags are found for a single key in a GSettings schema.  This check
should have been present from the start, but it was left out because the
schema compiler doesn't include these items in the cache file.  Even
still -- part of the schema compiler's job is validation, and it should
be enforcing proper syntax here.

Repeated <summary> and <description> tags are a semi-common problem when
intltool has been misconfigured in the build system of a package, but
it's possible to imagine mistakes being made by hand as well.

The idea is that these problems would be caught during the build of a
package and maintainers would be forced to fix their build systems.

An unintended side-effect of this change, however, is that the schema
compiler started ignoring already-installed schemas that contained these
problems, when rebuilding the cache.  This means that the installation
of _any_ application would cause the regeneration of the entire cache,
with these already-installed applications being excluded.  Without the
schema in the cache, the application would crash on next startup.

The validation check in the gsettings m4 macro passes --strict to the
compiler, which is not used when rebuilding the cache after
installation.  Pass this flag down into the parser and only throw the
error in case --strict was given.  This will result in the (desired)
build failure without also causing already-installed apps to stop
functioning.

This means that we will not get even a warning about the invalid schema
file in the already-installed case, but that's fine.  There is no sense
spamming the user with these messages when they are already quite fatal
for the developer at build time.

https://bugzilla.gnome.org/show_bug.cgi?id=747472
2015-04-08 22:35:35 -04:00
Matthias Clasen
b2734d762f glib-compile-schema: Don't accept duplicate docs
This schema compiler was completely ignoring <summary> and
<description> tags. Unfortunately, there are modules out there
who merge translations for these back in, with xml:lang. And
this is giving dconf-editor a hard time. Since this is not
how translations of schemas are meant to be done, just
reject such schema files.

Also add tests exercising the new error handling.

https://bugzilla.gnome.org/show_bug.cgi?id=747209
2015-04-01 18:55:54 -04:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Dan Winship
158dde0507 Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:25:39 -05:00
Ryan Lortie
908d7d6d6a glib-compile-schemas: ignore qualified tags/attrs
Ignore qualified (in the XML namespace sense) tags and attributes when
compiling GSettings schemas.

This will allow people to add custom tags and attributes to their schemas
without tripping up the compiler.

https://bugzilla.gnome.org/show_bug.cgi?id=635641
2013-10-28 15:30:25 -07:00
Ryan Lortie
f9eb9eed10 Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.

First, Makefile.decl has been renamed glib.mk and substantially
expanded.  We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.

By default, tests are no longer compiled as part of 'make'.  They will
be built when 'make check' is run.  The old behaviour can be obtained
with --enable-always-build-tests.

--disable-modular-tests is gone (because tests are no longer built by
default).  There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.

A new glibtests.m4 file is introduced.  Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).

Port our various test-installing Makefiles to the new framework.

This patch substantially improves the situation in the toplevel tests/
directory.  Things are now somewhat under control there.  There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.

As an experiment, 'make check' now runs the testcases on win32 builds,
by default.  We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS.  Most of
them are passing on win32.

Things are not quite done here, but this patch is already a substantial
improvement.  More to come.
2013-05-31 23:12:15 -04:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.

However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.

Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.

Fix this by just using 'dumb quotes' everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=700746
2013-05-21 11:23:22 -03:00
Dan Winship
3ac6cfaeaa win32: prototype _glib_get_dll_directory() and _glib_get_locale_dir()
Rather than using "extern" declarations of these win32 functions
everywhere they're needed, just prototype them in glib-private.h.
(Which also fixes the fact that they weren't prototyped in the files
where they're defined.)

https://bugzilla.gnome.org/show_bug.cgi?id=688109
2012-11-15 14:19:05 -05:00
Matthias Clasen
138f4c1e2f Remove trailing space from some translated strings
https://bugzilla.gnome.org/show_bug.cgi?id=687700
2012-11-09 22:12:57 -05:00
Matthias Clasen
6bee6dbce5 Miscellaneous string fixes
Typo and punctuation fixes, and some rewording, based
on a patch by Philip Withnall, bug
https://bugzilla.gnome.org/review?bug=628193
2012-08-16 23:02:41 -04:00
Matthias Clasen
191f09b044 Change "dash" to "hyphen" in translatable strings
GSchemas use hyphens, not dashes.
Patch by Philip Withnall, bug
https://bugzilla.gnome.org/review?bug=628193
2012-08-16 22:23:20 -04:00
Ryan Lortie
6560b37450 glib-compile-schemas: warn about bad dconf paths
For quite some time the recommended usage of GSettings and dconf has
been to use paths like /org/gnome/example/.  Use of /apps/ has spilled
over from GConf and is continuing to make its way into a number of
applications as they port.

glib-compile-schemas will now warn about these types of paths being
used.  This generates a lot of noise, but hopefully it will reduce the
number of ported applications making this mistake.
2012-04-12 19:55:34 -04:00
Ryan Lortie
9a7a98bf3b glib-compile-schemas: get strict about whitespace
It's important to have strict rules for handling of whitespace in
translated strings in GSettings schema files so that the tools
extracting the messages will end up with the same messages as the
runtime calling gettext().

The rules are designed to be simple and unambiguous yet cover most
normal uses in a convenient way.

Those rules are as follows (with rationale):

  - for <default> tags, the text content has its leading and trailing
    whitespace stripped off, but internal whitespace is not modified in
    any way.

    This allows for slightly more flexible use of whitespace without
    causing that whitespace to appear in the strings for translation.

  - for <summary> and <description> tags, the content is split into
    paragraphs.  Paragraphs are separated by two or more sequential
    newline characters.  Each paragraph has its leading and trailing
    whitespace removed and all other whitespace is normalised to a
    single ascii space character.  Finally, the paragraphs are rejoined,
    inserting exactly two newlines between them.

    This allows for longer explanations (particularly in the description
    tag) using a natural format that, when normalised, will display
    nicely in toolkits.

This patch implements the rules for <default> tags.  The schema compiler
currently ignores <summary> and <description> tags.
2012-01-28 01:23:05 +01:00
Christian Persch
3f691c6f51 Write list-of value correctly
Fixes a c&p typo. Bug #639099.
2012-01-24 14:20:37 +01:00
Matthias Clasen
7ec69ecd32 Accept CDATA in gschema.xml files 2011-11-07 00:13:56 -05:00