Parcourir la source

2009-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Fixed the bug that in Windows environment new blank line is
	inserted when console readout is updated.
	* src/ConsoleStatCalc.cc
Tatsuhiro Tsujikawa il y a 16 ans
Parent
commit
0dcb41da49
2 fichiers modifiés avec 14 ajouts et 0 suppressions
  1. 6 0
      ChangeLog
  2. 8 0
      src/ConsoleStatCalc.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2009-10-31  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Fixed the bug that in Windows environment new blank line is
+	inserted when console readout is updated.
+	* src/ConsoleStatCalc.cc
+
 2009-10-31  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Throw exception if binding listening port is failed.  Removed

+ 8 - 0
src/ConsoleStatCalc.cc

@@ -207,11 +207,19 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
 
   bool isTTY = isatty(STDOUT_FILENO) == 1;
   unsigned short int cols = 80;
+#ifdef __MINGW32__
+  // Windows terminal cannot handle at the end of line properly.
+  --cols;
+#endif // __MINGW32__
   if(isTTY) {
 #ifdef HAVE_TERMIOS_H
     struct winsize size;
     if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) {
       cols = size.ws_col;
+#ifdef __MINGW32__
+      // Windows terminal cannot handle at the end of line properly.
+      --cols;
+#endif // __MINGW32__
     }
 #endif // HAVE_TERMIOS_H
     std::cout << '\r' << std::setfill(' ') << std::setw(cols) << ' ' << '\r';