*** C:\Lars\Ethereal-Dev\ethereal-2004-01-26\gtk\gtk_stat_util.c	Thu Aug 21 19:48:04 2003
--- C:\Lars\Ethereal-Dev\ethereal-dev\gtk\gtk_stat_util.c	Tue Jan 27 14:04:29 2004
***************
*** 122,124 ****
--- 122,167 ----
  	return table;
  }
  
+ 
+ /*
+ * Compares two strings representing float values.
+ * Assume strings are in decimal, non-scientific notation
+ * and the dot '.' is the decimal separator.
+ */
+ int
+ float_strcmp( const char *string1, const char *string2 )
+ {
+ 	/* comparison-depth of decimal fraction is limited by the mask given for rX */
+ 	char r1[] = "00000000000000.00000000000000";
+ 	char r2[] = "00000000000000.00000000000000";
+ 	const char* t1 = strchr( r1, '.' );
+ 	const char* t2 = strchr( r2, '.' );
+ 	const char* p1 = strchr( string1, '.' );
+ 	const char* p2 = strchr( string2, '.' );
+ 
+ 	/* security checks */
+ 	g_assert(string1!=NULL);
+ 	g_assert(string2!=NULL);
+ 
+ 	/* check signs. assumes negative numbers start with '-' */
+ 	/* one of the numbers negative? easy: negative numbers come first */
+ 	if ((*string1 == '-') && (*string2 != '-'))
+ 		return -1;
+ 	if ((*string1 != '-') && (*string2 == '-'))
+ 		return 1;
+ 	/* both negative? */
+ 	if ((*string1 == '-') && (*string2 == '-'))
+ 		/* compare absolute values in reverse order. WARNING: recursion! */
+ 		return float_strcmp(++string2, ++string1);
+ 
+ 	/* will fail if integer part has more digits than allowed by the mask */
+ 	g_assert(t1-p1+string1 > r1);
+ 	g_assert(t2-p2+string2 > r2);
+ 
+ 	/* copy stringX onto rX so that the dot matches on both */
+ 	strncpy((char*) (t1-p1+string1), string1, sizeof(r1)-(t1-p1+string1-r1));
+ 	strncpy((char*) (t2-p2+string2), string2, sizeof(r2)-(t2-p2+string2-r2));
+ 
+ 	/* then compare the two strings with leading zeros */
+ 	return strcmp(r1,r2);
+ }
