aboutsummaryrefslogtreecommitdiffstats
path: root/debug.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-12-05 20:37:25 +0200
committerArnold D. Robbins <arnold@skeeve.com>2010-12-05 20:37:25 +0200
commit6b9ed56f74baa4af529e100dff19afcd23ed7cd8 (patch)
tree9e66902f2792d6e2216a8020805a14b6cccbc028 /debug.c
parent16458663c3bdf640e3352653ea94a89fb2949ad4 (diff)
downloadegawk-6b9ed56f74baa4af529e100dff19afcd23ed7cd8.tar.gz
egawk-6b9ed56f74baa4af529e100dff19afcd23ed7cd8.tar.bz2
egawk-6b9ed56f74baa4af529e100dff19afcd23ed7cd8.zip
More doc and code fixes. See ChangeLogs.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/debug.c b/debug.c
index 0f726d4a..3537350e 100644
--- a/debug.c
+++ b/debug.c
@@ -1052,7 +1052,35 @@ print_field(long field_num)
}
}
-extern int comp_func(const void *p1, const void *p2);
+/* comp_func --- array index comparison function for qsort */
+
+static int
+comp_func(const void *p1, const void *p2)
+{
+ size_t len1, len2;
+ const char *str1, *str2;
+ const NODE *t1, *t2;
+ int cmp1;
+
+ t1 = *((const NODE *const *) p1);
+ t2 = *((const NODE *const *) p2);
+
+/*
+ t1 = force_string(t1);
+ t2 = force_string(t2);
+*/
+ len1 = t1->ahname_len;
+ str1 = t1->ahname_str;
+
+ len2 = t2->ahname_len;
+ str2 = t2->ahname_str;
+
+ /* Array indexes are strings, compare as such, always! */
+ cmp1 = memcmp(str1, str2, len1 < len2 ? len1 : len2);
+ /* if prefixes are equal, size matters */
+ return (cmp1 != 0 ? cmp1 :
+ len1 < len2 ? -1 : (len1 > len2));
+}
/* print_array --- print the contents of an array */