2001-12-06 10:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Thu, 6 Dec 2001 15:32:18 +0000 (15:32 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Thu, 6 Dec 2001 15:32:18 +0000 (15:32 +0000)
* nnweb.el (nnweb-replace-in-string): Removed.

* gnus-util.el (gnus-replace-in-string): New.
(gnus-mode-string-quote): Use it.

* nnrss.el (nnrss-format-string): Use gnus-replace-in-string.
* nnwfm.el (nnwfm-create-mapping): Ditto.

lisp/ChangeLog
lisp/gnus-util.el
lisp/nnrss.el
lisp/nnweb.el
lisp/nnwfm.el

index 2e5afa1..f916d08 100644 (file)
@@ -1,3 +1,13 @@
+2001-12-06 10:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * nnweb.el (nnweb-replace-in-string): Removed.
+
+       * gnus-util.el (gnus-replace-in-string): New.
+       (gnus-mode-string-quote): Use it.
+
+       * nnrss.el (nnrss-format-string): Use gnus-replace-in-string.
+       * nnwfm.el (nnwfm-create-mapping): Ditto.
+
 2001-12-06 01:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * dgnushack.el (dgnushack-compile): nnrss.el and
index 2e92f33..ec4f490 100644 (file)
   (autoload 'rmail-count-new-messages "rmail")
   (autoload 'rmail-show-message "rmail"))
 
+(eval-and-compile
+  (cond
+   ((fboundp 'replace-in-string)
+    (defalias 'gnus-replace-in-string 'replace-in-string))
+   ((fboundp 'replace-regexp-in-string)
+    (defun gnus-replace-in-string  (string regexp newtext &optional literal)
+      (replace-regexp-in-string regexp newtext string nil literal)))
+   (t
+    (defun gnus-replace-in-string (string regexp newtext &optional literal)
+      (let ((start 0) tail)
+       (while (string-match regexp string start)
+         (setq tail (- (length string) (match-end 0)))
+         (setq string (replace-match newtext t t string))
+         (setq start (- (length string) tail))))
+      string))))
+
 (defun gnus-boundp (variable)
   "Return non-nil if VARIABLE is bound and non-nil."
   (and (boundp variable)
@@ -395,13 +411,7 @@ Cache the result as a text property stored in DATE."
 
 (defun gnus-mode-string-quote (string)
   "Quote all \"%\"'s in STRING."
-  (save-excursion
-    (gnus-set-work-buffer)
-    (insert string)
-    (goto-char (point-min))
-    (while (search-forward "%" nil t)
-      (insert "%"))
-    (buffer-string)))
+  (gnus-replace-in-string string "%" "%%"))
 
 ;; Make a hash table (default and minimum size is 256).
 ;; Optional argument HASHSIZE specifies the table size.
index 9d755e8..367cfce 100644 (file)
@@ -572,13 +572,8 @@ It is useful when `(setq nnrss-use-local t)'."
     (if changed
        (nnrss-save-server-data ""))))
 
-(defun nnrss-replace-in-string (string match newtext)
-  (while (string-match match string)
-    (setq string (replace-match newtext t t string)))
-  string)
-
 (defun nnrss-format-string (string)
-  (nnrss-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
+  (gnus-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
 
 (defun nnrss-node-text (node)
   (if (and node (listp node))
index 740b182..277e24e 100644 (file)
@@ -987,11 +987,6 @@ If FOLLOW-REFRESH is non-nil, redirect refresh url in META."
                 (listp (cdr element)))
        (nnweb-text-1 element)))))
 
-(defun nnweb-replace-in-string (string match newtext)
-  (while (string-match match string)
-    (setq string (replace-match newtext t t string)))
-  string)
-
 (provide 'nnweb)
 
 ;;; nnweb.el ends here
index ddf072b..27d2b72 100644 (file)
          (setq description (car (last (nnweb-text (nth 1 row)))))
          (setq articles
                (string-to-number
-                (nnweb-replace-in-string
+                (gnus-replace-in-string
                  (car (last (nnweb-text (nth 3 row)))) "," "")))
          (when (and href
                     (string-match "GroupId=\\([0-9]+\\)" href))
        (while (re-search-forward "  wr(" nil t)
          (forward-char -1)
          (setq elem (message-tokenize-header
-                     (nnweb-replace-in-string
+                     (gnus-replace-in-string
                       (buffer-substring
                        (1+ (point))
                        (progn
                       "\\\\[\"\\\\]" "")))
          (push (list
                 (string-to-number (nth 1 elem))
-                (nnweb-replace-in-string (nth 2 elem) "\"" "")
+                (gnus-replace-in-string (nth 2 elem) "\"" "")
                 (string-to-number (nth 5 elem)))
                forum-contents))
        (when (re-search-forward "href=\"\\(Thread.*DateLast=\\([^\"]+\\)\\)"