]> git.saurik.com Git - apt.git/commitdiff
Fix missing ScreenWidth check in apt.cc
authorMichael Vogt <mvo@debian.org>
Mon, 28 Apr 2014 11:41:33 +0000 (13:41 +0200)
committerMichael Vogt <mvo@debian.org>
Mon, 28 Apr 2014 11:41:33 +0000 (13:41 +0200)
apt-private/private-main.cc
apt-private/private-main.h
apt-private/private-output.cc
cmdline/apt-get.cc
cmdline/apt.cc

index 2d3965172b02227d21a1c200c2db5462846b1934..668b1733ae683b1e252f29e34fe211d4229c4111 100644 (file)
@@ -8,9 +8,18 @@
 #include <iostream>
 #include <string.h>
 #include <unistd.h>
+#include <signal.h>
 
 #include <apti18n.h>
 
+
+void InitSignals()
+{
+   // Setup the signals
+   signal(SIGPIPE,SIG_IGN);
+}
+
+
 void CheckSimulateMode(CommandLine &CmdL)
 {
    // simulate user-friendly if apt-get has no root privileges
index 23d4aca688bbf63af02465f74e286aa415e98666..a03bf444145523c7dcc73c28b103a127e37fb724 100644 (file)
@@ -6,5 +6,6 @@
 class CommandLine;
 
 APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL);
+APT_PUBLIC void InitSignals();
 
 #endif
index 757999167fc280492154980b8d45c58f82950293..7f3eef6c26649b4aff21bcb47229f2355fc2a07d 100644 (file)
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <langinfo.h>
 #include <unistd.h>
+#include <signal.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -32,8 +33,24 @@ std::ostream c0out(0);
 std::ostream c1out(0);
 std::ostream c2out(0);
 std::ofstream devnull("/dev/null");
+
+
 unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
 
+// SigWinch - Window size change signal handler                                /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static void SigWinch(int)
+{
+   // Riped from GNU ls
+#ifdef TIOCGWINSZ
+   struct winsize ws;
+  
+   if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
+      ScreenWidth = ws.ws_col - 1;
+#endif
+}
+                                                                       /*}}}*/
 bool InitOutput()                                                      /*{{{*/
 {
    if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
@@ -47,6 +64,10 @@ bool InitOutput()                                                    /*{{{*/
    if (_config->FindI("quiet",0) > 1)
       c1out.rdbuf(devnull.rdbuf());
 
+   // deal with window size changes
+   signal(SIGWINCH,SigWinch);
+   SigWinch(0);
+
    if(!isatty(1))
    {
       _config->Set("APT::Color", "false");
index caf69da2aeb7b7a735289f601b563e463e735213..566103f8c7a1c3907ae3fdbf62b21dd9df556eae 100644 (file)
@@ -1664,20 +1664,6 @@ static bool ShowHelp(CommandLine &)
       "pages for more information and options.\n"
       "                       This APT has Super Cow Powers.\n");
    return true;
-}
-                                                                       /*}}}*/
-// SigWinch - Window size change signal handler                                /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static void SigWinch(int)
-{
-   // Riped from GNU ls
-#ifdef TIOCGWINSZ
-   struct winsize ws;
-  
-   if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
-      ScreenWidth = ws.ws_col - 1;
-#endif
 }
                                                                        /*}}}*/
 int main(int argc,const char *argv[])                                  /*{{{*/
@@ -1734,14 +1720,12 @@ int main(int argc,const char *argv[])                                   /*{{{*/
    // see if we are in simulate mode
    CheckSimulateMode(CmdL);
 
+   // Init the signals
+   InitSignals();
+
    // Setup the output streams
    InitOutput();
 
-   // Setup the signals
-   signal(SIGPIPE,SIG_IGN);
-   signal(SIGWINCH,SigWinch);
-   SigWinch(0);
-
    // Match the operation
    CmdL.DispatchArg(Cmds);
 
index 4813861a441a61d88cc8c93758a535d2fc07a8e8..72086af14a97779c1fc3cded2036248e0f56519d 100644 (file)
@@ -96,6 +96,10 @@ int main(int argc, const char *argv[])                                       /*{{{*/
 
    std::vector<CommandLine::Args> Args = getCommandArgs("apt", CommandLine::GetCommand(Cmds, argc, argv));
 
+   // Init the signals
+   InitSignals();
+
+   // Init the output
    InitOutput();
 
    // Set up gettext support