[haiku-commits] Re: haiku: hrev48937 - src/bin/pkgman

  • From: Jérôme Duval <jerome.duval@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 27 Mar 2015 21:33:28 +0100

2015-03-27 21:20 GMT+01:00  <waddlesplash@xxxxxxxxx>:
> @@ -189,7 +192,10 @@ PackageManager::ProgressPackageDownloadActive(const 
> char* packageName,
>                 "\xE2\x96\x88",
>         };
>
> -       const int width = 70;
> +       struct winsize w;
> +       ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
> +       const int width = (w.ws_col > 77)
> +               ? 70 : (w.ws_col - 7); // we need 70 chars for the bar + 7 
> for %.

Well, the ioctl() return value has to be checked before making use of
the winsize struct.

Bye,
Jérôme

Other related posts: