This is the mail archive of the cygwin-apps mailing list for the Cygwin 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]

[PATCH setup 1/5] Make do_ini() succeed if found_ini_list is empty


Rather than count the number of .ini files read in do_{local,remote}_ini,
and assume success if greater than zero, actually track if an error occured.

This is a subtle change of behaviour if more than one .ini file is read:
previously all we needed was one to succeed, now we need them all to
succeed.

(Note that site_list should never be empty, and it's still an error if we
don't find an .ini file from a site, to the practical effect is to make
do_local_ini with an empty found_ini_list succeed)
---
 ini.cc | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/ini.cc b/ini.cc
index 0f8b927..85325c3 100644
--- a/ini.cc
+++ b/ini.cc
@@ -205,10 +205,10 @@ check_ini_sig (io_stream* ini_file, io_stream* ini_sig_file,
   return ini_file;
 }
 
-static int
+static bool
 do_local_ini (HWND owner)
 {
-  size_t ini_count = 0;
+  bool ini_error = false;
   GuiParseFeedback myFeedback;
   IniDBBuilderPackage aBuilder (myFeedback);
   io_stream *ini_file, *ini_sig_file;
@@ -233,6 +233,7 @@ do_local_ini (HWND owner)
 	  // no setup found or signature invalid
 	  note (owner, IDS_SETUPINI_MISSING, SetupBaseName.c_str (),
 		"localdir");
+	  ini_error = true;
 	}
       else
 	{
@@ -245,12 +246,11 @@ do_local_ini (HWND owner)
 	    rfc1738_unescape (current_ini_name.substr (ldl, cap - ldl));
 	  ini_init (ini_file, &aBuilder, myFeedback);
 
-	  /*yydebug = 1; */
-
 	  if (yyparse () || yyerror_count > 0)
-	    myFeedback.error (yyerror_messages);
-	  else
-	    ++ini_count;
+	    {
+	      myFeedback.error (yyerror_messages);
+	      ini_error = true;
+	    }
 
 	  if (aBuilder.timestamp > setup_timestamp)
 	    {
@@ -261,13 +261,13 @@ do_local_ini (HWND owner)
 	  ini_file = NULL;
 	}
     }
-  return ini_count;
+  return ini_error;
 }
 
-static int
+static bool
 do_remote_ini (HWND owner)
 {
-  size_t ini_count = 0;
+  bool ini_error = false;
   GuiParseFeedback myFeedback;
   IniDBBuilderPackage aBuilder (myFeedback);
   io_stream *ini_file = NULL, *ini_sig_file;
@@ -303,6 +303,7 @@ do_remote_ini (HWND owner)
 	{
 	  // no setup found or signature invalid
 	  note (owner, IDS_SETUPINI_MISSING, SetupBaseName.c_str (), n->url.c_str ());
+	  ini_error = true;
 	}
       else
 	{
@@ -311,10 +312,11 @@ do_remote_ini (HWND owner)
 	  aBuilder.parse_mirror = n->url;
 	  ini_init (ini_file, &aBuilder, myFeedback);
 
-	  /*yydebug = 1; */
-
 	  if (yyparse () || yyerror_count > 0)
-	    myFeedback.error (yyerror_messages);
+	    {
+	      myFeedback.error (yyerror_messages);
+	      ini_error = true;
+	    }
 	  else
 	    {
 	      /* save known-good setup.ini locally */
@@ -329,7 +331,6 @@ do_remote_ini (HWND owner)
 		    io_stream::remove (fp);
 		  delete out;
 		}
-	      ++ini_count;
 	    }
 	  if (aBuilder.timestamp > setup_timestamp)
 	    {
@@ -340,19 +341,19 @@ do_remote_ini (HWND owner)
 	  ini_file = NULL;
 	}
     }
-  return ini_count;
+  return ini_error;
 }
 
 static bool
 do_ini_thread (HINSTANCE h, HWND owner)
 {
-  size_t ini_count = 0;
+  bool ini_error = true;
   if (source == IDC_SOURCE_LOCALDIR)
-    ini_count = do_local_ini (owner);
+    ini_error = do_local_ini (owner);
   else
-    ini_count = do_remote_ini (owner);
+    ini_error = do_remote_ini (owner);
 
-  if (ini_count == 0)
+  if (ini_error)
     return false;
 
   if (get_root_dir ().c_str ())
-- 
2.15.0


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