]> cygwin.com Git - cygwin-apps/setup.git/blobdiff - ini.cc
Add command-line option help-text localization
[cygwin-apps/setup.git] / ini.cc
diff --git a/ini.cc b/ini.cc
index 7afeba229913ee97392194e15de1eb1889e1d8f2..3ef131185cc37abe16dcd890cf7dc57a45fb1e32 100644 (file)
--- a/ini.cc
+++ b/ini.cc
@@ -61,20 +61,21 @@ std::string ini_setup_version;
 IniList setup_ext_list (setup_exts,
                        setup_exts + (sizeof(setup_exts) / sizeof(*setup_exts)));
 
-static BoolOption NoVerifyOption (false, 'X', "no-verify", "Don't verify setup.ini signatures");
-
-extern int yyparse ();
-
-/*extern int yydebug;*/
+static BoolOption NoVerifyOption (false, 'X', "no-verify", IDS_HELPTEXT_NO_VERIFY);
+static BoolOption NoVersionCheckOption (false, '\0', "no-version-check", IDS_HELPTEXT_NO_VERSION_CHECK);
 
 class GuiParseFeedback : public IniParseFeedback
 {
 public:
   GuiParseFeedback () : lastpct (0)
     {
+      Progress.SetText1 (IDS_PROGRESS_PARSING);
       Progress.SetText2 ("");
       Progress.SetText3 ("");
-      Progress.SetText4 ("Progress:");
+      Progress.SetText4 (IDS_PROGRESS_PROGRESS);
+
+      yyerror_count = 0;
+      yyerror_messages.clear ();
     }
   virtual void progress (unsigned long const pos, unsigned long const max)
     {
@@ -98,9 +99,9 @@ public:
     }
   virtual void iniName (const std::string& name)
     {
-      Progress.SetText1 ("Parsing...");
       Progress.SetText2 (name.c_str ());
       Progress.SetText3 ("");
+      filename = name;
     }
   virtual void babble (const std::string& message)const
     {
@@ -110,20 +111,43 @@ public:
     {
       mbox (Progress.GetHWND(), message.c_str (), "Warning", 0);
     }
-  virtual void error (const std::string& message)const
+  virtual void note_error(int lineno, const std::string &error)
     {
-      mbox (Progress.GetHWND(), message.c_str (), "Parse Errors", 0);
+      char tmp[16];
+      sprintf (tmp, "%d", lineno);
+
+      std::string e = filename + " line " + tmp + ": " + error;
+
+      if (!yyerror_messages.empty ())
+        yyerror_messages += "\n";
+
+      yyerror_messages += e;
+      yyerror_count++;
+    }
+  virtual bool has_errors () const
+    {
+      return (yyerror_count > 0);
+    }
+  virtual void show_errors () const
+    {
+      mbox (Progress.GetHWND(), yyerror_messages.c_str (), "Parse Errors", 0);
     }
   virtual ~ GuiParseFeedback ()
     {
-      Progress.SetText4 ("Package:");
+      Progress.SetText2 ("");
+      Progress.SetText3 ("");
+      Progress.SetText4 (IDS_PROGRESS_PACKAGE);
+      Progress.SetBar1 (0);
     }
 private:
   unsigned int lastpct;
+  std::string filename;
+  std::string yyerror_messages;
+  int yyerror_count;
 };
 
 static io_stream*
-decompress_ini (io_stream *ini_file)
+decompress_ini (io_stream *ini_file, std::string &current_ini_name)
 {
   // Replace the current compressed setup stream with its decompressed
   // version.  Which decompressor to use is determined by file magic.
@@ -227,7 +251,7 @@ do_local_ini (HWND owner)
       ini_file = check_ini_sig (ini_file, ini_sig_file, sig_fail,
                                "localdir", current_ini_sig_name.c_str (), owner);
       if (ini_file)
-       ini_file = decompress_ini (ini_file);
+       ini_file = decompress_ini (ini_file, current_ini_name);
       if (!ini_file || sig_fail)
        {
          // no setup found or signature invalid
@@ -246,9 +270,9 @@ do_local_ini (HWND owner)
            rfc1738_unescape (current_ini_name.substr (ldl, cap - ldl));
          ini_init (ini_file, &aBuilder, myFeedback);
 
-         if (yyparse () || yyerror_count > 0)
+         if (yyparse () || myFeedback.has_errors())
            {
-             myFeedback.error (yyerror_messages);
+             myFeedback.show_errors ();
              ini_error = true;
            }
 
@@ -298,7 +322,7 @@ do_remote_ini (HWND owner)
            break;
        }
       if (ini_file)
-       ini_file = decompress_ini (ini_file);
+       ini_file = decompress_ini (ini_file, current_ini_name);
       if (!ini_file || sig_fail)
        {
          // no setup found or signature invalid
@@ -312,9 +336,9 @@ do_remote_ini (HWND owner)
          aBuilder.parse_mirror = n->url;
          ini_init (ini_file, &aBuilder, myFeedback);
 
-         if (yyparse () || yyerror_count > 0)
+         if (yyparse () || myFeedback.has_errors())
            {
-             myFeedback.error (yyerror_messages);
+             myFeedback.show_errors ();
              ini_error = true;
            }
          else
@@ -401,7 +425,8 @@ do_ini_thread (HINSTANCE h, HWND owner)
        setup_version);
   if (ini_setup_version.size ())
     {
-      if (version_compare (setup_version, ini_setup_version) < 0)
+      if ((version_compare (setup_version, ini_setup_version) < 0)
+          && !NoVersionCheckOption)
        note (owner, IDS_OLD_SETUP_VERSION, setup_version,
              ini_setup_version.c_str ());
     }
@@ -415,6 +440,8 @@ do_ini_thread_reflector (void* p)
   HANDLE *context;
   context = (HANDLE*)p;
 
+  SetThreadUILanguage(langid);
+
   try
   {
     bool succeeded = do_ini_thread ((HINSTANCE)context[0], (HWND)context[1]);
This page took 0.026862 seconds and 5 git commands to generate.