Commit Graph

2998 Commits

Author SHA1 Message Date
Ryan Lortie
92df8a1d77 Drop GTimeSpec type 2010-11-02 22:39:09 -04:00
Ryan Lortie
c3a0d32ef1 Switch GTimeSpec users to int64 microseconds
glib is trying to move toward using microseconds-in-gint64 as its
universal time format.

No real API breaks here since GTimeSpec is new this unstable release
series.
2010-11-02 22:39:09 -04:00
Ryan Lortie
d9f5ab56c3 GTimeout: simplify math for 'seconds' case
The code was designed to deal with any granularity of timer and due to
the use of GTimeVal/GTimeSpec, the math for this gets extremely
confusing.

From a practical standpoint, we only ever have a granularity of seconds.

Take advantage of that fact in the code and vastly simplify the math.
2010-11-02 22:39:09 -04:00
Matthias Clasen
d2612ad955 Fix a doc typo 2010-10-31 23:13:36 -04:00
Christian Persch
ab02965c50 Use G_GINT64_CONSTANT here
Bug #631482.
2010-10-30 21:40:28 -04:00
Ryan Lortie
99d2c2eef5 Add testcase for environment functions 2010-10-28 22:20:56 -04:00
Ryan Lortie
29ce7385bb Add g_get_environ(): portable access to 'environ'
Return a copy of 'environ' on platforms where that is possible, or do
something else on other platforms.
2010-10-28 22:20:56 -04:00
Ryan Lortie
7c184df292 Bug 158725 - free linked list with data
Add some helpers for freeing a linked list along with its elements by
providing a GDestroyNotify to call on each of them.

Add a test.

Based on a patch from Cosimo Cecchi.
2010-10-28 11:20:57 -04:00
Ryan Lortie
2af4b6e544 Deprecate g_source_get_current_time() 2010-10-27 09:22:13 -04:00
Ryan Lortie
91113a8aee switch GTimeoutSource to use monotonic time 2010-10-27 09:22:12 -04:00
Ryan Lortie
b7d8363fbe Add g_source_get_time()
Cached version of g_get_monotonic_time() that does similar to what
g_source_get_current_time() does for g_get_current_time().
2010-10-27 09:22:12 -04:00
Ryan Lortie
bf941f200c Rename time_is_current to current_time_is_fresh
Internal structure field; no semantic changes.
2010-10-27 09:22:12 -04:00
Ryan Lortie
ab548d240a Add g_get_monotonic_time()
Gets the system monotonic time on systems that have it.  Otherwise, call
g_get_current_time().
2010-10-27 09:22:12 -04:00
Ryan Lortie
ac82e74895 Add 'GTimeSpec' as 'struct timespec' equivalent 2010-10-27 09:22:12 -04:00
Ryan Lortie
817b322ca7 Link libglib against -lrt if we have clock_gettime 2010-10-27 09:22:12 -04:00
Ryan Lortie
181982c47c GVariant: avoid locking in a common case
Avoid acquiring the lock on the instance on the case of deserialising a
child.  We know that it is safe to do this unlocked because a serialised
child will never become unserialised.

Closes #626320
2010-10-26 11:49:32 -04:00
Tor Lillqvist
9d80c36141 Use CSIDL_LOCAL_APPDATA on Windows
Make g_get_user_data_dir() return the CSIDL_LOCAL_APPDATA folder on
Windows, and not CSIDL_PERSONAL. On Windows 7, that corresponds to the
subfolders AppData\Local vs. Documents under the profile ("home")
folder. This matches what Qt does, for instance, and has been widely
requested.

Also make g_get_user_config_dir() return this and not the (roaming)
CSIDL_APPDATA folder. The reason for this change is that it would be
surprising and hard to justify if g_get_user_data_dir() returned the
local application data folder while g_get_user_config_dir() would
return the roaming one. Nothing in the function names or the XDG specs
suggests that any roaming vs. local dichotomy would be involved.

Document the new semantics and the fact that these two functions now
return the same directory on Windows.

Note that in reality, code that really truly wants to support Windows
as well as possible probably will not use these GLib functions anyway,
but Win32 APIs directly to be sure what it is doing...

Should hopefully satisfy complaints in bug #620710 and related bugs.
2010-10-18 14:43:21 +03:00
Ryan Lortie
a7662ef315 GVariant tests: fix bad allignment assumption
One of the GVariant test cases allocates a pair of character arrays on
the stack and then passes them to functions that assume that they will
be aligned to a multiple of two.

This is not the case for some versions of GCC (4.0.3 on PowerPC).
2010-10-05 02:11:22 -04:00
Ryan Lortie
2ce2d587ed GVariant: avoid byteswapping in some cases
Make g_variant_byteswap() merely return a new reference on the given
value in the event that we know that byteswapping will have no effect
(ie: types which have no alignment requirement).

This fixes a somewhat complicated interaction between GVariant,
GSettings and GVDB on big endian machines:  GSettings assumes that it
can unref values returned from GVDB without losing access to the
underlying data.  This only works if the underlying data is in the
mapped file -- not a freshly-allocated buffer that GVariant byteswapped
into.
2010-10-03 22:55:39 -04:00
Ryan Lortie
92974b80fc Bug 618737 - "dispatch to context" functionality
Adds a new function g_main_context_invoke() (and _full() variant).

This function takes a main context, a function and a user_data.  If the
main context is already acquired in the current thread, the function is
invoked directly.  If the main context is the default main context of
the current thread and it can be acquired then the function is invoked
directly while the context is owned.  Otherwise, the function is
scheduled as an idle on the context.
2010-10-03 17:34:16 -04:00
Ryan Lortie
fff6814973 Bug 630077 - GDateTime week number support
Fully implement support for ISO 8601 week dates in GDateTime and
document that this is the case.

Add an exhaustive test case to ensure correctness.
2010-10-01 11:20:55 -04:00
Ryan Lortie
1a0dbff236 clean up g_date_time_get_week_day()
No functionality changes here.

Vastly simplify the algorithm for calculating the day of the week.

Fix the documentation (which is incorrectly stating that 1 means
Sunday) and clarify that the number we return is in line with ISO 8601
week day numbering.
2010-09-26 18:53:28 -04:00
Ryan Lortie
02451227ec fix argument order for g_date_time_difference()
The names of the arguments in the header file was reversed.

Closes bug #630000
2010-09-22 06:30:54 -04:00
Philip Withnall
60def049d9 Bug 630185 — Allow NULL strings in g_quark_try_string()
Allow NULL strings to be passed to g_quark_try_string(), returning a 0 quark
in that case, as per the existing documentation. Closes: bgo#630185
2010-09-21 10:35:36 +01:00
Behdad Esfahbod
f1f7e771d7 Fix typo 2010-09-20 22:51:26 -04:00
Colin Walters
291545b6ee gdir: Clarify in documentation that ordering is not defined 2010-09-20 13:25:24 -04:00
Ryan Lortie
cec629972b GDateTime: G_GNUC_WARN_UNUSED_RESULT for modifiers
Emmanuele suggested adding G_GNUC_WARN_UNUSED_RESULT to all of the
g_date_time_add_* functions to help deal with the situation where people
may mistakenly believe that these functions are inplace modifiers.
2010-09-18 16:31:00 -04:00
Ryan Lortie
ac05f990db Fix header cleaup fallout when using system pcre
Using the internal pcre has the side effect of exposing gregex.c to
glib.h.  When we use the system one, we lose that, so we need to
explicitly include the things we use (glist, gatomic, etc..)
2010-09-18 12:52:58 -04:00
Ryan Lortie
6393ffa3a6 GDateTime: fix a test that fails from time to time
The test fails if it's a different date in the time zone of the machine
running the test than it currently is in UTC.
2010-09-18 01:20:22 +03:00
Ryan Lortie
cf73ba47f1 Deal with gtk-doc's insane sensitivty to spaces
...by inserting a few of them.
2010-09-17 13:14:59 -04:00
Ryan Lortie
6b0e31ce48 Clean-up/tweaking of GDateTime and GTimeZone 2010-09-17 11:40:10 -04:00
Emmanuele Bassi
909289c763 datetime: Fix hashing
Convert to the epoch, just like we do when checking for equality, so
that timezones are correctly handled.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-17 11:40:10 -04:00
Emmanuele Bassi
3e9fb52214 datetime: Rename g_date_time_printf() to g_date_time_format()
The function does not use any printf() modifiers, so using printf() is a
misnomer.

Prior art: strftime, g_ascii_formatd

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-17 11:40:10 -04:00
Emmanuele Bassi
4bac6613cf datetime: Update modifiers for DST changes
If a DateTime gets modified to cross the DST state from its previous
state then we want to update the DateTime to compensate for the new
offset.

In other words, if we have a DateTime defined as:

  DateTime({ y: 2009, m: 8, d: 15, hh: 3, mm: 0, tz: 'Europe/London' });

and we add six months to it, the hour must be changed to 60 minutes
behind, as the DST comes into effect.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-17 11:40:10 -04:00
Emmanuele Bassi
0746f74036 datetime: Allow setting fractionary seconds in new_full()
Otherwise we'll have to do:

  dt = g_date_time_new_full (Y, M, D, h, m, s, tz);
  tmp = g_date_time_add_usec (dt, usec);
  g_date_time_unref (dt);
  dt = tmp;

With its additional allocations.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-17 11:40:10 -04:00
Emmanuele Bassi
67f1e52ce2 datetime: Rework time zone support in constructors
Timezone handling is complicated. Really complicated.

In order to simplify it a little bit, we need to expose the GTimeZone
structure.

First of all, we allow creating time zone information directly from the
offset and the DST state, and then pass it to the g_date_time_new_full()
constructor. We also need to clean up the mess that is UTC-vs.-localtime
for the other constructors.

We also allow creating a GTimeZone from the Olson zoneinfo database
names; a time zone created like this will be "floating": it will just
reference the zoneinfo file - which are mmap()'ed, kept in a cache and
refcounted. Once the GTimeZone has been associated with a GDateTime, it
will be "anchored" to it: the offset will be resolved, as well as the
DST state.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-17 11:40:10 -04:00
Ryan Lortie
11f06115a4 Bug 629709 - Empty variants
Fix some GVariant bugs uncovered by calling g_variant_new_from_data with
invalid data (which it should be immune to).
2010-09-15 11:21:44 -04:00
Ryan Lortie
235820d0ef GVariant: Check for size == 0 in get_bytestring
And add a test from David that shows the problem.

Closes #629698
2010-09-14 14:56:38 -04:00
Matthias Clasen
0ecfc6e1f9 Better msgctxt for month and weekday names
The current msgctxt string 'GDateTime" lead to the unability to
differentiate between the full and abbreviated name for May.
Therefore, the msgctxt strings have been changed to
  'full month name'
  'abbreviated month name'
  'full weekday name'
  'abbreviated weekday name'
This is a string change, but all translations have been updated
using an sed script.

Bug 629429
2010-09-13 12:27:04 -04:00
Ryan Lortie
445f708b8f Const 'parser' arg to g_markup_parse_context_push
This is a vtable structure and very likely the user has allocated it in
static storage and wants it to be const.  Since we never modify it, no
harm is done to us to have it const.

Closes bug #629328.
2010-09-13 12:14:08 -04:00
Tomeu Vizoso
124023b06d Make g_variant_builder_end's return to be (allow none) because callers
need to add a ref to it in addition to sinking it.
2010-09-13 17:55:18 +02:00
Kristian Rietveld
8466ba8dc1 Include giochannel.c for G_IO_IN, etc.
Fixes build on OS X.
2010-09-13 16:52:51 +02:00
Tor Lillqvist
8a8cdd1d32 Add some more individual own header includes where required 2010-09-12 14:05:49 +03:00
Tomeu Vizoso
38a3b1730d Add annotation for g_variant_get_string 2010-09-11 17:01:10 +02:00
Tor Lillqvist
dc8dc56ddd dos2unix glib/win_iconv.c 2010-09-11 12:08:32 +03:00
Tor Lillqvist
548ddd5fe9 Fix build on Windows and possibly other non-Linux platforms
Include glibconfig.h in files that test G_OS_WIN32. Include headers
for GLib APIs used conditionally where needed.
2010-09-06 15:57:32 +03:00
Emmanuele Bassi
2aa135ee3d Whitespace fixes 2010-09-06 12:26:40 +01:00
Damien Lespiau
43098d0038 datetime: Rename shadowing variables
timezone and tzname shadow variables declared in time.h. Let's rename
them to time_zone and tz_name then.

https://bugzilla.gnome.org/show_bug.cgi?id=628839
2010-09-06 11:51:11 +01:00
Thiago Santos
875ad12345 gdatetime: Use proleptic gregorian
Use Proleptic Gregorian calendar instead of the Julian calendar
as the internal representation.

https://bugzilla.gnome.org/show_bug.cgi?id=50076

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-06 11:50:30 +01:00
Christian Hergert
6bb89501cf datetime: use g_utf8_next_char() to walk utf8 string
Previously, the format string was iterated many times by
walking to the given offset in the string repeatedly.
This patch instead walks the string using g_utf8_next_char().

Additionally, the character for lookups was a char and could
loose content.  This uses gunichar instead.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-06 11:50:30 +01:00
Christian Hergert
52e44ddec2 datetime: avoid using __year
These were left over from when the inline functions where implemented
as macros.  They are no longer needed and where clashing with the
global __year anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=50076
2010-09-06 11:50:30 +01:00
Emmanuele Bassi
64300c0cc4 datetime: Add get_week_of_year()
https://bugzilla.gnome.org/show_bug.cgi?id=628029

Based on a patch by: Joseph Pingenot

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-06 11:50:30 +01:00
Emmanuele Bassi
70ef2e3bf6 datetime: Rename internal method
Use add_ymd(), to reflect the order of the arguments.
2010-09-06 11:50:30 +01:00
Emmanuele Bassi
959886d95e build: Fix warnings caused by missing includes 2010-09-06 11:43:04 +01:00
Matthias Clasen
f13d561211 More header inclusion cleanup 2010-09-05 00:23:03 -04:00
Emmanuele Bassi
581e68b7d3 gmain: Define _GNU_SOURCE before including glibconfig.h
As it pulls in unistd.h from something else.
2010-09-04 18:15:15 +01:00
Emmanuele Bassi
ca7dee5949 Build fixes for the fall-out of the inclusion changes 2010-09-04 18:04:34 +01:00
Emmanuele Bassi
b1dbcc4023 gtimer: Fix a compilation warning 2010-09-04 18:03:33 +01:00
Emmanuele Bassi
82db1446b3 Add missing gstrfuncs.h include
For g_strdup() and friends.
2010-09-04 17:22:18 +01:00
Matthias Clasen
04077ff5c5 More include cleanups 2010-09-03 23:03:14 -04:00
Matthias Clasen
dc2e46b2aa Don't include glib.h in other headers 2010-09-03 21:24:40 -04:00
Matthias Clasen
2effb8d0ea Remove excessive header includes 2010-09-03 21:20:07 -04:00
Matthias Clasen
7c68050451 Remove excessive header includes 2010-09-03 21:15:45 -04:00
Matthias Clasen
aad1921651 Don't include glib.h in other headers 2010-09-03 21:12:03 -04:00
Matthias Clasen
349aec676c Remove excessive header inclusions 2010-09-03 20:57:05 -04:00
Matthias Clasen
633f438300 Remove excessive header inclusions 2010-09-03 20:55:17 -04:00
Matthias Clasen
7ddd2100c3 Remove excessive header inclusions 2010-09-03 20:53:37 -04:00
Matthias Clasen
5681809448 Remove excessive header inclusions 2010-09-03 20:51:08 -04:00
Matthias Clasen
a376d9f4c8 Remove some unneeded headers 2010-09-03 20:46:40 -04:00
Matthias Clasen
92c577eeff Remove eexcessive header inclusions 2010-09-03 20:44:59 -04:00
Matthias Clasen
0a9eb80798 Remove redundant header inclusions 2010-09-03 20:41:52 -04:00
Matthias Clasen
6e3b14e155 Remove redundant header inclusions 2010-09-03 20:38:30 -04:00
Matthias Clasen
c5049d86f9 Remove redundant header inclusions 2010-09-03 20:34:15 -04:00
Matthias Clasen
96d87da379 Remove redundant header inclusions 2010-09-03 20:30:54 -04:00
Matthias Clasen
3e2f1e3825 Remove redundant header inclusions
and some whitespace cleanup.
2010-09-03 20:27:45 -04:00
Matthias Clasen
8f81ee86ee Remove redundant header inclusions 2010-09-03 20:15:16 -04:00
Matthias Clasen
d95c6b8834 Remove redundant header inclusions 2010-09-03 20:12:09 -04:00
Matthias Clasen
1409bbab67 Remove redundant header inclusions 2010-09-03 20:05:27 -04:00
Matthias Clasen
9471902d4d Remove redundant header inclusions 2010-09-03 20:01:55 -04:00
Matthias Clasen
ebcdbd9555 Remove redundant header inclusions
and clean up some whitespace
2010-09-03 19:49:34 -04:00
Matthias Clasen
9b3fb41a5e Remove redundant header inclusions
and clean up some whitespace
2010-09-03 19:41:49 -04:00
Matthias Clasen
156a3f7195 Whitespace cleanup 2010-09-03 19:38:56 -04:00
Matthias Clasen
8300820f7b Remove redundant header inclusions 2010-09-03 19:37:54 -04:00
Matthias Clasen
5d4ef36f91 Whitespace cleanup 2010-09-03 19:34:28 -04:00
Matthias Clasen
489b780bb9 Remove redundant header inclusions 2010-09-03 19:32:02 -04:00
Tor Lillqvist
6ddef375c8 Recuce DLL hijack risk on Windows
Don't call LoadLibrary() on shell32.dll or kernel32.dll. kernel32.dll
is always loaded. Shell32.dll is also already loaded as glib links to
functions in it. So just call GetModuleHandle() on them.

For mlang.dll in win_iconv.c and winhttp.dll in gwinhttpvfs.c, always
try loading them from a complete path, from the Windows system
directory.

Use the "tool help" API to enumerate modules in gmodule-win32.c. It is
present in all Windows versions since Windows 2000, which is all we
support anyway. Thus no need to look that API up dynamically. Just
link to it normally. We can bin the fallback code that attempts to use
the psapi API.
2010-09-02 22:36:47 +03:00
Jon Nordby
fb15dde6c1 docs: Inline docs from tmpl/memory.smgl 2010-09-01 09:48:16 +02:00
Jens Georg
db7ddcc195 Improve parsing of date-only iso8601 strings 2010-08-26 18:18:52 +03:00
Emmanuele Bassi
9a61fb2c64 datetime: Re-use add_dmy()
Avoid code duplication.
2010-08-26 12:58:19 +01:00
Tor Lillqvist
3c86a77ae5 Fix Win32 build 2010-08-26 12:41:46 +03:00
Matthias Clasen
ca26f9a502 Make this thing work 2010-08-26 00:16:30 -04:00
Matthias Clasen
b52cdaf2f0 Improve g_file_set_contents docs
Mention that the temporary filename is longer than the passed-in
filename, so people can avoid passing a name that is already
NAME_MAX long.
2010-08-26 00:00:56 -04:00
Matthias Clasen
8803182f4a Guarantee that g_get_tmp_dir () doesn't return an empty string
If it does, g_file_open_tmp() would be in trouble. Pointed
out by Morten Welinder in bug 627969.
2010-08-25 20:04:45 -04:00
Emmanuele Bassi
08877ee0dc datetime: Fix a thinko
We need to check if a year is a leap one *after* we increased it with
the given value, not before.
2010-08-25 23:08:18 +01:00
Emmanuele Bassi
026375b395 datetime: Avoid excessive copies in add_full()
The current implementation of g_date_time_add_full() creates multiple
GDateTime temporary objects and unrefs them immediately; even with the
slice allocator this could result in a performance bottleneck,
especially if the atomic integer operations fall back to slow paths.

We can isolate the components of the add_full() operation and create
internal modifiers that operate on an existing GDateTime; this brings
down the number of GDateTime copies created from six to one.

While at it, the test suite for add_full() should have more checks for
roll-over of months and days.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-25 23:04:42 +01:00
Emmanuele Bassi
99621efbd5 docs: Reword the datetime short description 2010-08-25 16:23:34 +01:00
Emmanuele Bassi
5e65ed4e44 datetime: Fix leap year check
Remove a FIXME and an approximation when computing the seconds from
the Unix epoch.
2010-08-25 13:42:48 +01:00
Emmanuele Bassi
2952e908e4 datetime: Fix coding style 2010-08-25 12:24:54 +01:00
Emmanuele Bassi
0a59ab6e85 datetime: Use %Z for the timezone name
We should try and follow strftime(3) for the format control characters
as much as possible.
2010-08-25 12:14:04 +01:00
Emmanuele Bassi
b4c0b958af datetime: Fix the format documentation
The %x format is for the preferred date, and the %X format is for the
preferred time.
2010-08-25 12:09:16 +01:00