> --- a/procps/top.c
> +++ b/procps/top.c
> @@ -694,10 +694,14 @@ static NOINLINE void display_process_list(int 
> lines_rem, int scr_width)
>                 CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> 
> pcpu_shift);
>  #endif
>
> -               if (s->vsz >= 100000)
> -                       sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
> +               if ((s->vsz / (1024 * 1024)) >= 100000)
> +                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldt", 
> s->vsz/(1024 * 1024 * 1024));
> +               else if ((s->vsz / 1024) >= 100000)
> +                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldg", 
> s->vsz/(1024 * 1024));
> +               else if (s->vsz >= 100000)
> +                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%6ldm", 
> s->vsz/1024);
>                 else
> -                       sprintf(vsz_str_buf, "%7lu", s->vsz);
> +                       snprintf(vsz_str_buf, sizeof(vsz_str_buf), "%7lu", 
> s->vsz);
>                 /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
>                 col = snprintf(line_buf, scr_width,
>                                 "\n" "%5u%6u %-8.8s %s%s" FMT

I propose this instead:


-               if (s->vsz >= 100000)
-                       sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
-               else
-                       sprintf(vsz_str_buf, "%7lu", s->vsz);
+               smart_ulltoa5(s->vsz, vsz_str_buf, " mgtpezy");
                /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
                col = snprintf(line_buf, scr_width,
-                               "\n" "%5u%6u %-8.8s %s%s" FMT
+                               "\n" "%5u%6u %-8.8s %s  %.5s" FMT
                                IF_FEATURE_TOP_SMP_PROCESS(" %3d")
                                IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(FMT)
                                " ",
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to