public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [setup - the official Cygwin setup program] branch master, updated. release_2.901-7-g0b90765c
@ 2020-02-24 15:00 jturney
  0 siblings, 0 replies; only message in thread
From: jturney @ 2020-02-24 15:00 UTC (permalink / raw)
  To: cygwin-apps-cvs




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=0b90765c0a0c0e52b7ba70d0c3019f83c55962f8

commit 0b90765c0a0c0e52b7ba70d0c3019f83c55962f8
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Feb 2 23:03:57 2020 +0000

    Make inilint do something slightly useful
    
    Add IniDBBuilderLint, a do-nothing subclass of InitDBBuilder
    Use CliParseFeedback for parser feedback

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=5518ac1ddeac17571846a3c19c57f6f5a97f6303

commit 5518ac1ddeac17571846a3c19c57f6f5a97f6303
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Feb 3 12:59:02 2020 +0000

    Pass a "Install for all users" flag into setDefaultSecurity()
    
    Pass an "Install for all users" flag into setDefaultSecurity(), rather
    than evaluating it there, for better decoupling from settings & UI.

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

commit a99dd611f65720cc7893c02b5b96146b6448e886
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Feb 2 20:50:53 2020 +0000

    Fix building inilint
    
    Fix Makefile.am for inilint
    Always build inilint, so it doesn't rust again

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=605034ca68c0586c8449be865a7621ece9866f6a

commit 605034ca68c0586c8449be865a7621ece9866f6a
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Feb 2 20:55:44 2020 +0000

    Restore abstract base class IniDBBuilder
    
    This effectively reverts commit 618bd457849ed44d301d27d81d3b2f262f798897.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=4b81d7a12a9526bf2b4d60385410deaeb79722cc

commit 4b81d7a12a9526bf2b4d60385410deaeb79722cc
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Feb 6 21:25:46 2020 +0000

    Add CliParseFeedback class
    
    Move the yyerror() handling from inilint into that class

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=8081184150dfc4d75a4dd39af0a3c513371ead78

commit 8081184150dfc4d75a4dd39af0a3c513371ead78
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Feb 2 22:14:14 2020 +0000

    Pull yyerror() handling up into IniParseFeedback
    
    Pull yyerror() handling up into IniParseFeedback
    Collect the parser errors in IniParseFeedback
    Make IniParseFeedback an abstract base class

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=2b9efbf6e468eebea682bb8a2bb8c1b00f1b8459

commit 2b9efbf6e468eebea682bb8a2bb8c1b00f1b8459
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Feb 4 12:29:46 2020 +0000

    More updates for "using namespace std;" removal
    
    overlooked in 155eacb6


Diff:
---
 CliParseFeedback.cc   | 54 +++++++++++++++++++++++++++++++++++++++++++++++
 CliParseFeedback.h    | 28 +++++++++++++++++++++++++
 IniDBBuilder.h        | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
 IniDBBuilderLint.h    | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
 IniDBBuilderPackage.h |  6 ++----
 IniParseFeedback.cc   | 24 ---------------------
 IniParseFeedback.h    | 13 ++++++------
 Makefile.am           | 32 +++++++++++-----------------
 configure.ac          | 13 ------------
 ini.cc                | 46 ++++++++++++++++++++++++++++------------
 ini.h                 | 13 +++---------
 inilex.ll             | 24 ++++-----------------
 inilintmain.cc        | 48 +++++++++++++++++++++++-------------------
 iniparse.yy           |  4 ++--
 main.cc               |  2 +-
 win32.cc              |  5 ++---
 win32.h               |  2 +-
 17 files changed, 288 insertions(+), 139 deletions(-)

diff --git a/CliParseFeedback.cc b/CliParseFeedback.cc
new file mode 100644
index 00000000..6dc48ba3
--- /dev/null
+++ b/CliParseFeedback.cc
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2020 Jon Turney
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ */
+
+#include "CliParseFeedback.h"
+#include "LogSingleton.h"
+#include <sstream>
+#include <iostream>
+
+void CliParseFeedback::progress (unsigned long const pos, unsigned long const max)
+{
+  std::cout << pos << "/" << max << std::endl;
+}
+
+void CliParseFeedback::iniName (const std::string& name)
+{
+}
+
+void CliParseFeedback::babble (const std::string& message) const
+{
+  Log (LOG_BABBLE) << message << endLog;
+}
+
+void CliParseFeedback::warning (const std::string& message) const
+{
+  std::cout << "Warning: " << message << std::endl;
+}
+
+void CliParseFeedback::show_errors () const
+{
+}
+
+void CliParseFeedback::note_error(int lineno, const std::string &s)
+{
+  std::ostringstream buf;
+  buf << "line " << lineno << ": ";
+  buf << s << std::endl;
+  std::cout << buf.str();
+  error_count++;
+}
+
+bool CliParseFeedback::has_errors () const
+{
+  return (error_count > 0);
+}
diff --git a/CliParseFeedback.h b/CliParseFeedback.h
new file mode 100644
index 00000000..a19659eb
--- /dev/null
+++ b/CliParseFeedback.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2020 Jon Turney
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ */
+
+#include "IniParseFeedback.h"
+
+class CliParseFeedback : public IniParseFeedback
+{
+public:
+  virtual void progress (unsigned long const pos, unsigned long const max);
+  virtual void iniName (const std::string& name);
+  virtual void babble (const std::string& message) const;
+  virtual void warning (const std::string& message) const;
+  virtual void show_errors () const;
+  virtual void note_error(int lineno, const std::string &s);
+  virtual bool has_errors () const;
+private:
+  int error_count = 0;
+};
diff --git a/IniDBBuilder.h b/IniDBBuilder.h
new file mode 100644
index 00000000..3b890412
--- /dev/null
+++ b/IniDBBuilder.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2002, Robert Collins.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins  <rbtcollins@hotmail.com>
+ *
+ */
+
+#ifndef SETUP_INIDBBUILDER_H
+#define SETUP_INIDBBUILDER_H
+
+#include "PackageSpecification.h"
+#include "PackageTrust.h"
+
+enum class hashType { none, md5, sha512 };
+
+class IniDBBuilder
+{
+public:
+  virtual ~IniDBBuilder() {};
+
+  virtual void buildTimestamp (const std::string& ) = 0;
+  virtual void buildVersion (const std::string& ) = 0;
+  virtual const std::string buildMinimumVersion(const std::string &) = 0;
+  virtual void buildPackage (const std::string& ) = 0;
+  virtual void buildPackageVersion (const std::string& ) = 0;
+  virtual void buildPackageSDesc (const std::string& ) = 0;
+  virtual void buildPackageLDesc (const std::string& ) = 0;
+  virtual void buildPackageInstall (const std::string&, const std::string&,
+                                    char *, hashType) = 0;
+  virtual void buildPackageSource (const std::string&, const std::string&,
+                                   char *, hashType) = 0;
+  virtual void buildPackageTrust (trusts) = 0;
+  virtual void buildPackageCategory (const std::string& ) = 0;
+  virtual void buildBeginDepends () = 0;
+  virtual void buildBeginBuildDepends () = 0;
+  virtual void buildBeginObsoletes () = 0;
+  virtual void buildBeginProvides () = 0;
+  virtual void buildBeginConflicts () = 0;
+  virtual void buildMessage (const std::string&, const std::string&) = 0;
+  virtual void buildSourceName (const std::string& ) = 0;
+  virtual void buildSourceNameVersion (const std::string& ) = 0;
+  virtual void buildPackageListNode (const std::string& ) = 0;
+  virtual void buildPackageListOperator (PackageSpecification::_operators const &) = 0;
+  virtual void buildPackageListOperatorVersion (const std::string& ) = 0;
+  virtual void buildPackageReplaceVersionsList (const std::string& ) = 0;
+  virtual void set_arch (const std::string& a) = 0;
+  virtual void set_release (const std::string& rel) = 0;
+};
+
+#endif /* SETUP_INIDBBUILDER_H */
diff --git a/IniDBBuilderLint.h b/IniDBBuilderLint.h
new file mode 100644
index 00000000..29a98eeb
--- /dev/null
+++ b/IniDBBuilderLint.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2002, Robert Collins.
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     A copy of the GNU General Public License can be found at
+ *     http://www.gnu.org/
+ *
+ * Written by Robert Collins  <rbtcollins@hotmail.com>
+ *
+ */
+
+#ifndef SETUP_INIDBBUILDERLINT_H
+#define SETUP_INIDBBUILDERLINT_H
+
+#include "IniDBBuilder.h"
+
+class IniDBBuilderLint:public IniDBBuilder
+{
+public:
+  virtual ~IniDBBuilderLint() {};
+
+  virtual void buildTimestamp (const std::string& ) {};
+  virtual void buildVersion (const std::string& ) {};
+  virtual const std::string buildMinimumVersion(const std::string &s) { return ""; }
+  virtual void buildPackage (const std::string& ) {};
+  virtual void buildPackageVersion (const std::string& ) {};
+  virtual void buildPackageSDesc (const std::string& ) {};
+  virtual void buildPackageLDesc (const std::string& ) {};
+  virtual void buildPackageInstall (const std::string&, const std::string&,
+                                    char *, hashType) {};
+  virtual void buildPackageSource (const std::string&, const std::string&,
+                                   char *, hashType) {};
+  virtual void buildPackageTrust (trusts) {};
+  virtual void buildPackageCategory (const std::string& ) {};
+  virtual void buildBeginDepends () {};
+  virtual void buildBeginBuildDepends () {};
+  virtual void buildBeginObsoletes () {};
+  virtual void buildBeginProvides () {};
+  virtual void buildBeginConflicts () {};
+  virtual void buildMessage (const std::string&, const std::string&) {};
+  virtual void buildSourceName (const std::string& ) {};
+  virtual void buildSourceNameVersion (const std::string& ) {};
+  virtual void buildPackageListNode (const std::string& ) {};
+  virtual void buildPackageListOperator (PackageSpecification::_operators const &) {};
+  virtual void buildPackageListOperatorVersion (const std::string& ) {};
+  virtual void buildPackageReplaceVersionsList (const std::string& ) {};
+  virtual void set_arch (const std::string& a) {};
+  virtual void set_release (const std::string& rel) {};
+};
+
+#endif /* SETUP_INIDBBUILDERLINT_H */
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index e5d36629..3e3a9e4b 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -16,20 +16,18 @@
 #ifndef SETUP_INIDBBUILDERPACKAGE_H
 #define SETUP_INIDBBUILDERPACKAGE_H
 
+#include "IniDBBuilder.h"
 #include <vector>
 #include <set>
 
 #include "package_message.h"
-#include "PackageTrust.h"
 #include "String++.h"
 #include "libsolv.h"
 
 class IniParseFeedback;
 class packagesource;
 
-enum class hashType { none, md5, sha512 };
-
-class IniDBBuilderPackage
+class IniDBBuilderPackage:public IniDBBuilder
 {
 public:
   IniDBBuilderPackage (IniParseFeedback const &);
diff --git a/IniParseFeedback.cc b/IniParseFeedback.cc
deleted file mode 100644
index 8b7ebd12..00000000
--- a/IniParseFeedback.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2002 Robert Collins.
- *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     A copy of the GNU General Public License can be found at
- *     http://www.gnu.org/
- *
- * Written by Robert Collins <robertc@hotmail.com>
- *
- */
-
-#include "IniParseFeedback.h"
-
-IniParseFeedback::~IniParseFeedback(){}
-
-void IniParseFeedback::progress(unsigned long const, unsigned long const) {}
-void IniParseFeedback::iniName (const std::string& ) {}
-void IniParseFeedback::babble(const std::string& ) const {}
-void IniParseFeedback::warning (const std::string& ) const {}
-void IniParseFeedback::error(const std::string& ) const {}
diff --git a/IniParseFeedback.h b/IniParseFeedback.h
index 23f9d315..c3c78033 100644
--- a/IniParseFeedback.h
+++ b/IniParseFeedback.h
@@ -26,12 +26,13 @@
 class IniParseFeedback
 {
 public:
-  virtual void progress (unsigned long const, unsigned long const);
-  virtual void iniName (const std::string& );
-  virtual void babble (const std::string& ) const;
-  virtual void warning (const std::string& ) const;
-  virtual void error (const std::string& ) const;
-  virtual ~ IniParseFeedback ();
+  virtual void progress (unsigned long const, unsigned long const) = 0;
+  virtual void iniName (const std::string& ) = 0;
+  virtual void babble (const std::string& ) const = 0;
+  virtual void warning (const std::string& ) const = 0;
+  virtual void show_errors () const = 0;
+  virtual void note_error(int lineno, const std::string &error) = 0;
+  virtual bool has_errors () const = 0;
 };
 
 #endif /* SETUP_INIPARSEFEEDBACK_H */
diff --git a/Makefile.am b/Makefile.am
index 3c413897..4ceeb98d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,10 +33,7 @@ AM_CPPFLAGS = -DLZMA_API_STATIC -I$(srcdir)/libgetopt++/include \
 
 inilex_CXXFLAGS:=-Wno-sign-compare
 
-noinst_PROGRAMS = @SETUP@$(EXEEXT) @INILINT@
-
-EXTRA_PROGRAMS = inilint
-## noinst_PROGRAMS +=inilint
+noinst_PROGRAMS = @SETUP@$(EXEEXT) inilint
 
 EXTRA_DIST = \
 	CHANGES \
@@ -61,37 +58,33 @@ BUILT_SOURCES = \
 CLEANFILES = setup_version.c
 
 inilint_LDADD = \
-	libgetopt++/libgetopt++.la
+	libgetopt++/libgetopt++.la \
+	-lntdll -luuid
+
 inilint_SOURCES = \
 	filemanip.cc \
 	filemanip.h \
-	find.cc \
-	find.h \
-	FindVisitor.cc \
-	FindVisitor.h \
+	CliParseFeedback.cc \
+	CliParseFeedback.h \
 	LogSingleton.cc \
 	LogSingleton.h \
 	IniDBBuilder.h \
 	inilintmain.cc \
 	inilex.ll \
 	iniparse.yy \
-	IniParseFeedback.cc \
-	IniParseFeedback.h \
-	io_stream.h \
 	io_stream.cc \
-	io_stream_file.h \
+	io_stream.h \
 	io_stream_file.cc \
-	IOStreamProvider.h \
+	io_stream_file.h \
 	mkdir.cc \
 	mkdir.h \
 	mklink2.cc \
-	PackageSpecification.cc \
-	PackageSpecification.h \
+	mklink2.h \
 	PackageTrust.h \
-	csu_util/rfc1738.cc \
-	csu_util/rfc1738.h \
 	String++.cc \
-	String++.h
+	String++.h \
+	win32.cc \
+	win32.h
 
 @SETUP@_LDADD = \
 	libgetopt++/libgetopt++.la \
@@ -162,7 +155,6 @@ inilint_SOURCES = \
 	IniDBBuilderPackage.h \
 	inilex.ll \
 	iniparse.yy \
-	IniParseFeedback.cc \
 	IniParseFeedback.h \
 	install.cc \
 	io_stream.cc \
diff --git a/configure.ac b/configure.ac
index 08fe16be..ab6f3ff6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,19 +23,6 @@ dnl AM_CONFIG_HEADER(include/autoconf.h)
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES(yes)])
 AC_CONFIG_SRCDIR([Makefile.in])
 
-AC_MSG_CHECKING([Whether to build inilint])
-AC_ARG_ENABLE(inilint,
-	    AC_HELP_STRING([--enable-inilint],
-			   [Build the inilint tool]),
-	    ac_cv_enable_inilint=$enableval, ac_cv_enable_inilint=no)
-AC_MSG_RESULT([$ac_cv_enable_inilint])
-if test $ac_cv_enable_inilint = yes; then
-  INILINT="inilint\$(EXEEXT)"
-else
-  INILINT=
-fi
-AC_SUBST(INILINT)
-
 AC_LANG_CPLUSPLUS
 AC_PROG_CXX
 AM_PROG_CC_C_O
diff --git a/ini.cc b/ini.cc
index 78684a71..ee9c6482 100644
--- a/ini.cc
+++ b/ini.cc
@@ -64,10 +64,6 @@ IniList setup_ext_list (setup_exts,
 static BoolOption NoVerifyOption (false, 'X', "no-verify", "Don't verify setup.ini signatures");
 static BoolOption NoVersionCheckOption (false, '\0', "no-version-check", "Suppress checking if a newer version of setup is available");
 
-extern int yyparse ();
-
-/*extern int yydebug;*/
-
 class GuiParseFeedback : public IniParseFeedback
 {
 public:
@@ -76,6 +72,9 @@ public:
       Progress.SetText2 ("");
       Progress.SetText3 ("");
       Progress.SetText4 ("Progress:");
+
+      yyerror_count = 0;
+      yyerror_messages.clear ();
     }
   virtual void progress (unsigned long const pos, unsigned long const max)
     {
@@ -102,6 +101,7 @@ public:
       Progress.SetText1 ("Parsing...");
       Progress.SetText2 (name.c_str ());
       Progress.SetText3 ("");
+      filename = name;
     }
   virtual void babble (const std::string& message)const
     {
@@ -111,9 +111,26 @@ 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)
+    {
+      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(), message.c_str (), "Parse Errors", 0);
+      mbox (Progress.GetHWND(), yyerror_messages.c_str (), "Parse Errors", 0);
     }
   virtual ~ GuiParseFeedback ()
     {
@@ -121,10 +138,13 @@ public:
     }
 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.
@@ -228,7 +248,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
@@ -247,9 +267,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;
 	    }
 
@@ -299,7 +319,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
@@ -313,9 +333,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
diff --git a/ini.h b/ini.h
index 07e1a46d..ecc4b78e 100644
--- a/ini.h
+++ b/ini.h
@@ -30,9 +30,9 @@ extern std::string SetupIniDir;
 extern std::string SetupBaseName;
 
 class IniState;
-class IniDBBuilderPackage;
+class IniDBBuilder;
 class IniParseFeedback;
-void ini_init (io_stream *, IniDBBuilderPackage *, IniParseFeedback &);
+void ini_init (io_stream *, IniDBBuilder *, IniParseFeedback &);
 #define YYSTYPE char *
 
 /* When setup.ini is parsed, the information is stored according to
@@ -42,14 +42,7 @@ void ini_init (io_stream *, IniDBBuilderPackage *, IniParseFeedback &);
    packages (the chosen "install" field).  install.cc installs
    selected packages. */
 
-/* The following three vars are used to facilitate error handling between the
-   parser/lexer and its callers, namely ini.cc:do_remote_ini() and
-   IniParseFindVisitor::visitFile().  */
-
-extern std::string current_ini_name;  /* current filename/URL being parsed */
-extern std::string current_ini_sig_name;  /* current filename/URL for sig file */
-extern std::string yyerror_messages;  /* textual parse error messages */
-extern int yyerror_count;             /* number of parse errors */
+extern int yyparse ();
 
 /* The following definitions are used in the parser implementation */
 
diff --git a/inilex.ll b/inilex.ll
index 209152fc..26a95e3c 100644
--- a/inilex.ll
+++ b/inilex.ll
@@ -166,21 +166,17 @@ B64	[a-zA-Z0-9_-]
 #include "io_stream.h"
 
 static io_stream *input_stream = 0;
-extern IniDBBuilderPackage *iniBuilder;
+extern IniDBBuilder *iniBuilder;
 static IniParseFeedback *iniFeedback;
-std::string current_ini_name, yyerror_messages;
-int yyerror_count;
 
 void
-ini_init(io_stream *stream, IniDBBuilderPackage *aBuilder, IniParseFeedback &aFeedback)
+ini_init(io_stream *stream, IniDBBuilder *aBuilder, IniParseFeedback &aFeedback)
 {
   input_stream = stream;
   iniBuilder = aBuilder;
   iniFeedback = &aFeedback;
   YY_FLUSH_BUFFER;
   yylineno = 1;
-  yyerror_count = 0;
-  yyerror_messages.clear ();
 }
 
 static int
@@ -214,20 +210,8 @@ ignore_line ()
     }
 }
 
-int
+void
 yyerror (const std::string& s)
 {
-  char tmp[16];
-  sprintf (tmp, "%d", yylineno - (!!YY_AT_BOL ()));
-  
-  std::string e = current_ini_name + " line " + tmp + ": " + s;
-  
-  if (!yyerror_messages.empty ())
-    yyerror_messages += "\n";
-
-  yyerror_messages += e;
-  // OutputDebugString (e.c_str ());
-  yyerror_count++;
-  /* TODO: is return 0 correct? */
-  return 0;
+  iniFeedback->note_error(yylineno - (!!YY_AT_BOL ()), s);
 }
diff --git a/inilintmain.cc b/inilintmain.cc
index 33239fb3..f31e5eb4 100644
--- a/inilintmain.cc
+++ b/inilintmain.cc
@@ -13,42 +13,46 @@
  *
  */
 
-#include "getopt++/GetOption.h"
+#include "io_stream.h"
+#include "IniDBBuilderLint.h"
+#include "CliParseFeedback.h"
+#include "ini.h"
 #include <iostream>
 #include <sstream>
-
-extern int yylineno;
-
-static std::ostringstream error_buf;
-static int error_count = 0;
-
-extern int
-yyerror (const std::string& s)
-{
-  std::ostringstream buf;
-  buf << "setup.ini line " << yylineno << ": ";
-  buf << s << endl;
-  cout << buf;
-  error_buf << buf; 
-  error_count++;
-  /* TODO: is return 0 correct? */
-  return 0;
-}
+#include "LogSingleton.h"
 
 void
 show_help()
 {
-  cout << "inilint checks cygwin setup.ini files and reports any errors with" << endl;
-  cout << "diagnostics" << endl;
+  std::cout << "inilint checks cygwin setup.ini files and reports any errors" << std::endl;
 }
 
 int
 main (int argc, char **argv)
 {
-  if (!GetOption::GetInstance().Process (argc,argv,NULL))
+  if (argc != 2)
     {
       show_help();
       return 1;
     }
+
+  std::string inifilename = argv[1];
+
+  // Note: this only accepts absolute pathnames
+  io_stream *ini_file = io_stream::open ("file://" + inifilename, "rb", 0);
+  if (!ini_file)
+    {
+      std::cerr << "could not open " << inifilename << std::endl;
+      return 1;
+    }
+
+  CliParseFeedback feedback;
+  IniDBBuilderLint builder;
+  ini_init(ini_file, &builder, feedback);
+
+  // Note: unrecognized lines are ignored by ignore_line(), so this is currently
+  // only useful for finding where recognized lines don't fit the grammar.
+  yyparse();
+
   return 0;
 }
diff --git a/iniparse.yy b/iniparse.yy
index f85fe13a..ca9b8a78 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -25,13 +25,13 @@
 extern int yyerror (const std::string& s);
 int yylex ();
 
-#include "IniDBBuilderPackage.h"
+#include "IniDBBuilder.h"
 
 #define YYERROR_VERBOSE 1
 #define YYINITDEPTH 1000
 /*#define YYDEBUG 1*/
 
-IniDBBuilderPackage *iniBuilder;
+IniDBBuilder *iniBuilder;
 extern int yylineno;
 %}
 
diff --git a/main.cc b/main.cc
index 749b00ce..5de1f360 100644
--- a/main.cc
+++ b/main.cc
@@ -355,7 +355,7 @@ WinMain (HINSTANCE h,
     else
       {
 	/* Set default DACL and Group. */
-	nt_sec.setDefaultSecurity ();
+	nt_sec.setDefaultSecurity ((root_scope == IDC_ROOT_SYSTEM));
 
 	UserSettings Settings (local_dir);
 	main_display ();
diff --git a/win32.cc b/win32.cc
index 09813556..6a551bac 100644
--- a/win32.cc
+++ b/win32.cc
@@ -18,7 +18,6 @@
 #include <malloc.h>
 #include "LogFile.h"
 #include "resource.h"
-#include "state.h"
 #include "ini.h"
 #include <sys/stat.h>
 
@@ -308,7 +307,7 @@ NTSecurity::setAdminGroup ()
 }
 
 void
-NTSecurity::setDefaultSecurity ()
+NTSecurity::setDefaultSecurity (bool isAdmin)
 {
   /* Get the processes access token. */
   if (!OpenProcessToken (GetCurrentProcess (),
@@ -359,7 +358,7 @@ NTSecurity::setDefaultSecurity ()
   /* Try to set the primary group to the Administrators group, but only if
      "Install for all users" has been chosen.  If it doesn't work, we're
      no admin and that's all there's to say about it. */
-  if (root_scope == IDC_ROOT_SYSTEM)
+  if (isAdmin)
     setAdminGroup ();
 }
 
diff --git a/win32.h b/win32.h
index c866790d..1b9db490 100644
--- a/win32.h
+++ b/win32.h
@@ -130,7 +130,7 @@ public:
   void resetPrimaryGroup();
   void setAdminGroup ();
   void initialiseWellKnownSIDs ();
-  void setDefaultSecurity();
+  void setDefaultSecurity(bool isAdmin);
   bool isRunAsAdmin ();
 private:
   void NoteFailedAPI (const std::string &);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-24 15:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 15:00 [setup - the official Cygwin setup program] branch master, updated. release_2.901-7-g0b90765c jturney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).