diff options
author | Gerald Combs <gerald@wireshark.org> | 2005-08-25 13:58:34 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2005-08-25 13:58:34 +0000 |
commit | 1b8f8ffcb35abeda1e2f62d12651217a6589249f (patch) | |
tree | e7c2aad7c953c3850799ed1cb37fddc1d66dd0ec | |
parent | 3c01b45ac2fa18b73807aa8ed87b96b9082acee3 (diff) |
Fix sorting in the "Ports" columns. Add a comment about address sorting.
Remove unused code.
svn path=/trunk/; revision=15529
-rw-r--r-- | gtk/conversations_table.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gtk/conversations_table.c b/gtk/conversations_table.c index 5b6340aa3c..e6f283c2f4 100644 --- a/gtk/conversations_table.c +++ b/gtk/conversations_table.c @@ -30,6 +30,7 @@ #endif #include <string.h> +#include <ctype.h> #include <stdlib.h> #include <stdio.h> #include <math.h> @@ -323,27 +324,30 @@ ct_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2) switch(clist->sort_column){ case 0: case 2: + /* Addresses */ + /* XXX - We should sort addresses numerically. */ return strcmp (text1, text2); case 1: case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: + /* Ports */ + /* If we have two numbers, do a numeric compare. Otherwise, + * use strcmp. */ + if (text1 && text2 && isdigit(text1[0]) && isdigit(text2[0])) { + sscanf(text1, "%" PRIu64, &i1); + sscanf(text2, "%" PRIu64, &i2); + /* XXX - See overflow comment below */ + return (gint) (i1-i2); + } else { + return strcmp (text1, text2); + } + default: sscanf(text1, "%" PRIu64, &i1); sscanf(text2, "%" PRIu64, &i2); /* XXX - this might cause trouble because of overflow problems */ /* XXX - is this correct anyway? Subtracting two unsigned values will still be an unsigned value, which will never become negative */ return (gint) (i1-i2); } - g_assert_not_reached(); - - /* Allow clist to redraw */ - - gtk_clist_thaw(clist); - gtk_clist_freeze(clist); + g_assert_not_reached(); return 0; } |