# HG changeset patch # User rosfran # Date 1161209336 -3600 # Node ID 79fca2122593bbb26517bc4c908bca50ecb4a800 # Parent 6b9c77b9817ec2f51278fed206f4eedeeae56ee2 [svn r34] Fixes the gmyth_stringlist getuint64 function (problems on bitwise operations). diff -r 6b9c77b9817e -r 79fca2122593 gmyth/src/gmyth_stringlist.c --- a/gmyth/src/gmyth_stringlist.c Wed Oct 18 20:38:47 2006 +0100 +++ b/gmyth/src/gmyth_stringlist.c Wed Oct 18 23:08:56 2006 +0100 @@ -116,12 +116,13 @@ { GString *tmp_str1 = g_string_new (""); GString *tmp_str2 = g_string_new (""); + g_print( "[%s]\tseek value = %llu.\n", __FUNCTION__, value ); - glong l2 = ( (guint64)value & 0xffffffff ); - glong l1 = ( (guint64)value >> 32 ); + gulong l2 = ( (guint64)value & 0xffffffff ); + gulong l1 = ( (guint64)value >> 32 ); /* high order part of guint64 value */ - g_string_printf (tmp_str1, "%ld", l1); + g_string_printf (tmp_str1, "%lu", l1); g_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str ); @@ -129,7 +130,7 @@ strlist->glist = g_list_append( strlist->glist, tmp_str1 ); /* low order part of guint64 value */ - g_string_printf (tmp_str2, "%ld", l2); + g_string_printf (tmp_str2, "%lu", l2); g_debug( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str ); @@ -215,16 +216,29 @@ { //TODO: Create static method check_index() guint64 ret_value = 0; + guint64 l2 = 0; g_return_val_if_fail( strlist != NULL, 0 ); const GString *tmp_str1 = (GString *) g_list_nth_data (strlist->glist, index); const GString *tmp_str2 = (GString *) g_list_nth_data (strlist->glist, index+1); + + if ( tmp_str1 != NULL ) + g_print( "[%s] seek high bytes = %s\n", __FUNCTION__, tmp_str1->str ); + if ( tmp_str2 == NULL || strlen( tmp_str2->str ) > 0 ) { + } else { + g_print( "[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str ); + } - glong l1 = (glong)g_ascii_strtoull (tmp_str1->str, NULL, 10); - glong l2 = (glong)g_ascii_strtoull (tmp_str2->str, NULL, 10); + guint64 l1 = ( (guint64)g_ascii_strtoull (tmp_str1->str, NULL, 10) & 0xffffffff ); + if ( tmp_str2 != NULL && tmp_str2->str != NULL && strlen(tmp_str2->str) > 0 ) { + l2 = ( (guint64)g_ascii_strtoull (tmp_str2->str, NULL, 10) & 0xffffffff ); + } else { + l2 = l1; + l1 = 0; + } - g_print ( "[%s]\t[l1 == %ld, l2 == %ld]\n", __FUNCTION__, l1, l2 ); + g_print ( "[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2 ); ret_value = ((guint64)(l2) /*& 0xffffffff*/) | ((guint64)l1 << 32);