changeset 5695:9dc294ae3004

Fix erroneous regular xpression in register.el. Thank you Stephen Turnbull. lisp/ChangeLog additions: 2012-12-14 Mats Lidell <matsl@xemacs.org> * register.el (describe-register-1): Fix erroneous regular expression. Thank you Stephen Turnbull. tests/ChangeLog additions: 2012-12-14 Mats Lidell <matsl@xemacs.org> * automated/register-tests.el: New. Test for register.el. Test case for bug in regular expression in describe-register-1
author Mats Lidell <matsl@xemacs.org>
date Fri, 14 Dec 2012 01:19:36 +0100
parents 7f4c8574a590
children 9f1c9f957073
files lisp/ChangeLog lisp/register.el tests/ChangeLog tests/automated/register-tests.el
diffstat 4 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Nov 06 23:12:06 2012 +0000
+++ b/lisp/ChangeLog	Fri Dec 14 01:19:36 2012 +0100
@@ -1,3 +1,8 @@
+2012-12-14  Mats Lidell  <matsl@xemacs.org>
+
+	* register.el (describe-register-1): Fix erroneous regular
+	expression. Thank you Stephen Turnbull.
+
 2012-11-06  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* cl-macs.el (equal, member, assoc, rassoc):
--- a/lisp/register.el	Tue Nov 06 23:12:06 2012 +0000
+++ b/lisp/register.el	Fri Dec 14 01:19:36 2012 +0100
@@ -1,6 +1,6 @@
 ;;; register.el --- register commands for Emacs
 
-;; Copyright (C) 1985, 1993, 1994, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1993, 1994, 1997, 2012 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal, dumped
@@ -237,7 +237,7 @@
 	    (princ val))
 	(cond
 	 ;; Extract first N characters starting with first non-whitespace.
-	 ((string-match (format "[^ \t\n].\\{,%d\\}"
+	 ((string-match (format "[^ \t\n].\\{0,%d\\}"
 				;; Deduct 6 for the spaces inserted below.
 				(min 20 (max 0 (- (window-width) 6))))
 			val)
--- a/tests/ChangeLog	Tue Nov 06 23:12:06 2012 +0000
+++ b/tests/ChangeLog	Fri Dec 14 01:19:36 2012 +0100
@@ -1,3 +1,8 @@
+2012-12-14  Mats Lidell  <matsl@xemacs.org>
+
+	* automated/register-tests.el: New. Test for register.el. Test
+	case for bug in regular expression in describe-register-1
+
 2012-10-13  Mats Lidell  <matsl@xemacs.org>
 
 	* automated/process-tests.el: Simple test cases for
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/automated/register-tests.el	Fri Dec 14 01:19:36 2012 +0100
@@ -0,0 +1,48 @@
+;; Copyright (C) 2012 Free Software Foundation, Inc.
+
+;; Author: Mats Lidell <matsl@xemacs.org>
+;; Maintainer: 
+;; Created: 2012
+;; Keywords: tests
+
+;; This file is part of XEmacs.
+
+;; XEmacs 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 3 of the License, or (at your
+;; option) any later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+;; for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Synched up with: Not in FSF.
+
+;;; Commentary:
+
+;; Test tag support.
+;; See test-harness.el for instructions on how to run these tests.
+
+(require 'test-harness)
+
+(let ((s "Short"))
+  (with-output-to-temp-buffer "*Output Register Tests*"
+    (set-register 'a s)
+    (Assert (equal (get-register 'a) s))
+    (Assert (equal (describe-register-1 'a t) s))
+    (Assert (equal (describe-register-1 'a) s))))
+
+;; describe-register-1 without verbose on depends on window-width
+;; which is 10!? in batch mode. Hence the short part of the string
+;; returned
+
+(let ((s "String longer than 5 chars"))
+  (with-output-to-temp-buffer "*Output Register Tests*"
+    (set-register 'a s)
+    (Assert (equal (get-register 'a) s))
+    (Assert (equal (describe-register-1 'a t) s))
+    (Assert (equal (describe-register-1 'a) (subseq s 0 5)))))