]> Savannah Git Hosting - gnulib.git/commitdiff
cache: eliminate configure and m4 comments
authorDmitry Selyutin <ghostmansd@gmail.com>
Wed, 13 Sep 2017 12:32:01 +0000 (15:32 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Wed, 13 Sep 2017 17:50:03 +0000 (20:50 +0300)
pygnulib/config.py

index 1fcf728a2fd9cf45a1f46249262a4de015057c5a..b0fadfe7edbcaac5aebd238de823f8273f1c4834 100644 (file)
@@ -427,6 +427,7 @@ class Base:
 
 class Cache(Base):
     """gnulib cached configuration"""
+    _COMMENTS_ = _re_.compile(r"((?:(?:#)|(?:^dnl\s+)|(?:\s+dnl\s+)).*)$", _re_.M)
     _AUTOCONF_ = {
         "autoconf" : _re_.compile(r"AC_PREREQ\(\[(.*?)\]\)", _re_.S | _re_.M),
         "auxdir"   : _re_.compile(r"AC_CONFIG_AUX_DIR\(\[(.*?)\]\)$", _re_.S | _re_.M),
@@ -485,7 +486,7 @@ class Cache(Base):
 
     def __autoconf(self, configure):
         with _codecs_.open(configure, "rb", "UTF-8") as stream:
-            data = stream.read()
+            data = Cache._COMMENTS_.sub("", stream.read())
         for (key, pattern) in Cache._AUTOCONF_.items():
             match = pattern.findall(data)
             if not match:
@@ -501,7 +502,7 @@ class Cache(Base):
         if not _os_.path.exists(path):
             raise FileNotFoundError(path)
         with _codecs_.open(path, "rb", "UTF-8") as stream:
-            data = stream.read()
+            data = Cache._COMMENTS_.sub("", stream.read())
         for key in Cache._GNULIB_CACHE_BOOL_:
             (_, macro) = Cache._GNULIB_CACHE_[key]
             if key in data:
@@ -522,7 +523,7 @@ class Cache(Base):
         if not _os_.path.exists(path):
             raise FileNotFoundError(path)
         with _codecs_.open(path, "rb", "UTF-8") as stream:
-            data = stream.read()
+            data = Cache._COMMENTS_.sub("", stream.read())
         regex = r"AC_DEFUN\(\[{0}_FILE_LIST\], \[(.*?)\]\)".format(self["macro-prefix"])
         pattern = _re_.compile(regex, _re_.S | _re_.M)
         match = pattern.findall(data)