Commit Graph

25 Commits

Author SHA1 Message Date
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
Ryan Lortie
b076020719 gobject/gio: some last missed statics/inclues 2011-10-16 21:53:03 -04:00
Ryan Lortie
b83e0a39fb glib-compile-schemas: remove --uninstall option
This option does nothing as has been documented as "will be removed
soon" for the vast majority of its life.
2011-09-17 19:11:10 -04:00
Matthias Clasen
ec3653be00 glib-compile-schemas: Pedantic string fixes
Replace 'can not' by 'cannot' in several places. String change!

https://bugzilla.gnome.org/show_bug.cgi?id=658207
2011-09-10 10:36:56 -04:00
Ryan Lortie
fe6dad271b GSettings: remove key length restrictions
The key length now stands effectively unlimited at 1024 characters.

https://bugzilla.gnome.org/show_bug.cgi?id=654536
2011-07-19 16:12:30 +02:00
Chun-wei Fan
09c98f18fc Update gsettings utilities in GIO
Avoid C99-style variable declaration
2011-06-07 10:49:29 +08:00
Matthias Clasen
7d0eac03e9 glib-compile-schemas: write informational messages to stdout
The fact that we return 0 here makes it clear that this
is not considered an error, so it makes sense to not
write these messages to stderr.
Proposed by Antoine Jacoutot,
https://bugzilla.gnome.org/show_bug.cgi?id=650882
2011-05-27 18:30:45 -04:00
Dan Winship
e56498ee0b Fix usage of _GNU_SOURCE
_GNU_SOURCE must be defined before including any other (system)
header, so defining it in glib-unix.h (and hoping no one has included
anything else before that) is wrong. And the "#define _USE_GNU"
workaround for this problem in gnetworkingprivate.h is even wronger
(and still prone to failure anyway due to single-include guards).

Fix this by defining _GNU_SOURCE in config.h when building against
glibc. In theory this is bad because new releases of glibc may include
symbols that conflict with glib symbols, which could then cause
compile failures. However, most people only see new releases of glibc
when they upgrade their distro, at which point they also generally get
new releases of gcc, which have new warnings/errors to clean up
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=649201
2011-05-03 07:07:41 -04:00
Matthias Clasen
3c94299b0f Don't include unistd.h unconditionally
It doesn't exist on all platforms. Partial fix for bug 647341.
2011-04-11 12:57:19 -04:00
David Zeuthen
0729260141 Silence a bunch of -Wunused-but-set-variable warnings
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-08 15:44:25 -04:00
Ryan Lortie
3498d58289 glib-compile-schemas: check for undefined refs
For child schemas, verify that the named schema actually exists and
issue a warning if not.  This error in schema files will cause runtime
errors when iterating over the list of child schemas and attempting to
instantiate each one.

This will move from being merely a warning to a hard error in the
future.

Bug #646039.
2011-04-08 01:47:52 -04:00
Ryan Lortie
cde83c8ccd glib-compile-schemas: min and max are now optional
Will be taken to be the minimum and maximum value for the type of the
key if they are left out.

Bug #646310.
2011-03-31 15:14:46 +05:30
Tor Lillqvist
1158f9c171 Export _glib_get_locale_dir() as it is now used in gio, too 2011-02-20 01:30:51 +02:00
Matthias Clasen
a536a1f2d7 Complete the translation setup for glib-compile-schemas 2011-02-12 12:45:25 -05:00
Christian Persch
57143e311d Inherit gettext-domain from <schemalist>
When the <schema> doesn't have a 'gettext-domain' attribute, but
the <schemalist> does, use that one.

Bug #635640.
2010-11-28 19:01:21 +01:00
Matthias Clasen
9040eac4eb Prevent error pileup 2010-10-16 23:31:30 -04:00
Ryan Lortie
833e389516 schema compiler: Don't store zero-valued flags
Don't store the "none" value for flags into the compiled schema file.
"none" should never appear as a value -- no flags set is indicated by an
empty array.
2010-10-04 02:57:06 -04:00
Ryan Lortie
8efcc0d8c8 glib-compile-schemas: write strinfo little endian
Ensure that the strinfo is output in little-endian byte order on big
endian machines.

GSettings is now passing all of its tests on PowerPC.

Bug #630968 is closed.
2010-10-03 23:26:18 -04:00
Ryan Lortie
3e771509b4 Bug 628937 - gracefully handle broken schemas
Implement the second feature requested in the bug: silently ignore
override files that attempt to override schemas that are not currently
installed.

Also, support 'strictness' being optional for other errors when parsing
override files (ie: inability to open the file, unknown key name, parse
errors, out of range).  We don't completely back out the file in this
case — as that is difficult with the current implementation — but just
ignore the override for the single key.
2010-10-01 11:21:13 -04:00
Ryan Lortie
bd290081ff glib-compile-schemas: improve error accuracy
We wrote "<enum> must contain at least one <value>" for empty <flags>.
Fix that.
2010-10-01 11:21:07 -04:00
Ryan Lortie
e40f3932dd Bug 628937 - gracefully handle broken schemas
Implement the first of two features requested in the bug: when
encountering a broken .xml schema file, back out the changes in that
file and continue to parse other files.

This prevents a single broken .xml file from messing up GSettings for
everyone else.

Add a --strict option to get the old behaviour.  Use this from the test
cases.
2010-10-01 11:21:02 -04:00
Ryan Lortie
f8cb2a60b9 Add 3 new restrictions to the schema compiler
- can not extend schemas that already have paths
 - can not form list of schemas that already have paths
 - the path of a list schema, if given, must end with ':/'
2010-09-09 16:43:03 -04:00
Ryan Lortie
7777dd2c39 Rename gschema-compile.c -> glib-compile-schemas.c 2010-09-09 16:42:55 -04:00