]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/copyright.el
(string-to-syntax): Mark it as pure.
[gnu-emacs] / lisp / emacs-lisp / copyright.el
index 30c76b8769a64c85484055cebe170a41b17cea4d..ff44b3cb59e3528ffa2faef60bf9384f355ff147 100644 (file)
@@ -1,7 +1,7 @@
 ;;; copyright.el --- update the copyright notice in current buffer
 
-;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2003, 2004, 2005
-;;           Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2002, 2003,
+;;   2004, 2005 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
 ;; Keywords: maint, tools
@@ -20,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -185,25 +185,24 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
   (widen)
   (goto-char (point-min))
   (if (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
-      (let ((s (match-beginning 2)) (e (make-marker))
+      (let ((s (match-beginning 2))
+           (e (copy-marker (1+ (match-end 2))))
+           (p (make-marker))
            last)
-       (set-marker e (1+ (match-end 2)))
        (goto-char s)
-       ;; Back up one character so that our search can match the first year.
-       (backward-char 1)
-       (while (and (< (point) (marker-position e))
-                   (re-search-forward "\\([^0-9]\\)\\([0-9]+\\)[^0-9]"
-                                      (marker-position e) t))
-         (let ((p (point))
-               (sep (match-string 1))
-               (year (string-to-number (match-string 2))))
-           (goto-char (1+ (match-beginning 0)))
-           (unless (= (char-syntax (string-to-char sep)) ?\s)
+       (while (re-search-forward "[0-9]+" e t)
+         (set-marker p (point))
+         (goto-char (match-beginning 0))
+         (let ((sep (char-before))
+               (year (string-to-number (match-string 0))))
+           (when (and sep
+                      (/= (char-syntax sep) ?\s)
+                      (/= sep ?-))
              (insert " "))
-           (if (< year 100)
-               (insert (if (>= year 50) "19" "20")))
-           (goto-char p)
-           (setq last p)))
+           (when (< year 100)
+             (insert (if (>= year 50) "19" "20"))))
+         (goto-char p)
+         (setq last p))
        (when last
          (goto-char last)
          ;; Don't mess up whitespace after the years.
@@ -211,12 +210,11 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
          (save-restriction
            (narrow-to-region (point-min) (point))
            (let ((fill-prefix "     "))
-             (fill-region s last)))
-         )
+             (fill-region s last))))
        (set-marker e nil)
+       (set-marker p nil)
        (copyright-update nil t))
-    (message "No copyright message")
-    (goto-char (point-min))))
+    (message "No copyright message")))
 
 ;;;###autoload
 (define-skeleton copyright