From b2815bc13cbb9319163dd570faa17126511fa65b Mon Sep 17 00:00:00 2001
From: Gary King <gwking@franz.com>
Date: Fri, 22 May 2009 09:14:46 -0400
Subject: [PATCH] Robustified *asdf-revision* detection

---
 asdf.lisp | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/asdf.lisp b/asdf.lisp
index d3ad267e..a2a790d7 100644
--- a/asdf.lisp
+++ b/asdf.lisp
@@ -1,4 +1,4 @@
-;;; This is asdf: Another System Definition Facility. Revision: @@VERSION@@ 
+;;; This is asdf: Another System Definition Facility. 
 ;;; hash - $Format:%H$
 ;;;
 ;;; Feedback, bug reports, and patches are all welcome: please mail to
@@ -120,16 +120,25 @@
 (in-package #:asdf)
 
 (defvar *asdf-revision*
+  ;; find first tag that looks like /tags/[0-9]*\.[0-9]*. E.g., /tags/1.34
+  ;; return nil or a list of the major and minor version numbers
   (let* ((v "$Format:%d$")
 	 (to-find "tags/")
-	 (tags (search to-find v :test #'char=)))
-    (when (and v tags)
-      (let ((dot (position #\. v :start tags)))
-	(when dot
-	  (list (parse-integer v :start (+ tags (length to-find))
-			       :junk-allowed t)
-		(parse-integer v :start (1+ dot)
-			       :junk-allowed t)))))))
+	 (start 0))
+    (when v
+      (loop for tag-start = (search to-find v :test #'char= :start2 start)
+	 while tag-start do
+	 (when tag-start
+	   (let ((dot (position #\. v :start tag-start))
+		 (space (position #\space v :start tag-start)))
+	     (when (and dot (or (not space) (< dot space)))
+	       ;; success
+	       (return
+		 (list (parse-integer v :start (+ tag-start (length to-find))
+				      :junk-allowed t)
+		       (parse-integer v :start (1+ dot)
+				      :junk-allowed t))))
+	     (setf start (1+ tag-start))))))))
 
 (defvar *compile-file-warnings-behaviour* :warn)
 
-- 
GitLab