This is the mail archive of the cygwin-apps-cvs mailing list for the cygwin-apps project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[setup] branch master, updated. release_2.870-7-g6f2a737




https://sourceware.org/git/gitweb.cgi?p=cygwin-setup.git;h=6f2a7375cc67410aeb4ccdd5e6a396c3ecccdb57

commit 6f2a7375cc67410aeb4ccdd5e6a396c3ecccdb57
Author: Jon TURNEY <jon.turney@dronecode.org.uk>
Date:   Tue Mar 3 13:28:48 2015 +0000

    Remove msg() and convert to log output
    
    Remove msg(), which writes output to the debugger via OutputDebugString() and
    convert it's uses to log output using the printf-style log adaptors.
    
    Examining the uses of msg(), some of these are genuine errors, which should be
    logged somewhere we might have a chance to see them.  Convert those to
    LOG_PLAIN.  Convert the other uses of msg() for debug output to LOG_BABBLE.
    
    ChangeLog:
    
    2015-03-04  Jon TURNEY  <jon.turney@dronecode.org.uk>
    
    	* msg.cc (msg): Remove.
    	* msg.h (msg): Ditto.
    	* compress_xz.cc (read, bid_xz, bid_lzma): Convert from msg() to
    	LogBabblePrintf() or LogPlainPrintf() as appropriate.
    	* crypto.cc (MESSAGE): Ditto.
    	* desktop.cc (make_link, start_menu, desktop_icon)
    	(check_desktop, check_startmenu): Ditto.
    	* gpg-packet.cc (MESSAGE): Ditto.
    	* ini.cc (do_ini_thread): Ditto.
    	* simpsock.cc (SimpleSocket): Ditto.

https://sourceware.org/git/gitweb.cgi?p=cygwin-setup.git;h=5c8becf23c99af45183490aea5842f542ba74329

commit 5c8becf23c99af45183490aea5842f542ba74329
Author: Jon TURNEY <jon.turney@dronecode.org.uk>
Date:   Tue Mar 3 13:08:18 2015 +0000

    Add Log adaptors for printf-style output
    
    ChangeLog:
    
    2015-03-04  Jon TURNEY  <jon.turney@dronecode.org.uk>
    
    	* LogSingleton.cc (LogBabblePrintf, LogPlainPrintf): Add.
    	* LogSingleton.h: Ditto.


Diff:
---
 ChangeLog       |   18 ++++++++++++++++++
 LogSingleton.cc |   28 ++++++++++++++++++++++++++++
 LogSingleton.h  |    5 +++++
 compress_xz.cc  |   22 +++++++++++-----------
 crypto.cc       |    5 +++--
 desktop.cc      |   13 ++++++-------
 gpg-packet.cc   |    5 +++--
 ini.cc          |    3 +--
 msg.cc          |   10 ----------
 msg.h           |    6 ------
 simpsock.cc     |    8 ++++----
 11 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 30609dd..6c7327e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2015-03-04  Jon TURNEY  <jon.turney@dronecode.org.uk>
+
+	* msg.cc (msg): Remove.
+	* msg.h (msg): Ditto.
+	* compress_xz.cc (read, bid_xz, bid_lzma): Convert from msg() to
+	LogBabblePrintf() or LogPlainPrintf() as appropriate.
+	* crypto.cc (MESSAGE): Ditto.
+	* desktop.cc (make_link, start_menu, desktop_icon)
+	(check_desktop, check_startmenu): Ditto.
+	* gpg-packet.cc (MESSAGE): Ditto.
+	* ini.cc (do_ini_thread): Ditto.
+	* simpsock.cc (SimpleSocket): Ditto.
+
+2015-03-04  Jon TURNEY  <jon.turney@dronecode.org.uk>
+
+	* LogSingleton.cc (LogBabblePrintf, LogPlainPrintf): Add.
+	* LogSingleton.h: Ditto.
+
 2015-03-05  Achim Gratz  <Stromeko@NexGo.DE>
 
 	* package_meta.cc (isManuallyWanted, isManuallyDeleted): Demote
diff --git a/LogSingleton.cc b/LogSingleton.cc
index 387e6fe..a103a20 100644
--- a/LogSingleton.cc
+++ b/LogSingleton.cc
@@ -15,6 +15,7 @@
 
 #include "LogSingleton.h"
 #include <stdexcept>
+#include <stdarg.h>
 
 using namespace std;
 
@@ -76,3 +77,30 @@ private:
   static LogSingleton *theInstance;
 };
 #endif
+
+// Log adapators for printf-style output
+void
+LogBabblePrintf(const char *fmt, ...)
+{
+  int len;
+  char buf[2000];
+  va_list args;
+  va_start (args, fmt);
+  len = vsnprintf (buf, 2000, fmt, args);
+  if ((len > 0) && (buf[len-1] == '\n'))
+    buf[len-1] = 0;
+  Log (LOG_BABBLE) << buf << endLog;
+}
+
+void
+LogPlainPrintf(const char *fmt, ...)
+{
+  int len;
+  char buf[2000];
+  va_list args;
+  va_start (args, fmt);
+  len = vsnprintf (buf, 2000, fmt, args);
+  if ((len > 0) && (buf[len-1] == '\n'))
+    buf[len-1] = 0;
+  Log (LOG_PLAIN) << buf << endLog;
+}
diff --git a/LogSingleton.h b/LogSingleton.h
index 2c7a7c5..2fd1e36 100644
--- a/LogSingleton.h
+++ b/LogSingleton.h
@@ -57,4 +57,9 @@ extern std::ostream& endLog(std::ostream& outs);
 //extern ostream& endLog(ostream& outs);
 
 #define Log(X) (LogSingleton::GetInstance ()(X))
+
+// Log adapators for printf-style output
+void LogBabblePrintf(const char *fmt, ...);
+void LogPlainPrintf(const char *fmt, ...);
+
 #endif /* SETUP_LOGSINGLETON_H */
diff --git a/compress_xz.cc b/compress_xz.cc
index 6c9980b..1480c6c 100644
--- a/compress_xz.cc
+++ b/compress_xz.cc
@@ -18,7 +18,7 @@
  */
 
 #include "compress_xz.h"
-#include "msg.h"
+#include "LogSingleton.h"
 
 #include <stdexcept>
 using namespace std;
@@ -186,35 +186,35 @@ compress_xz::read (void *buffer, size_t len)
           case LZMA_OK: /* Decompressor made some progress. */
             break;
           case LZMA_MEM_ERROR:
-            msg ("Lzma library error: Cannot allocate memory\n");
+            LogPlainPrintf ("Lzma library error: Cannot allocate memory\n");
             this->lasterr = ENOMEM;
             return -1;
           case LZMA_MEMLIMIT_ERROR:
-            msg ("Lzma library error: Out of memory\n");
+            LogPlainPrintf ("Lzma library error: Out of memory\n");
             this->lasterr = ENOMEM;
             return -1;
           case LZMA_FORMAT_ERROR:
-            msg ("Lzma library error: format not recognized\n");
+            LogPlainPrintf ("Lzma library error: format not recognized\n");
             this->lasterr = EINVAL;
             return -1;
           case LZMA_OPTIONS_ERROR:
-            msg ("Lzma library error: Invalid options\n");
+            LogPlainPrintf ("Lzma library error: Invalid options\n");
             this->lasterr = EINVAL;
             return -1;
           case LZMA_DATA_ERROR:
-            msg ("Lzma library error: Corrupted input data\n");
+            LogPlainPrintf ("Lzma library error: Corrupted input data\n");
             this->lasterr = EINVAL;
             return -1;
           case LZMA_BUF_ERROR:
-            msg ("Lzma library error: No progress is possible\n");
+            LogPlainPrintf ("Lzma library error: No progress is possible\n");
             this->lasterr = EINVAL;
             return -1;
           case LZMA_PROG_ERROR:
-            msg ("Lzma library error: Internal error\n");
+            LogPlainPrintf ("Lzma library error: Internal error\n");
             this->lasterr = EINVAL;
             return -1;
           default:
-            msg ("Lzma decompression failed:  Unknown error %d\n", res);
+            LogPlainPrintf ("Lzma decompression failed:  Unknown error %d\n", res);
             this->lasterr = EINVAL;
             return -1;
         }
@@ -508,7 +508,7 @@ compress_xz::bid_xz (void * buffer, size_t len)
     return 0;
   bits_checked += 8;
 
-  msg ("compress_xz::bid_xz: success: %d\n", bits_checked);
+  LogBabblePrintf ("compress_xz::bid_xz: success: %d\n", bits_checked);
   return (bits_checked);
 }
 
@@ -616,7 +616,7 @@ compress_xz::bid_lzma (void * buffer, size_t len)
 
   /* TODO: The above test is still very weak.  It would be
    * good to do better. */
-  msg ("compress_xz::bid_lzma: success: %d\n", bits_checked);
+  LogBabblePrintf ("compress_xz::bid_lzma: success: %d\n", bits_checked);
   return (bits_checked);
 }
 
diff --git a/crypto.cc b/crypto.cc
index 13270a7..6ac7a54 100755
--- a/crypto.cc
+++ b/crypto.cc
@@ -27,6 +27,7 @@ static const char *cvsid =
 #include "compress.h"
 #include "gcrypt.h"
 #include "msg.h"
+#include "LogSingleton.h"
 #include "resource.h"
 #include "getopt++/StringArrayOption.h"
 #include "getopt++/BoolOption.h"
@@ -38,10 +39,10 @@ static const char *cvsid =
 
 #if CRYPTODEBUGGING
 #define ERRKIND __asm__ __volatile__ (".byte 0xcc"); note
-#define MESSAGE msg
+#define MESSAGE LogBabblePrintf
 #else  /* !CRYPTODEBUGGING */
 #define ERRKIND note
-#define MESSAGE while (0) msg
+#define MESSAGE while (0) LogBabblePrintf
 #endif /* CRYPTODEBUGGING */
 
 /*  Command-line options for specifying and controlling extra keys.  */
diff --git a/desktop.cc b/desktop.cc
index 33a9891..1add57a 100644
--- a/desktop.cc
+++ b/desktop.cc
@@ -34,7 +34,6 @@ static const char *cvsid =
 
 #include "ini.h"
 #include "resource.h"
-#include "msg.h"
 #include "state.h"
 #include "dialog.h"
 #include "mount.h"
@@ -85,7 +84,7 @@ make_link (const std::string& linkpath,
   if (_access (fname.c_str(), 0) == 0)
     return;			/* already exists */
 
-  msg ("make_link %s, %s, %s\n",
+  LogBabblePrintf ("make_link %s, %s, %s\n",
        fname.c_str(), title.c_str(), target.c_str());
 
   io_stream::mkpath_p (PATH_TO_FILE, std::string ("file://") + fname, 0);
@@ -96,7 +95,7 @@ make_link (const std::string& linkpath,
   exepath = target;
   argbuf = arg;
 
-  msg ("make_link_2 (%s, %s, %s, %s)",
+  LogBabblePrintf ("make_link_2 (%s, %s, %s, %s)",
        exepath.c_str(), argbuf.c_str(),
        icon.c_str(), fname.c_str());
   make_link_2 (exepath.c_str(), argbuf.c_str(),
@@ -116,7 +115,7 @@ start_menu (const std::string& title, const std::string& target,
 			      CSIDL_PROGRAMS, &id);
   SHGetPathFromIDList (id, path);
   strncat (path, "/Cygwin", MAX_PATH);
-  msg ("Program directory for program link: %s", path);
+  LogBabblePrintf ("Program directory for program link: %s", path);
   make_link (path, title, target, arg, iconpath);
 }
 
@@ -132,7 +131,7 @@ desktop_icon (const std::string& title, const std::string& target,
 			      issystem ? CSIDL_COMMON_DESKTOPDIRECTORY :
 			      CSIDL_DESKTOPDIRECTORY, &id);
   SHGetPathFromIDList (id, path);
-  msg ("Desktop directory for desktop link: %s", path);
+  LogBabblePrintf ("Desktop directory for desktop link: %s", path);
   make_link (path, title, target, arg, iconpath);
 }
 
@@ -287,7 +286,7 @@ check_desktop (const std::string title, const std::string target)
 			      issystem ? CSIDL_COMMON_DESKTOPDIRECTORY :
 			      CSIDL_DESKTOPDIRECTORY, &id);
   SHGetPathFromIDList (id, path);
-  msg ("Desktop directory for desktop link: %s", path);
+  LogBabblePrintf ("Desktop directory for desktop link: %s", path);
   std::string fname = std::string(path) + "/" + title + ".lnk";
 
   if (_access (fname.c_str(), 0) == 0)
@@ -307,7 +306,7 @@ check_startmenu (const std::string title, const std::string target)
 			      issystem ? CSIDL_COMMON_PROGRAMS :
 			      CSIDL_PROGRAMS, &id);
   SHGetPathFromIDList (id, path);
-  msg ("Program directory for program link: %s", path);
+  LogBabblePrintf ("Program directory for program link: %s", path);
   strcat (path, STARTMENUDIR);
   std::string fname = std::string(path) + "/" + title + ".lnk";
 
diff --git a/gpg-packet.cc b/gpg-packet.cc
index 3a3bef4..e288b0a 100755
--- a/gpg-packet.cc
+++ b/gpg-packet.cc
@@ -31,16 +31,17 @@ static const char *cvsid =
 #include "gcrypt.h"
 #include "gpg-packet.h"
 #include "msg.h"
+#include "LogSingleton.h"
 #include "resource.h"
 
 #define CRYPTODEBUGGING         (0)
 
 #if CRYPTODEBUGGING
 #define ERRKIND __asm__ __volatile__ (".byte 0xcc"); note
-#define MESSAGE msg
+#define MESSAGE LogBabblePrintf
 #else  /* !CRYPTODEBUGGING */
 #define ERRKIND note
-#define MESSAGE while (0) msg
+#define MESSAGE while (0) LogBabblePrintf
 #endif /* CRYPTODEBUGGING */
 
 #ifndef ARRAYSIZE
diff --git a/ini.cc b/ini.cc
index 7d7b917..e90f98c 100644
--- a/ini.cc
+++ b/ini.cc
@@ -36,7 +36,6 @@
 #include "state.h"
 #include "geturl.h"
 #include "dialog.h"
-#include "msg.h"
 #include "mount.h"
 #include "site.h"
 #include "find.h"
@@ -333,7 +332,7 @@ do_ini_thread (HINSTANCE h, HWND owner)
 	}
     }
 
-  msg (".ini setup_version is %s, our setup_version is %s", ini_setup_version.size() ?
+  LogBabblePrintf (".ini setup_version is %s, our setup_version is %s", ini_setup_version.size() ?
        ini_setup_version.c_str () : "(null)",
        setup_version);
   if (ini_setup_version.size ())
diff --git a/msg.cc b/msg.cc
index d0cbfa2..b7d96bb 100644
--- a/msg.cc
+++ b/msg.cc
@@ -31,16 +31,6 @@ static const char *cvsid =
 #include "dialog.h"
 #include "state.h"
 
-void
-msg (const char *fmt, ...)
-{
-  char buf[2000];
-  va_list args;
-  va_start (args, fmt);
-  vsnprintf (buf, 2000, fmt, args);
-  OutputDebugString (buf);
-}
-
 int
 mbox (HWND owner, const char *buf, const char *name, int type)
 {
diff --git a/msg.h b/msg.h
index 72551c4..4810057 100644
--- a/msg.h
+++ b/msg.h
@@ -18,12 +18,6 @@
 
 #include "win32.h"
 
-/* This is for "printf"-like debugging.  Messages go to
-   OutputDebugString, which can be seen while debugging under GDB or
-   via a debug message monitor. */
-
-void msg (const char *fmt, ...);
-
 /* This pops up a dialog with text from the string table ("id"), which
    is interpreted like printf.  The program exits when the user
    presses OK. */
diff --git a/simpsock.cc b/simpsock.cc
index b1bb5f0..852f043 100644
--- a/simpsock.cc
+++ b/simpsock.cc
@@ -27,7 +27,7 @@ static const char *cvsid =
 #include <stdlib.h>
 
 #include "simpsock.h"
-#include "msg.h"
+#include "LogSingleton.h"
 
 #define SSBUFSZ 1024
 
@@ -61,7 +61,7 @@ SimpleSocket::SimpleSocket (const char *hostname, int port)
       he = gethostbyname (hostname);
       if (!he)
 	{
-	  msg ("Can't resolve `%s'\n", hostname);
+	  LogPlainPrintf ("Can't resolve `%s'\n", hostname);
 	  return;
 	}
       memcpy (ip, he->h_addr_list[0], 4);
@@ -70,7 +70,7 @@ SimpleSocket::SimpleSocket (const char *hostname, int port)
   s = socket (AF_INET, SOCK_STREAM, 0);
   if (s == INVALID_SOCKET)
     {
-      msg ("Can't create socket, %d", WSAGetLastError ());
+      LogPlainPrintf ("Can't create socket, %d", WSAGetLastError ());
       return;
     }
 
@@ -83,7 +83,7 @@ SimpleSocket::SimpleSocket (const char *hostname, int port)
 
   if (connect (s, (sockaddr *) & name, sizeof (name)))
     {
-      msg ("Can't connect to %s:%d", hostname, port);
+      LogPlainPrintf ("Can't connect to %s:%d", hostname, port);
       closesocket (s);
       s = INVALID_SOCKET;
       return;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]