changeset 110534:826d60163924

Merge changes from emacs-23 branch.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 23 Sep 2010 22:10:54 -0400
parents 64945cefe6a6 (diff) b799d38f522a (current diff)
children eb986ca47c5a
files lisp/gnus/ChangeLog src/ChangeLog
diffstat 28 files changed, 504 insertions(+), 278 deletions(-) [+]
line wrap: on
line diff
--- a/doc/misc/gnus.texi	Thu Sep 23 15:00:31 2010 -0400
+++ b/doc/misc/gnus.texi	Thu Sep 23 22:10:54 2010 -0400
@@ -1646,6 +1646,12 @@
 Jingle to be played if the above variable is non-@code{nil}.  The
 default is @samp{Tuxedomoon.Jingle4.au}.
 
+@item gnus-use-backend-marks
+@vindex gnus-use-backend-marks
+If non-@code{nil}, Gnus will store article marks both in the
+@file{.newsrc.eld} file and in the backends.  This will slow down
+group operation some.
+
 @end table
 
 
--- a/lisp/gnus/ChangeLog	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/ChangeLog	Thu Sep 23 22:10:54 2010 -0400
@@ -1,8 +1,74 @@
-2010-09-21  Glenn Morris  <rgm@gnu.org>
+2010-09-24  Glenn Morris  <rgm@gnu.org>
 
 	* message.el (message-output): Use gnus-output-to-rmail if a buffer is
 	visiting the fcc file in rmail-mode.
 
+2010-09-24  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+	* nnir.el: Silence the byte compiler.
+
+	* gnus-html.el (gnus-html-encode-url-chars): New function, that's an
+	alias to browse-url-url-encode-chars if any.
+	(gnus-html-encode-url): Use it.
+
+2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-start.el (gnus-use-backend-marks): New variable.
+	(gnus-get-unread-articles-in-group): Use it.
+
+	* gnus-sum.el (gnus-summary-local-variables): Prepare for list/range
+	makeover.
+
+2010-09-23  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnimap.el (nnimap-retrieve-headers): Return 'headers.
+
+2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* gnus-start.el (gnus-fixup-nnimap-unread-after-getting-new-news):
+	Removed.
+	(gnus-setup-news-hook): Removed
+	gnus-fixup-nnimap-unread-after-getting-new-news.
+
+	* gnus-int.el (gnus-request-update-info): Protect against backends not
+	having the function.
+
+	* nnimap.el (nnimap-stream): Mention starttls.
+	(nnimap-open-connection): Add starttls support.
+
+2010-09-23  Andrew Cohen  <cohen@andy.bu.edu>
+
+	* nnir.el (nnir-run-imap): Fix up nnir to work with the new nnimap.
+
+2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* nnimap.el (nnimap-transform-headers): Don't bug out on invalid
+	BODYSTRUCTUREs.
+	(nnimap-transform-headers): Unfold quoted {42} headers.
+
+	* gnus-start.el (gnus-get-unread-articles): Allow backends to update
+	the info.
+	(gnus-get-unread-articles): Only call updatep on backends that support
+	it.
+
+	* nnweb.el (nnweb-request-update-info): NOOP.
+
+	* nnmaildir.el (nnmaildir-request-marks): Renamed from -update-info.
+
+	* nnfolder.el (nnfolder-request-marks): Renamed from -update-info,
+	since it only deals with marks.
+
+	* gnus-int.el (gnus-request-marks): Renamed gnus-request-update-info to
+	gnus-request-marks, and make a new gnus-request-update-info.
+
+	* nnimap.el (nnimap-update-info): When UIDNEXT is present, use that for
+	the active instead of the high number, which is usually too low.
+
+2010-09-23  Teodor Zlatanov  <tzz@lifelogs.com>
+
+	* netrc.el (netrc-parse): Remove encrypt.el mentions.
+	* encrypt.el: Removed.
+
 2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* nnimap.el (nnimap-update-info): Sync non-standard flags from the
@@ -27,11 +93,6 @@
 	`gnus-get-unread-articles-in-group' update info, since that can be
 	really slow and doesn't seem to be needed?
 
-2010-09-22  Dan Christensen  <jdc@uwo.ca>
-
-	* time-date.el (date-to-time): Try using parse-time-string first before
-	using the slower timezone-make-date-arpa-standard.
-
 2010-09-22  Julien Danjou  <julien@danjou.info>
 
 	* gnus-group.el (gnus-group-insert-group-line): Call
@@ -89,11 +150,9 @@
 
 2010-09-22  Julien Danjou  <julien@danjou.info>
 
-	* gnus-html.el (gnus-html-rescale-image): Use window-inside-pixel-edges
-	rather than window-pixel-edges.
-	(gnus-html-put-image): Stop using markers. They are harmful if you have
-	2 images side-by-side, they can't be properly update on text deletion.
-	Using text-property is safer here.
+	* gnus-html.el (gnus-html-put-image): Stop using markers. They are
+	harmful if you have 2 images side-by-side, they can't be properly
+	update on text deletion.  Using text-property is safer here.
 	(gnus-html-image-fetched): Search also for \r\n\r\n to get the start of
 	data.
 
--- a/lisp/gnus/gnus-html.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/gnus-html.el	Thu Sep 23 22:10:54 2010 -0400
@@ -88,9 +88,27 @@
     (define-key map [tab] 'widget-forward)
     map))
 
+(eval-and-compile
+  (defalias 'gnus-html-encode-url-chars
+    (if (fboundp 'browse-url-url-encode-chars)
+	'browse-url-url-encode-chars
+      (lambda (text chars)
+	"URL-encode the chars in TEXT that match CHARS.
+CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
+	(let ((encoded-text (copy-sequence text))
+	      (s 0))
+	  (while (setq s (string-match chars encoded-text s))
+	    (setq encoded-text
+		  (replace-match (format "%%%x"
+					 (string-to-char
+					  (match-string 0 encoded-text)))
+				 t t encoded-text)
+		  s (1+ s)))
+	  encoded-text)))))
+
 (defun gnus-html-encode-url (url)
   "Encode URL."
-  (browse-url-url-encode-chars url "[)$ ]"))
+  (gnus-html-encode-url-chars url "[)$ ]"))
 
 (defun gnus-html-cache-expired (url ttl)
   "Check if URL is cached for more than TTL."
@@ -432,7 +450,7 @@
       image
     (let* ((width (car size))
 	   (height (cdr size))
-	   (edges (window-inside-pixel-edges (get-buffer-window (current-buffer))))
+	   (edges (window-pixel-edges (get-buffer-window (current-buffer))))
 	   (window-width (truncate (* gnus-max-image-proportion
 				      (- (nth 2 edges) (nth 0 edges)))))
 	   (window-height (truncate (* gnus-max-image-proportion
--- a/lisp/gnus/gnus-int.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/gnus-int.el	Thu Sep 23 22:10:54 2010 -0400
@@ -584,12 +584,21 @@
 	       (and group (gnus-group-real-name group))
 	       (nth 1 gnus-command-method)))))
 
-(defsubst gnus-request-update-info (info gnus-command-method)
+(defun gnus-request-update-info (info gnus-command-method)
+  (when (gnus-check-backend-function
+	 'request-update-info (car gnus-command-method))
+    (when (stringp gnus-command-method)
+      (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
+    (funcall (gnus-get-function gnus-command-method 'request-update-info)
+	     (gnus-group-real-name (gnus-info-group info)) info
+	     (nth 1 gnus-command-method))))
+
+(defsubst gnus-request-marks (info gnus-command-method)
   "Request that GNUS-COMMAND-METHOD update INFO."
   (when (stringp gnus-command-method)
     (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
   (when (gnus-check-backend-function
-	 'request-update-info (car gnus-command-method))
+	 'request-marks (car gnus-command-method))
     (let ((group (gnus-info-group info)))
       (and (funcall (gnus-get-function gnus-command-method
 				       'request-update-info)
--- a/lisp/gnus/gnus-start.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/gnus-start.el	Thu Sep 23 22:10:54 2010 -0400
@@ -380,6 +380,13 @@
   :group 'gnus-newsrc
   :type 'boolean)
 
+(defcustom gnus-use-backend-marks nil
+  "If non-nil, Gnus will store and retrieve marks from the backends.
+This means that marks will be stored both in .newsrc.eld and in
+the backend, and will slow operation down somewhat."
+  :group 'gnus-newsrc
+  :type 'boolean)
+
 (defcustom gnus-check-bogus-groups-hook nil
   "A hook run after removing bogus groups."
   :group 'gnus-start-server
@@ -402,8 +409,7 @@
   :group 'gnus-start
   :type 'hook)
 
-(defcustom gnus-setup-news-hook
-  '(gnus-fixup-nnimap-unread-after-getting-new-news)
+(defcustom gnus-setup-news-hook nil
   "A hook after reading the .newsrc file, but before generating the buffer."
   :group 'gnus-start
   :type 'hook)
@@ -420,8 +426,7 @@
   :type 'hook)
 
 (defcustom gnus-after-getting-new-news-hook
-  '(gnus-display-time-event-handler
-    gnus-fixup-nnimap-unread-after-getting-new-news)
+  '(gnus-display-time-event-handler)
   "*A hook run after Gnus checks for new news when Gnus is already running."
   :group 'gnus-group-new
   :type 'hook)
@@ -1580,6 +1585,13 @@
 			      (gnus-info-group info)))))
       (gnus-activate-group (gnus-info-group info) nil t))
 
+    ;; Allow backends to update marks, 
+    (when gnus-use-backend-marks
+      (let ((method (inline (gnus-find-method-for-group
+			     (gnus-info-group info)))))
+	(when (gnus-check-backend-function 'request-marks (car method))
+	  (gnus-request-marks info method))))
+
     (let* ((range (gnus-info-read info))
 	   (num 0))
 
@@ -1765,11 +1777,14 @@
     (dolist (elem type-cache)
       (destructuring-bind (method method-type infos early-data) elem
 	(when (and method infos)
-	  ;; See if any of the groups from this method require updating.
-	  (gnus-read-active-for-groups method infos early-data)
-	  (dolist (info infos)
-	    (inline (gnus-get-unread-articles-in-group
-		     info (gnus-active (gnus-info-group info))))))))
+	  (let ((updatep (gnus-check-backend-function
+			  'request-update-info (car method))))
+	    ;; See if any of the groups from this method require updating.
+	    (gnus-read-active-for-groups method infos early-data)
+	    (dolist (info infos)
+	      (inline (gnus-get-unread-articles-in-group
+		       info (gnus-active (gnus-info-group info))
+		       updatep)))))))
     (gnus-message 6 "Checking new news...done")))
 
 (defun gnus-method-rank (type method)
@@ -3145,20 +3160,6 @@
 	   (gnus-boundp 'display-time-timer))
       (display-time-event-handler)))
 
-;;;###autoload
-(defun gnus-fixup-nnimap-unread-after-getting-new-news ()
-  (let (server group info)
-    (mapatoms
-     (lambda (sym)
-       (when (and (setq group (symbol-name sym))
-		  (gnus-group-entry group)
-		  (setq info (symbol-value sym)))
-	 (gnus-sethash group (cons (nth 2 info) (cdr (gnus-group-entry group)))
-		       gnus-newsrc-hashtb)))
-     (if (boundp 'nnimap-mailbox-info)
-	 (symbol-value 'nnimap-mailbox-info)
-       (make-vector 1 0)))))
-
 (defun gnus-check-reasonable-setup ()
   ;; Check whether nnml and nnfolder share a directory.
   (let ((display-warn
--- a/lisp/gnus/gnus-sum.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/gnus-sum.el	Thu Sep 23 22:10:54 2010 -0400
@@ -1539,22 +1539,34 @@
 
 (defvar gnus-summary-local-variables
   '(gnus-newsgroup-name
+
+    ;; Marks lists
+    gnus-newsgroup-unreads
+    gnus-newsgroup-unselected
+    gnus-newsgroup-marked
+    gnus-newsgroup-spam-marked
+    gnus-newsgroup-reads
+    gnus-newsgroup-saved
+    gnus-newsgroup-replied
+    gnus-newsgroup-forwarded
+    gnus-newsgroup-recent
+    gnus-newsgroup-expirable
+    gnus-newsgroup-killed
+    gnus-newsgroup-unseen
+    gnus-newsgroup-seen
+    gnus-newsgroup-cached
+    gnus-newsgroup-downloadable
+    gnus-newsgroup-undownloaded
+    gnus-newsgroup-unsendable
+
     gnus-newsgroup-begin gnus-newsgroup-end
     gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
     gnus-newsgroup-last-folder gnus-newsgroup-last-file
     gnus-newsgroup-last-directory
-    gnus-newsgroup-auto-expire gnus-newsgroup-unreads
-    gnus-newsgroup-unselected gnus-newsgroup-marked
-    gnus-newsgroup-spam-marked
-    gnus-newsgroup-reads gnus-newsgroup-saved
-    gnus-newsgroup-replied gnus-newsgroup-forwarded
-    gnus-newsgroup-recent
-    gnus-newsgroup-expirable
-    gnus-newsgroup-processable gnus-newsgroup-killed
-    gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
+    gnus-newsgroup-auto-expire
+    gnus-newsgroup-processable
     gnus-newsgroup-unfetched
-    gnus-newsgroup-unsendable gnus-newsgroup-unseen
-    gnus-newsgroup-seen gnus-newsgroup-articles
+    gnus-newsgroup-articles
     gnus-newsgroup-bookmarks gnus-newsgroup-dormant
     gnus-newsgroup-headers gnus-newsgroup-threads
     gnus-newsgroup-prepared gnus-summary-highlight-line-function
@@ -1573,7 +1585,7 @@
     (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
     gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
     (gnus-newsgroup-expunged-tally . 0)
-    gnus-cache-removable-articles gnus-newsgroup-cached
+    gnus-cache-removable-articles
     gnus-newsgroup-data gnus-newsgroup-data-reverse
     gnus-newsgroup-limit gnus-newsgroup-limits
     gnus-newsgroup-charset gnus-newsgroup-display
--- a/lisp/gnus/nnfolder.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnfolder.el	Thu Sep 23 22:10:54 2010 -0400
@@ -1202,7 +1202,7 @@
     (nnfolder-save-marks group server))
   nil)
 
-(deffoo nnfolder-request-update-info (group info &optional server)
+(deffoo nnfolder-request-marks (group info &optional server)
   ;; Change servers.
   (when (and server
 	     (not (nnfolder-server-opened server)))
--- a/lisp/gnus/nnimap.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnimap.el	Thu Sep 23 22:10:54 2010 -0400
@@ -51,7 +51,7 @@
 
 (defvoo nnimap-stream 'ssl
   "How nnimap will talk to the IMAP server.
-Values are `ssl', `network' or `shell'.")
+Values are `ssl', `network', `starttls' or `shell'.")
 
 (defvoo nnimap-shell-program (if (boundp 'imap-shell-program)
 				 (if (listp imap-shell-program)
@@ -135,19 +135,26 @@
 	(nnimap-transform-headers))
       (insert-buffer-substring
        (nnimap-find-process-buffer (current-buffer))))
-    t))
+    'headers))
 
 (defun nnimap-transform-headers ()
   (goto-char (point-min))
-  (let (article bytes lines size)
+  (let (article bytes lines size string)
     (block nil
       (while (not (eobp))
 	(while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
 	  (delete-region (point) (progn (forward-line 1) (point)))
 	  (when (eobp)
 	    (return)))
-	(setq article (match-string 1)
-	      bytes (nnimap-get-length)
+	(setq article (match-string 1))
+	;; Unfold quoted {number} strings.
+	(while (re-search-forward "[^]] {\\([0-9]+\\)}\r\n"
+				  (1+ (line-end-position)) t)
+	  (setq size (string-to-number (match-string 1)))
+	  (delete-region (+ (match-beginning 0) 2) (point))
+	  (setq string (delete-region (point) (+ (point) size)))
+	  (insert (format "%S" string)))
+	(setq bytes (nnimap-get-length)
 	      lines nil)
 	(beginning-of-line)
 	(setq size
@@ -157,7 +164,8 @@
 		   (match-string 1)))
 	(beginning-of-line)
 	(when (search-forward "BODYSTRUCTURE" (line-end-position) t)
-	  (let ((structure (ignore-errors (read (current-buffer)))))
+	  (let ((structure (ignore-errors
+			     (read (current-buffer)))))
 	    (while (and (consp structure)
 			(not (stringp (car structure))))
 	      (setq structure (car structure)))
@@ -257,6 +265,11 @@
 	       "*nnimap*" (current-buffer) nnimap-address
 	       (or nnimap-server-port "imap"))
 	      '("imap"))
+	     ((eq nnimap-stream 'starttls)
+	      (starttls-open-stream
+	       "*nnimap*" (current-buffer) nnimap-address
+	       (or nnimap-server-port "imap"))
+	      '("imap"))
 	     ((eq nnimap-stream 'ssl)
 	      (open-tls-stream
 	       "*nnimap*" (current-buffer) nnimap-address
@@ -273,6 +286,9 @@
 		       '(open run)))
 	(gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil)
 	(when (setq connection-result (nnimap-wait-for-connection))
+	  (when (eq nnimap-stream 'starttls)
+	    (nnimap-send-command "STARTTLS")
+	    (starttls-negotiate (nnimap-process nnimap-object)))
 	  (unless (equal connection-result "PREAUTH")
 	    (if (not (setq credentials
 			   (if (eq nnimap-authenticator 'anonymous)
@@ -419,14 +435,11 @@
 	      (when info
 		(nnimap-update-infos marks (list info)))
 	      (goto-char (point-max))
-	      (cond
-	       (marks
-		(let ((uidnext (nth 5 (car marks))))
-		  (setq high (or (nth 3 (car marks)) (1- uidnext))
-			low (or (nth 4 (car marks)) uidnext))))
-	       ((re-search-backward "UIDNEXT \\([0-9]+\\)" nil t)
-		(setq high (1- (string-to-number (match-string 1)))
-		      low 1)))))
+	      (let ((uidnext (nth 5 (car marks))))
+		(setq high (if uidnext
+			       (1- uidnext)
+			     (nth 3 (car marks)))
+		      low (or (nth 4 (car marks)) uidnext)))))
 	  (erase-buffer)
 	  (insert
 	   (format
@@ -782,11 +795,13 @@
       (let ((group (gnus-info-group info))
 	    (completep (and start-article
 			    (= start-article 1))))
+	(when uidnext
+	  (setq high (1- uidnext)))
 	;; First set the active ranges based on high/low.
 	(if (or completep
 		(not (gnus-active group)))
 	    (gnus-set-active group
-			     (if high
+			     (if (and low high)
 				 (cons low high)
 			       ;; No articles in this group.
 			       (cons uidnext (1- uidnext))))
--- a/lisp/gnus/nnir.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnir.el	Thu Sep 23 22:10:54 2010 -0400
@@ -956,6 +956,11 @@
 (autoload 'imap-search "imap")
 (autoload 'imap-quote-specials "imap")
 
+(eval-when-compile
+  (autoload 'nnimap-buffer "nnimap")
+  (autoload 'nnimap-command "nnimap")
+  (autoload 'nnimap-possibly-change-group "nnimap"))
+
 (defun nnir-run-imap (query srv &optional group-option)
   "Run a search against an IMAP back-end server.
 This uses a custom query language parser; see `nnir-imap-make-query' for
@@ -967,23 +972,27 @@
 	  (defs (caddr (gnus-server-to-method srv)))
 	  (criteria (or (cdr (assq 'criteria query))
 			nnir-imap-search-field))
-	  artlist buf)
+	  (gnus-inhibit-demon t)
+	  artlist)
       (message "Opening server %s" server)
       (condition-case ()
-	  (when (nnimap-open-server server defs) ;; xxx
-	    (setq buf nnimap-server-buffer) ;; xxx
-	    (message "Searching %s..." group)
-            (let ((arts 0)
-                  (mbx (gnus-group-real-name group)))
-              (when (imap-mailbox-select mbx nil buf)
-                (mapc
-                 (lambda (artnum)
-                   (push (vector group artnum 1) artlist)
-                   (setq arts (1+ arts)))
-                 (imap-search (nnir-imap-make-query criteria qstring) buf))
-                (message "Searching %s... %d matches" mbx arts)))
-            (message "Searching %s...done" group))
-        (quit nil))
+	  (when (nnimap-possibly-change-group (gnus-group-short-name group) server)
+	    (with-current-buffer (nnimap-buffer)
+	      (message "Searching %s..." group)
+	      (let ((arts 0)
+		    (result
+		     (nnimap-command "UID SEARCH  %s" 
+				     (nnir-imap-make-query criteria qstring))))
+		(mapc
+		 (lambda (artnum)
+		   (push (vector group artnum 1) artlist)
+		   (setq arts (1+ arts)))
+		 (and (car result)
+		      (delete 0 (mapcar #'string-to-number
+					(cdr (assoc "SEARCH" (cdr result)))))))
+		(message "Searching %s... %d matches" group arts)))
+	    (message "Searching %s...done" group))
+	(quit nil))
       (reverse artlist))))
 
 (defun nnir-imap-make-query (criteria qstring)
--- a/lisp/gnus/nnmaildir.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnmaildir.el	Thu Sep 23 22:10:54 2010 -0400
@@ -916,7 +916,7 @@
 		  "\n")))))
   'group)
 
-(defun nnmaildir-request-update-info (gname info &optional server)
+(defun nnmaildir-request-marks (gname info &optional server)
   (let ((group (nnmaildir--prepare server gname))
 	pgname flist always-marks never-marks old-marks dotfile num dir
 	markdirs marks mark ranges markdir article read end new-marks ls
--- a/lisp/gnus/nnmairix.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnmairix.el	Thu Sep 23 22:10:54 2010 -0400
@@ -705,7 +705,7 @@
 
 (autoload 'nnimap-request-update-info-internal "nnimap")
 
-(deffoo nnmairix-request-update-info (group info &optional server)
+(deffoo nnmairix-request-marks (group info &optional server)
 ;; propagate info from underlying IMAP folder to nnmairix group
 ;; This is currently experimental and must be explicitly activated
 ;; with nnmairix-propagate-marks-to-nnmairix-group
--- a/lisp/gnus/nnml.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnml.el	Thu Sep 23 22:10:54 2010 -0400
@@ -1047,7 +1047,7 @@
     (nnml-save-marks group server))
   nil)
 
-(deffoo nnml-request-update-info (group info &optional server)
+(deffoo nnml-request-marks (group info &optional server)
   (nnml-possibly-change-directory group server)
   (when (and (not nnml-marks-is-evil) (nnml-marks-changed-p group server))
     (nnheader-message 8 "Updating marks for %s..." group)
--- a/lisp/gnus/nntp.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nntp.el	Thu Sep 23 22:10:54 2010 -0400
@@ -1130,7 +1130,7 @@
     (nntp-save-marks group server))
   nil)
 
-(deffoo nntp-request-update-info (group info &optional server)
+(deffoo nntp-request-marks (group info &optional server)
   (when (and (not nntp-marks-is-evil)
 	     nntp-marks-file-name)
     (nntp-possibly-create-directory group server)
--- a/lisp/gnus/nnweb.el	Thu Sep 23 15:00:31 2010 -0400
+++ b/lisp/gnus/nnweb.el	Thu Sep 23 22:10:54 2010 -0400
@@ -193,8 +193,7 @@
     (nnmail-generate-active (list (assoc server nnweb-group-alist)))
     t))
 
-(deffoo nnweb-request-update-info (group info &optional server)
-  (nnweb-possibly-change-server group server))
+(deffoo nnweb-request-update-info (group info &optional server))
 
 (deffoo nnweb-asynchronous-p ()
   nil)
--- a/src/ChangeLog	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/ChangeLog	Thu Sep 23 22:10:54 2010 -0400
@@ -7,8 +7,85 @@
 
 	* gtkutil.c (xg_tool_bar_menu_proxy): Set gtk-menu-items to TRUE.
 
+2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* lisp.h (SPECPDL_INDEX): Cast to int, since we're not going to
+	unwind_protect more than 2GB worth of functions.
+
+	* editfns.c (Finsert_char): EMACS_INT/int cleanup.
+
+	* lisp.h: Have oblookup take EMACS_INT to allow interning big
+	string and avoid compiler warnings.
+	(USE_SAFE_ALLOCA): Cast to int to avoid compilation warnings in
+	all users.
+
+	* lread.c (oblookup): EMACS_INT/int cleanup.
+
+	* cmds.c (Fforward_line, Fdelete_char): EMACS_INT/int cleanup.
+
 2010-09-23  Eli Zaretskii  <eliz@gnu.org>
 
+	* editfns.c (clip_to_bounds): Return an EMACS_INT value.
+
+	* lisp.h (clip_to_bounds): Adjust prototype.
+
+	* intervals.c (adjust_for_invis_intang): Return EMACS_INT value.
+
+2010-09-23  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+	* lisp.h: doprnt.c EMACS_INT/int cleanup.
+
+	* doprnt.c (doprnt): EMACS_INT/int cleanup.
+
+	* doc.c (Fsnarf_documentation, get_doc_string): EMACS_INT/int
+	cleanup.
+
+	* lisp.h: Change the definition of all marker.c functions that
+	take and return buffer stuff to be EMACS_INT instead of int.
+
+	* marker.c (buf_charpos_to_bytepos, CONSIDER, set_marker_both)
+	(buf_charpos_to_bytepos, bytepos_to_charpos)
+	(buf_bytepos_to_charpos, Fbuffer_has_markers_at)
+	(set_marker_restricted, set_marker_both): Convert int to EMACS_INT
+	for all buffer positions.
+
+2010-09-23  Chong Yidong  <cyd@stupidchicken.com>
+
+	* intervals.c (traverse_intervals, rotate_right, rotate_left)
+	(split_interval_right, find_interval, next_interval)
+	(delete_node, delete_interval, interval_deletion_adjustment)
+	(adjust_intervals_for_deletion, merge_interval_right)
+	(merge_interval_left, graft_intervals_into_buffer)
+	(copy_intervals): Convert EMACS_UINTs to EMACS_INT.
+
+	* intervals.h (traverse_intervals): Update prototype.
+
+2010-09-23  Eli Zaretskii  <eliz@gnu.org>
+
+	* indent.c (compute_motion): Use EMACS_INT for arguments to
+	region_cache_forward.
+
+	* region-cache.c (struct boundary, struct region_cache): Use
+	EMACS_INT for positions.
+	(find_cache_boundary, move_cache_gap, insert_cache_boundary)
+	(delete_cache_boundaries, set_cache_region)
+	(invalidate_region_cache, know_region_cache)
+	(region_cache_forward, region_cache_backward, pp_cache): Use
+	EMACS_INT for buffer positions.
+
+	* region-cache.h (know_region_cache, invalidate_region_cache)
+	(region_cache_forward, region_cache_backward): Adjust prototypes.
+
+	* search.c (string_match_1, fast_c_string_match_ignore_case)
+	(looking_at_1, scan_buffer, scan_newline)
+	(find_next_newline_no_quit, find_before_next_newline)
+	(search_command, trivial_regexp_p, search_buffer, simple_search)
+	(boyer_moore, wordify, Freplace_match): Use EMACS_INT for buffer
+	and string positions and length.
+
+	* lisp.h (scan_buffer, scan_newline, find_next_newline_no_quit)
+	(find_before_next_newline): Adjust prototypes.
+
 	* editfns.c (transpose_markers, update_buffer_properties)
 	(buildmark, clip_to_bounds, Fgoto_char, overlays_around)
 	(get_pos_property, Fconstrain_to_field)
@@ -17,6 +94,7 @@
 	(Finsert_buffer_substring, Fcompare_buffer_substrings)
 	(Fsubst_char_in_region, Fformat, Ftranspose_regions): Use
 	EMACS_INT for buffer and string position variables.
+	(Finsert_char): Protect against too large insertions.
 
 	* lisp.h (clip_to_bounds): Adjust prototype.
 
@@ -30,7 +108,7 @@
 	(move_if_not_intangible, get_local_map, copy_intervals)
 	(copy_intervals_to_string, compare_string_intervals)
 	(set_intervals_multibyte_1): Use EMACS_INT for buffer positions
-	and EMACS_UINT for interval tree size.
+	and for interval tree size.
 
 	* intervals.h (traverse_intervals, split_interval_right)
 	(split_interval_left, find_interval, offset_intervals)
--- a/src/cmds.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/cmds.c	Thu Sep 23 22:10:54 2010 -0400
@@ -68,7 +68,7 @@
      hooks, etcetera), that's not a good approach.  So we validate the
      proposed position, then set point.  */
   {
-    int new_point = PT + XINT (n);
+    EMACS_INT new_point = PT + XINT (n);
 
     if (new_point < BEGV)
       {
@@ -116,9 +116,9 @@
 successfully moved (for the return value).  */)
   (Lisp_Object n)
 {
-  int opoint = PT, opoint_byte = PT_BYTE;
-  int pos, pos_byte;
-  int count, shortage;
+  EMACS_INT opoint = PT, opoint_byte = PT_BYTE;
+  EMACS_INT pos, pos_byte;
+  EMACS_INT count, shortage;
 
   if (NILP (n))
     count = 1;
@@ -188,7 +188,7 @@
 to t.  */)
   (Lisp_Object n)
 {
-  int newpos;
+  EMACS_INT newpos;
 
   if (NILP (n))
     XSETFASTINT (n, 1);
@@ -233,7 +233,7 @@
 The command `delete-forward' is preferable for interactive use.  */)
   (Lisp_Object n, Lisp_Object killflag)
 {
-  int pos;
+  EMACS_INT pos;
 
   CHECK_NUMBER (n);
 
@@ -303,8 +303,8 @@
     bitch_at_user ();
   {
     int character = translate_char (Vtranslation_table_for_input,
-				    XINT (last_command_event));
-    int val = internal_self_insert (character, XFASTINT (n));
+				    (int) XINT (last_command_event));
+    int val = internal_self_insert (character, (int) XFASTINT (n));
     if (val == 2)
       nonundocount = 0;
     frame_make_pointer_invisible ();
@@ -333,8 +333,8 @@
   int len;
   /* Working buffer and pointer for multi-byte form of C.  */
   unsigned char str[MAX_MULTIBYTE_LENGTH];
-  int chars_to_delete = 0;
-  int spaces_to_insert = 0;
+  EMACS_INT chars_to_delete = 0;
+  EMACS_INT spaces_to_insert = 0;
 
   overwrite = current_buffer->overwrite_mode;
   if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
@@ -380,12 +380,12 @@
 	chars_to_delete = n;
       else if (c != '\n' && c2 != '\n')
 	{
-	  int pos = PT;
-	  int pos_byte = PT_BYTE;
+	  EMACS_INT pos = PT;
+	  EMACS_INT pos_byte = PT_BYTE;
 	  /* Column the cursor should be placed at after this insertion.
 	     The correct value should be calculated only when necessary.  */
 	  int target_clm = ((int) current_column () /* iftc */
-			    + n * XINT (Fchar_width (make_number (c))));
+			    + n * (int) XINT (Fchar_width (make_number (c))));
 
 	      /* The actual cursor position after the trial of moving
 		 to column TARGET_CLM.  It is greater than TARGET_CLM
@@ -393,7 +393,8 @@
 		 character.  In that case, the new point is set after
 		 that character.  */
 	      int actual_clm
-		= XFASTINT (Fmove_to_column (make_number (target_clm), Qnil));
+		= (int) XFASTINT (Fmove_to_column (make_number (target_clm),
+						   Qnil));
 
 	      chars_to_delete = PT - pos;
 
--- a/src/doc.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/doc.c	Thu Sep 23 22:10:54 2010 -0400
@@ -99,8 +99,8 @@
   register int fd;
   register char *name;
   register char *p, *p1;
-  int minsize;
-  int offset, position;
+  EMACS_INT minsize;
+  EMACS_INT offset, position;
   Lisp_Object file, tem;
 
   if (INTEGERP (filepos))
@@ -179,14 +179,14 @@
   p = get_doc_string_buffer;
   while (1)
     {
-      int space_left = (get_doc_string_buffer_size
-			- (p - get_doc_string_buffer));
+      EMACS_INT space_left = (get_doc_string_buffer_size
+			      - (p - get_doc_string_buffer));
       int nread;
 
       /* Allocate or grow the buffer if we need to.  */
       if (space_left == 0)
 	{
-	  int in_buffer = p - get_doc_string_buffer;
+	  EMACS_INT in_buffer = p - get_doc_string_buffer;
 	  get_doc_string_buffer_size += 16 * 1024;
 	  get_doc_string_buffer
 	    = (char *) xrealloc (get_doc_string_buffer,
@@ -286,8 +286,8 @@
   else
     {
       /* The data determines whether the string is multibyte.  */
-      int nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
-					    to - (get_doc_string_buffer + offset));
+      EMACS_INT nchars = multibyte_chars_in_text (get_doc_string_buffer + offset,
+						  to - (get_doc_string_buffer + offset));
       return make_string_from_bytes (get_doc_string_buffer + offset,
 				     nchars,
 				     to - (get_doc_string_buffer + offset));
@@ -551,8 +551,8 @@
 {
   int fd;
   char buf[1024 + 1];
-  register int filled;
-  register int pos;
+  register EMACS_INT filled;
+  register EMACS_INT pos;
   register char *p, *end;
   Lisp_Object sym;
   char *name;
@@ -586,7 +586,7 @@
 
     for (beg = buildobj; *beg; beg = end)
       {
-        int len;
+        EMACS_INT len;
 
         while (*beg && isspace (*beg)) ++beg;
 
@@ -633,7 +633,7 @@
               if (end - p > 4 && end[-2] == '.'
                   && (end[-1] == 'o' || end[-1] == 'c'))
                 {
-                  int len = end - p - 2;
+                  EMACS_INT len = end - p - 2;
                   char *fromfile = alloca (len + 1);
                   strncpy (fromfile, &p[2], len);
                   fromfile[len] = 0;
@@ -705,16 +705,16 @@
   int changed = 0;
   register unsigned char *strp;
   register unsigned char *bufp;
-  int idx;
-  int bsize;
+  EMACS_INT idx;
+  EMACS_INT bsize;
   Lisp_Object tem;
   Lisp_Object keymap;
   unsigned char *start;
-  int length, length_byte;
+  EMACS_INT length, length_byte;
   Lisp_Object name;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int multibyte;
-  int nchars;
+  EMACS_INT nchars;
 
   if (NILP (string))
     return Qnil;
@@ -766,7 +766,7 @@
 	}
       else if (strp[0] == '\\' && strp[1] == '[')
 	{
-	  int start_idx;
+	  EMACS_INT start_idx;
 	  int follow_remap = 1;
 
 	  changed = 1;
@@ -805,7 +805,7 @@
 
 	  if (NILP (tem))	/* but not on any keys */
 	    {
-	      int offset = bufp - buf;
+	      EMACS_INT offset = bufp - buf;
 	      buf = (unsigned char *) xrealloc (buf, bsize += 4);
 	      bufp = buf + offset;
 	      memcpy (bufp, "M-x ", 4);
@@ -828,7 +828,7 @@
       else if (strp[0] == '\\' && (strp[1] == '{' || strp[1] == '<'))
 	{
 	  struct buffer *oldbuf;
-	  int start_idx;
+	  EMACS_INT start_idx;
 	  /* This is for computing the SHADOWS arg for describe_map_tree.  */
 	  Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
 	  Lisp_Object earlier_maps;
@@ -899,7 +899,7 @@
 	  length_byte = SBYTES (tem);
 	subst:
 	  {
-	    int offset = bufp - buf;
+	    EMACS_INT offset = bufp - buf;
 	    buf = (unsigned char *) xrealloc (buf, bsize += length_byte);
 	    bufp = buf + offset;
 	    memcpy (bufp, start, length_byte);
--- a/src/doprnt.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/doprnt.c	Thu Sep 23 22:10:54 2010 -0400
@@ -54,7 +54,7 @@
    String arguments are passed as C strings.
    Integers are passed as C integers.  */
 
-int
+EMACS_INT
 doprnt (char *buffer, register int bufsize, const char *format,
 	const char *format_end, va_list ap)
 {
@@ -96,7 +96,7 @@
       if (*fmt == '%')	/* Check for a '%' character */
 	{
 	  unsigned size_bound = 0;
-	  int width;		/* Columns occupied by STRING.  */
+	  EMACS_INT width;  /* Columns occupied by STRING.  */
 
 	  fmt++;
 	  /* Copy this one %-spec into fmtcpy.  */
--- a/src/editfns.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/editfns.c	Thu Sep 23 22:10:54 2010 -0400
@@ -272,7 +272,7 @@
   return buildmark (PT, PT_BYTE);
 }
 
-int
+EMACS_INT
 clip_to_bounds (EMACS_INT lower, EMACS_INT num, EMACS_INT upper)
 {
   if (num < lower)
@@ -2270,7 +2270,7 @@
   (Lisp_Object character, Lisp_Object count, Lisp_Object inherit)
 {
   register unsigned char *string;
-  register int strlen;
+  register EMACS_INT strlen;
   register int i;
   register EMACS_INT n;
   int len;
@@ -2955,7 +2955,7 @@
   register unsigned char *tt;	/* Trans table. */
   register int nc;		/* New character. */
   int cnt;			/* Number of changes made. */
-  int size;			/* Size of translate table. */
+  EMACS_INT size;		/* Size of translate table. */
   EMACS_INT pos, pos_byte, end_pos;
   int multibyte = !NILP (current_buffer->enable_multibyte_characters);
   int string_multibyte;
@@ -3026,7 +3026,7 @@
 	    }
 	  else
 	    {
-	      int c;
+	      EMACS_INT c;
 
 	      nc = oc;
 	      val = CHAR_TABLE_REF (table, oc);
@@ -3239,7 +3239,7 @@
 	/* The restriction has changed from the saved one, so restore
 	   the saved restriction.  */
 	{
-	  int pt = BUF_PT (buf);
+	  EMACS_INT pt = BUF_PT (buf);
 
 	  SET_BUF_BEGV_BOTH (buf, beg->charpos, beg->bytepos);
 	  SET_BUF_ZV_BOTH (buf, end->charpos, end->bytepos);
--- a/src/indent.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/indent.c	Thu Sep 23 22:10:54 2010 -0400
@@ -1448,7 +1448,7 @@
          the text character-by-character.  */
       if (current_buffer->width_run_cache && pos >= next_width_run)
         {
-          int run_end;
+          EMACS_INT run_end;
           int common_width
             = region_cache_forward (current_buffer,
                                     current_buffer->width_run_cache,
--- a/src/intervals.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/intervals.c	Thu Sep 23 22:10:54 2010 -0400
@@ -222,7 +222,7 @@
    Pass FUNCTION two args: an interval, and ARG.  */
 
 void
-traverse_intervals (INTERVAL tree, EMACS_UINT position,
+traverse_intervals (INTERVAL tree, EMACS_INT position,
 		    void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
 {
   while (!NULL_INTERVAL_P (tree))
@@ -317,7 +317,7 @@
 {
   INTERVAL i;
   INTERVAL B = interval->left;
-  EMACS_UINT old_total = interval->total_length;
+  EMACS_INT old_total = interval->total_length;
 
   /* Deal with any Parent of A;  make it point to B.  */
   if (! ROOT_INTERVAL_P (interval))
@@ -364,7 +364,7 @@
 {
   INTERVAL i;
   INTERVAL B = interval->right;
-  EMACS_UINT old_total = interval->total_length;
+  EMACS_INT old_total = interval->total_length;
 
   /* Deal with any parent of A;  make it point to B.  */
   if (! ROOT_INTERVAL_P (interval))
@@ -506,8 +506,8 @@
 split_interval_right (INTERVAL interval, EMACS_INT offset)
 {
   INTERVAL new = make_interval ();
-  EMACS_UINT position = interval->position;
-  EMACS_UINT new_length = LENGTH (interval) - offset;
+  EMACS_INT position = interval->position;
+  EMACS_INT new_length = LENGTH (interval) - offset;
 
   new->position = position + offset;
   SET_INTERVAL_PARENT (new, interval);
@@ -618,7 +618,7 @@
 {
   /* The distance from the left edge of the subtree at TREE
                     to POSITION.  */
-  register EMACS_UINT relative_position;
+  register EMACS_INT relative_position;
 
   if (NULL_INTERVAL_P (tree))
     return NULL_INTERVAL;
@@ -671,7 +671,7 @@
 next_interval (register INTERVAL interval)
 {
   register INTERVAL i = interval;
-  register EMACS_UINT next_position;
+  register EMACS_INT next_position;
 
   if (NULL_INTERVAL_P (i))
     return NULL_INTERVAL;
@@ -1230,7 +1230,7 @@
 delete_node (register INTERVAL i)
 {
   register INTERVAL migrate, this;
-  register EMACS_UINT migrate_amt;
+  register EMACS_INT migrate_amt;
 
   if (NULL_INTERVAL_P (i->left))
     return i->right;
@@ -1263,7 +1263,7 @@
 delete_interval (register INTERVAL i)
 {
   register INTERVAL parent;
-  EMACS_UINT amt = LENGTH (i);
+  EMACS_INT amt = LENGTH (i);
 
   if (amt > 0)			/* Only used on zero-length intervals now.  */
     abort ();
@@ -1313,11 +1313,11 @@
    Do this by recursing down TREE to the interval in question, and
    deleting the appropriate amount of text.  */
 
-static EMACS_UINT
-interval_deletion_adjustment (register INTERVAL tree, register EMACS_UINT from,
-			      register EMACS_UINT amount)
+static EMACS_INT
+interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from,
+			      register EMACS_INT amount)
 {
-  register EMACS_UINT relative_position = from;
+  register EMACS_INT relative_position = from;
 
   if (NULL_INTERVAL_P (tree))
     return 0;
@@ -1325,7 +1325,7 @@
   /* Left branch */
   if (relative_position < LEFT_TOTAL_LENGTH (tree))
     {
-      EMACS_UINT subtract = interval_deletion_adjustment (tree->left,
+      EMACS_INT subtract = interval_deletion_adjustment (tree->left,
 							  relative_position,
 							  amount);
       tree->total_length -= subtract;
@@ -1336,7 +1336,7 @@
   else if (relative_position >= (TOTAL_LENGTH (tree)
 				 - RIGHT_TOTAL_LENGTH (tree)))
     {
-      EMACS_UINT subtract;
+      EMACS_INT subtract;
 
       relative_position -= (tree->total_length
 			    - RIGHT_TOTAL_LENGTH (tree));
@@ -1351,7 +1351,7 @@
   else
     {
       /* How much can we delete from this interval?  */
-      EMACS_UINT my_amount = ((tree->total_length
+      EMACS_INT my_amount = ((tree->total_length
 			       - RIGHT_TOTAL_LENGTH (tree))
 			      - relative_position);
 
@@ -1381,7 +1381,7 @@
   register EMACS_INT left_to_delete = length;
   register INTERVAL tree = BUF_INTERVALS (buffer);
   Lisp_Object parent;
-  EMACS_UINT offset;
+  EMACS_INT offset;
 
   GET_INTERVAL_OBJECT (parent, tree);
   offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0);
@@ -1450,7 +1450,7 @@
 INTERVAL
 merge_interval_right (register INTERVAL i)
 {
-  register EMACS_UINT absorb = LENGTH (i);
+  register EMACS_INT absorb = LENGTH (i);
   register INTERVAL successor;
 
   /* Zero out this interval.  */
@@ -1506,7 +1506,7 @@
 INTERVAL
 merge_interval_left (register INTERVAL i)
 {
-  register EMACS_UINT absorb = LENGTH (i);
+  register EMACS_INT absorb = LENGTH (i);
   register INTERVAL predecessor;
 
   /* Zero out this interval.  */
@@ -1680,7 +1680,7 @@
 {
   register INTERVAL under, over, this, prev;
   register INTERVAL tree;
-  EMACS_UINT over_used;
+  EMACS_INT over_used;
 
   tree = BUF_INTERVALS (buffer);
 
@@ -1926,7 +1926,7 @@
    Note that `stickiness' is determined by overlay marker insertion types,
    if the invisible property comes from an overlay.  */
 
-static int
+static EMACS_INT
 adjust_for_invis_intang (EMACS_INT pos, EMACS_INT test_offs, EMACS_INT adj,
 			 int test_intang)
 {
@@ -2354,7 +2354,7 @@
 copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length)
 {
   register INTERVAL i, new, t;
-  register EMACS_UINT got, prevlen;
+  register EMACS_INT got, prevlen;
 
   if (NULL_INTERVAL_P (tree) || length <= 0)
     return NULL_INTERVAL;
--- a/src/intervals.h	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/intervals.h	Thu Sep 23 22:10:54 2010 -0400
@@ -250,7 +250,7 @@
 extern INTERVAL create_root_interval (Lisp_Object);
 extern void copy_properties (INTERVAL, INTERVAL);
 extern int intervals_equal (INTERVAL, INTERVAL);
-extern void traverse_intervals (INTERVAL, EMACS_UINT,
+extern void traverse_intervals (INTERVAL, EMACS_INT,
                                 void (*) (INTERVAL, Lisp_Object),
                                 Lisp_Object);
 extern void traverse_intervals_noorder (INTERVAL,
--- a/src/lisp.h	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/lisp.h	Thu Sep 23 22:10:54 2010 -0400
@@ -1881,7 +1881,7 @@
 
 extern EMACS_INT max_specpdl_size;
 
-#define SPECPDL_INDEX()	(specpdl_ptr - specpdl)
+#define SPECPDL_INDEX()	((int) (specpdl_ptr - specpdl))
 
 /* Everything needed to describe an active condition case.  */
 struct handler
@@ -2816,7 +2816,7 @@
 extern void syms_of_print (void);
 
 /* Defined in doprnt.c */
-extern int doprnt (char *, int, const char *, const char *, va_list);
+extern EMACS_INT doprnt (char *, int, const char *, const char *, va_list);
 
 /* Defined in lread.c */
 extern Lisp_Object Vafter_load_alist;
@@ -2839,7 +2839,7 @@
 extern Lisp_Object intern (const char *);
 extern Lisp_Object intern_c_string (const char *);
 extern Lisp_Object make_symbol (const char *);
-extern Lisp_Object oblookup (Lisp_Object, const char *, int, int);
+extern Lisp_Object oblookup (Lisp_Object, const char *, EMACS_INT, EMACS_INT);
 #define LOADHIST_ATTACH(x) \
   do {									\
     if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \
@@ -2991,7 +2991,7 @@
 EXFUN (Fuser_login_name, 1);
 EXFUN (Fsystem_name, 0);
 EXFUN (Fcurrent_time, 0);
-extern int clip_to_bounds (EMACS_INT, EMACS_INT, EMACS_INT);
+extern EMACS_INT clip_to_bounds (EMACS_INT, EMACS_INT, EMACS_INT);
 extern Lisp_Object make_buffer_string (EMACS_INT, EMACS_INT, int);
 extern Lisp_Object make_buffer_string_both (EMACS_INT, EMACS_INT, EMACS_INT,
 					    EMACS_INT, int);
@@ -3054,17 +3054,17 @@
 EXFUN (Fmarker_buffer, 1);
 EXFUN (Fcopy_marker, 2);
 EXFUN (Fset_marker, 3);
-extern int marker_position (Lisp_Object);
-extern int marker_byte_position (Lisp_Object);
+extern EMACS_INT marker_position (Lisp_Object);
+extern EMACS_INT marker_byte_position (Lisp_Object);
 extern void clear_charpos_cache (struct buffer *);
-extern int charpos_to_bytepos (int);
-extern int buf_charpos_to_bytepos (struct buffer *, int);
-extern int buf_bytepos_to_charpos (struct buffer *, int);
+extern EMACS_INT charpos_to_bytepos (EMACS_INT);
+extern EMACS_INT buf_charpos_to_bytepos (struct buffer *, EMACS_INT);
+extern EMACS_INT buf_bytepos_to_charpos (struct buffer *, EMACS_INT);
 extern void unchain_marker (struct Lisp_Marker *marker);
 extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
-extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, int, int);
+extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT);
 extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
-                                               int, int);
+                                               EMACS_INT, EMACS_INT);
 extern void syms_of_marker (void);
 
 /* Defined in fileio.c */
@@ -3122,12 +3122,13 @@
 extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
 extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT,
                                   EMACS_INT, EMACS_INT, Lisp_Object);
-extern int scan_buffer (int, EMACS_INT, EMACS_INT, int, int *, int);
-extern int scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
-                         int, int);
-extern int find_next_newline (EMACS_INT, int);
-extern int find_next_newline_no_quit (EMACS_INT, int);
-extern int find_before_next_newline (EMACS_INT, EMACS_INT, int);
+extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT,
+			      int *, int);
+extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT,
+			       EMACS_INT, int);
+extern EMACS_INT find_next_newline (EMACS_INT, int);
+extern EMACS_INT find_next_newline_no_quit (EMACS_INT, EMACS_INT);
+extern EMACS_INT find_before_next_newline (EMACS_INT, EMACS_INT, EMACS_INT);
 extern void syms_of_search (void);
 extern void clear_regexp_cache (void);
 
@@ -3725,7 +3726,7 @@
 extern Lisp_Object safe_alloca_unwind (Lisp_Object);
 
 #define USE_SAFE_ALLOCA			\
-  int sa_count = SPECPDL_INDEX (), sa_must_free = 0
+  int sa_count = (int) SPECPDL_INDEX (), sa_must_free = 0
 
 /* SAFE_ALLOCA allocates a simple buffer.  */
 
--- a/src/lread.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/lread.c	Thu Sep 23 22:10:54 2010 -0400
@@ -3739,7 +3739,7 @@
    Also store the bucket number in oblookup_last_bucket_number.  */
 
 Lisp_Object
-oblookup (Lisp_Object obarray, register const char *ptr, int size, int size_byte)
+oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte)
 {
   int hash;
   int obsize;
--- a/src/marker.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/marker.c	Thu Sep 23 22:10:54 2010 -0400
@@ -27,12 +27,12 @@
 /* Record one cached position found recently by
    buf_charpos_to_bytepos or buf_bytepos_to_charpos.  */
 
-static int cached_charpos;
-static int cached_bytepos;
+static EMACS_INT cached_charpos;
+static EMACS_INT cached_bytepos;
 static struct buffer *cached_buffer;
 static int cached_modiff;
 
-static void byte_char_debug_check (struct buffer *, int, int);
+static void byte_char_debug_check (struct buffer *, EMACS_INT, EMACS_INT);
 
 /* Nonzero means enable debugging checks on byte/char correspondences.  */
 
@@ -60,12 +60,12 @@
 
 #define CONSIDER(CHARPOS, BYTEPOS)					\
 {									\
-  int this_charpos = (CHARPOS);						\
+  EMACS_INT this_charpos = (CHARPOS);					\
   int changed = 0;							\
 									\
   if (this_charpos == charpos)						\
     {									\
-      int value = (BYTEPOS);						\
+      EMACS_INT value = (BYTEPOS);				       	\
       if (byte_debug_flag)						\
 	byte_char_debug_check (b, charpos, value);			\
       return value;							\
@@ -90,7 +90,7 @@
     {									\
       if (best_above - best_below == best_above_byte - best_below_byte)	\
         {								\
-	  int value = best_below_byte + (charpos - best_below);		\
+	  EMACS_INT value = best_below_byte + (charpos - best_below);	\
 	  if (byte_debug_flag)						\
 	    byte_char_debug_check (b, charpos, value);			\
 	  return value;							\
@@ -99,9 +99,9 @@
 }
 
 static void
-byte_char_debug_check (struct buffer *b, int charpos, int bytepos)
+byte_char_debug_check (struct buffer *b, EMACS_INT charpos, EMACS_INT bytepos)
 {
-  int nchars = 0;
+  EMACS_INT nchars = 0;
 
   if (bytepos > BUF_GPT_BYTE (b))
     {
@@ -118,18 +118,18 @@
     abort ();
 }
 
-int
-charpos_to_bytepos (int charpos)
+EMACS_INT
+charpos_to_bytepos (EMACS_INT charpos)
 {
   return buf_charpos_to_bytepos (current_buffer, charpos);
 }
 
-int
-buf_charpos_to_bytepos (struct buffer *b, int charpos)
+EMACS_INT
+buf_charpos_to_bytepos (struct buffer *b, EMACS_INT charpos)
 {
   struct Lisp_Marker *tail;
-  int best_above, best_above_byte;
-  int best_below, best_below_byte;
+  EMACS_INT best_above, best_above_byte;
+  EMACS_INT best_below, best_below_byte;
 
   if (charpos < BUF_BEG (b) || charpos > BUF_Z (b))
     abort ();
@@ -269,12 +269,12 @@
 
 #define CONSIDER(BYTEPOS, CHARPOS)					\
 {									\
-  int this_bytepos = (BYTEPOS);						\
+  EMACS_INT this_bytepos = (BYTEPOS);					\
   int changed = 0;							\
 									\
   if (this_bytepos == bytepos)						\
     {									\
-      int value = (CHARPOS);						\
+      EMACS_INT value = (CHARPOS);				       	\
       if (byte_debug_flag)						\
 	byte_char_debug_check (b, value, bytepos);			\
       return value;							\
@@ -299,7 +299,7 @@
     {									\
       if (best_above - best_below == best_above_byte - best_below_byte)	\
 	{								\
-	  int value = best_below + (bytepos - best_below_byte);		\
+	  EMACS_INT value = best_below + (bytepos - best_below_byte);	\
 	  if (byte_debug_flag)						\
 	    byte_char_debug_check (b, value, bytepos);			\
 	  return value;							\
@@ -307,18 +307,18 @@
     }									\
 }
 
-int
-bytepos_to_charpos (int bytepos)
+EMACS_INT
+bytepos_to_charpos (EMACS_INT bytepos)
 {
   return buf_bytepos_to_charpos (current_buffer, bytepos);
 }
 
-int
-buf_bytepos_to_charpos (struct buffer *b, int bytepos)
+EMACS_INT
+buf_bytepos_to_charpos (struct buffer *b, EMACS_INT bytepos)
 {
   struct Lisp_Marker *tail;
-  int best_above, best_above_byte;
-  int best_below, best_below_byte;
+  EMACS_INT best_above, best_above_byte;
+  EMACS_INT best_below, best_below_byte;
 
   if (bytepos < BUF_BEG_BYTE (b) || bytepos > BUF_Z_BYTE (b))
     abort ();
@@ -470,7 +470,7 @@
 Returns MARKER.  */)
   (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer)
 {
-  register int charno, bytepos;
+  register EMACS_INT charno, bytepos;
   register struct buffer *b;
   register struct Lisp_Marker *m;
 
@@ -545,7 +545,7 @@
 Lisp_Object
 set_marker_restricted (Lisp_Object marker, Lisp_Object pos, Lisp_Object buffer)
 {
-  register int charno, bytepos;
+  register EMACS_INT charno, bytepos;
   register struct buffer *b;
   register struct Lisp_Marker *m;
 
@@ -618,7 +618,7 @@
    character position and the corresponding byte position.  */
 
 Lisp_Object
-set_marker_both (Lisp_Object marker, Lisp_Object buffer, int charpos, int bytepos)
+set_marker_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos)
 {
   register struct buffer *b;
   register struct Lisp_Marker *m;
@@ -666,7 +666,7 @@
    be outside the visible part.  */
 
 Lisp_Object
-set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, int charpos, int bytepos)
+set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, EMACS_INT charpos, EMACS_INT bytepos)
 {
   register struct buffer *b;
   register struct Lisp_Marker *m;
@@ -776,7 +776,7 @@
 
 /* Return the char position of marker MARKER, as a C integer.  */
 
-int
+EMACS_INT
 marker_position (Lisp_Object marker)
 {
   register struct Lisp_Marker *m = XMARKER (marker);
@@ -790,12 +790,12 @@
 
 /* Return the byte position of marker MARKER, as a C integer.  */
 
-int
+EMACS_INT
 marker_byte_position (Lisp_Object marker)
 {
   register struct Lisp_Marker *m = XMARKER (marker);
   register struct buffer *buf = m->buffer;
-  register int i = m->bytepos;
+  register EMACS_INT i = m->bytepos;
 
   if (!buf)
     error ("Marker does not point anywhere");
@@ -856,7 +856,7 @@
   (Lisp_Object position)
 {
   register struct Lisp_Marker *tail;
-  register int charno;
+  register EMACS_INT charno;
 
   charno = XINT (position);
 
--- a/src/region-cache.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/region-cache.c	Thu Sep 23 22:10:54 2010 -0400
@@ -62,7 +62,7 @@
    revalidate_region_cache to see how this helps.  */
 
 struct boundary {
-  int pos;
+  EMACS_INT pos;
   int value;
 };
 
@@ -72,7 +72,7 @@
   struct boundary *boundaries;
 
   /* boundaries[gap_start ... gap_start + gap_len - 1] is the gap.  */
-  int gap_start, gap_len;
+  EMACS_INT gap_start, gap_len;
 
   /* The number of elements allocated to boundaries, not including the
      gap.  */
@@ -81,7 +81,7 @@
   /* The areas that haven't changed since the last time we cleaned out
      invalid entries from the cache.  These overlap when the buffer is
      entirely unchanged.  */
-  int beg_unchanged, end_unchanged;
+  EMACS_INT beg_unchanged, end_unchanged;
 
   /* The first and last positions in the buffer.  Because boundaries
      store their positions relative to the start (BEG) and end (Z) of
@@ -91,7 +91,7 @@
 
      Yes, buffer_beg is always 1.  It's there for symmetry with
      buffer_end and the BEG and BUF_BEG macros.  */
-  int buffer_beg, buffer_end;
+  EMACS_INT buffer_beg, buffer_end;
 };
 
 /* Return the position of boundary i in cache c.  */
@@ -173,7 +173,7 @@
    entries.  It would be nice if it took advantage of locality of
    reference, too, by searching entries near the last entry found.  */
 static int
-find_cache_boundary (struct region_cache *c, int pos)
+find_cache_boundary (struct region_cache *c, EMACS_INT pos)
 {
   int low = 0, high = c->cache_len;
 
@@ -182,7 +182,7 @@
       /* mid is always a valid index, because low < high and ">> 1"
          rounds down.  */
       int mid = (low + high) >> 1;
-      int boundary = BOUNDARY_POS (c, mid);
+      EMACS_INT boundary = BOUNDARY_POS (c, mid);
 
       if (pos < boundary)
         high = mid;
@@ -207,13 +207,13 @@
 /* Move the gap of cache C to index POS, and make sure it has space
    for at least MIN_SIZE boundaries.  */
 static void
-move_cache_gap (struct region_cache *c, int pos, int min_size)
+move_cache_gap (struct region_cache *c, EMACS_INT pos, int min_size)
 {
   /* Copy these out of the cache and into registers.  */
-  int gap_start = c->gap_start;
-  int gap_len = c->gap_len;
-  int buffer_beg = c->buffer_beg;
-  int buffer_end = c->buffer_end;
+  EMACS_INT gap_start = c->gap_start;
+  EMACS_INT gap_len = c->gap_len;
+  EMACS_INT buffer_beg = c->buffer_beg;
+  EMACS_INT buffer_end = c->buffer_end;
 
   if (pos < 0
       || pos > c->cache_len)
@@ -245,7 +245,7 @@
      when the portion after the gap is smallest.  */
   if (gap_len < min_size)
     {
-      int i;
+      EMACS_INT i;
 
       /* Always make at least NEW_CACHE_GAP elements, as long as we're
          expanding anyway.  */
@@ -292,7 +292,8 @@
 /* Insert a new boundary in cache C; it will have cache index INDEX,
    and have the specified POS and VALUE.  */
 static void
-insert_cache_boundary (struct region_cache *c, int index, int pos, int value)
+insert_cache_boundary (struct region_cache *c, int index, EMACS_INT pos,
+		       int value)
 {
   /* index must be a valid cache index.  */
   if (index < 0 || index > c->cache_len)
@@ -328,9 +329,10 @@
 /* Delete the i'th entry from cache C if START <= i < END.  */
 
 static void
-delete_cache_boundaries (struct region_cache *c, int start, int end)
+delete_cache_boundaries (struct region_cache *c,
+			 EMACS_INT start, EMACS_INT end)
 {
-  int len = end - start;
+  EMACS_INT len = end - start;
 
   /* Gotta be in range.  */
   if (start < 0
@@ -380,7 +382,8 @@
 
 /* Set the value in cache C for the region START..END to VALUE.  */
 static void
-set_cache_region (struct region_cache *c, int start, int end, int value)
+set_cache_region (struct region_cache *c,
+		  EMACS_INT start, EMACS_INT end, int value)
 {
   if (start > end)
     abort ();
@@ -481,7 +484,8 @@
    buffer positions in the presence of insertions and deletions; the
    args to pass are the same before and after such an operation.)  */
 void
-invalidate_region_cache (struct buffer *buf, struct region_cache *c, int head, int tail)
+invalidate_region_cache (struct buffer *buf, struct region_cache *c,
+			 EMACS_INT head, EMACS_INT tail)
 {
   /* Let chead = c->beg_unchanged, and
          ctail = c->end_unchanged.
@@ -687,7 +691,8 @@
    buffer positions) is "known," for the purposes of CACHE (e.g. "has
    no newlines", in the case of the line cache).  */
 void
-know_region_cache (struct buffer *buf, struct region_cache *c, int start, int end)
+know_region_cache (struct buffer *buf, struct region_cache *c,
+		   EMACS_INT start, EMACS_INT end)
 {
   revalidate_region_cache (buf, c);
 
@@ -701,7 +706,8 @@
    the purposes of CACHE.  If NEXT is non-zero, set *NEXT to the nearest
    position after POS where the knownness changes.  */
 int
-region_cache_forward (struct buffer *buf, struct region_cache *c, int pos, int *next)
+region_cache_forward (struct buffer *buf, struct region_cache *c,
+		      EMACS_INT pos, EMACS_INT *next)
 {
   revalidate_region_cache (buf, c);
 
@@ -736,7 +742,8 @@
 /* Return true if the text immediately before POS in BUF is known, for
    the purposes of CACHE.  If NEXT is non-zero, set *NEXT to the nearest
    position before POS where the knownness changes.  */
-int region_cache_backward (struct buffer *buf, struct region_cache *c, int pos, int *next)
+int region_cache_backward (struct buffer *buf, struct region_cache *c,
+			   EMACS_INT pos, EMACS_INT *next)
 {
   revalidate_region_cache (buf, c);
 
@@ -777,8 +784,8 @@
 pp_cache (struct region_cache *c)
 {
   int i;
-  int beg_u = c->buffer_beg + c->beg_unchanged;
-  int end_u = c->buffer_end - c->end_unchanged;
+  EMACS_INT beg_u = c->buffer_beg + c->beg_unchanged;
+  EMACS_INT end_u = c->buffer_end - c->end_unchanged;
 
   fprintf (stderr,
            "basis: %d..%d    modified: %d..%d\n",
--- a/src/region-cache.h	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/region-cache.h	Thu Sep 23 22:10:54 2010 -0400
@@ -71,7 +71,7 @@
    no newlines", in the case of the line cache).  */
 extern void know_region_cache (struct buffer *BUF,
                                struct region_cache *CACHE,
-                               int START, int END);
+                               EMACS_INT START, EMACS_INT END);
 
 /* Indicate that a section of BUF has changed, to invalidate CACHE.
    HEAD is the number of chars unchanged at the beginning of the buffer.
@@ -83,7 +83,7 @@
    args to pass are the same before and after such an operation.)  */
 extern void invalidate_region_cache (struct buffer *BUF,
                                      struct region_cache *CACHE,
-                                     int HEAD, int TAIL);
+                                     EMACS_INT HEAD, EMACS_INT TAIL);
 
 /* The scanning functions.
 
@@ -99,16 +99,16 @@
    position after POS where the knownness changes.  */
 extern int region_cache_forward (struct buffer *BUF,
                                  struct region_cache *CACHE,
-                                 int POS,
-                                 int *NEXT);
+                                 EMACS_INT POS,
+                                 EMACS_INT *NEXT);
 
 /* Return true if the text immediately before POS in BUF is known, for
    the purposes of CACHE.  If NEXT is non-zero, set *NEXT to the nearest
    position before POS where the knownness changes.  */
 extern int region_cache_backward (struct buffer *BUF,
                                   struct region_cache *CACHE,
-                                  int POS,
-                                  int *NEXT);
+                                  EMACS_INT POS,
+                                  EMACS_INT *NEXT);
 
 /* arch-tag: 70f79125-ef22-4f58-9aec-a48ca2791435
    (do not change this comment) */
--- a/src/search.c	Thu Sep 23 15:00:31 2010 -0400
+++ b/src/search.c	Thu Sep 23 22:10:54 2010 -0400
@@ -100,15 +100,15 @@
 
 static void set_search_regs (EMACS_INT, EMACS_INT);
 static void save_search_regs (void);
-static EMACS_INT simple_search (int, unsigned char *, int, int,
-                                Lisp_Object, EMACS_INT, EMACS_INT,
+static EMACS_INT simple_search (EMACS_INT, unsigned char *, EMACS_INT,
+				EMACS_INT, Lisp_Object, EMACS_INT, EMACS_INT,
                                 EMACS_INT, EMACS_INT);
-static EMACS_INT boyer_moore (int, unsigned char *, int, int,
+static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, EMACS_INT, EMACS_INT,
                               Lisp_Object, Lisp_Object,
                               EMACS_INT, EMACS_INT,
                               EMACS_INT, EMACS_INT, int);
 static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT,
-                                EMACS_INT, EMACS_INT, int, int,
+                                EMACS_INT, EMACS_INT, EMACS_INT, int,
                                 Lisp_Object, Lisp_Object, int);
 static void matcher_overflow (void) NO_RETURN;
 
@@ -286,7 +286,7 @@
   Lisp_Object val;
   unsigned char *p1, *p2;
   EMACS_INT s1, s2;
-  register int i;
+  register EMACS_INT i;
   struct re_pattern_buffer *bufp;
 
   if (running_asynch_code)
@@ -396,7 +396,7 @@
     pos = 0, pos_byte = 0;
   else
     {
-      int len = SCHARS (string);
+      EMACS_INT len = SCHARS (string);
 
       CHECK_NUMBER (start);
       pos = XINT (start);
@@ -509,7 +509,7 @@
 {
   int val;
   struct re_pattern_buffer *bufp;
-  int len = strlen (string);
+  size_t len = strlen (string);
 
   regexp = string_make_unibyte (regexp);
   re_match_object = Qt;
@@ -654,8 +654,9 @@
    If ALLOW_QUIT is non-zero, set immediate_quit.  That's good to do
    except when inside redisplay.  */
 
-int
-scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int *shortage, int allow_quit)
+EMACS_INT
+scan_buffer (register int target, EMACS_INT start, EMACS_INT end,
+	     EMACS_INT count, int *shortage, int allow_quit)
 {
   struct region_cache *newline_cache;
   int direction;
@@ -695,7 +696,7 @@
            to see where we can avoid some scanning.  */
         if (target == '\n' && newline_cache)
           {
-            int next_change;
+            EMACS_INT next_change;
             immediate_quit = 0;
             while (region_cache_forward
                    (current_buffer, newline_cache, start_byte, &next_change))
@@ -767,7 +768,7 @@
         /* Consult the newline cache, if appropriate.  */
         if (target == '\n' && newline_cache)
           {
-            int next_change;
+            EMACS_INT next_change;
             immediate_quit = 0;
             while (region_cache_backward
                    (current_buffer, newline_cache, start_byte, &next_change))
@@ -846,8 +847,10 @@
    If ALLOW_QUIT is non-zero, set immediate_quit.  That's good to do
    except in special cases.  */
 
-int
-scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT limit_byte, register int count, int allow_quit)
+EMACS_INT
+scan_newline (EMACS_INT start, EMACS_INT start_byte,
+	      EMACS_INT limit, EMACS_INT limit_byte,
+	      register EMACS_INT count, int allow_quit)
 {
   int direction = ((count > 0) ? 1 : -1);
 
@@ -940,8 +943,8 @@
   return count * direction;
 }
 
-int
-find_next_newline_no_quit (EMACS_INT from, int cnt)
+EMACS_INT
+find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt)
 {
   return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0);
 }
@@ -950,11 +953,11 @@
    not after, and only search up to TO.  This isn't just
    find_next_newline (...)-1, because you might hit TO.  */
 
-int
-find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt)
+EMACS_INT
+find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt)
 {
   int shortage;
-  int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
+  EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1);
 
   if (shortage == 0)
     pos--;
@@ -965,10 +968,11 @@
 /* Subroutines of Lisp buffer search functions. */
 
 static Lisp_Object
-search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix)
+search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
+		Lisp_Object count, int direction, int RE, int posix)
 {
   register int np;
-  int lim, lim_byte;
+  EMACS_INT lim, lim_byte;
   int n = direction;
 
   if (!NILP (count))
@@ -1044,7 +1048,7 @@
 static int
 trivial_regexp_p (Lisp_Object regexp)
 {
-  int len = SBYTES (regexp);
+  EMACS_INT len = SBYTES (regexp);
   unsigned char *s = SDATA (regexp);
   while (--len >= 0)
     {
@@ -1109,11 +1113,11 @@
 
 static EMACS_INT
 search_buffer (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
-	       EMACS_INT lim, EMACS_INT lim_byte, int n,
+	       EMACS_INT lim, EMACS_INT lim_byte, EMACS_INT n,
 	       int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix)
 {
-  int len = SCHARS (string);
-  int len_byte = SBYTES (string);
+  EMACS_INT len = SCHARS (string);
+  EMACS_INT len_byte = SBYTES (string);
   register int i;
 
   if (running_asynch_code)
@@ -1130,7 +1134,7 @@
   if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
     {
       unsigned char *p1, *p2;
-      int s1, s2;
+      EMACS_INT s1, s2;
       struct re_pattern_buffer *bufp;
 
       bufp = compile_pattern (string,
@@ -1166,7 +1170,7 @@
 
       while (n < 0)
 	{
-	  int val;
+	  EMACS_INT val;
 	  val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
 			     pos_byte - BEGV_BYTE, lim_byte - pos_byte,
 			     (NILP (Vinhibit_changing_match_data)
@@ -1210,7 +1214,7 @@
 	}
       while (n > 0)
 	{
-	  int val;
+	  EMACS_INT val;
 	  val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
 			     pos_byte - BEGV_BYTE, lim_byte - pos_byte,
 			     (NILP (Vinhibit_changing_match_data)
@@ -1255,8 +1259,8 @@
   else				/* non-RE case */
     {
       unsigned char *raw_pattern, *pat;
-      int raw_pattern_size;
-      int raw_pattern_size_byte;
+      EMACS_INT raw_pattern_size;
+      EMACS_INT raw_pattern_size_byte;
       unsigned char *patbuf;
       int multibyte = !NILP (current_buffer->enable_multibyte_characters);
       unsigned char *base_pat;
@@ -1450,13 +1454,16 @@
    boyer_moore cannot work.  */
 
 static EMACS_INT
-simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT lim, EMACS_INT lim_byte)
+simple_search (EMACS_INT n, unsigned char *pat,
+	       EMACS_INT len, EMACS_INT len_byte, Lisp_Object trt,
+	       EMACS_INT pos, EMACS_INT pos_byte,
+	       EMACS_INT lim, EMACS_INT lim_byte)
 {
   int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
   int forward = n > 0;
   /* Number of buffer bytes matched.  Note that this may be different
      from len_byte in a multibyte buffer.  */
-  int match_byte;
+  EMACS_INT match_byte;
 
   if (lim > pos && multibyte)
     while (n > 0)
@@ -1466,7 +1473,7 @@
 	    /* Try matching at position POS.  */
 	    EMACS_INT this_pos = pos;
 	    EMACS_INT this_pos_byte = pos_byte;
-	    int this_len = len;
+	    EMACS_INT this_len = len;
 	    unsigned char *p = pat;
 	    if (pos + len > lim || pos_byte + len_byte > lim_byte)
 	      goto stop;
@@ -1511,7 +1518,7 @@
 	  {
 	    /* Try matching at position POS.  */
 	    EMACS_INT this_pos = pos;
-	    int this_len = len;
+	    EMACS_INT this_len = len;
 	    unsigned char *p = pat;
 
 	    if (pos + len > lim)
@@ -1551,7 +1558,7 @@
 	    /* Try matching at position POS.  */
 	    EMACS_INT this_pos = pos;
 	    EMACS_INT this_pos_byte = pos_byte;
-	    int this_len = len;
+	    EMACS_INT this_len = len;
 	    const unsigned char *p = pat + len_byte;
 
 	    if (this_pos - len < lim || (pos_byte - len_byte) < lim_byte)
@@ -1594,7 +1601,7 @@
 	  {
 	    /* Try matching at position POS.  */
 	    EMACS_INT this_pos = pos - len;
-	    int this_len = len;
+	    EMACS_INT this_len = len;
 	    unsigned char *p = pat;
 
 	    if (this_pos < lim)
@@ -1657,18 +1664,20 @@
    If that criterion is not satisfied, do not call this function.  */
 
 static EMACS_INT
-boyer_moore (int n, unsigned char *base_pat, int len, int len_byte,
+boyer_moore (EMACS_INT n, unsigned char *base_pat,
+	     EMACS_INT len, EMACS_INT len_byte,
 	     Lisp_Object trt, Lisp_Object inverse_trt,
 	     EMACS_INT pos, EMACS_INT pos_byte,
 	     EMACS_INT lim, EMACS_INT lim_byte, int char_base)
 {
   int direction = ((n > 0) ? 1 : -1);
-  register int dirlen;
+  register EMACS_INT dirlen;
   EMACS_INT limit;
   int stride_for_teases = 0;
   int BM_tab[0400];
   register unsigned char *cursor, *p_limit;
-  register int i, j;
+  register EMACS_INT i;
+  register int j;
   unsigned char *pat, *pat_end;
   int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
 
@@ -2098,10 +2107,11 @@
 wordify (Lisp_Object string, int lax)
 {
   register unsigned char *p, *o;
-  register int i, i_byte, len, punct_count = 0, word_count = 0;
+  register EMACS_INT i, i_byte, len, punct_count = 0, word_count = 0;
   Lisp_Object val;
   int prev_c = 0;
-  int adjust, whitespace_at_end;
+  EMACS_INT adjust;
+  int whitespace_at_end;
 
   CHECK_STRING (string);
   p = SDATA (string);
@@ -2151,7 +2161,7 @@
   for (i = 0, i_byte = 0; i < len; )
     {
       int c;
-      int i_byte_orig = i_byte;
+      EMACS_INT i_byte_orig = i_byte;
 
       FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE (c, string, i, i_byte);
 
@@ -2392,7 +2402,7 @@
   (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp)
 {
   enum { nochange, all_caps, cap_initial } case_action;
-  register int pos, pos_byte;
+  register EMACS_INT pos, pos_byte;
   int some_multiletter_word;
   int some_lowercase;
   int some_uppercase;
@@ -2540,8 +2550,8 @@
 
 	  for (pos_byte = 0, pos = 0; pos_byte < length;)
 	    {
-	      int substart = -1;
-	      int subend = 0;
+	      EMACS_INT substart = -1;
+	      EMACS_INT subend = 0;
 	      int delbackslash = 0;
 
 	      FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
@@ -2634,9 +2644,9 @@
      perform substitution on the replacement string.  */
   if (NILP (literal))
     {
-      int length = SBYTES (newtext);
+      EMACS_INT length = SBYTES (newtext);
       unsigned char *substed;
-      int substed_alloc_size, substed_len;
+      EMACS_INT substed_alloc_size, substed_len;
       int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters);
       int str_multibyte = STRING_MULTIBYTE (newtext);
       Lisp_Object rev_tbl;
@@ -2656,7 +2666,7 @@
 	{
 	  unsigned char str[MAX_MULTIBYTE_LENGTH];
 	  const unsigned char *add_stuff = NULL;
-	  int add_len = 0;
+	  EMACS_INT add_len = 0;
 	  int idx = -1;
 
 	  if (str_multibyte)
@@ -2750,7 +2760,8 @@
 	{
 	  if (buf_multibyte)
 	    {
-	      int nchars = multibyte_chars_in_text (substed, substed_len);
+	      EMACS_INT nchars =
+		multibyte_chars_in_text (substed, substed_len);
 
 	      newtext = make_multibyte_string (substed, nchars, substed_len);
 	    }