From e3ed2c1dafb3924a17f56ca5bd037ccbc2fd18a8 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Tue, 16 Jan 2007 17:28:22 +0000
Subject: [PATCH] Version numbers should not start with 0.  This causes
 problems print/read consistency because "foo.~01~ is printed as "foo.~1~".
 This could be fixed in other places, but it seems best not to allow leading
 zeroes in the version number.

Patch from Madhu, cmucl-imp, 2007-01-14.
---
 code/filesys.lisp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/code/filesys.lisp b/code/filesys.lisp
index 5da81b0f1..ea18878b4 100644
--- a/code/filesys.lisp
+++ b/code/filesys.lisp
@@ -6,7 +6,7 @@
 ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/filesys.lisp,v 1.100 2006/03/14 15:19:10 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/filesys.lisp,v 1.101 2007/01/16 17:28:22 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -38,7 +38,7 @@
 ;;; search-list := [^:/]*:
 ;;; file := [^/]*
 ;;; type := "." [^/.]*
-;;; version := ".*" | ".~" ([0-9]+ | "*") "~"
+;;; version := ".*" | ".~" ([1-9]+[0-9]* | "*") "~"
 ;;;
 ;;; Note: this grammar is ambiguous.  The string foo.bar.~5~ can be parsed
 ;;; as either just the file specified or as specifying the file, type, and
@@ -204,9 +204,10 @@
 	       (t
 		;; Look for a version number.  Start at the end, just
 		;; before the ~ and keep looking for digits.  If the
-		;; first non-digit is ~, we have a version number, so
-		;; get it.  If not, we didn't find a version number,
-		;; so we call it :newest
+		;; first non-digit is ~, and the leading character is
+		;; a non-zero digit, we have a version number, so get
+		;; it.  If not, we didn't find a version number, so we
+		;; call it :newest
 		(do ((i (- end 2) (1- i)))
 		    ((< i (+ start 1))
 		     ;;(format t "case 3: ~A ~A~%" :newest end)
@@ -214,9 +215,11 @@
 		  (let ((char (schar namestr i)))
 		    (when (eql char #\~)
 		      (return (if (char= (schar namestr (1- i)) #\.)
-				  (values (parse-integer namestr :start (1+ i)
-							 :end (1- end))
-					  (1- i))
+				  (if (char= (schar namestr (1+ i)) #\0)
+				      (values nil end)
+				      (values (parse-integer namestr :start (1+ i)
+							     :end (1- end))
+					      (1- i)))
 				  (values :newest end))))
 		    (unless (char<= #\0 char #\9)
 		      ;; It's not a digit.  Give up, and say the
-- 
GitLab