]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Make inilint do something slightly useful
authorJon Turney <jon.turney@dronecode.org.uk>
Sun, 2 Feb 2020 23:03:57 +0000 (23:03 +0000)
committerJon Turney <jon.turney@dronecode.org.uk>
Sat, 15 Feb 2020 16:18:37 +0000 (16:18 +0000)
Add IniDBBuilderLint, a do-nothing subclass of InitDBBuilder
Use CliParseFeedback for parser feedback

IniDBBuilderLint.h [new file with mode: 0644]
Makefile.am
ini.cc
ini.h
inilintmain.cc

diff --git a/IniDBBuilderLint.h b/IniDBBuilderLint.h
new file mode 100644 (file)
index 0000000..29a98ee
--- /dev/null
@@ -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 */
index 04bb6681cab5d7aa49df69a5eecb47073d829225..4ceeb98d8329073e5545ebb75d5494685541d136 100644 (file)
@@ -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 2c568e1dcd89d674c67faa205cdef5cc411d69ad..ee9c6482184fb9da07a16624b12f7eaa09c9263a 100644 (file)
--- 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 1e4f889422bfbc4c5e9e1f616539c039b4e93371..ecc4b78e2072d3f95d91a28d136170bed8117980 100644 (file)
--- 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')
index 7ae98ff3d48ca429188fc6285a1d98247915e5db..f31e5eb41aa734821b60125e687fae8e1e58c011 100644 (file)
  *
  */
 
-#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;
 }
This page took 0.036119 seconds and 5 git commands to generate.