[Xfce4-commits] <squeeze:peter/datetime> Changed LSQDateTime from struct tm to manual packed 64 bit
Peter de Ridder
noreply at xfce.org
Sun Oct 9 20:06:01 CEST 2011
Updating branch refs/heads/peter/datetime
to f1786b6561e7d7b3293c5675b385fe467ce6cf6b (commit)
from 15c767a3557acf54ae9dd5bba7e08879aa4f5fd4 (commit)
commit f1786b6561e7d7b3293c5675b385fe467ce6cf6b
Author: Peter de Ridder <peter at xfce.org>
Date: Sun Oct 9 19:51:58 2011 +0200
Changed LSQDateTime from struct tm to manual packed 64 bit
libsqueeze/archive-iter.c | 37 ++----
libsqueeze/datetime.c | 282 +++++++++++++++++---------------------------
libsqueeze/datetime.h | 41 +++----
libsqueeze/pcre-parser.c | 13 +-
libsqueeze/scanf-parser.c | 17 ++--
src/archive_store.c | 10 --
6 files changed, 150 insertions(+), 250 deletions(-)
diff --git a/libsqueeze/archive-iter.c b/libsqueeze/archive-iter.c
index 5b8887b..cac717a 100644
--- a/libsqueeze/archive-iter.c
+++ b/libsqueeze/archive-iter.c
@@ -84,7 +84,7 @@ inline static guint
lsq_archive_entry_get_prop_uint(const LSQArchive *, const LSQArchiveEntry *, guint);
inline static guint64
lsq_archive_entry_get_prop_uint64(const LSQArchive *, const LSQArchiveEntry *, guint);
-inline static const LSQDateTime *
+inline static LSQDateTime
lsq_archive_entry_get_prop_datetime(const LSQArchive *, const LSQArchiveEntry *, guint);
static void
@@ -94,7 +94,7 @@ lsq_archive_entry_set_prop_uint(const LSQArchive *, LSQArchiveEntry *, guint, gu
static void
lsq_archive_entry_set_prop_uint64(const LSQArchive *, LSQArchiveEntry *, guint, guint64);
static void
-lsq_archive_entry_set_prop_datetime(const LSQArchive *, LSQArchiveEntry *, guint, LSQDateTime *);
+lsq_archive_entry_set_prop_datetime(const LSQArchive *, LSQArchiveEntry *, guint, LSQDateTime);
static void
lsq_archive_entry_set_propsv(const LSQArchive *, LSQArchiveEntry *, gpointer *);
static void
@@ -706,7 +706,7 @@ lsq_archive_iter_set_prop_value(LSQArchiveIter *iter, guint n, const GValue *val
default:
if ( LSQ_TYPE_DATETIME == G_VALUE_TYPE(value) )
{
- lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, g_value_dup_datetime(value));
+ lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, g_value_get_datetime(value));
break;
}
break;
@@ -736,7 +736,7 @@ lsq_archive_iter_set_prop(LSQArchiveIter *iter, guint n, gpointer value)
default:
if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(iter->archive, n) )
{
- lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, value);
+ lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, *(LSQDateTime*)value);
break;
}
break;
@@ -1001,16 +1001,6 @@ lsq_archive_entry_props_free(const LSQArchive *archive, LSQArchiveEntry *entry)
g_free(((gchar **)props_iter)[offset]);
((gchar **)props_iter)[offset] = NULL;
break;
-
- default:
- if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
- {
- offset = lsq_archive_get_entry_property_offset(archive, i+LSQ_ARCHIVE_PROP_USER);
- g_free(((LSQDateTime **)props_iter)[offset]);
- ((LSQDateTime **)props_iter)[offset] = NULL;
- break;
- }
- break;
}
}
g_free(entry->props);
@@ -1501,24 +1491,24 @@ lsq_archive_entry_get_prop_uint64(const LSQArchive *archive, const LSQArchiveEnt
return (((guint64 *)props_iter)[offset]);
}
-inline static const LSQDateTime *
+inline static LSQDateTime
lsq_archive_entry_get_prop_datetime(const LSQArchive *archive, const LSQArchiveEntry *entry, guint i)
{
gpointer props_iter = entry->props;
guint offset;
if ( NULL == props_iter )
{
- return NULL;
+ return 0;
}
if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type(archive, i) )
{
- return NULL;
+ return 0;
}
offset = lsq_archive_get_entry_property_offset(archive, i);
- return (((LSQDateTime **)props_iter)[offset]);
+ return (((LSQDateTime *)props_iter)[offset]);
}
static gpointer
@@ -1586,7 +1576,7 @@ lsq_archive_entry_set_prop_uint64(const LSQArchive *archive, LSQArchiveEntry *en
}
static void
-lsq_archive_entry_set_prop_datetime(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, LSQDateTime *dt_val)
+lsq_archive_entry_set_prop_datetime(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, LSQDateTime dt_val)
{
gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
guint offset;
@@ -1598,8 +1588,7 @@ lsq_archive_entry_set_prop_datetime(const LSQArchive *archive, LSQArchiveEntry *
offset = lsq_archive_get_entry_property_offset(archive, n);
- g_free(((LSQDateTime **)props_iter)[offset]);
- ((LSQDateTime **)props_iter)[offset] = dt_val; /* We take ownership */
+ ((LSQDateTime *)props_iter)[offset] = dt_val; /* We take ownership */
}
static void
@@ -1628,8 +1617,7 @@ lsq_archive_entry_set_propsv(const LSQArchive *archive, LSQArchiveEntry *entry,
default:
if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
{
- g_free(((LSQDateTime **)props_iter)[offset]);
- ((LSQDateTime **)props_iter)[offset] = (LSQDateTime*)props[i]; /* We take ownership */
+ ((LSQDateTime *)props_iter)[offset] = *(LSQDateTime*)props[i];
break;
}
break;
@@ -1662,8 +1650,7 @@ lsq_archive_entry_set_propsva(const LSQArchive *archive, LSQArchiveEntry *entry,
default:
if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
{
- g_free(((LSQDateTime **)props_iter)[offset]);
- ((LSQDateTime **)props_iter)[offset] = va_arg(ap, LSQDateTime*); /* We take ownership */
+ ((LSQDateTime *)props_iter)[offset] = va_arg(ap, LSQDateTime);
break;
}
break;
diff --git a/libsqueeze/datetime.c b/libsqueeze/datetime.c
index 2989a00..1a120c7 100644
--- a/libsqueeze/datetime.c
+++ b/libsqueeze/datetime.c
@@ -32,19 +32,35 @@
#include "internals.h"
+#define TM_SEC_SIZE (6)
+#define TM_MIN_SIZE (6)
+#define TM_HOUR_SIZE (5)
+#define TM_MDAY_SIZE (5)
+#define TM_MON_SIZE (4)
+#define TM_YEAR_SIZE (64 - TM_SEC_SIZE - TM_MIN_SIZE - TM_HOUR_SIZE - TM_MDAY_SIZE - TM_MON_SIZE - TM_WDAY_SIZE - TM_YDAY_SIZE - TM_ISDST_SIZE)
+#define TM_WDAY_SIZE (3)
+#define TM_YDAY_SIZE (9)
+#define TM_ISDST_SIZE (2)
+
+#define TM_SEC_OFFSET (0)
+#define TM_MIN_OFFSET (TM_SEC_OFFSET + TM_SEC_SIZE)
+#define TM_HOUR_OFFSET (TM_MIN_OFFSET + TM_MIN_SIZE)
+#define TM_MDAY_OFFSET (TM_HOUR_OFFSET + TM_HOUR_SIZE)
+#define TM_MON_OFFSET (TM_MDAY_OFFSET + TM_MDAY_SIZE)
+#define TM_YEAR_OFFSET (TM_MON_OFFSET + TM_MON_SIZE)
+#define TM_WDAY_OFFSET (TM_YEAR_OFFSET + TM_YEAR_SIZE)
+#define TM_YDAY_OFFSET (TM_WDAY_OFFSET + TM_WDAY_SIZE)
+#define TM_ISDST_OFFSET (TM_YDAY_OFFSET + TM_YDAY_SIZE)
+
+#define TM_X_MAKE(x,v) (((guint64)((v) & ((1<<(TM_##x##_SIZE)) - 1))) << (TM_##x##_OFFSET))
+#define TM_X_GET(x,v) (((v) >> (TM_##x##_OFFSET)) & ((1<<(TM_##x##_SIZE)) - 1))
+#define TM_X_MASK(x) (((guint64)((1<<(TM_##x##_SIZE)) - 1)) << (TM_##x##_OFFSET))
+#define LSQ_DATETIME_CMP_MASK(v) ((v)&(TM_X_MASK(YEAR)|TM_X_MASK(MON)|TM_X_MASK(MDAY)|TM_X_MASK(HOUR)|TM_X_MASK(MIN)|TM_X_MASK(SEC)))
+
static void
value_init_datetime ( GValue *value )
{
- value->data[0].v_pointer = NULL;
-}
-
-static void
-value_free_datetime ( GValue *value )
-{
- if ( ! ( value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS ) )
- {
- g_free( value->data[0].v_pointer );
- }
+ value->data[0].v_int64 = LSQ_DATETIME_NULL;
}
static void
@@ -52,19 +68,7 @@ value_copy_datetime (
const GValue *src_value,
GValue *dest_value )
{
- LSQDateTime *copy = NULL;
- if ( NULL != src_value->data[0].v_pointer )
- {
- copy = g_new( LSQDateTime, 1 );
- *copy = *LSQ_DATETIME(src_value->data[0].v_pointer);
- }
- dest_value->data[0].v_pointer = copy;
-}
-
-static gpointer
-value_peek_datetime ( const GValue *value )
-{
- return value->data[0].v_pointer;
+ dest_value->data[0].v_int64 = src_value->data[0].v_int64;
}
static gchar *
@@ -74,25 +78,7 @@ value_collect_datetime (
GTypeCValue *collect_values,
guint collect_flags )
{
- if ( NULL == collect_values[0].v_pointer )
- {
- value->data[0].v_pointer = NULL;
- }
- else if ( collect_flags & G_VALUE_NOCOPY_CONTENTS )
- {
- value->data[0].v_pointer = collect_values[0].v_pointer;
- value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
- }
- else
- {
- LSQDateTime *copy = NULL;
- if ( NULL != collect_values[0].v_pointer )
- {
- copy = g_new( LSQDateTime, 1 );
- *copy = *LSQ_DATETIME(collect_values[0].v_pointer);
- }
- value->data[0].v_pointer = copy;
- }
+ value->data[0].v_int64 = collect_values[0].v_int64;
return NULL;
}
@@ -104,31 +90,12 @@ value_lcopy_datetime (
GTypeCValue *collect_values,
guint collect_flags )
{
- LSQDateTime **dt_p = collect_values[0].v_pointer;
+ gint64 *int64_p = collect_values[0].v_pointer;
- if ( NULL == dt_p )
- {
+ if (!int64_p)
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
- }
- if ( NULL == value->data[0].v_pointer)
- {
- *dt_p = NULL;
- }
- else if ( collect_flags & G_VALUE_NOCOPY_CONTENTS )
- {
- *dt_p = value->data[0].v_pointer;
- }
- else
- {
- LSQDateTime *copy = NULL;
- if ( NULL != value->data[0].v_pointer )
- {
- copy = g_new( LSQDateTime, 1 );
- *copy = *LSQ_DATETIME(value->data[0].v_pointer);
- }
- *dt_p = copy;
- }
+ *int64_p = value->data[0].v_int64;
return NULL;
}
@@ -138,11 +105,14 @@ value_datetime_to_string (
const GValue *src_value,
GValue *dest_value )
{
- gchar buffer[200]; /* An abitrary size to fit the time string in */
- const LSQDateTime *dt = g_value_get_datetime( src_value );
- if ( NULL != dt )
+ gchar buffer[80]; /* An abitrary size to fit the time string in */
+ struct tm timeval;
+ LSQDateTime dt = g_value_get_datetime( src_value );
+
+ if ( LSQ_DATETIME_NULL != dt )
{
- strftime( buffer, sizeof(buffer), "%c", dt );
+ lsq_datetime_to_tm( dt, &timeval );
+ strftime( buffer, sizeof(buffer), "%c", &timeval );
g_value_set_string( dest_value, buffer );
}
}
@@ -156,10 +126,10 @@ lsq_datetime_get_type ( void )
{
GTypeValueTable value_table = {
value_init_datetime,
- value_free_datetime,
+ NULL,
value_copy_datetime,
- value_peek_datetime,
- "p",
+ NULL,
+ "q",
value_collect_datetime,
"p",
value_lcopy_datetime
@@ -204,141 +174,107 @@ lsq_datetime_register_type ( void )
type = lsq_datetime_get_type();
}
-LSQDateTime *
-lsq_datetime_new_from_string (
+LSQDateTime
+lsq_datetime_from_tm ( const struct tm *timeval )
+{
+ g_return_val_if_fail( NULL != timeval, LSQ_DATETIME_NULL );
+
+ return (
+ TM_X_MAKE( SEC, timeval->tm_sec ) |
+ TM_X_MAKE( MIN, timeval->tm_min ) |
+ TM_X_MAKE( HOUR, timeval->tm_hour ) |
+ TM_X_MAKE( MDAY, timeval->tm_mday ) |
+ TM_X_MAKE( MON, timeval->tm_mon ) |
+ TM_X_MAKE( YEAR, timeval->tm_year ) |
+ TM_X_MAKE( WDAY, timeval->tm_wday ) |
+ TM_X_MAKE( YDAY, timeval->tm_yday ) |
+ TM_X_MAKE( ISDST, timeval->tm_isdst ));
+}
+
+LSQDateTime
+lsq_datetime_from_string (
const gchar *str,
const gchar *format,
gchar **endp )
{
- LSQDateTime *dt;
+ struct tm timeval;
+ LSQDateTime dt = LSQ_DATETIME_NULL;
- g_return_val_if_fail( NULL != str, NULL );
- g_return_val_if_fail( NULL != format, NULL );
+ g_return_val_if_fail( NULL != str, LSQ_DATETIME_NULL );
+ g_return_val_if_fail( NULL != format, LSQ_DATETIME_NULL );
- /* we don't expect it to fail, so the chance of an unnecessary alloc isn't high,
- * if it would fail most of the time, a read to stack and copy to a alloc on success would be better. */
- dt = g_new0( LSQDateTime, 1 );
+ str = strptime( str, format, &timeval );
- str = strptime( str, format, dt );
-
- if ( G_UNLIKELY( NULL == str ) )
- {
- g_free( dt );
- dt = NULL;
- }
- else if ( NULL != endp )
+ if ( G_LIKELY( NULL != str ) )
{
- *endp = (gchar*)str;
+ if ( NULL != endp )
+ {
+ *endp = (gchar*)str;
+ }
+
+ dt = lsq_datetime_from_tm( &timeval );
}
return dt;
}
-gchar *
-lsq_datetime_from_string (
- LSQDateTime *dt,
- const gchar *str,
- const gchar *format )
+void
+lsq_datetime_to_tm ( LSQDateTime dt, struct tm *timeval )
{
- g_return_val_if_fail( NULL != dt, NULL );
- g_return_val_if_fail( NULL != str, NULL );
- g_return_val_if_fail( NULL != format, NULL );
-
- return strptime( str, format, dt );
+ g_return_if_fail( LSQ_DATETIME_NULL!= dt );
+ g_return_if_fail( NULL != timeval );
+
+ memset( timeval, 0, sizeof(struct tm) );
+
+ timeval->tm_sec = TM_X_GET( SEC, dt );
+ timeval->tm_min = TM_X_GET( MIN, dt );
+ timeval->tm_hour = TM_X_GET( HOUR, dt );
+ timeval->tm_mday = TM_X_GET( MDAY, dt );
+ timeval->tm_mon = TM_X_GET( MON, dt );
+ timeval->tm_year = TM_X_GET( YEAR, dt );
+ timeval->tm_wday = TM_X_GET( WDAY, dt );
+ timeval->tm_yday = TM_X_GET( YDAY, dt );
+ timeval->tm_isdst = TM_X_GET( ISDST, dt );
}
gint
lsq_datetime_cmp (
- const LSQDateTime *a,
- const LSQDateTime *b )
+ LSQDateTime a,
+ LSQDateTime b )
{
- g_return_val_if_fail( NULL != a, 0 );
- g_return_val_if_fail( NULL != b, 0 );
+ gint cmp;
- return difftime( mktime( (struct tm*)a ), mktime( (struct tm*)b ) );
-}
+ if ( a == b )
+ return 0;
-const LSQDateTime *
-g_value_get_datetime ( const GValue *value )
-{
- g_return_val_if_fail( G_VALUE_HOLDS_DATETIME( value ), NULL );
+ if ( LSQ_DATETIME_NULL == a )
+ return -1;
+ if ( LSQ_DATETIME_NULL == b )
+ return 1;
- return value->data[0].v_pointer;
+ /* Ignoring daylight saveing */
+ cmp = LSQ_DATETIME_CMP_MASK( a ) - LSQ_DATETIME_CMP_MASK( b );
+ if ( 0 != cmp )
+ return cmp;
+
+ return difftime( mktime( (struct tm*)a ), mktime( (struct tm*)b ) );
}
-LSQDateTime *
-g_value_dup_datetime ( const GValue *value )
+LSQDateTime
+g_value_get_datetime ( const GValue *value )
{
- LSQDateTime *copy = NULL;
-
- g_return_val_if_fail( G_VALUE_HOLDS_DATETIME( value ), NULL );
-
- if ( NULL != value->data[0].v_pointer )
- {
- copy = g_new( LSQDateTime, 1 );
- *copy = *LSQ_DATETIME(value->data[0].v_pointer);
- }
+ g_return_val_if_fail( G_VALUE_HOLDS_DATETIME( value ), LSQ_DATETIME_NULL );
- return copy;
+ return value->data[0].v_int64;
}
void
g_value_set_datetime (
GValue *value,
- const LSQDateTime *dt )
+ LSQDateTime v_dt )
{
- LSQDateTime *new_val = NULL;
-
g_return_if_fail( G_VALUE_HOLDS_DATETIME( value ) );
- if ( NULL != dt )
- {
- new_val = g_new( LSQDateTime, 1 );
- *new_val = *LSQ_DATETIME(dt);
- }
-
- if ( value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS )
- {
- value->data[1].v_uint = 0;
- }
- else
- {
- g_free( value->data[0].v_pointer );
- }
-
- value->data[0].v_pointer = new_val;
-}
-
-void
-g_value_set_static_datetime (
- GValue *value,
- const gchar *dt )
-{
- g_return_if_fail( G_VALUE_HOLDS_STRING( value ) );
-
- if ( ! ( value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS ) )
- {
- g_free (value->data[0].v_pointer);
- }
- value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
- value->data[0].v_pointer = LSQ_DATETIME(dt);
-}
-
-void
-g_value_take_datetime (
- GValue *value,
- LSQDateTime *dt )
-{
- g_return_if_fail( G_VALUE_HOLDS_STRING( value ) );
-
- if ( value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
- {
- value->data[1].v_uint = 0;
- }
- else
- {
- g_free( value->data[0].v_pointer );
- }
- value->data[0].v_pointer = dt;
+ value->data[0].v_int64 = v_dt;
}
diff --git a/libsqueeze/datetime.h b/libsqueeze/datetime.h
index 8ade25e..fbc534c 100644
--- a/libsqueeze/datetime.h
+++ b/libsqueeze/datetime.h
@@ -20,11 +20,13 @@ G_BEGIN_DECLS
#define LSQ_TYPE_DATETIME lsq_datetime_get_type()
-#define LSQ_DATETIME(p) ((LSQDateTime*)(p))
+#define LSQ_DATETIME(v) ((LSQDateTime)(v))
+
+#define LSQ_DATETIME_NULL (LSQ_DATETIME(0))
#define G_VALUE_HOLDS_DATETIME(value) (G_TYPE_CHECK_VALUE_TYPE((value), LSQ_TYPE_DATETIME))
-typedef struct tm LSQDateTime;
+typedef gint64 LSQDateTime;
GType
lsq_datetime_get_type ( void ) G_GNUC_CONST;
@@ -32,43 +34,30 @@ lsq_datetime_get_type ( void ) G_GNUC_CONST;
void
lsq_datetime_register_type ( void );
-LSQDateTime *
-lsq_datetime_new_from_string (
+LSQDateTime
+lsq_datetime_from_tm ( const struct tm * );
+
+LSQDateTime
+lsq_datetime_from_string (
const gchar *,
const gchar *,
gchar ** );
-gchar *
-lsq_datetime_from_string (
- LSQDateTime *,
- const gchar *,
- const gchar * );
+void
+lsq_datetime_to_tm ( LSQDateTime, struct tm * );
gint
lsq_datetime_cmp (
- const LSQDateTime *,
- const LSQDateTime * );
+ LSQDateTime,
+ LSQDateTime );
-const LSQDateTime *
+LSQDateTime
g_value_get_datetime ( const GValue * );
-LSQDateTime *
-g_value_dup_datetime ( const GValue * );
-
void
g_value_set_datetime (
GValue *,
- const LSQDateTime * );
-
-void
-g_value_set_static_datetime (
- GValue *,
- const gchar * );
-
-void
-g_value_take_datetime (
- GValue *,
- LSQDateTime * );
+ LSQDateTime );
G_END_DECLS
diff --git a/libsqueeze/pcre-parser.c b/libsqueeze/pcre-parser.c
index 2853f5c..c98769f 100644
--- a/libsqueeze/pcre-parser.c
+++ b/libsqueeze/pcre-parser.c
@@ -190,21 +190,20 @@ parse_string( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParse
static void
parse_datetime( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
{
- LSQDateTime *val;
+ LSQDateTime val;
#ifdef DO_EXSTENSIVE_CHECKING
gchar *end;
- val = lsq_datetime_new_from_string( str, LSQ_PARSER(parser)->datetime_format, *end);
- if ( val && ( end - str ) > lng )
+ val = lsq_datetime_from_string( str, LSQ_PARSER(parser)->datetime_format, *end);
+ if ( LSQ_DATETIME_NULL != val && ( end - str ) > lng )
{
- g_free( val );
- val = NULL;
+ val = LSQ_DATETIME_NULL;
}
#else
- val = lsq_datetime_new_from_string( str, LSQ_PARSER(parser)->datetime_format, NULL);
+ val = lsq_datetime_from_string( str, LSQ_PARSER(parser)->datetime_format, NULL);
#endif
- lsq_archive_iter_set_prop( iter, n, val );
+ lsq_archive_iter_set_prop( iter, n, &val );
}
DEF_PARSE_UNS(unsigned, 10, guint)
diff --git a/libsqueeze/scanf-parser.c b/libsqueeze/scanf-parser.c
index 6c80a2a..873c9af 100644
--- a/libsqueeze/scanf-parser.c
+++ b/libsqueeze/scanf-parser.c
@@ -60,6 +60,7 @@ struct _LSQScanfParserContext
guint64 ull;
gfloat f;
gdouble d;
+ LSQDateTime dt;
} *data_store;
gpointer *props_store;
parse_part *parse_loc;
@@ -476,7 +477,6 @@ skip_datetime (
gchar *ptr;
gchar *cur;
const gchar *delim;
- LSQDateTime val;
if ( 0 == lng )
{
@@ -493,7 +493,7 @@ skip_datetime (
{
}
- ptr = lsq_datetime_from_string(&val, cur, LSQ_PARSER(parser)->datetime_format);
+ lsq_datetime_from_string(cur, LSQ_PARSER(parser)->datetime_format, &ptr);
if ( NULL == ptr )
{
return 0;
@@ -845,7 +845,7 @@ parse_datetime (
gchar *ptr;
gchar *cur;
const gchar *delim;
- LSQDateTime *val;
+ LSQDateTime *pval;
if ( 0 == lng )
{
@@ -862,25 +862,24 @@ parse_datetime (
{
}
- val = lsq_datetime_new_from_string( cur, LSQ_PARSER(parser)->datetime_format, &ptr );
- if ( NULL == val )
+ pval = &ctx->data_store[part->index_].dt;
+ ctx->props_store[part->index_] = pval;
+
+ *pval = lsq_datetime_from_string( cur, LSQ_PARSER(parser)->datetime_format, &ptr );
+ if ( LSQ_DATETIME_NULL == *pval )
return 0;
if ( ( ptr - str ) > lng )
{
- g_free( val );
return 0;
}
- ctx->props_store[ part->index_ ] = val;
-
if ( '\0' == delim[0] )
{
lng -= ptr - str;
ptr = g_strstr_len ( ptr, lng, delim );
if ( NULL == ptr )
{
- g_free( val );
return 0;
}
}
diff --git a/src/archive_store.c b/src/archive_store.c
index 56787f6..03f8e74 100644
--- a/src/archive_store.c
+++ b/src/archive_store.c
@@ -894,16 +894,6 @@ sq_archive_entry_compare(SQArchiveStore *store, LSQArchiveIter *a, LSQArchiveIte
default:
if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, column) )
{
- if(g_value_get_datetime(&prop_a) == NULL)
- {
- retval = ( NULL == g_value_get_datetime( &prop_b ) ) ? 0 : -1;
- break;
- }
- if(g_value_get_datetime(&prop_b) == NULL)
- {
- retval = 1;
- break;
- }
retval = lsq_datetime_cmp( g_value_get_datetime(&prop_a), g_value_get_datetime(&prop_b) );
break;
}
More information about the Xfce4-commits
mailing list