[gnome-db] [PATCH] gda-value.c



Hi,

This fixes a few bugs and compilation warnings in gda-value.c.

Bob

-- 
Bob Ham <rah bash sh>
Index: gda-value.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-value.c,v
retrieving revision 1.76
diff -u -u -p -r1.76 gda-value.c
--- gda-value.c	7 Oct 2005 13:15:12 -0000	1.76
+++ gda-value.c	23 Nov 2005 18:55:34 -0000
@@ -125,7 +125,7 @@ set_from_string (GdaValue *value, const 
 		break;
 
 	case GDA_VALUE_TYPE_BINARY:
-		binary.data = as_string;
+		binary.data = (gchar *) as_string;
 		binary.binary_length = strlen (as_string);
 		gda_value_set_binary (value, &binary);
 		break;
@@ -1021,8 +1021,8 @@ gda_timestamp_copy (gpointer boxed)
 	copy->month = src->month;
 	copy->day = src->day;
 	copy->hour = src->hour;
-	copy->minute = src->hour;
-	copy->second = src->hour;
+	copy->minute = src->minute;
+	copy->second = src->second;
 	copy->fraction = src->fraction;
 	copy->timezone = src->timezone;
 	
@@ -1053,16 +1053,23 @@ gda_value_new_timestamp_from_timet (time
 	value = g_new0 (GdaValue, 1);
 	ltm = localtime ((const time_t *) &val);
 	if (ltm) {
+	        printf ("%s: hour: %d, minute: %d, second: %d\n", __FUNCTION__, ltm->tm_hour, ltm->tm_min, ltm->tm_sec);
 		GdaTimestamp tstamp;
-		tstamp.year = ltm->tm_year;
-		tstamp.month = ltm->tm_mon;
+		tstamp.year = 1900 + ltm->tm_year;
+		tstamp.month = ltm->tm_mon + 1;
 		tstamp.day = ltm->tm_mday;
 		tstamp.hour = ltm->tm_hour;
 		tstamp.minute = ltm->tm_min;
 		tstamp.second = ltm->tm_sec;
 		tstamp.fraction = 0;
 		tstamp.timezone = 0; /* FIXME */
+	        printf ("%s: hour: %u, minute: %u, second: %u\n", __FUNCTION__, tstamp.hour, tstamp.minute, tstamp.second);
 		gda_value_set_timestamp (value, (const GdaTimestamp *) &tstamp);
+		{
+		  const GdaTimestamp * t;
+		  t = gda_value_get_timestamp (value);
+		  printf ("%s: hour: %u, minute: %u, second: %u\n", __FUNCTION__, t->hour, t->minute, t->second);
+		}
 	}
 
 	return value;
@@ -1269,12 +1276,15 @@ gda_value_is_number (GdaValue *value)
 	type = GDA_VALUE_TYPE(value);
 	switch (type) {
 	case GDA_VALUE_TYPE_BIGINT:
+	case GDA_VALUE_TYPE_BIGUINT:
 	case GDA_VALUE_TYPE_DOUBLE:
 	case GDA_VALUE_TYPE_INTEGER:
+	case GDA_VALUE_TYPE_UINTEGER:
 	case GDA_VALUE_TYPE_MONEY:
 	case GDA_VALUE_TYPE_NUMERIC:
 	case GDA_VALUE_TYPE_SINGLE:
 	case GDA_VALUE_TYPE_SMALLINT:
+	case GDA_VALUE_TYPE_SMALLUINT:
 	case GDA_VALUE_TYPE_TINYINT:
 	case GDA_VALUE_TYPE_TINYUINT:
 		return TRUE;
@@ -1285,6 +1295,7 @@ gda_value_is_number (GdaValue *value)
     }
 }
 
+
 /**
  * gda_value_copy
  * @value: value to get a copy from.
@@ -1440,13 +1451,9 @@ gda_value_set_blob (GdaValue *value, con
 	g_return_if_fail (value);
 	g_return_if_fail (GDA_IS_BLOB (val));
 	
-	GdaBlob *blob;
 	l_g_value_unset (value);
 	g_value_init (value, G_VALUE_TYPE_BLOB);
-	
-	blob = g_object_ref (val);
-		
-	g_value_set_object (value, blob);
+	g_value_take_object (value, (gpointer) val);
 }
 
 /**
@@ -2245,7 +2252,7 @@ gda_value_stringify (GdaValue *value)
 	
 	case GDA_VALUE_TYPE_BLOB:
 		gdablob = gda_value_get_blob (value);
-		retval = g_strdup_printf ("%s", gda_blob_get_sql_id (gdablob));
+		retval = g_strdup_printf ("%s", gda_blob_get_sql_id ((GdaBlob *) gdablob));
 		break;
 
 	case GDA_VALUE_TYPE_LIST:
@@ -2338,8 +2345,8 @@ gda_value_compare (GdaValue *value1, Gda
 
 	case GDA_VALUE_TYPE_BINARY:
 	{
-		GdaBinary *binary1 = gda_value_get_binary (value1);
-		GdaBinary *binary2 = gda_value_get_binary (value2);
+		GdaBinary *binary1 = (GdaBinary *) gda_value_get_binary (value1);
+		const GdaBinary *binary2 = gda_value_get_binary (value2);
 		if(binary1 && binary2 && (binary1->binary_length == binary2->binary_length))
 		    retval = memcmp (binary1->data, binary2->data, binary1->binary_length) ;
 		else
@@ -2406,7 +2413,7 @@ gda_value_compare (GdaValue *value1, Gda
 
 	case GDA_VALUE_TYPE_MONEY:
 	{
-		GdaMoney *money1, *money2;
+		const GdaMoney *money1, *money2;
 		money1 = gda_value_get_money(value1);
 		money2 = gda_value_get_money(value2);
 		if (!strcmp (money1->currency ? money2->currency : "",
@@ -2420,7 +2427,7 @@ gda_value_compare (GdaValue *value1, Gda
 
 	case GDA_VALUE_TYPE_NUMERIC:
 	{
-		GdaNumeric *num1, *num2;
+		const GdaNumeric *num1, *num2;
 		num1= gda_value_get_numeric (value1);
 		num2 = gda_value_get_numeric (value2);
                 if (num1) {
@@ -2452,7 +2459,7 @@ gda_value_compare (GdaValue *value1, Gda
 
 	case GDA_VALUE_TYPE_STRING:
 	{
-		gchar *str1, *str2;
+		const gchar *str1, *str2;
 		str1 = gda_value_get_string (value1);
 		str2 = gda_value_get_string (value2);
 		if (str1 && str2)

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]