[PATCH setup 7/7] Make inilint do something slightly useful

Jon Turney jon.turney@dronecode.org.uk
Sat Feb 15 17:05:00 GMT 2020


Add IniDBBuilderLint, a do-nothing subclass of InitDBBuilder
Use CliParseFeedback for parser feedback
---
 IniDBBuilderLint.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.am        | 17 ++++++++++++--
 ini.cc             |  2 --
 ini.h              |  2 ++
 inilintmain.cc     | 31 ++++++++++++++++++++++----
 5 files changed, 99 insertions(+), 8 deletions(-)
 create mode 100644 IniDBBuilderLint.h

diff --git a/IniDBBuilderLint.h b/IniDBBuilderLint.h
new file mode 100644
index 0000000..29a98ee
--- /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/Makefile.am b/Makefile.am
index 04bb668..4ceeb98 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,9 +58,12 @@ BUILT_SOURCES = \
 CLEANFILES = setup_version.c
 
 inilint_LDADD = \
-	libgetopt++/libgetopt++.la
+	libgetopt++/libgetopt++.la \
+	-lntdll -luuid
 
 inilint_SOURCES = \
+	filemanip.cc \
+	filemanip.h \
 	CliParseFeedback.cc \
 	CliParseFeedback.h \
 	LogSingleton.cc \
@@ -69,9 +72,19 @@ inilint_SOURCES = \
 	inilintmain.cc \
 	inilex.ll \
 	iniparse.yy \
+	io_stream.cc \
+	io_stream.h \
+	io_stream_file.cc \
+	io_stream_file.h \
+	mkdir.cc \
+	mkdir.h \
+	mklink2.cc \
+	mklink2.h \
 	PackageTrust.h \
 	String++.cc \
-	String++.h
+	String++.h \
+	win32.cc \
+	win32.h
 
 @SETUP@_LDADD = \
 	libgetopt++/libgetopt++.la \
diff --git a/ini.cc b/ini.cc
index 2c568e1..ee9c648 100644
--- a/ini.cc
+++ b/ini.cc
@@ -64,8 +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 ();
-
 class GuiParseFeedback : public IniParseFeedback
 {
 public:
diff --git a/ini.h b/ini.h
index 1e4f889..ecc4b78 100644
--- a/ini.h
+++ b/ini.h
@@ -42,6 +42,8 @@ void ini_init (io_stream *, IniDBBuilder *, IniParseFeedback &);
    packages (the chosen "install" field).  install.cc installs
    selected packages. */
 
+extern int yyparse ();
+
 /* The following definitions are used in the parser implementation */
 
 #define hexnibble(val)  ('\xff' & (val > '9') ? val - 'a' + 10 : val - '0')
diff --git a/inilintmain.cc b/inilintmain.cc
index 7ae98ff..f31e5eb 100644
--- a/inilintmain.cc
+++ b/inilintmain.cc
@@ -13,23 +13,46 @@
  *
  */
 
-#include "getopt++/GetOption.h"
+#include "io_stream.h"
+#include "IniDBBuilderLint.h"
+#include "CliParseFeedback.h"
+#include "ini.h"
 #include <iostream>
+#include <sstream>
+#include "LogSingleton.h"
 
 void
 show_help()
 {
-  std::cout << "inilint checks cygwin setup.ini files and reports any errors with" << std::endl;
-  std::cout << "diagnostics" << std::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;
 }
-- 
2.21.0



More information about the Cygwin-apps mailing list