[svn r34] Fixes the gmyth_stringlist getuint64 function (problems on bitwise operations). trunk
authorrosfran
Wed Oct 18 23:08:56 2006 +0100 (2006-10-18)
branchtrunk
changeset 3379fca2122593
parent 32 6b9c77b9817e
child 34 c71d37b93734
[svn r34] Fixes the gmyth_stringlist getuint64 function (problems on bitwise operations).
gmyth/src/gmyth_stringlist.c
     1.1 --- a/gmyth/src/gmyth_stringlist.c	Wed Oct 18 20:38:47 2006 +0100
     1.2 +++ b/gmyth/src/gmyth_stringlist.c	Wed Oct 18 23:08:56 2006 +0100
     1.3 @@ -116,12 +116,13 @@
     1.4  {
     1.5  	GString *tmp_str1 = g_string_new ("");
     1.6  	GString *tmp_str2 = g_string_new ("");
     1.7 +	g_print( "[%s]\tseek value = %llu.\n", __FUNCTION__, value );
     1.8  
     1.9 -	glong l2 = ( (guint64)value & 0xffffffff  );
    1.10 -	glong l1 = ( (guint64)value >> 32  );
    1.11 +	gulong l2 = ( (guint64)value & 0xffffffff  );
    1.12 +	gulong l1 = ( (guint64)value >> 32 );
    1.13    
    1.14  	/* high order part of guint64 value */
    1.15 -	g_string_printf (tmp_str1, "%ld", l1);
    1.16 +	g_string_printf (tmp_str1, "%lu", l1);
    1.17  	
    1.18  	g_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
    1.19  
    1.20 @@ -129,7 +130,7 @@
    1.21  	strlist->glist = g_list_append( strlist->glist, tmp_str1 );
    1.22  
    1.23   	/* low order part of guint64 value */
    1.24 -	g_string_printf (tmp_str2, "%ld", l2);
    1.25 +	g_string_printf (tmp_str2, "%lu", l2);
    1.26  
    1.27  	g_debug( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
    1.28  
    1.29 @@ -215,16 +216,29 @@
    1.30  {
    1.31  	//TODO: Create static method check_index()
    1.32  	guint64 ret_value = 0;
    1.33 +	guint64 l2 = 0;
    1.34  
    1.35  	g_return_val_if_fail( strlist != NULL, 0 );
    1.36    
    1.37  	const GString *tmp_str1 = (GString *) g_list_nth_data (strlist->glist, index);
    1.38  	const GString *tmp_str2 = (GString *) g_list_nth_data (strlist->glist, index+1);
    1.39 +
    1.40 +	if ( tmp_str1 != NULL )
    1.41 +		g_print( "[%s] seek high bytes = %s\n", __FUNCTION__, tmp_str1->str );
    1.42 +	if ( tmp_str2 == NULL || strlen( tmp_str2->str ) > 0 ) {
    1.43 +	} else {
    1.44 +		g_print( "[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str );
    1.45 +	}
    1.46  	
    1.47 -	glong l1 = (glong)g_ascii_strtoull (tmp_str1->str, NULL, 10);
    1.48 -	glong l2 = (glong)g_ascii_strtoull (tmp_str2->str, NULL, 10);
    1.49 +	guint64 l1 = ( (guint64)g_ascii_strtoull (tmp_str1->str, NULL, 10) & 0xffffffff  );
    1.50 +	if ( tmp_str2 != NULL && tmp_str2->str != NULL && strlen(tmp_str2->str) > 0 ) {
    1.51 +		l2 = ( (guint64)g_ascii_strtoull (tmp_str2->str, NULL, 10) & 0xffffffff  );
    1.52 +	} else {
    1.53 +		l2 = l1;
    1.54 +		l1 = 0;
    1.55 +	}
    1.56  
    1.57 -	g_print ( "[%s]\t[l1 == %ld, l2 == %ld]\n", __FUNCTION__, l1, l2 );
    1.58 +	g_print ( "[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2 );
    1.59  	
    1.60  	ret_value = ((guint64)(l2) /*& 0xffffffff*/) | ((guint64)l1 << 32);
    1.61