diff options
author | dsmith <dsmith> | 2007-08-21 21:28:09 +0000 |
---|---|---|
committer | dsmith <dsmith> | 2007-08-21 21:28:09 +0000 |
commit | 6a59236bb21bf7f19faa6ce5332d21bb9c90e14e (patch) | |
tree | 3963309e669c97f5cd285d762bea57962620b982 /translate.cxx | |
parent | c88e093987ced0c683058e16973e9fd45a692827 (diff) | |
download | systemtap-steved-6a59236bb21bf7f19faa6ce5332d21bb9c90e14e.tar.gz systemtap-steved-6a59236bb21bf7f19faa6ce5332d21bb9c90e14e.tar.xz systemtap-steved-6a59236bb21bf7f19faa6ce5332d21bb9c90e14e.zip |
2007-08-21 David Smith <dsmith@redhat.com>
PR 2305
* translate.cxx (c_unparser::visit_foreach_loop): When the user
requested sorting an array of aggregates by value, sort by
@count.
Diffstat (limited to 'translate.cxx')
-rw-r--r-- | translate.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/translate.cxx b/translate.cxx index 736e380f..4891c617 100644 --- a/translate.cxx +++ b/translate.cxx @@ -2489,19 +2489,29 @@ c_unparser::visit_foreach_loop (foreach_loop *s) // sort array if desired if (s->sort_direction) { + int sort_column; + + // If the user wanted us to sort by value, we'll sort by + // @count instead for aggregates. '-5' tells the + // runtime to sort by count. + if (s->sort_column == 0) + sort_column = -5; + else + sort_column = s->sort_column; + o->newline() << "else"; // only sort if aggregation was ok if (s->limit) { o->newline(1) << "_stp_map_sortn (" << mv.fetch_existing_aggregate() << ", " - << *res_limit << ", " << s->sort_column << ", " + << *res_limit << ", " << sort_column << ", " << - s->sort_direction << ");"; } else { o->newline(1) << "_stp_map_sort (" << mv.fetch_existing_aggregate() << ", " - << s->sort_column << ", " + << sort_column << ", " << - s->sort_direction << ");"; } o->indent(-1); |