Op Tue,  8 Nov 2005 22:50:55 +0100 (MET) schreef Bas van Gompel
in <[EMAIL PROTECTED]>:
:  Hi,

:  Here is a patch to make setup tell where files are actually being
:  downloaded from.

So, here is a modified version, using more std::stringy ways.
I got carried away a bit, and turned some more Strings into
std::string.
Also I needed to edit res.rc to prevent wrapping.


ChangeLog-entry: (Please fix the <at>.)


2005-12-05  Bas van Gompel  <patch-cygsup.buzz<at>bavag.tmfweb.nl>

        * geturl.cc: Use std::string, not String.
        (init_dialog): Tell where file is downloaded from.
        * geturl.h: Use std::string, not String.
        * res.rc (IDD_INSTATUS): make IDC_INS_PKG not wrap.


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   /    /   really is |   and false bits entirely.    | mail for
  ) |  |  /    /    a 72 by 4 +-------------------------------+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe "s.u(z)\1.as."    | me. 4^re
Index: setup/geturl.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/geturl.cc,v
retrieving revision 2.25
diff -u -p -r2.25 geturl.cc
--- setup/geturl.cc     5 May 2005 22:48:35 -0000       2.25
+++ setup/geturl.cc     5 Dec 2005 02:58:22 -0000
@@ -61,18 +61,17 @@ int total_download_bytes_sofar = 0;
 static DWORD start_tics;
 
 static void
-init_dialog (String const &url, int length, HWND owner)
+init_dialog (std::string const &url, int length, HWND owner)
 {
   if (is_local_install)
     return;
 
-  char const *last_component = url.c_str();
-  for (const char *ch = last_component; *ch; ch++)
-    if (*ch == '/' || *ch == '\\' || *ch == ':')
-      last_component = ch + 1;
+  int p_slash = url.find_last_of ('/');
+
   max_bytes = length;
   Progress.SetText1("Downloading...");
-  Progress.SetText2(last_component);
+  Progress.SetText2((url.substr(p_slash + 1) + " from "
+                    + url.substr(0, p_slash)).c_str());
   Progress.SetText3("Connecting...");
   Progress.SetBar1(0);
   start_tics = GetTickCount ();
@@ -112,7 +111,7 @@ progress (int bytes)
 }
 
 static void
-getUrlToStream (String const &_url, HWND owner, io_stream *output)
+getUrlToStream (std::string const &_url, HWND owner, io_stream *output)
 {
   log (LOG_BABBLE) << "getUrlToStream " << _url << endLog;
   is_local_install = (source == IDC_SOURCE_CWD);
@@ -153,7 +152,7 @@ getUrlToStream (String const &_url, HWND
 }
 
 io_stream *
-get_url_to_membuf (String const &_url, HWND owner)
+get_url_to_membuf (std::string const &_url, HWND owner)
 {
   io_stream_memory *membuf = new io_stream_memory ();
   try 
@@ -181,31 +180,31 @@ get_url_to_membuf (String const &_url, H
 }
 
 // predicate: url has no '\0''s in it.
-String
-get_url_to_string (String const &_url, HWND owner)
+std::string
+get_url_to_string (std::string const &_url, HWND owner)
 {
   io_stream *stream = get_url_to_membuf (_url, owner);
   if (!stream)
-    return String();
+    return std::string();
   size_t bytes = stream->get_size ();
   if (!bytes)
     {
       /* zero length, or error retrieving length */
       delete stream;
       log (LOG_BABBLE) << "get_url_to_string(): couldn't retrieve buffer size, 
or zero length buffer" << endLog;
-      return String();
+      return std::string();
     }
   char temp [bytes + 1];
   /* membufs are quite safe */
   stream->read (temp, bytes);
   temp [bytes] = '\0';
   delete stream;
-  return String(temp);
+  return std::string(temp);
 }
 
 int
-get_url_to_file (String const &_url,
-                 String const &_filename,
+get_url_to_file (std::string const &_url,
+                 std::string const &_filename,
                  int expected_length,
                 HWND owner)
 {
Index: setup/geturl.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/geturl.h,v
retrieving revision 2.10
diff -u -p -r2.10 geturl.h
--- setup/geturl.h      23 Dec 2004 18:12:12 -0000      2.10
+++ setup/geturl.h      5 Dec 2005 02:58:22 -0000
@@ -23,11 +23,10 @@ extern int total_download_bytes;
 extern int total_download_bytes_sofar;
 
 class io_stream;
-class String;
 
-io_stream *get_url_to_membuf (String const &, HWND owner);
-String get_url_to_string (String const&, HWND owner);
-int get_url_to_file (String const &_url, String const &_filename,
+io_stream *get_url_to_membuf (std::string const &, HWND owner);
+std::string get_url_to_string (std::string const&, HWND owner);
+int get_url_to_file (std::string const &_url, std::string const &_filename,
                      int expected_size, HWND owner);
 
 #endif /* SETUP_GETURL_H */
Index: setup/res.rc
===================================================================
RCS file: /cvs/cygwin-apps/setup/res.rc,v
retrieving revision 2.68
diff -u -p -r2.68 res.rc
--- setup/res.rc        30 Nov 2005 22:48:31 -0000      2.68
+++ setup/res.rc        5 Dec 2005 02:58:49 -0000
@@ -190,7 +190,7 @@ CAPTION "Cygwin Setup"
 FONT 8, "MS Shell Dlg"
 BEGIN
     LTEXT           "Installing...",IDC_INS_ACTION,45,55,205,8,NOT WS_GROUP
-    LTEXT           "(PKG)",IDC_INS_PKG,45,70,205,8,NOT WS_GROUP
+    LTEXT           "(PKG)",IDC_INS_PKG,45,70,205,8,NOT WS_GROUP | 
SS_LEFTNOWORDWRAP
     LTEXT           "(FILE)",IDC_INS_FILE,45,85,205,8,NOT WS_GROUP
     CONTROL         "Progress1",IDC_INS_DISKFULL,"msctls_progress32",
                     PBS_SMOOTH | WS_BORDER,95,130,155,10

Reply via email to