From a6da6c45e5bf69491c83d8244081e6245eae6658 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 21 Jan 2010 16:47:34 +0100
Subject: [PATCH] maint.mk: make VC_LIST_EXCEPT robustly handle a srcdir
 containing "."

* top/maint.mk (_dot_escaped_srcdir): Define.
(VC_LIST_EXCEPT): Use it in LHS of preprocessing sed substitution.
---
 ChangeLog    | 6 ++++++
 top/maint.mk | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 681b56a268..e294c72523 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-21  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: handle source file names containing "." robustly
+	* top/maint.mk (_dot_escaped_srcdir): Define.
+	(VC_LIST): Use it in LHS of sed substitution.
+
 2010-01-21  Jiri Denemark  <jdenemar@redhat.com>
 
 	maint.mk: fix VC_LIST_EXCEPT for srcdir != builddir
diff --git a/top/maint.mk b/top/maint.mk
index bbf8a91975..1ef28d3919 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -40,8 +40,13 @@ VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
 # matching files to ignore.
 VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
 
+# This is to preprocess robustly the output of $(VC_LIST), so that even
+# when $(srcdir) is a pathological name like "....", the leading sed command
+# removes only the intended prefix.
+_dot_escaped_srcdir = $(subst .,\\.,$(srcdir))
+
 VC_LIST_EXCEPT = \
-  $(VC_LIST) | sed 's|^$(srcdir)/||' \
+  $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
 	| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
 	  else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
 	| grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \
-- 
2.39.5