Author: fabient
Date: Fri Mar 26 14:29:57 2010
New Revision: 205693
URL: http://svn.freebsd.org/changeset/base/205693

Log:
  Do not overflow the term in the case of multi-line display.
  
  MFC after: 3days

Modified:
  head/usr.sbin/pmcstat/pmcpl_calltree.c

Modified: head/usr.sbin/pmcstat/pmcpl_calltree.c
==============================================================================
--- head/usr.sbin/pmcstat/pmcpl_calltree.c      Fri Mar 26 14:08:21 2010        
(r205692)
+++ head/usr.sbin/pmcstat/pmcpl_calltree.c      Fri Mar 26 14:29:57 2010        
(r205693)
@@ -366,7 +366,7 @@ pmcpl_ct_node_cleartag(void)
 
 static int
 pmcpl_ct_node_dumptop(int pmcin, struct pmcpl_ct_node *ct,
-    struct pmcpl_ct_sample *rsamples, int x, int *y)
+    struct pmcpl_ct_sample *rsamples, int x, int *y, int maxy)
 {
        int i;
 
@@ -387,7 +387,7 @@ pmcpl_ct_node_dumptop(int pmcin, struct 
        if (ct->pct_narc == 0) {
                pmcpl_ct_topscreen[x+1][*y] = NULL;
                if (*y >= PMCPL_CT_MAXLINE ||
-                   *y >= pmcstat_displayheight)
+                   *y >= maxy)
                        return 1;
                *y = *y + 1;
                for (i=0; i < x; i++)
@@ -407,7 +407,7 @@ pmcpl_ct_node_dumptop(int pmcin, struct 
                    &ct->pct_arc[i].pcta_samples) > pmcstat_threshold) {
                        if (pmcpl_ct_node_dumptop(pmcin,
                                ct->pct_arc[i].pcta_child,
-                               rsamples, x+1, y))
+                               rsamples, x+1, y, maxy))
                                return 1;
                }
        }
@@ -472,6 +472,9 @@ pmcpl_ct_node_printtop(struct pmcpl_ct_s
                        /* Check for line wrap. */
                        width += ns_len + is_len + vs_len + 1;
                        if (width >= pmcstat_displaywidth) {
+                               maxy--;
+                               if (y >= maxy)
+                                       break;
                                PMCSTAT_PRINTW("\n%*s", indentwidth, space);
                                width = indentwidth + ns_len + is_len + vs_len;
                        }
@@ -515,7 +518,7 @@ pmcpl_ct_topdisplay(void)
                for (i = 0; i < pmcpl_ct_root->pct_narc; i++) {
                        if (pmcpl_ct_node_dumptop(pmcin,
                                pmcpl_ct_root->pct_arc[i].pcta_child,
-                               &rsamples, x, &y)) {
+                               &rsamples, x, &y, pmcstat_displayheight - 2)) {
                                break;
                        }
                }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to