Now on revision 104602. ------------------------------------------------------------ revno: 104602 author: Teodor Zlatanov committer: Katsumi Yamaoka branch nick: trunk timestamp: Thu 2011-06-16 06:18:18 +0000 message: Merge changes made in Gnus trunk. auth-source.el (auth-source-save-secrets): New variable to control if secret tokens should be saved encrypted. (auth-source-netrc-parse, auth-source-netrc-search): Pass the file name to `auth-source-netrc-normalize'. (with-auth-source-epa-overrides): Add convenience macro. Don't depend on the EPA variables being defined. (auth-source-epa-make-gpg-token): Convert text to a "gpg:" token. (auth-source-netrc-normalize): Convert "gpg:" tokens back to text in the lexical-let closure. (auth-source-netrc-create): Create "gpg:" tokens according to `auth-source-save-secrets'. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-06-10 00:10:24 +0000 +++ lisp/gnus/ChangeLog 2011-06-16 06:18:18 +0000 @@ -1,3 +1,17 @@ +2011-06-16 Teodor Zlatanov + + * auth-source.el (auth-source-save-secrets): New variable to control if + secret tokens should be saved encrypted. + (auth-source-netrc-parse, auth-source-netrc-search): Pass the file name + to `auth-source-netrc-normalize'. + (with-auth-source-epa-overrides): Add convenience macro. Don't depend + on the EPA variables being defined. + (auth-source-epa-make-gpg-token): Convert text to a "gpg:" token. + (auth-source-netrc-normalize): Convert "gpg:" tokens back to text in + the lexical-let closure. + (auth-source-netrc-create): Create "gpg:" tokens according to + `auth-source-save-secrets'. + 2011-06-10 Katsumi Yamaoka * gnus-group.el (gnus-group-update-group): Add new argument === modified file 'lisp/gnus/auth-source.el' --- lisp/gnus/auth-source.el 2011-03-15 17:39:56 +0000 +++ lisp/gnus/auth-source.el 2011-06-16 06:18:18 +0000 @@ -154,6 +154,16 @@ (const :tag "Never save" nil) (const :tag "Ask" ask))) +(defcustom auth-source-save-secrets nil + "If set, auth-source will respect it for password tokens behavior." + :group 'auth-source + :version "23.2" ;; No Gnus + :type `(choice + :tag "auth-source new password token behavior" + (const :tag "Use GPG tokens" gpg) + (const :tag "Save unencrypted" nil) + (const :tag "Ask" ask))) + (defvar auth-source-magic "auth-source-magic ") (defcustom auth-source-do-cache t @@ -898,7 +908,7 @@ (null require) ;; every element of require is in the normalized list (let ((normalized (nth 0 (auth-source-netrc-normalize - (list alist))))) + (list alist) file)))) (loop for req in require always (plist-get normalized req))))) (decf max) @@ -934,7 +944,54 @@ (nreverse result)))))) -(defun auth-source-netrc-normalize (alist) +(defmacro with-auth-source-epa-overrides (&rest body) + `(let ((file-name-handler-alist + ',(if (boundp 'epa-file-handler) + (remove (symbol-value 'epa-file-handler) + file-name-handler-alist) + file-name-handler-alist)) + (find-file-hook + ',(remove 'epa-file-find-file-hook find-file-hook)) + (auto-mode-alist + ',(if (boundp 'epa-file-auto-mode-alist-entry) + (remove (symbol-value 'epa-file-auto-mode-alist-entry) + auto-mode-alist) + auto-mode-alist))) + ,@body)) + +(defun auth-source-epa-make-gpg-token (secret file) + (require 'epa nil t) + (unless (featurep 'epa) + (error "EPA could not be loaded.")) + (let* ((base (file-name-sans-extension file)) + (passkey (format "gpg:-%s" base)) + (stash (concat base ".gpg")) + ;; temporarily disable EPA + (stashfile + (with-auth-source-epa-overrides + (make-temp-file "gpg-token" nil + stash))) + (epa-file-passphrase-alist + `((,stashfile + . ,(password-read + (format + "token pass for %s? " + file) + passkey))))) + (write-region secret nil stashfile) + ;; temporarily disable EPA + (unwind-protect + (with-auth-source-epa-overrides + (with-temp-buffer + (insert-file-contents stashfile) + (base64-encode-region (point-min) (point-max) t) + (concat "gpg:" + (buffer-substring-no-properties + (point-min) + (point-max))))) + (delete-file stashfile)))) + +(defun auth-source-netrc-normalize (alist filename) (mapcar (lambda (entry) (let (ret item) (while (setq item (pop entry)) @@ -950,15 +1007,65 @@ ;; send back the secret in a function (lexical binding) (when (equal k "secret") - (setq v (lexical-let ((v v)) - (lambda () v)))) - - (setq ret (plist-put ret - (intern (concat ":" k)) - v)) - )) - ret)) - alist)) + (setq v (lexical-let ((v v) + (filename filename) + (base (file-name-nondirectory + filename)) + (token-decoder nil) + (gpgdata nil) + (stash nil)) + (setq stash (concat base ".gpg")) + (when (string-match "gpg:\\(.+\\)" v) + (require 'epa nil t) + (unless (featurep 'epa) + (error "EPA could not be loaded.")) + (setq gpgdata (base64-decode-string + (match-string 1 v))) + ;; it's a GPG token + (setq + token-decoder + (lambda (gpgdata) +;;; FIXME: this relies on .gpg files being handled by EPA/EPG + (let* ((passkey (format "gpg:-%s" base)) + ;; temporarily disable EPA + (stashfile + (with-auth-source-epa-overrides + (make-temp-file "gpg-token" nil + stash))) + (epa-file-passphrase-alist + `((,stashfile + . ,(password-read + (format + "token pass for %s? " + filename) + passkey))))) + (unwind-protect + (progn + ;; temporarily disable EPA + (with-auth-source-epa-overrides + (write-region gpgdata + nil + stashfile)) + (setq + v + (with-temp-buffer + (insert-file-contents stashfile) + (buffer-substring-no-properties + (point-min) + (point-max))))) + (delete-file stashfile))) + ;; clear out the decoder at end + (setq token-decoder nil + gpgdata nil)))) + (lambda () + (when token-decoder + (funcall token-decoder gpgdata)) + v)))) + (setq ret (plist-put ret + (intern (concat ":" k)) + v)))) + ret)) + alist)) ;;; (setq secret (plist-get (nth 0 (auth-source-search :host t :type 'netrc :K 1 :max 1)) :secret)) ;;; (funcall secret) @@ -982,7 +1089,8 @@ :file (oref backend source) :host (or host t) :user (or user t) - :port (or port t))))) + :port (or port t)) + (oref backend source)))) ;; if we need to create an entry AND none were found to match (when (and create @@ -1098,7 +1206,21 @@ (cond ((and (null data) (eq r 'secret)) ;; Special case prompt for passwords. - (read-passwd prompt)) + ;; Respect `auth-source-save-secrets' + (let* ((ep (format "Do you want GPG password tokens? (%s)" + "see `auth-source-save-secrets'")) + (gpg-encrypt +;;; FIXME: this relies on .gpg files being handled by EPA/EPG + ;; don't put GPG tokens in GPG-encrypted files + (and (not (equal "gpg" (file-name-extension file))) + (or (eq auth-source-save-secrets 'gpg) + (and (eq auth-source-save-secrets 'ask) + (setq auth-source-save-secrets + (and (y-or-n-p ep) 'gpg)))))) + (plain (read-passwd prompt))) + (if (eq auth-source-save-secrets 'gpg) + (auth-source-epa-make-gpg-token plain file) + plain))) ((null data) (when default (setq prompt ------------------------------------------------------------ revno: 104601 committer: Paul Eggert branch nick: trunk timestamp: Wed 2011-06-15 15:27:54 -0700 message: Merge from gnulib: lib/gnulib.mk, m4/*.m4. diff: === modified file 'ChangeLog' --- ChangeLog 2011-06-15 18:50:18 +0000 +++ ChangeLog 2011-06-15 22:27:54 +0000 @@ -1,6 +1,11 @@ 2011-06-15 Paul Eggert - * lib/ftoastr.c, lib/stdio.in.h, lib/verify.h: Merge from gnulib. + * lib/ftoastr.c, lib/stdio.in.h, lib/verify.h: + * lib/gnulib.mk, m4/c-strtod.m4, m4/filemode.m4, m4/getloadavg.m4: + * m4/getopt.m4, m4/gl-comp.m4, m4/lstat.m4, m4/md5.m4, m4/mktime.m4: + * m4/readlink.m4, m4/sha1.m4, m4/stat.m4, m4/strftime.m4: + * m4/strtoull.m4, m4/strtoumax.m4, m4/symlink.m4, m4/time_r.m4: + Merge from gnulib. 2011-06-14 Jan Djärv === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-06-08 16:26:45 +0000 +++ lib/gnulib.mk 2011-06-15 22:27:54 +0000 @@ -87,19 +87,17 @@ ## begin gnulib module crypto/md5 - -EXTRA_DIST += md5.c md5.h - -EXTRA_libgnu_a_SOURCES += md5.c +libgnu_a_SOURCES += md5.c + +EXTRA_DIST += md5.h ## end gnulib module crypto/md5 ## begin gnulib module crypto/sha1 - -EXTRA_DIST += sha1.c sha1.h - -EXTRA_libgnu_a_SOURCES += sha1.c +libgnu_a_SOURCES += sha1.c + +EXTRA_DIST += sha1.h ## end gnulib module crypto/sha1 @@ -124,10 +122,9 @@ ## begin gnulib module filemode - -EXTRA_DIST += filemode.c filemode.h - -EXTRA_libgnu_a_SOURCES += filemode.c +libgnu_a_SOURCES += filemode.c + +EXTRA_DIST += filemode.h ## end gnulib module filemode @@ -616,10 +613,9 @@ ## begin gnulib module strftime - -EXTRA_DIST += strftime.c strftime.h - -EXTRA_libgnu_a_SOURCES += strftime.c +libgnu_a_SOURCES += strftime.c + +EXTRA_DIST += strftime.h ## end gnulib module strftime === modified file 'm4/c-strtod.m4' --- m4/c-strtod.m4 2011-01-09 01:20:28 +0000 +++ m4/c-strtod.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# c-strtod.m4 serial 12 +# c-strtod.m4 serial 14 # Copyright (C) 2004-2006, 2009-2011 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -33,11 +33,9 @@ fi ]) +dnl Prerequisites of lib/c-strtod.c. AC_DEFUN([gl_C_STRTOD], [ - AC_LIBOBJ([c-strtod]) - - dnl Prerequisites of lib/c-strtod.c. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_CHECK_FUNCS([strtod_l]) @@ -45,11 +43,9 @@ : ]) +dnl Prerequisites of lib/c-strtold.c. AC_DEFUN([gl_C_STRTOLD], [ - AC_LIBOBJ([c-strtold]) - - dnl Prerequisites of lib/c-strtold.c. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_C99_STRTOLD]) AC_CHECK_FUNCS([strtold_l]) === modified file 'm4/filemode.m4' --- m4/filemode.m4 2011-02-20 10:51:50 +0000 +++ m4/filemode.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# filemode.m4 serial 7 +# filemode.m4 serial 8 dnl Copyright (C) 2002, 2005-2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,6 +7,5 @@ AC_DEFUN([gl_FILEMODE], [ AC_REQUIRE([AC_STRUCT_ST_DM_MODE]) - AC_LIBOBJ([filemode]) AC_CHECK_DECLS_ONCE([strmode]) ]) === modified file 'm4/getloadavg.m4' --- m4/getloadavg.m4 2011-05-29 21:52:18 +0000 +++ m4/getloadavg.m4 2011-06-15 22:27:54 +0000 @@ -7,7 +7,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -#serial 3 +#serial 4 # Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. # New applications should use gl_GETLOADAVG instead. @@ -24,6 +24,7 @@ # getloadvg is present in libc on glibc >= 2.2, MacOS X, FreeBSD >= 2.0, # NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. +HAVE_GETLOADAVG=1 AC_CHECK_FUNC([getloadavg], [], [gl_have_func=no @@ -52,8 +53,7 @@ # Set up the replacement function if necessary. if test $gl_have_func = no; then - AC_LIBOBJ([getloadavg]) - gl_PREREQ_GETLOADAVG + HAVE_GETLOADAVG=0 fi]) if test "x$gl_save_LIBS" = x; then === modified file 'm4/getopt.m4' --- m4/getopt.m4 2011-01-24 04:53:39 +0000 +++ m4/getopt.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# getopt.m4 serial 34 +# getopt.m4 serial 35 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,10 +9,25 @@ [ m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX]) AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - gl_GETOPT_IFELSE([ - gl_REPLACE_GETOPT - ], - []) + dnl Other modules can request the gnulib implementation of the getopt + dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS. + dnl argp.m4 does this. + m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [ + gl_GETOPT_IFELSE([], []) + REPLACE_GETOPT=1 + ], [ + REPLACE_GETOPT=0 + gl_GETOPT_IFELSE([ + REPLACE_GETOPT=1 + ], + []) + ]) + if test $REPLACE_GETOPT = 1; then + dnl Arrange for getopt.h to be created. + gl_GETOPT_SUBSTITUTE_HEADER + dnl Arrange for unistd.h to include getopt.h. + GNULIB_UNISTD_H_GETOPT=1 + fi ]) # Request a POSIX compliant getopt function with GNU extensions (such as @@ -25,20 +40,6 @@ AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) ]) -# Request the gnulib implementation of the getopt functions unconditionally. -# argp.m4 uses this. -AC_DEFUN([gl_REPLACE_GETOPT], -[ - dnl Arrange for getopt.h to be created. - gl_GETOPT_SUBSTITUTE_HEADER - dnl Arrange for unistd.h to include getopt.h. - GNULIB_UNISTD_H_GETOPT=1 - dnl Arrange to compile the getopt implementation. - AC_LIBOBJ([getopt]) - AC_LIBOBJ([getopt1]) - gl_PREREQ_GETOPT -]) - # emacs' configure.in uses this. AC_DEFUN([gl_GETOPT_IFELSE], [ === modified file 'm4/gl-comp.m4' --- m4/gl-comp.m4 2011-05-29 21:52:18 +0000 +++ m4/gl-comp.m4 2011-06-15 22:27:54 +0000 @@ -97,18 +97,44 @@ AC_REQUIRE([gl_C99_STRTOLD]) gl_FILEMODE gl_GETLOADAVG +if test $HAVE_GETLOADAVG = 0; then + AC_LIBOBJ([getloadavg]) + gl_PREREQ_GETLOADAVG +fi gl_STDLIB_MODULE_INDICATOR([getloadavg]) gl_FUNC_GETOPT_GNU +if test $REPLACE_GETOPT = 1; then + AC_LIBOBJ([getopt]) + AC_LIBOBJ([getopt1]) + gl_PREREQ_GETOPT +fi gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu]) gl_FUNC_GETOPT_POSIX +if test $REPLACE_GETOPT = 1; then + AC_LIBOBJ([getopt]) + AC_LIBOBJ([getopt1]) + gl_PREREQ_GETOPT +fi AC_REQUIRE([AC_C_INLINE]) gl_INTTYPES_INCOMPLETE gl_FUNC_LSTAT +if test $REPLACE_LSTAT = 1; then + AC_LIBOBJ([lstat]) + gl_PREREQ_LSTAT +fi gl_SYS_STAT_MODULE_INDICATOR([lstat]) gl_FUNC_MKTIME +if test $REPLACE_MKTIME = 1; then + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME +fi gl_TIME_MODULE_INDICATOR([mktime]) gl_MULTIARCH gl_FUNC_READLINK +if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then + AC_LIBOBJ([readlink]) + gl_PREREQ_READLINK +fi gl_UNISTD_MODULE_INDICATOR([readlink]) gl_TYPE_SOCKLEN_T gt_TYPE_SSIZE_T @@ -120,13 +146,24 @@ gl_STDLIB_H gl_FUNC_GNU_STRFTIME gl_FUNC_STRTOUMAX +if test "$ac_cv_have_decl_strtoumax" != yes && test $ac_cv_func_strtoumax = no; then + AC_LIBOBJ([strtoumax]) + gl_PREREQ_STRTOUMAX +fi gl_INTTYPES_MODULE_INDICATOR([strtoumax]) gl_FUNC_SYMLINK +if test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1; then + AC_LIBOBJ([symlink]) +fi gl_UNISTD_MODULE_INDICATOR([symlink]) gl_HEADER_SYS_STAT_H AC_PROG_MKDIR_P gl_HEADER_TIME_H gl_TIME_R +if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then + AC_LIBOBJ([time_r]) + gl_PREREQ_TIME_R +fi gl_TIME_MODULE_INDICATOR([time_r]) gl_UNISTD_H gl_gnulib_enabled_dosname=false @@ -152,6 +189,10 @@ { if ! $gl_gnulib_enabled_stat; then gl_FUNC_STAT +if test $REPLACE_STAT = 1; then + AC_LIBOBJ([stat]) + gl_PREREQ_STAT +fi gl_SYS_STAT_MODULE_INDICATOR([stat]) gl_gnulib_enabled_stat=true if $condition; then @@ -163,6 +204,10 @@ { if ! $gl_gnulib_enabled_strtoull; then gl_FUNC_STRTOULL +if test $HAVE_STRTOULL = 0; then + AC_LIBOBJ([strtoull]) + gl_PREREQ_STRTOULL +fi gl_STDLIB_MODULE_INDICATOR([strtoull]) gl_gnulib_enabled_strtoull=true fi @@ -173,7 +218,7 @@ gl_gnulib_enabled_verify=true fi } - if test $GNULIB_UNISTD_H_GETOPT = 1; then + if test $REPLACE_GETOPT = 1; then func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 fi if test $REPLACE_LSTAT = 1; then === modified file 'm4/lstat.m4' --- m4/lstat.m4 2011-02-22 19:30:07 +0000 +++ m4/lstat.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# serial 21 +# serial 22 # Copyright (C) 1997-2001, 2003-2011 Free Software Foundation, Inc. # @@ -16,23 +16,27 @@ AC_CHECK_FUNCS_ONCE([lstat]) if test $ac_cv_func_lstat = yes; then AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) - if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then - dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ([lstat]). + if test $gl_cv_func_lstat_dereferences_slashed_symlink = no; then REPLACE_LSTAT=1 fi - # Prerequisites of lib/lstat.c. - AC_REQUIRE([AC_C_INLINE]) else HAVE_LSTAT=0 fi ]) -# Redefine AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, because it is no longer -# maintained in Autoconf. -AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK], -[ +# Prerequisites of lib/lstat.c. +AC_DEFUN([gl_PREREQ_LSTAT], +[ + AC_REQUIRE([AC_C_INLINE]) + : +]) + +AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK], +[ + dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it + dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ. AC_CACHE_CHECK([whether lstat correctly handles trailing slash], - [ac_cv_func_lstat_dereferences_slashed_symlink], + [gl_cv_func_lstat_dereferences_slashed_symlink], [rm -f conftest.sym conftest.file echo >conftest.file if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then @@ -45,25 +49,22 @@ have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ]])], - [ac_cv_func_lstat_dereferences_slashed_symlink=yes], - [ac_cv_func_lstat_dereferences_slashed_symlink=no], + [gl_cv_func_lstat_dereferences_slashed_symlink=yes], + [gl_cv_func_lstat_dereferences_slashed_symlink=no], [# When cross-compiling, be pessimistic so we will end up using the # replacement version of lstat that checks for trailing slashes and # calls lstat a second time when necessary. - ac_cv_func_lstat_dereferences_slashed_symlink=no + gl_cv_func_lstat_dereferences_slashed_symlink=no ]) else # If the 'ln -s' command failed, then we probably don't even # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no + gl_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f conftest.sym conftest.file ]) - test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + test $gl_cv_func_lstat_dereferences_slashed_symlink = yes && AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1], [Define to 1 if `lstat' dereferences a symlink specified with a trailing slash.]) - if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then - AC_LIBOBJ([lstat]) - fi ]) === modified file 'm4/md5.m4' --- m4/md5.m4 2011-02-18 08:07:03 +0000 +++ m4/md5.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# md5.m4 serial 11 +# md5.m4 serial 12 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,8 +6,6 @@ AC_DEFUN([gl_MD5], [ - AC_LIBOBJ([md5]) - dnl Prerequisites of lib/md5.c. AC_REQUIRE([gl_BIGENDIAN]) AC_REQUIRE([AC_C_INLINE]) === modified file 'm4/mktime.m4' --- m4/mktime.m4 2011-05-22 21:02:48 +0000 +++ m4/mktime.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# serial 20 +# serial 21 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,21 +7,24 @@ dnl From Jim Meyering. -# Redefine AC_FUNC_MKTIME, because it is no longer maintained in Autoconf. -# AC_FUNC_MKTIME -# -------------- -AC_DEFUN([AC_FUNC_MKTIME], -[AC_CHECK_HEADERS_ONCE([unistd.h]) -AC_CHECK_FUNCS_ONCE([alarm]) -AC_REQUIRE([gl_MULTIARCH]) -if test $APPLE_UNIVERSAL_BUILD = 1; then - # A universal build on Apple MacOS X platforms. - # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. - # But we need a configuration result that is valid in both modes. - ac_cv_func_working_mktime=no -fi -AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime], -[AC_RUN_IFELSE([AC_LANG_SOURCE( +AC_DEFUN([gl_FUNC_MKTIME], +[ + AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + + dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained + dnl in Autoconf and because it invokes AC_LIBOBJ. + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_FUNCS_ONCE([alarm]) + AC_REQUIRE([gl_MULTIARCH]) + if test $APPLE_UNIVERSAL_BUILD = 1; then + # A universal build on Apple MacOS X platforms. + # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. + # But we need a configuration result that is valid in both modes. + gl_cv_func_working_mktime=no + fi + AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( [[/* Test program from Paul Eggert and Tony Leneis. */ #include #include @@ -213,22 +216,13 @@ result |= 64; return result; }]])], - [ac_cv_func_working_mktime=yes], - [ac_cv_func_working_mktime=no], - [ac_cv_func_working_mktime=no])]) -if test $ac_cv_func_working_mktime = no; then - AC_LIBOBJ([mktime]) -fi -])# AC_FUNC_MKTIME + [gl_cv_func_working_mktime=yes], + [gl_cv_func_working_mktime=no], + [gl_cv_func_working_mktime=no]) + ]) -AC_DEFUN([gl_FUNC_MKTIME], -[ - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) - AC_FUNC_MKTIME - dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]). - if test $ac_cv_func_working_mktime = no; then + if test $gl_cv_func_working_mktime = no; then REPLACE_MKTIME=1 - gl_PREREQ_MKTIME else REPLACE_MKTIME=0 fi @@ -245,8 +239,6 @@ [dnl mktime works but it doesn't export __mktime_internal, dnl so we need to substitute our own mktime implementation. REPLACE_MKTIME=1 - AC_LIBOBJ([mktime]) - gl_PREREQ_MKTIME ]) fi ]) === modified file 'm4/readlink.m4' --- m4/readlink.m4 2011-05-22 21:02:48 +0000 +++ m4/readlink.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# readlink.m4 serial 10 +# readlink.m4 serial 11 dnl Copyright (C) 2003, 2007, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,8 +10,6 @@ AC_CHECK_FUNCS_ONCE([readlink]) if test $ac_cv_func_readlink = no; then HAVE_READLINK=0 - AC_LIBOBJ([readlink]) - gl_PREREQ_READLINK else AC_CACHE_CHECK([whether readlink signature is correct], [gl_cv_decl_readlink_works], @@ -40,10 +38,8 @@ AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink fails to recognize a trailing slash.]) REPLACE_READLINK=1 - AC_LIBOBJ([readlink]) elif test "$gl_cv_decl_readlink_works" != yes; then REPLACE_READLINK=1 - AC_LIBOBJ([readlink]) fi fi ]) === modified file 'm4/sha1.m4' --- m4/sha1.m4 2011-05-24 08:12:52 +0000 +++ m4/sha1.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# sha1.m4 serial 9 +# sha1.m4 serial 10 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,8 +6,6 @@ AC_DEFUN([gl_SHA1], [ - AC_LIBOBJ([sha1]) - dnl Prerequisites of lib/sha1.c. AC_REQUIRE([gl_BIGENDIAN]) AC_REQUIRE([AC_C_INLINE]) === modified file 'm4/stat.m4' --- m4/stat.m4 2011-02-25 20:05:36 +0000 +++ m4/stat.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# serial 7 +# serial 8 # Copyright (C) 2009-2011 Free Software Foundation, Inc. # @@ -58,9 +58,11 @@ AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs help when passed a file name with a trailing slash]);; esac - if test $REPLACE_STAT = 1; then - AC_LIBOBJ([stat]) - dnl Prerequisites of lib/stat.c. - AC_REQUIRE([AC_C_INLINE]) - fi +]) + +# Prerequisites of lib/stat.c. +AC_DEFUN([gl_PREREQ_STAT], +[ + AC_REQUIRE([AC_C_INLINE]) + : ]) === modified file 'm4/strftime.m4' --- m4/strftime.m4 2011-01-30 23:34:18 +0000 +++ m4/strftime.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# serial 32 +# serial 33 # Copyright (C) 1996-1997, 1999-2007, 2009-2011 Free Software Foundation, Inc. # @@ -16,8 +16,6 @@ # These are the prerequisite macros for GNU's strftime.c replacement. AC_DEFUN([gl_FUNC_STRFTIME], [ - AC_LIBOBJ([strftime]) - # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. AC_REQUIRE([AC_STRUCT_TIMEZONE]) === modified file 'm4/strtoull.m4' --- m4/strtoull.m4 2011-04-21 19:12:13 +0000 +++ m4/strtoull.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# strtoull.m4 serial 6 +# strtoull.m4 serial 7 dnl Copyright (C) 2002, 2004, 2006, 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,10 +11,9 @@ dnl unless the type 'unsigned long long int' exists. AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) if test "$ac_cv_type_unsigned_long_long_int" = yes; then - AC_REPLACE_FUNCS([strtoull]) + AC_CHECK_FUNCS([strtoull]) if test $ac_cv_func_strtoull = no; then HAVE_STRTOULL=0 - gl_PREREQ_STRTOULL fi fi ]) === modified file 'm4/strtoumax.m4' --- m4/strtoumax.m4 2011-04-26 19:29:47 +0000 +++ m4/strtoumax.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# strtoumax.m4 serial 9 +# strtoumax.m4 serial 10 dnl Copyright (C) 2002-2004, 2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,10 +12,7 @@ if test "$ac_cv_have_decl_strtoumax" != yes; then HAVE_DECL_STRTOUMAX=0 - AC_REPLACE_FUNCS([strtoumax]) - if test $ac_cv_func_strtoumax = no; then - gl_PREREQ_STRTOUMAX - fi + AC_CHECK_FUNCS([strtoumax]) fi ]) === modified file 'm4/symlink.m4' --- m4/symlink.m4 2011-02-22 19:30:07 +0000 +++ m4/symlink.m4 2011-06-15 22:27:54 +0000 @@ -1,4 +1,4 @@ -# serial 4 +# serial 5 # See if we need to provide symlink replacement. dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. @@ -17,7 +17,6 @@ dnl and Solaris 9, we want to fix a bug with trailing slash handling. if test $ac_cv_func_symlink = no; then HAVE_SYMLINK=0 - AC_LIBOBJ([symlink]) else AC_CACHE_CHECK([whether symlink handles trailing slash correctly], [gl_cv_func_symlink_works], @@ -39,7 +38,6 @@ rm -f conftest.f conftest.link conftest.lnk2]) if test "$gl_cv_func_symlink_works" != yes; then REPLACE_SYMLINK=1 - AC_LIBOBJ([symlink]) fi fi ]) === modified file 'm4/time_r.m4' --- m4/time_r.m4 2011-01-09 06:57:07 +0000 +++ m4/time_r.m4 2011-06-15 22:27:54 +0000 @@ -50,10 +50,6 @@ else HAVE_LOCALTIME_R=0 fi - if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then - AC_LIBOBJ([time_r]) - gl_PREREQ_TIME_R - fi ]) # Prerequisites of lib/time_r.c. ------------------------------------------------------------ revno: 104600 committer: Lars Magne Ingebrigtsen branch nick: trunk timestamp: Wed 2011-06-15 22:44:45 +0200 message: (open-network-stream): Add the keyword :always-query-capabilities. This is for the case where you want to force a `plain' network connection, but the protocol still requires the capabilitiy command (i.e., SMTP and EHLO). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 18:40:00 +0000 +++ lisp/ChangeLog 2011-06-15 20:44:45 +0000 @@ -14,6 +14,11 @@ 2011-06-15 Lars Magne Ingebrigtsen + * net/network-stream.el (open-network-stream): Add the keyword + :always-query-capabilities for the case where you want to force a + `plain' network connection, but the protocol still requires the + capabilitiy command (i.e., SMTP and EHLO). + * subr.el (process-live-p): Rename from `process-alive-p' for consistency with other `-live-p' functions. === modified file 'lisp/net/network-stream.el' --- lisp/net/network-stream.el 2011-05-05 06:35:41 +0000 +++ lisp/net/network-stream.el 2011-06-15 20:44:45 +0000 @@ -109,6 +109,9 @@ capability command, and should return the command to switch on STARTTLS if the server supports STARTTLS, and nil otherwise. +:always-query-capabilies says whether to query the server for +capabilities, even if we're doing a `plain' network connection. + :nowait is a boolean that says the connection should be made asynchronously, if possible." (unless (featurep 'make-network-process) @@ -126,8 +129,11 @@ :nowait (plist-get parameters :nowait)) (let ((work-buffer (or buffer (generate-new-buffer " *stream buffer*"))) - (fun (cond ((eq type 'plain) 'network-stream-open-plain) - ((memq type '(nil network starttls)) + (fun (cond ((and (eq type 'plain) + (not (plist-get parameters + :always-query-capabilities))) + 'network-stream-open-plain) + ((memq type '(nil network starttls plain)) 'network-stream-open-starttls) ((memq type '(tls ssl)) 'network-stream-open-tls) ((eq type 'shell) 'network-stream-open-shell) @@ -182,7 +188,8 @@ (executable-find "gnutls-cli"))) capabilities success-string starttls-function (setq starttls-command - (funcall starttls-function capabilities))) + (funcall starttls-function capabilities)) + (not (eq (plist-get parameters :type) 'plain))) ;; If using external STARTTLS, drop this connection and start ;; anew with `starttls-open-stream'. (unless (fboundp 'open-gnutls-stream) ------------------------------------------------------------ revno: 104599 [merge] fixes bug(s): http://debbugs.gnu.org/8873 committer: Paul Eggert branch nick: trunk timestamp: Wed 2011-06-15 12:57:25 -0700 message: Integer overflow and signedness fixes (Bug#8873). diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-15 18:36:00 +0000 +++ src/ChangeLog 2011-06-15 19:57:25 +0000 @@ -1,3 +1,253 @@ +2011-06-15 Paul Eggert + + Integer overflow and signedness fixes (Bug#8873). + + * ccl.c (ASCENDING_ORDER): New macro, to work around GCC bug 43772. + (GET_CCL_RANGE, IN_INT_RANGE): Use it. + + * fileio.c: Don't assume EMACS_INT fits in off_t. + (emacs_lseek): New static function. + (Finsert_file_contents, Fwrite_region): Use it. + Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate. + + * fns.c (Fload_average): Don't assume 100 * load average fits in int. + + * fns.c: Don't overflow int when computing a list length. + * fns.c (QUIT_COUNT_HEURISTIC): New constant. + (Flength, Fsafe_length): Use EMACS_INT, not int, to avoid unwanted + truncation on 64-bit hosts. Check for QUIT every + QUIT_COUNT_HEURISTIC entries rather than every other entry; that's + faster and is responsive enough. + (Flength): Report an error instead of overflowing an integer. + (Fsafe_length): Return a float if the value is not representable + as a fixnum. This shouldn't happen except in contrived situations. + (Fnthcdr, Fsort): Don't assume list length fits in int. + (Fcopy_sequence): Don't assume vector length fits in int. + + * alloc.c: Check that resized vectors' lengths fit in fixnums. + (header_size, word_size): New constants. + (allocate_vectorlike): Don't check size overflow here. + (allocate_vector): Check it here instead, since this is the only + caller of allocate_vectorlike that could cause overflow. + Check that the new vector's length is representable as a fixnum. + + * fns.c (next_almost_prime): Don't return a multiple of 3 or 5. + The previous code was bogus. For example, next_almost_prime (32) + returned 39, which is undesirable as it is a multiple of 3; and + next_almost_prime (24) returned 25, which is a multiple of 5 so + why was the code bothering to check for multiples of 7? + + * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, for vector length. + + * eval.c, doprnt.c (SIZE_MAX): Remove; inttypes.h defines this now. + + Variadic C functions now count arguments with ptrdiff_t. + This partly undoes my 2011-03-30 change, which replaced int with size_t. + Back then I didn't know that the Emacs coding style prefers signed int. + Also, in the meantime I found a few more instances where arguments + were being counted with int, which may truncate counts on 64-bit + machines, or EMACS_INT, which may be unnecessarily wide. + * lisp.h (struct Lisp_Subr.function.aMANY) + (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): + Arg counts are now ptrdiff_t, not size_t. + All variadic functions and their callers changed accordingly. + (struct gcpro.nvars): Now size_t, not size_t. All uses changed. + * bytecode.c (exec_byte_code): Check maxdepth for overflow, + to avoid potential buffer overrun. Don't assume arg counts fit in 'int'. + * callint.c (Fcall_interactively): Check arg count for overflow, + to avoid potential buffer overrun. Use signed char, not 'int', + for 'varies' array, so that we needn't bother to check its size + calculation for overflow. + * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args. + * eval.c (apply_lambda): + * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length. + (struct textprop_rec.argnum): Now ptrdiff_t, not int. All uses changed. + (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args. + + * callint.c (Fcall_interactively): Don't use index var as event count. + + * vm-limit.c (check_memory_limits): Fix incorrect extern function decls. + * mem-limits.h (SIZE): Remove; no longer used. + + * xterm.c (x_alloc_nearest_color_1): Prefer int to long when int works. + + Remove unnecessary casts. + * xterm.c (x_term_init): + * xfns.c (x_set_border_pixel): + * widget.c (create_frame_gcs): Remove casts to unsigned long etc. + These aren't needed now that we assume ANSI C. + + * sound.c (Fplay_sound_internal): Remove cast to unsigned long. + It's more likely to cause problems (due to unsigned overflow) + than to cure them. + + * dired.c (Ffile_attributes): Don't use 32-bit hack on 64-bit hosts. + + * unexelf.c (unexec): Don't assume BSS addr fits in unsigned. + + * xterm.c (handle_one_xevent): Omit unnecessary casts to unsigned. + + * keyboard.c (modify_event_symbol): Don't limit alist len to UINT_MAX. + + * lisp.h (CHAR_TABLE_SET): Omit now-redundant test. + + * lread.c (Fload): Don't compare a possibly-garbage time_t value. + + GLYPH_CODE_FACE returns EMACS_INT, not int. + * dispextern.h (merge_faces): + * xfaces.c (merge_faces): + * xdisp.c (get_next_display_element, next_element_from_display_vector): + Don't assume EMACS_INT fits in int. + + * character.h (CHAR_VALID_P): Remove unused parameter. + * fontset.c, lisp.h, xdisp.c: All uses changed. + + * editfns.c (Ftranslate_region_internal): Omit redundant test. + + * fns.c (concat): Minor tuning based on overflow analysis. + This doesn't fix any bugs. Use int to hold character, instead + of constantly refetching from Emacs object. Use XFASTINT, not + XINT, for value known to be a character. Don't bother comparing + a single byte to 0400, as it's always less. + + * floatfns.c (Fexpt): + * fileio.c (make_temp_name): Omit unnecessary cast to unsigned. + + * editfns.c (Ftranslate_region_internal): Use int, not EMACS_INT + for characters. + + * doc.c (get_doc_string): Omit (unsigned)c that mishandled negatives. + + * data.c (Faset): If ARRAY is a string, check that NEWELT is a char. + Without this fix, on a 64-bit host (aset S 0 4294967386) would + incorrectly succeed when S was a string, because 4294967386 was + truncated before it was used. + + * chartab.c (Fchar_table_range): Use CHARACTERP to check range. + Otherwise, an out-of-range integer could cause undefined behavior + on a 64-bit host. + + * composite.c: Use int, not EMACS_INT, for characters. + (fill_gstring_body, composition_compute_stop_pos): Use int, not + EMACS_INT, for values that are known to be in character range. + This doesn't fix any bugs but is the usual style inside Emacs and + may generate better code on 32-bit machines. + + Make sure a 64-bit char is never passed to ENCODE_CHAR. + This is for reasons similar to the recent CHAR_STRING fix. + * charset.c (Fencode_char): Check that character arg is actually + a character. Pass an int to ENCODE_CHAR. + * charset.h (ENCODE_CHAR): Verify that the character argument is no + wider than 'int', as a compile-time check to prevent future regressions + in this area. + + * character.c (char_string): Remove unnecessary casts. + + Make sure a 64-bit char is never passed to CHAR_STRING. + Otherwise, CHAR_STRING would do the wrong thing on a 64-bit platform, + by silently ignoring the top 32 bits, allowing some values + that were far too large to be valid characters. + * character.h: Include . + (CHAR_STRING, CHAR_STRING_ADVANCE): Verify that the character + arguments are no wider than unsigned, as a compile-time check + to prevent future regressions in this area. + * data.c (Faset): + * editfns.c (Fchar_to_string, general_insert_function, Finsert_char) + (Fsubst_char_in_region): + * fns.c (concat): + * xdisp.c (decode_mode_spec_coding): + Adjust to CHAR_STRING's new requirement. + * editfns.c (Finsert_char, Fsubst_char_in_region): + * fns.c (concat): Check that character args are actually + characters. Without this test, these functions did the wrong + thing with wildly out-of-range values on 64-bit hosts. + + Remove incorrect casts to 'unsigned' that lose info on 64-bit hosts. + These casts should not be needed on 32-bit hosts, either. + * keyboard.c (read_char): + * lread.c (Fload): Remove casts to unsigned. + + * lisp.h (UNSIGNED_CMP): New macro. + This fixes comparison bugs on 64-bit hosts. + (ASCII_CHAR_P): Use it. + * casefiddle.c (casify_object): + * character.h (ASCII_BYTE_P, CHAR_VALID_P) + (SINGLE_BYTE_CHAR_P, CHAR_STRING): + * composite.h (COMPOSITION_ENCODE_RULE_VALID): + * dispextern.h (FACE_FROM_ID): + * keyboard.c (read_char): Use UNSIGNED_CMP. + + * xmenu.c (dialog_selection_callback) [!USE_GTK]: Cast to intptr_t, + not to EMACS_INT, to avoid GCC warning. + + * xfns.c (x_set_scroll_bar_default_width): Remove unused 'int' locals. + + * buffer.h (PTR_BYTE_POS, BUF_PTR_BYTE_POS): Remove harmful cast. + The cast incorrectly truncated 64-bit byte offsets to 32 bits, and + isn't needed on 32-bit machines. + + * buffer.c (Fgenerate_new_buffer_name): + Use EMACS_INT for count, not int. + (advance_to_char_boundary): Return EMACS_INT, not int. + + * data.c (Qcompiled_function): Now static. + + * window.c (window_body_lines): Now static. + + * image.c (gif_load): Rename local to avoid shadowing. + + * lisp.h (SAFE_ALLOCA_LISP): Check for integer overflow. + (struct Lisp_Save_Value): Use ptrdiff_t, not int, for 'integer' member. + * alloc.c (make_save_value): Integer argument is now of type + ptrdiff_t, not int. + (mark_object): Use ptrdiff_t, not int. + * lisp.h (pD): New macro. + * print.c (print_object): Use it. + + * alloc.c: Use EMACS_INT, not int, to count objects. + (total_conses, total_markers, total_symbols, total_vector_size) + (total_free_conses, total_free_markers, total_free_symbols) + (total_free_floats, total_floats, total_free_intervals) + (total_intervals, total_strings, total_free_strings): + Now EMACS_INT, not int. All uses changed. + (Fgarbage_collect): Compute overall total using a double, so that + integer overflow is less likely to be a problem. Check for overflow + when converting back to an integer. + (n_interval_blocks, n_string_blocks, n_float_blocks, n_cons_blocks) + (n_vectors, n_symbol_blocks, n_marker_blocks): Remove. + These were 'int' variables that could overflow on 64-bit hosts; + they were never used, so remove them instead of repairing them. + (nzombies, ngcs, max_live, max_zombies): Now EMACS_INT, not 'int'. + (inhibit_garbage_collection): Set gc_cons_threshold to max value. + Previously, this ceilinged at INT_MAX, but that doesn't work on + 64-bit machines. + (allocate_pseudovector): Don't use EMACS_INT when int would do. + + * alloc.c (Fmake_bool_vector): Don't assume vector size fits in int. + (allocate_vectorlike): Check for ptrdiff_t overflow. + (mark_vectorlike, mark_char_table, mark_object): Avoid EMACS_UINT + when a (possibly-narrower) signed value would do just as well. + We prefer using signed arithmetic, to avoid comparison confusion. + + * alloc.c: Catch some string size overflows that we were missing. + (XMALLOC_OVERRUN_CHECK_SIZE) [!XMALLOC_OVERRUN_CHECK]: Define to 0, + for convenience in STRING_BYTES_MAX. + (STRING_BYTES_MAX): New macro, superseding the old one in lisp.h. + The definition here is exact; the one in lisp.h was approximate. + (allocate_string_data): Check for string overflow. This catches + some instances we weren't catching before. Also, it catches + size_t overflow on (unusual) hosts where SIZE_MAX <= min + (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM), e.g., when size_t is 32 bits + and ptrdiff_t and EMACS_INT are both 64 bits. + + * character.c, coding.c, doprnt.c, editfns.c, eval.c: + All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND. + * lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX. + + * character.c (string_escape_byte8): Fix nbytes/nchars typo. + + * alloc.c (Fmake_string): Check for out-of-range init. + 2011-06-15 Stefan Monnier * eval.c (Fdefvaralias): Also mark the target as variable-special-p. === modified file 'src/alloc.c' --- src/alloc.c 2011-06-06 19:43:39 +0000 +++ src/alloc.c 2011-06-14 21:30:16 +0000 @@ -180,9 +180,9 @@ /* Number of live and free conses etc. */ -static int total_conses, total_markers, total_symbols, total_vector_size; -static int total_free_conses, total_free_markers, total_free_symbols; -static int total_free_floats, total_floats; +static EMACS_INT total_conses, total_markers, total_symbols, total_vector_size; +static EMACS_INT total_free_conses, total_free_markers, total_free_symbols; +static EMACS_INT total_free_floats, total_floats; /* Points to memory space allocated as "spare", to be freed if we run out of memory. We keep one large block, four cons-blocks, and @@ -485,7 +485,9 @@ } -#ifdef XMALLOC_OVERRUN_CHECK +#ifndef XMALLOC_OVERRUN_CHECK +#define XMALLOC_OVERRUN_CHECK_SIZE 0 +#else /* Check for overrun in malloc'ed buffers by wrapping a 16 byte header and a 16 byte trailer around each block. @@ -1336,16 +1338,12 @@ /* Number of free and live intervals. */ -static int total_free_intervals, total_intervals; +static EMACS_INT total_free_intervals, total_intervals; /* List of free intervals. */ static INTERVAL interval_free_list; -/* Total number of interval blocks now in use. */ - -static int n_interval_blocks; - /* Initialize interval allocation. */ @@ -1355,7 +1353,6 @@ interval_block = NULL; interval_block_index = INTERVAL_BLOCK_SIZE; interval_free_list = 0; - n_interval_blocks = 0; } @@ -1387,7 +1384,6 @@ newi->next = interval_block; interval_block = newi; interval_block_index = 0; - n_interval_blocks++; } val = &interval_block->intervals[interval_block_index++]; } @@ -1580,10 +1576,9 @@ static struct sblock *large_sblocks; -/* List of string_block structures, and how many there are. */ +/* List of string_block structures. */ static struct string_block *string_blocks; -static int n_string_blocks; /* Free-list of Lisp_Strings. */ @@ -1591,7 +1586,7 @@ /* Number of live and free Lisp_Strings. */ -static int total_strings, total_free_strings; +static EMACS_INT total_strings, total_free_strings; /* Number of bytes used by live strings. */ @@ -1659,6 +1654,18 @@ #define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE) +/* Exact bound on the number of bytes in a string, not counting the + terminating null. A string cannot contain more bytes than + STRING_BYTES_BOUND, nor can it be so long that the size_t + arithmetic in allocate_string_data would overflow while it is + calculating a value to be passed to malloc. */ +#define STRING_BYTES_MAX \ + min (STRING_BYTES_BOUND, \ + ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_SIZE - GC_STRING_EXTRA \ + - offsetof (struct sblock, first_data) \ + - SDATA_DATA_OFFSET) \ + & ~(sizeof (EMACS_INT) - 1))) + /* Initialize string allocation. Called from init_alloc_once. */ static void @@ -1667,7 +1674,6 @@ total_strings = total_free_strings = total_string_size = 0; oldest_sblock = current_sblock = large_sblocks = NULL; string_blocks = NULL; - n_string_blocks = 0; string_free_list = NULL; empty_unibyte_string = make_pure_string ("", 0, 0, 0); empty_multibyte_string = make_pure_string ("", 0, 0, 1); @@ -1799,7 +1805,6 @@ memset (b, 0, sizeof *b); b->next = string_blocks; string_blocks = b; - ++n_string_blocks; for (i = STRING_BLOCK_SIZE - 1; i >= 0; --i) { @@ -1858,6 +1863,9 @@ struct sblock *b; EMACS_INT needed, old_nbytes; + if (STRING_BYTES_MAX < nbytes) + string_overflow (); + /* Determine the number of bytes needed to store NBYTES bytes of string data. */ needed = SDATA_SIZE (nbytes); @@ -2025,7 +2033,6 @@ && total_free_strings > STRING_BLOCK_SIZE) { lisp_free (b); - --n_string_blocks; string_free_list = free_list_before; } else @@ -2186,9 +2193,9 @@ EMACS_INT nbytes; CHECK_NATNUM (length); - CHECK_NUMBER (init); + CHECK_CHARACTER (init); - c = XINT (init); + c = XFASTINT (init); if (ASCII_CHAR_P (c)) { nbytes = XINT (length); @@ -2229,7 +2236,6 @@ { register Lisp_Object val; struct Lisp_Bool_Vector *p; - int real_init, i; EMACS_INT length_in_chars, length_in_elts; int bits_per_value; @@ -2251,9 +2257,7 @@ p = XBOOL_VECTOR (val); p->size = XFASTINT (length); - real_init = (NILP (init) ? 0 : -1); - for (i = 0; i < length_in_chars ; i++) - p->data[i] = real_init; + memset (p->data, NILP (init) ? 0 : -1, length_in_chars); /* Clear the extraneous bits in the last byte. */ if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR) @@ -2463,10 +2467,6 @@ static int float_block_index; -/* Total number of float blocks now in use. */ - -static int n_float_blocks; - /* Free-list of Lisp_Floats. */ static struct Lisp_Float *float_free_list; @@ -2480,7 +2480,6 @@ float_block = NULL; float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */ float_free_list = 0; - n_float_blocks = 0; } @@ -2514,7 +2513,6 @@ memset (new->gcmarkbits, 0, sizeof new->gcmarkbits); float_block = new; float_block_index = 0; - n_float_blocks++; } XSETFLOAT (val, &float_block->floats[float_block_index]); float_block_index++; @@ -2579,10 +2577,6 @@ static struct Lisp_Cons *cons_free_list; -/* Total number of cons blocks now in use. */ - -static int n_cons_blocks; - /* Initialize cons allocation. */ @@ -2592,7 +2586,6 @@ cons_block = NULL; cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */ cons_free_list = 0; - n_cons_blocks = 0; } @@ -2636,7 +2629,6 @@ new->next = cons_block; cons_block = new; cons_block_index = 0; - n_cons_blocks++; } XSETCONS (val, &cons_block->conses[cons_block_index]); cons_block_index++; @@ -2705,7 +2697,7 @@ doc: /* Return a newly created list with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (list &rest OBJECTS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object val; val = Qnil; @@ -2775,10 +2767,12 @@ static struct Lisp_Vector *all_vectors; -/* Total number of vector-like objects now in use. */ - -static int n_vectors; - +/* Handy constants for vectorlike objects. */ +enum + { + header_size = offsetof (struct Lisp_Vector, contents), + word_size = sizeof (Lisp_Object) + }; /* Value is a pointer to a newly allocated Lisp_Vector structure with room for LEN Lisp_Objects. */ @@ -2788,11 +2782,6 @@ { struct Lisp_Vector *p; size_t nbytes; - int header_size = offsetof (struct Lisp_Vector, contents); - int word_size = sizeof p->contents[0]; - - if ((SIZE_MAX - header_size) / word_size < len) - memory_full (SIZE_MAX); MALLOC_BLOCK_INPUT; @@ -2822,18 +2811,22 @@ MALLOC_UNBLOCK_INPUT; - ++n_vectors; return p; } -/* Allocate a vector with NSLOTS slots. */ +/* Allocate a vector with LEN slots. */ struct Lisp_Vector * -allocate_vector (EMACS_INT nslots) +allocate_vector (EMACS_INT len) { - struct Lisp_Vector *v = allocate_vectorlike (nslots); - v->header.size = nslots; + struct Lisp_Vector *v; + ptrdiff_t nbytes_max = min (PTRDIFF_MAX, SIZE_MAX); + + if (min ((nbytes_max - header_size) / word_size, MOST_POSITIVE_FIXNUM) < len) + memory_full (SIZE_MAX); + v = allocate_vectorlike (len); + v->header.size = len; return v; } @@ -2844,7 +2837,7 @@ allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag) { struct Lisp_Vector *v = allocate_vectorlike (memlen); - EMACS_INT i; + int i; /* Only the first lisplen slots will be traced normally by the GC. */ for (i = 0; i < lisplen; ++i) @@ -2925,10 +2918,10 @@ doc: /* Return a newly created vector with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (vector &rest OBJECTS) */) - (register size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object len, val; - register size_t i; + ptrdiff_t i; register struct Lisp_Vector *p; XSETFASTINT (len, nargs); @@ -2956,15 +2949,15 @@ arguments will not be dynamically bound but will be instead pushed on the stack before executing the byte-code. usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS) */) - (register size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object len, val; - register size_t i; + ptrdiff_t i; register struct Lisp_Vector *p; XSETFASTINT (len, nargs); if (!NILP (Vpurify_flag)) - val = make_pure_vector ((EMACS_INT) nargs); + val = make_pure_vector (nargs); else val = Fmake_vector (len, Qnil); @@ -3018,10 +3011,6 @@ static struct Lisp_Symbol *symbol_free_list; -/* Total number of symbol blocks now in use. */ - -static int n_symbol_blocks; - /* Initialize symbol allocation. */ @@ -3031,7 +3020,6 @@ symbol_block = NULL; symbol_block_index = SYMBOL_BLOCK_SIZE; symbol_free_list = 0; - n_symbol_blocks = 0; } @@ -3064,7 +3052,6 @@ new->next = symbol_block; symbol_block = new; symbol_block_index = 0; - n_symbol_blocks++; } XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]); symbol_block_index++; @@ -3112,17 +3099,12 @@ static union Lisp_Misc *marker_free_list; -/* Total number of marker blocks now in use. */ - -static int n_marker_blocks; - static void init_marker (void) { marker_block = NULL; marker_block_index = MARKER_BLOCK_SIZE; marker_free_list = 0; - n_marker_blocks = 0; } /* Return a newly allocated Lisp_Misc object, with no substructure. */ @@ -3151,7 +3133,6 @@ new->next = marker_block; marker_block = new; marker_block_index = 0; - n_marker_blocks++; total_free_markers += MARKER_BLOCK_SIZE; } XSETMISC (val, &marker_block->markers[marker_block_index]); @@ -3184,7 +3165,7 @@ The unwind function can get the C values back using XSAVE_VALUE. */ Lisp_Object -make_save_value (void *pointer, int integer) +make_save_value (void *pointer, ptrdiff_t integer) { register Lisp_Object val; register struct Lisp_Save_Value *p; @@ -3929,11 +3910,11 @@ /* Number of zombie objects. */ -static int nzombies; +static EMACS_INT nzombies; /* Number of garbage collections. */ -static int ngcs; +static EMACS_INT ngcs; /* Average percentage of zombies per collection. */ @@ -3941,7 +3922,7 @@ /* Max. number of live and zombie objects. */ -static int max_live, max_zombies; +static EMACS_INT max_live, max_zombies; /* Average number of live objects per GC. */ @@ -3952,7 +3933,7 @@ (void) { Lisp_Object args[8], zombie_list = Qnil; - int i; + EMACS_INT i; for (i = 0; i < nzombies; i++) zombie_list = Fcons (zombies[i], zombie_list); args[0] = build_string ("%d GCs, avg live/zombies = %.2f/%.2f (%f%%), max %d/%d\nzombies: %S"); @@ -4262,7 +4243,7 @@ check_gcpros (void) { struct gcpro *p; - size_t i; + ptrdiff_t i; for (p = gcprolist; p; p = p->next) for (i = 0; i < p->nvars; ++i) @@ -4279,7 +4260,7 @@ { int i; - fprintf (stderr, "\nZombies kept alive = %d:\n", nzombies); + fprintf (stderr, "\nZombies kept alive = %"pI":\n", nzombies); for (i = 0; i < min (MAX_ZOMBIES, nzombies); ++i) { fprintf (stderr, " %d = ", i); @@ -4851,9 +4832,8 @@ inhibit_garbage_collection (void) { int count = SPECPDL_INDEX (); - int nbits = min (VALBITS, BITS_PER_INT); - specbind (Qgc_cons_threshold, make_number (((EMACS_INT) 1 << (nbits - 1)) - 1)); + specbind (Qgc_cons_threshold, make_number (MOST_POSITIVE_FIXNUM)); return count; } @@ -4873,7 +4853,7 @@ { register struct specbinding *bind; char stack_top_variable; - register size_t i; + ptrdiff_t i; int message_p; Lisp_Object total[8]; int count = SPECPDL_INDEX (); @@ -5103,9 +5083,10 @@ if (gc_cons_threshold < 10000) gc_cons_threshold = 10000; + gc_relative_threshold = 0; if (FLOATP (Vgc_cons_percentage)) { /* Set gc_cons_combined_threshold. */ - EMACS_INT tot = 0; + double tot = 0; tot += total_conses * sizeof (struct Lisp_Cons); tot += total_symbols * sizeof (struct Lisp_Symbol); @@ -5116,10 +5097,15 @@ tot += total_intervals * sizeof (struct interval); tot += total_strings * sizeof (struct Lisp_String); - gc_relative_threshold = tot * XFLOAT_DATA (Vgc_cons_percentage); + tot *= XFLOAT_DATA (Vgc_cons_percentage); + if (0 < tot) + { + if (tot < TYPE_MAXIMUM (EMACS_INT)) + gc_relative_threshold = tot; + else + gc_relative_threshold = TYPE_MAXIMUM (EMACS_INT); + } } - else - gc_relative_threshold = 0; if (garbage_collection_messages) { @@ -5250,8 +5236,8 @@ static void mark_vectorlike (struct Lisp_Vector *ptr) { - register EMACS_UINT size = ptr->header.size; - register EMACS_UINT i; + EMACS_INT size = ptr->header.size; + EMACS_INT i; eassert (!VECTOR_MARKED_P (ptr)); VECTOR_MARK (ptr); /* Else mark it */ @@ -5273,8 +5259,8 @@ static void mark_char_table (struct Lisp_Vector *ptr) { - register EMACS_UINT size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK; - register EMACS_UINT i; + int size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK; + int i; eassert (!VECTOR_MARKED_P (ptr)); VECTOR_MARK (ptr); @@ -5402,12 +5388,11 @@ recursion there. */ { register struct Lisp_Vector *ptr = XVECTOR (obj); - register EMACS_UINT size = ptr->header.size; - register EMACS_UINT i; + int size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK; + int i; CHECK_LIVE (live_vector_p); VECTOR_MARK (ptr); /* Else mark it */ - size &= PSEUDOVECTOR_SIZE_MASK; for (i = 0; i < size; i++) /* and then mark its elements */ { if (i != COMPILED_CONSTANTS) @@ -5534,7 +5519,7 @@ if (ptr->dogc) { Lisp_Object *p = (Lisp_Object *) ptr->pointer; - int nelt; + ptrdiff_t nelt; for (nelt = ptr->integer; nelt > 0; nelt--, p++) mark_maybe_object (*p); } @@ -5734,7 +5719,7 @@ register struct cons_block *cblk; struct cons_block **cprev = &cons_block; register int lim = cons_block_index; - register int num_free = 0, num_used = 0; + EMACS_INT num_free = 0, num_used = 0; cons_free_list = 0; @@ -5795,7 +5780,6 @@ /* Unhook from the free list. */ cons_free_list = cblk->conses[0].u.chain; lisp_align_free (cblk); - n_cons_blocks--; } else { @@ -5812,7 +5796,7 @@ register struct float_block *fblk; struct float_block **fprev = &float_block; register int lim = float_block_index; - register int num_free = 0, num_used = 0; + EMACS_INT num_free = 0, num_used = 0; float_free_list = 0; @@ -5842,7 +5826,6 @@ /* Unhook from the free list. */ float_free_list = fblk->floats[0].u.chain; lisp_align_free (fblk); - n_float_blocks--; } else { @@ -5859,7 +5842,7 @@ register struct interval_block *iblk; struct interval_block **iprev = &interval_block; register int lim = interval_block_index; - register int num_free = 0, num_used = 0; + EMACS_INT num_free = 0, num_used = 0; interval_free_list = 0; @@ -5892,7 +5875,6 @@ /* Unhook from the free list. */ interval_free_list = INTERVAL_PARENT (&iblk->intervals[0]); lisp_free (iblk); - n_interval_blocks--; } else { @@ -5909,7 +5891,7 @@ register struct symbol_block *sblk; struct symbol_block **sprev = &symbol_block; register int lim = symbol_block_index; - register int num_free = 0, num_used = 0; + EMACS_INT num_free = 0, num_used = 0; symbol_free_list = NULL; @@ -5956,7 +5938,6 @@ /* Unhook from the free list. */ symbol_free_list = sblk->symbols[0].next; lisp_free (sblk); - n_symbol_blocks--; } else { @@ -5974,7 +5955,7 @@ register struct marker_block *mblk; struct marker_block **mprev = &marker_block; register int lim = marker_block_index; - register int num_free = 0, num_used = 0; + EMACS_INT num_free = 0, num_used = 0; marker_free_list = 0; @@ -6013,7 +5994,6 @@ /* Unhook from the free list. */ marker_free_list = mblk->markers[0].u_free.chain; lisp_free (mblk); - n_marker_blocks--; } else { @@ -6063,7 +6043,6 @@ all_vectors = vector->header.next.vector; next = vector->header.next.vector; lisp_free (vector); - n_vectors--; vector = next; } === modified file 'src/buffer.c' --- src/buffer.c 2011-06-11 21:31:32 +0000 +++ src/buffer.c 2011-06-13 08:00:15 +0000 @@ -850,8 +850,8 @@ (register Lisp_Object name, Lisp_Object ignore) { register Lisp_Object gentemp, tem; - int count; - char number[10]; + EMACS_INT count; + char number[INT_BUFSIZE_BOUND (EMACS_INT) + sizeof "<>"]; CHECK_STRING (name); @@ -865,7 +865,7 @@ count = 1; while (1) { - sprintf (number, "<%d>", ++count); + sprintf (number, "<%"pI"d>", ++count); gentemp = concat2 (name, build_string (number)); tem = Fstring_equal (gentemp, ignore); if (!NILP (tem)) @@ -1969,7 +1969,7 @@ /* Advance BYTE_POS up to a character boundary and return the adjusted position. */ -static int +static EMACS_INT advance_to_char_boundary (EMACS_INT byte_pos) { int c; === modified file 'src/buffer.h' --- src/buffer.h 2011-06-10 20:52:30 +0000 +++ src/buffer.h 2011-06-11 05:46:16 +0000 @@ -338,7 +338,7 @@ #define PTR_BYTE_POS(ptr) \ ((ptr) - (current_buffer)->text->beg \ - - (ptr - (current_buffer)->text->beg <= (unsigned) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \ + - (ptr - (current_buffer)->text->beg <= GPT_BYTE - BEG_BYTE ? 0 : GAP_SIZE) \ + BEG_BYTE) /* Return character at byte position POS. */ @@ -397,7 +397,7 @@ #define BUF_PTR_BYTE_POS(buf, ptr) \ ((ptr) - (buf)->text->beg \ - - (ptr - (buf)->text->beg <= (unsigned) (BUF_GPT_BYTE ((buf)) - BEG_BYTE)\ + - (ptr - (buf)->text->beg <= BUF_GPT_BYTE (buf) - BEG_BYTE \ ? 0 : BUF_GAP_SIZE ((buf))) \ + BEG_BYTE) === modified file 'src/bytecode.c' --- src/bytecode.c 2011-06-01 14:19:45 +0000 +++ src/bytecode.c 2011-06-14 20:12:13 +0000 @@ -433,7 +433,7 @@ Lisp_Object exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, - Lisp_Object args_template, int nargs, Lisp_Object *args) + Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args) { int count = SPECPDL_INDEX (); #ifdef BYTE_CODE_METER @@ -444,7 +444,7 @@ /* Lisp_Object v1, v2; */ Lisp_Object *vectorp; #ifdef BYTE_CODE_SAFE - int const_length; + ptrdiff_t const_length; Lisp_Object *stacke; int bytestr_length; #endif @@ -464,7 +464,7 @@ CHECK_STRING (bytestr); CHECK_VECTOR (vector); - CHECK_NUMBER (maxdepth); + CHECK_NATNUM (maxdepth); #ifdef BYTE_CODE_SAFE const_length = ASIZE (vector); @@ -486,6 +486,8 @@ stack.byte_string = bytestr; stack.pc = stack.byte_string_start = SDATA (bytestr); stack.constants = vector; + if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) < XFASTINT (maxdepth)) + memory_full (SIZE_MAX); top = (Lisp_Object *) alloca (XFASTINT (maxdepth) * sizeof (Lisp_Object)); #if BYTE_MAINTAIN_TOP @@ -502,14 +504,14 @@ if (INTEGERP (args_template)) { - int at = XINT (args_template); + ptrdiff_t at = XINT (args_template); int rest = at & 128; int mandatory = at & 127; - int nonrest = at >> 8; + ptrdiff_t nonrest = at >> 8; eassert (mandatory <= nonrest); if (nargs <= nonrest) { - int i; + ptrdiff_t i; for (i = 0 ; i < nargs; i++, args++) PUSH (*args); if (nargs < mandatory) @@ -528,7 +530,7 @@ } else if (rest) { - int i; + ptrdiff_t i; for (i = 0 ; i < nonrest; i++, args++) PUSH (*args); PUSH (Flist (nargs - nonrest, args)); === modified file 'src/callint.c' --- src/callint.c 2011-05-12 07:07:06 +0000 +++ src/callint.c 2011-06-14 18:57:19 +0000 @@ -269,10 +269,9 @@ /* If varies[i] > 0, the i'th argument shouldn't just have its value in this call quoted in the command history. It should be recorded as a call to the function named callint_argfuns[varies[i]]. */ - int *varies; + signed char *varies; - register size_t i; - size_t nargs; + ptrdiff_t i, nargs; int foo; char prompt1[100]; char *tem1; @@ -339,7 +338,7 @@ { Lisp_Object input; Lisp_Object funval = Findirect_function (function, Qt); - i = num_input_events; + size_t events = num_input_events; input = specs; /* Compute the arg values using the user's expression. */ GCPRO2 (input, filter_specs); @@ -347,7 +346,7 @@ CONSP (funval) && EQ (Qclosure, XCAR (funval)) ? Qt : Qnil); UNGCPRO; - if (i != num_input_events || !NILP (record_flag)) + if (events != num_input_events || !NILP (record_flag)) { /* We should record this command on the command history. */ Lisp_Object values; @@ -465,9 +464,14 @@ break; } + if (min (MOST_POSITIVE_FIXNUM, + min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) + < nargs) + memory_full (SIZE_MAX); + args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); visargs = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); - varies = (int *) alloca (nargs * sizeof (int)); + varies = (signed char *) alloca (nargs); for (i = 0; i < nargs; i++) { === modified file 'src/callproc.c' --- src/callproc.c 2011-05-31 05:12:19 +0000 +++ src/callproc.c 2011-06-14 18:57:19 +0000 @@ -184,7 +184,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object infile, buffer, current_dir, path; volatile int display_p_volatile; @@ -231,7 +231,7 @@ /* Decide the coding-system for giving arguments. */ { Lisp_Object val, *args2; - size_t i; + ptrdiff_t i; /* If arguments are supplied, we may have to encode them. */ if (nargs >= 5) @@ -422,7 +422,7 @@ (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); if (nargs > 4) { - register size_t i; + ptrdiff_t i; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; GCPRO5 (infile, buffer, current_dir, path, error_file); @@ -716,7 +716,7 @@ { if (EQ (coding_systems, Qt)) { - size_t i; + ptrdiff_t i; SAFE_ALLOCA (args2, Lisp_Object *, (nargs + 1) * sizeof *args2); args2[0] = Qcall_process; @@ -944,7 +944,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again. usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { struct gcpro gcpro1; Lisp_Object filename_string; @@ -953,7 +953,7 @@ /* Qt denotes we have not yet called Ffind_operation_coding_system. */ Lisp_Object coding_systems; Lisp_Object val, *args2; - size_t i; + ptrdiff_t i; char *tempfile; Lisp_Object tmpdir, pattern; === modified file 'src/casefiddle.c' --- src/casefiddle.c 2011-04-14 05:04:02 +0000 +++ src/casefiddle.c 2011-06-12 23:25:12 +0000 @@ -52,7 +52,7 @@ /* If the character has higher bits set above the flags, return it unchanged. It is not a real character. */ - if ((unsigned) XFASTINT (obj) > (unsigned) flagbits) + if (UNSIGNED_CMP (XFASTINT (obj), >, flagbits)) return obj; c1 = XFASTINT (obj) & ~flagbits; === modified file 'src/ccl.c' --- src/ccl.c 2011-05-31 06:05:00 +0000 +++ src/ccl.c 2011-06-15 19:40:52 +0000 @@ -745,11 +745,15 @@ #endif +/* Use "&" rather than "&&" to suppress a bogus GCC warning; see + . */ +#define ASCENDING_ORDER(lo, med, hi) (((lo) <= (med)) & ((med) <= (hi))) + #define GET_CCL_RANGE(var, ccl_prog, ic, lo, hi) \ do \ { \ EMACS_INT prog_word = XINT ((ccl_prog)[ic]); \ - if (! ((lo) <= prog_word && prog_word <= (hi))) \ + if (! ASCENDING_ORDER (lo, prog_word, hi)) \ CCL_INVALID_CMD; \ (var) = prog_word; \ } \ @@ -761,7 +765,7 @@ #define GET_CCL_INT(var, ccl_prog, ic) \ GET_CCL_RANGE (var, ccl_prog, ic, INT_MIN, INT_MAX) -#define IN_INT_RANGE(val) (INT_MIN <= (val) && (val) <= INT_MAX) +#define IN_INT_RANGE(val) ASCENDING_ORDER (INT_MIN, val, INT_MAX) /* Encode one character CH to multibyte form and write to the current output buffer. If CH is less than 256, CH is written as is. */ === modified file 'src/character.c' --- src/character.c 2011-06-06 19:43:39 +0000 +++ src/character.c 2011-06-14 18:57:19 +0000 @@ -123,7 +123,7 @@ if (c & CHAR_MODIFIER_MASK) { - c = (unsigned) char_resolve_modifier_mask ((int) c); + c = char_resolve_modifier_mask (c); /* If C still has any modifier bits, just ignore it. */ c &= ~CHAR_MODIFIER_MASK; } @@ -838,7 +838,7 @@ if (multibyte) { if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count - || (STRING_BYTES_MAX - nbytes) / 2 < byte8_count) + || (STRING_BYTES_BOUND - nbytes) / 2 < byte8_count) string_overflow (); /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ @@ -847,7 +847,7 @@ } else { - if ((STRING_BYTES_MAX - nchars) / 3 < byte8_count) + if ((STRING_BYTES_BOUND - nbytes) / 3 < byte8_count) string_overflow (); /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ @@ -893,9 +893,9 @@ doc: /* Concatenate all the argument characters and make the result a string. usage: (string &rest CHARACTERS) */) - (size_t n, Lisp_Object *args) + (ptrdiff_t n, Lisp_Object *args) { - size_t i; + ptrdiff_t i; int c; unsigned char *buf, *p; Lisp_Object str; @@ -919,9 +919,9 @@ DEFUN ("unibyte-string", Funibyte_string, Sunibyte_string, 0, MANY, 0, doc: /* Concatenate all the argument bytes and make the result a unibyte string. usage: (unibyte-string &rest BYTES) */) - (size_t n, Lisp_Object *args) + (ptrdiff_t n, Lisp_Object *args) { - size_t i; + ptrdiff_t i; int c; unsigned char *buf, *p; Lisp_Object str; === modified file 'src/character.h' --- src/character.h 2011-06-01 02:49:12 +0000 +++ src/character.h 2011-06-15 18:57:45 +0000 @@ -23,6 +23,8 @@ #ifndef EMACS_CHARACTER_H #define EMACS_CHARACTER_H +#include + /* character code 1st byte byte sequence -------------- -------- ------------- 0-7F 00..7F 0xxxxxxx @@ -102,13 +104,13 @@ #define make_char(c) make_number (c) /* Nonzero iff C is an ASCII byte. */ -#define ASCII_BYTE_P(c) ((unsigned) (c) < 0x80) +#define ASCII_BYTE_P(c) UNSIGNED_CMP (c, <, 0x80) /* Nonzero iff X is a character. */ #define CHARACTERP(x) (NATNUMP (x) && XFASTINT (x) <= MAX_CHAR) -/* Nonzero iff C is valid as a character code. GENERICP is not used. */ -#define CHAR_VALID_P(c, genericp) ((unsigned) (c) <= MAX_CHAR) +/* Nonzero iff C is valid as a character code. */ +#define CHAR_VALID_P(c) UNSIGNED_CMP (c, <=, MAX_CHAR) /* Check if Lisp object X is a character or not. */ #define CHECK_CHARACTER(x) \ @@ -129,7 +131,7 @@ } while (0) /* Nonzero iff C is a character of code less than 0x100. */ -#define SINGLE_BYTE_CHAR_P(c) ((unsigned) (c) < 0x100) +#define SINGLE_BYTE_CHAR_P(c) UNSIGNED_CMP (c, <, 0x100) /* Nonzero if character C has a printable glyph. */ #define CHAR_PRINTABLE_P(c) \ @@ -161,19 +163,19 @@ Returns the length of the multibyte form. */ #define CHAR_STRING(c, p) \ - ((unsigned) (c) <= MAX_1_BYTE_CHAR \ + (UNSIGNED_CMP (c, <=, MAX_1_BYTE_CHAR) \ ? ((p)[0] = (c), \ 1) \ - : (unsigned) (c) <= MAX_2_BYTE_CHAR \ + : UNSIGNED_CMP (c, <=, MAX_2_BYTE_CHAR) \ ? ((p)[0] = (0xC0 | ((c) >> 6)), \ (p)[1] = (0x80 | ((c) & 0x3F)), \ 2) \ - : (unsigned) (c) <= MAX_3_BYTE_CHAR \ + : UNSIGNED_CMP (c, <=, MAX_3_BYTE_CHAR) \ ? ((p)[0] = (0xE0 | ((c) >> 12)), \ (p)[1] = (0x80 | (((c) >> 6) & 0x3F)), \ (p)[2] = (0x80 | ((c) & 0x3F)), \ 3) \ - : char_string ((unsigned) c, p)) + : verify_expr (sizeof (c) <= sizeof (unsigned), char_string (c, p))) /* Store multibyte form of byte B in P. The caller should allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance. Returns the @@ -201,7 +203,10 @@ *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \ *(p)++ = (0x80 | ((c) & 0x3F)); \ else \ - (p) += char_string ((c), (p)); \ + { \ + verify (sizeof (c) <= sizeof (unsigned)); \ + (p) += char_string (c, p); \ + } \ } while (0) === modified file 'src/charset.c' --- src/charset.c 2011-06-06 19:43:39 +0000 +++ src/charset.c 2011-06-14 18:57:19 +0000 @@ -844,7 +844,7 @@ Sdefine_charset_internal, charset_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-charset-internal ...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { /* Charset attr vector. */ Lisp_Object attrs; @@ -1862,14 +1862,15 @@ code-point in CCS. Currently not supported and just ignored. */) (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction) { - int id; + int c, id; unsigned code; struct charset *charsetp; CHECK_CHARSET_GET_ID (charset, id); - CHECK_NATNUM (ch); + CHECK_CHARACTER (ch); + c = XFASTINT (ch); charsetp = CHARSET_FROM_ID (id); - code = ENCODE_CHAR (charsetp, XINT (ch)); + code = ENCODE_CHAR (charsetp, c); if (code == CHARSET_INVALID_CODE (charsetp)) return Qnil; return INTEGER_TO_CONS (code); @@ -2144,11 +2145,11 @@ 1, MANY, 0, doc: /* Assign higher priority to the charsets given as arguments. usage: (set-charset-priority &rest charsets) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object new_head, old_list, arglist[2]; Lisp_Object list_2022, list_emacs_mule; - size_t i; + ptrdiff_t i; int id; old_list = Fcopy_sequence (Vcharset_ordered_list); === modified file 'src/charset.h' --- src/charset.h 2011-05-31 06:05:00 +0000 +++ src/charset.h 2011-06-15 18:57:45 +0000 @@ -27,6 +27,8 @@ #ifndef EMACS_CHARSET_H #define EMACS_CHARSET_H +#include + /* Index to arguments of Fdefine_charset_internal. */ enum define_charset_arg_index @@ -424,28 +426,30 @@ /* Return a code point of CHAR in CHARSET. Try some optimization before calling encode_char. */ -#define ENCODE_CHAR(charset, c) \ - ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \ - ? (c) \ - : ((charset)->unified_p \ - || (charset)->method == CHARSET_METHOD_SUBSET \ - || (charset)->method == CHARSET_METHOD_SUPERSET) \ - ? encode_char ((charset), (c)) \ - : ((c) < (charset)->min_char || (c) > (charset)->max_char) \ - ? (charset)->invalid_code \ - : (charset)->method == CHARSET_METHOD_OFFSET \ - ? ((charset)->code_linear_p \ - ? (c) - (charset)->code_offset + (charset)->min_code \ - : encode_char ((charset), (c))) \ - : (charset)->method == CHARSET_METHOD_MAP \ - ? (((charset)->compact_codes_p \ - && CHAR_TABLE_P (CHARSET_ENCODER (charset))) \ - ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c)), \ - (NILP (charset_work) \ - ? (charset)->invalid_code \ - : XFASTINT (charset_work))) \ - : encode_char ((charset), (c))) \ - : encode_char ((charset), (c))) +#define ENCODE_CHAR(charset, c) \ + (verify_expr \ + (sizeof (c) <= sizeof (int), \ + (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p \ + ? (c) \ + : ((charset)->unified_p \ + || (charset)->method == CHARSET_METHOD_SUBSET \ + || (charset)->method == CHARSET_METHOD_SUPERSET) \ + ? encode_char (charset, c) \ + : (c) < (charset)->min_char || (c) > (charset)->max_char \ + ? (charset)->invalid_code \ + : (charset)->method == CHARSET_METHOD_OFFSET \ + ? ((charset)->code_linear_p \ + ? (c) - (charset)->code_offset + (charset)->min_code \ + : encode_char (charset, c)) \ + : (charset)->method == CHARSET_METHOD_MAP \ + ? (((charset)->compact_codes_p \ + && CHAR_TABLE_P (CHARSET_ENCODER (charset))) \ + ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), c), \ + (NILP (charset_work) \ + ? (charset)->invalid_code \ + : XFASTINT (charset_work))) \ + : encode_char (charset, c)) \ + : encode_char (charset, c)))) /* Set to 1 when a charset map is loaded to warn that a buffer text === modified file 'src/chartab.c' --- src/chartab.c 2011-05-12 07:07:06 +0000 +++ src/chartab.c 2011-06-13 01:38:25 +0000 @@ -524,15 +524,15 @@ if (EQ (range, Qnil)) val = XCHAR_TABLE (char_table)->defalt; - else if (INTEGERP (range)) - val = CHAR_TABLE_REF (char_table, XINT (range)); + else if (CHARACTERP (range)) + val = CHAR_TABLE_REF (char_table, XFASTINT (range)); else if (CONSP (range)) { int from, to; CHECK_CHARACTER_CAR (range); CHECK_CHARACTER_CDR (range); - val = char_table_ref_and_range (char_table, XINT (XCAR (range)), + val = char_table_ref_and_range (char_table, XFASTINT (XCAR (range)), &from, &to); /* Not yet implemented. */ } === modified file 'src/coding.c' --- src/coding.c 2011-06-06 19:43:39 +0000 +++ src/coding.c 2011-06-14 18:57:19 +0000 @@ -1071,7 +1071,7 @@ static void coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) { - if (STRING_BYTES_MAX - coding->dst_bytes < bytes) + if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) string_overflow (); coding->destination = (unsigned char *) xrealloc (coding->destination, coding->dst_bytes + bytes); @@ -9278,7 +9278,7 @@ contents of BUFFER instead of reading the file. usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object operation, target_idx, target, val; register Lisp_Object chain; @@ -9355,9 +9355,9 @@ all but the first one are ignored. usage: (set-coding-system-priority &rest coding-systems) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - size_t i, j; + ptrdiff_t i, j; int changed[coding_category_max]; enum coding_category priorities[coding_category_max]; @@ -9461,7 +9461,7 @@ Sdefine_coding_system_internal, coding_arg_max, MANY, 0, doc: /* For internal use only. usage: (define-coding-system-internal ...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object name; Lisp_Object spec_vec; /* [ ATTRS ALIASE EOL_TYPE ] */ === modified file 'src/composite.c' --- src/composite.c 2011-05-31 06:05:00 +0000 +++ src/composite.c 2011-06-13 01:35:47 +0000 @@ -858,7 +858,7 @@ for (i = 0; i < len; i++) { Lisp_Object g = LGSTRING_GLYPH (gstring, i); - EMACS_INT c = XINT (AREF (header, i + 1)); + int c = XFASTINT (AREF (header, i + 1)); if (NILP (g)) { @@ -995,7 +995,8 @@ void composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, EMACS_INT endpos, Lisp_Object string) { - EMACS_INT start, end, c; + EMACS_INT start, end; + int c; Lisp_Object prop, val; /* This is from forward_to_next_line_start in xdisp.c. */ const int MAX_NEWLINE_DISTANCE = 500; === modified file 'src/composite.h' --- src/composite.h 2011-06-06 19:43:39 +0000 +++ src/composite.h 2011-06-12 23:25:12 +0000 @@ -151,7 +151,7 @@ /* Nonzero if the global reference point GREF and new reference point NREF are valid. */ #define COMPOSITION_ENCODE_RULE_VALID(gref, nref) \ - ((unsigned) (gref) < 12 && (unsigned) (nref) < 12) + (UNSIGNED_CMP (gref, <, 12) && UNSIGNED_CMP (nref, <, 12)) /* Return encoded composition rule for the pair of global reference point GREF and new reference point NREF. Arguments must be valid. */ === modified file 'src/data.c' --- src/data.c 2011-06-10 20:05:21 +0000 +++ src/data.c 2011-06-14 18:57:19 +0000 @@ -2148,61 +2148,62 @@ CHECK_CHARACTER (idx); CHAR_TABLE_SET (array, idxval, newelt); } - else if (STRING_MULTIBYTE (array)) + else { - EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; - unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; + int c; if (idxval < 0 || idxval >= SCHARS (array)) args_out_of_range (array, idx); CHECK_CHARACTER (newelt); - - nbytes = SBYTES (array); - - idxval_byte = string_char_to_byte (array, idxval); - p1 = SDATA (array) + idxval_byte; - prev_bytes = BYTES_BY_CHAR_HEAD (*p1); - new_bytes = CHAR_STRING (XINT (newelt), p0); - if (prev_bytes != new_bytes) + c = XFASTINT (newelt); + + if (STRING_MULTIBYTE (array)) { - /* We must relocate the string data. */ - EMACS_INT nchars = SCHARS (array); - unsigned char *str; - USE_SAFE_ALLOCA; + EMACS_INT idxval_byte, prev_bytes, new_bytes, nbytes; + unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; - SAFE_ALLOCA (str, unsigned char *, nbytes); - memcpy (str, SDATA (array), nbytes); - allocate_string_data (XSTRING (array), nchars, - nbytes + new_bytes - prev_bytes); - memcpy (SDATA (array), str, idxval_byte); + nbytes = SBYTES (array); + idxval_byte = string_char_to_byte (array, idxval); p1 = SDATA (array) + idxval_byte; - memcpy (p1 + new_bytes, str + idxval_byte + prev_bytes, - nbytes - (idxval_byte + prev_bytes)); - SAFE_FREE (); - clear_string_char_byte_cache (); + prev_bytes = BYTES_BY_CHAR_HEAD (*p1); + new_bytes = CHAR_STRING (c, p0); + if (prev_bytes != new_bytes) + { + /* We must relocate the string data. */ + EMACS_INT nchars = SCHARS (array); + unsigned char *str; + USE_SAFE_ALLOCA; + + SAFE_ALLOCA (str, unsigned char *, nbytes); + memcpy (str, SDATA (array), nbytes); + allocate_string_data (XSTRING (array), nchars, + nbytes + new_bytes - prev_bytes); + memcpy (SDATA (array), str, idxval_byte); + p1 = SDATA (array) + idxval_byte; + memcpy (p1 + new_bytes, str + idxval_byte + prev_bytes, + nbytes - (idxval_byte + prev_bytes)); + SAFE_FREE (); + clear_string_char_byte_cache (); + } + while (new_bytes--) + *p1++ = *p0++; } - while (new_bytes--) - *p1++ = *p0++; - } - else - { - if (idxval < 0 || idxval >= SCHARS (array)) - args_out_of_range (array, idx); - CHECK_NUMBER (newelt); - - if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) + else { - int i; + if (! SINGLE_BYTE_CHAR_P (c)) + { + int i; - for (i = SBYTES (array) - 1; i >= 0; i--) - if (SREF (array, i) >= 0x80) - args_out_of_range (array, newelt); - /* ARRAY is an ASCII string. Convert it to a multibyte - string, and try `aset' again. */ - STRING_SET_MULTIBYTE (array); - return Faset (array, idx, newelt); + for (i = SBYTES (array) - 1; i >= 0; i--) + if (SREF (array, i) >= 0x80) + args_out_of_range (array, newelt); + /* ARRAY is an ASCII string. Convert it to a multibyte + string, and try `aset' again. */ + STRING_SET_MULTIBYTE (array); + return Faset (array, idx, newelt); + } + SSET (array, idxval, c); } - SSET (array, idxval, XINT (newelt)); } return newelt; @@ -2502,18 +2503,18 @@ Amin }; -static Lisp_Object float_arith_driver (double, size_t, enum arithop, - size_t, Lisp_Object *); +static Lisp_Object float_arith_driver (double, ptrdiff_t, enum arithop, + ptrdiff_t, Lisp_Object *); static Lisp_Object -arith_driver (enum arithop code, size_t nargs, register Lisp_Object *args) +arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object val; - register size_t argnum; + ptrdiff_t argnum; register EMACS_INT accum = 0; register EMACS_INT next; int overflow = 0; - size_t ok_args; + ptrdiff_t ok_args; EMACS_INT ok_accum; switch (SWITCH_ENUM_CAST (code)) @@ -2617,8 +2618,8 @@ #define isnan(x) ((x) != (x)) static Lisp_Object -float_arith_driver (double accum, register size_t argnum, enum arithop code, - size_t nargs, register Lisp_Object *args) +float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code, + ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object val; double next; @@ -2680,7 +2681,7 @@ DEFUN ("+", Fplus, Splus, 0, MANY, 0, doc: /* Return sum of any number of arguments, which are numbers or markers. usage: (+ &rest NUMBERS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Aadd, nargs, args); } @@ -2690,7 +2691,7 @@ With one arg, negates it. With more than one arg, subtracts all but the first from the first. usage: (- &optional NUMBER-OR-MARKER &rest MORE-NUMBERS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Asub, nargs, args); } @@ -2698,7 +2699,7 @@ DEFUN ("*", Ftimes, Stimes, 0, MANY, 0, doc: /* Return product of any number of arguments, which are numbers or markers. usage: (* &rest NUMBERS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Amult, nargs, args); } @@ -2707,9 +2708,9 @@ doc: /* Return first argument divided by all the remaining arguments. The arguments must be numbers or markers. usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - size_t argnum; + ptrdiff_t argnum; for (argnum = 2; argnum < nargs; argnum++) if (FLOATP (args[argnum])) return float_arith_driver (0, 0, Adiv, nargs, args); @@ -2791,7 +2792,7 @@ doc: /* Return largest of all the arguments (which must be numbers or markers). The value is always a number; markers are converted to numbers. usage: (max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Amax, nargs, args); } @@ -2800,7 +2801,7 @@ doc: /* Return smallest of all the arguments (which must be numbers or markers). The value is always a number; markers are converted to numbers. usage: (min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Amin, nargs, args); } @@ -2809,7 +2810,7 @@ doc: /* Return bitwise-and of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logand &rest INTS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Alogand, nargs, args); } @@ -2818,7 +2819,7 @@ doc: /* Return bitwise-or of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logior &rest INTS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Alogior, nargs, args); } @@ -2827,7 +2828,7 @@ doc: /* Return bitwise-exclusive-or of all the arguments. Arguments may be integers, or markers converted to integers. usage: (logxor &rest INTS-OR-MARKERS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return arith_driver (Alogxor, nargs, args); } === modified file 'src/dbusbind.c' --- src/dbusbind.c 2011-05-24 07:41:16 +0000 +++ src/dbusbind.c 2011-06-14 18:57:19 +0000 @@ -1078,7 +1078,7 @@ => "i686" usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service, path, interface, method; Lisp_Object result; @@ -1090,7 +1090,7 @@ DBusError derror; unsigned int dtype; int timeout = -1; - size_t i = 5; + ptrdiff_t i = 5; char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ @@ -1143,7 +1143,7 @@ { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); - XD_DEBUG_MESSAGE ("Parameter%lu %s %s", (unsigned long) (i-4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, SDATA (format2 ("%s", args[i], Qnil)), SDATA (format2 ("%s", args[i+1], Qnil))); ++i; @@ -1151,7 +1151,7 @@ else { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); - XD_DEBUG_MESSAGE ("Parameter%lu %s", (unsigned long) (i-4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, SDATA (format2 ("%s", args[i], Qnil))); } @@ -1260,7 +1260,7 @@ -| i686 usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service, path, interface, method, handler; Lisp_Object result; @@ -1271,7 +1271,7 @@ unsigned int dtype; dbus_uint32_t serial; int timeout = -1; - size_t i = 6; + ptrdiff_t i = 6; char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ @@ -1326,7 +1326,7 @@ { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); - XD_DEBUG_MESSAGE ("Parameter%lu %s %s", (unsigned long) (i-4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, SDATA (format2 ("%s", args[i], Qnil)), SDATA (format2 ("%s", args[i+1], Qnil))); ++i; @@ -1334,7 +1334,7 @@ else { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); - XD_DEBUG_MESSAGE ("Parameter%lu %s", (unsigned long) (i - 4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, SDATA (format2 ("%s", args[i], Qnil))); } @@ -1386,7 +1386,7 @@ This is an internal function, it shall not be used outside dbus.el. usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service; struct gcpro gcpro1, gcpro2; @@ -1395,7 +1395,7 @@ DBusMessageIter iter; dbus_uint32_t serial; unsigned int ui_serial, dtype; - size_t i; + ptrdiff_t i; char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ @@ -1435,7 +1435,7 @@ { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); - XD_DEBUG_MESSAGE ("Parameter%lu %s %s", (unsigned long) (i-2), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, SDATA (format2 ("%s", args[i], Qnil)), SDATA (format2 ("%s", args[i+1], Qnil))); ++i; @@ -1443,7 +1443,7 @@ else { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); - XD_DEBUG_MESSAGE ("Parameter%lu %s", (unsigned long) (i-2), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, SDATA (format2 ("%s", args[i], Qnil))); } @@ -1475,7 +1475,7 @@ This is an internal function, it shall not be used outside dbus.el. usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service; struct gcpro gcpro1, gcpro2; @@ -1484,7 +1484,7 @@ DBusMessageIter iter; dbus_uint32_t serial; unsigned int ui_serial, dtype; - size_t i; + ptrdiff_t i; char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ @@ -1525,7 +1525,7 @@ { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); - XD_DEBUG_MESSAGE ("Parameter%lu %s %s", (unsigned long) (i-2), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, SDATA (format2 ("%s", args[i], Qnil)), SDATA (format2 ("%s", args[i+1], Qnil))); ++i; @@ -1533,7 +1533,7 @@ else { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); - XD_DEBUG_MESSAGE ("Parameter%lu %s", (unsigned long) (i-2), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, SDATA (format2 ("%s", args[i], Qnil))); } @@ -1588,7 +1588,7 @@ "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs") usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service, path, interface, signal; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; @@ -1596,7 +1596,7 @@ DBusMessage *dmessage; DBusMessageIter iter; unsigned int dtype; - size_t i; + ptrdiff_t i; char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; /* Check parameters. */ @@ -1640,7 +1640,7 @@ { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); - XD_DEBUG_MESSAGE ("Parameter%lu %s %s", (unsigned long) (i-4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, SDATA (format2 ("%s", args[i], Qnil)), SDATA (format2 ("%s", args[i+1], Qnil))); ++i; @@ -1648,7 +1648,7 @@ else { XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); - XD_DEBUG_MESSAGE ("Parameter%lu %s", (unsigned long) (i-4), + XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, SDATA (format2 ("%s", args[i], Qnil))); } @@ -1919,11 +1919,11 @@ => :already-owner. usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service; DBusConnection *connection; - size_t i; + ptrdiff_t i; unsigned int value; unsigned int flags = 0; int result; @@ -2019,13 +2019,13 @@ `dbus-unregister-object' for removing the registration. usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object bus, service, path, interface, signal, handler; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; Lisp_Object uname, key, key1, value; DBusConnection *connection; - size_t i; + ptrdiff_t i; char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; char x[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; DBusError derror; @@ -2095,7 +2095,7 @@ if (!NILP (args[i])) { CHECK_STRING (args[i]); - sprintf (x, ",arg%lu='%s'", (unsigned long) (i-6), + sprintf (x, ",arg%"pD"d='%s'", i - 6, SDATA (args[i])); strcat (rule, x); } === modified file 'src/dired.c' --- src/dired.c 2011-06-06 19:43:39 +0000 +++ src/dired.c 2011-06-13 06:34:04 +0000 @@ -978,11 +978,14 @@ values[4] = make_time (s.st_atime); values[5] = make_time (s.st_mtime); values[6] = make_time (s.st_ctime); - values[7] = make_fixnum_or_float (s.st_size); - /* If the size is negative, and its type is long, convert it back to - positive. */ - if (s.st_size < 0 && sizeof (s.st_size) == sizeof (long)) - values[7] = make_float ((double) ((unsigned long) s.st_size)); + + /* If the file size is a 4-byte type, assume that files of sizes in + the 2-4 GiB range wrap around to negative values, as this is a + common bug on older 32-bit platforms. */ + if (sizeof (s.st_size) == 4) + values[7] = make_fixnum_or_float (s.st_size & 0xffffffffu); + else + values[7] = make_fixnum_or_float (s.st_size); filemodestring (&s, modes); values[8] = make_string (modes, 10); === modified file 'src/dispextern.h' --- src/dispextern.h 2011-06-11 01:48:59 +0000 +++ src/dispextern.h 2011-06-13 05:15:27 +0000 @@ -1729,7 +1729,7 @@ face doesn't exist. */ #define FACE_FROM_ID(F, ID) \ - (((unsigned) (ID) < FRAME_FACE_CACHE (F)->used) \ + (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \ ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \ : NULL) @@ -3163,7 +3163,7 @@ EMACS_INT pos, EMACS_INT bufpos, EMACS_INT region_beg, EMACS_INT region_end, EMACS_INT *endptr, enum face_id, int mouse); -int merge_faces (struct frame *, Lisp_Object, int, int); +int merge_faces (struct frame *, Lisp_Object, EMACS_INT, int); int compute_char_face (struct frame *, int, Lisp_Object); void free_all_realized_faces (Lisp_Object); extern Lisp_Object Qforeground_color, Qbackground_color; === modified file 'src/doc.c' --- src/doc.c 2011-05-12 07:07:06 +0000 +++ src/doc.c 2011-06-13 02:09:34 +0000 @@ -253,9 +253,12 @@ else if (c == '_') *to++ = 037; else - error ("\ + { + unsigned char uc = c; + error ("\ Invalid data in documentation file -- %c followed by code %03o", - 1, (unsigned)c); + 1, uc); + } } else *to++ = *from++; === modified file 'src/doprnt.c' --- src/doprnt.c 2011-06-06 19:43:39 +0000 +++ src/doprnt.c 2011-06-14 20:09:52 +0000 @@ -118,10 +118,6 @@ another macro. */ #include "character.h" -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - #ifndef DBL_MAX_10_EXP #define DBL_MAX_10_EXP 308 /* IEEE double */ #endif @@ -329,7 +325,7 @@ minlen = atoi (&fmtcpy[1]); string = va_arg (ap, char *); tem = strlen (string); - if (tem > STRING_BYTES_MAX) + if (STRING_BYTES_BOUND < tem) error ("String for %%s or %%S format is too long"); width = strwidth (string, tem); goto doit1; @@ -338,7 +334,7 @@ doit: /* Coming here means STRING contains ASCII only. */ tem = strlen (string); - if (tem > STRING_BYTES_MAX) + if (STRING_BYTES_BOUND < tem) error ("Format width or precision too large"); width = tem; doit1: === modified file 'src/editfns.c' --- src/editfns.c 2011-06-06 19:43:39 +0000 +++ src/editfns.c 2011-06-14 18:57:19 +0000 @@ -96,7 +96,7 @@ void (*) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int), - int, size_t, Lisp_Object *); + int, ptrdiff_t, Lisp_Object *); static Lisp_Object subst_char_in_region_unwind (Lisp_Object); static Lisp_Object subst_char_in_region_unwind_1 (Lisp_Object); static void transpose_markers (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, @@ -185,12 +185,13 @@ usage: (char-to-string CHAR) */) (Lisp_Object character) { - int len; + int c, len; unsigned char str[MAX_MULTIBYTE_LENGTH]; CHECK_CHARACTER (character); + c = XFASTINT (character); - len = CHAR_STRING (XFASTINT (character), str); + len = CHAR_STRING (c, str); return make_string_from_bytes ((char *) str, 1, len); } @@ -1857,7 +1858,7 @@ year values as low as 1901 do work. usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { time_t value; struct tm tm; @@ -2193,9 +2194,9 @@ void (*insert_from_string_func) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int), - int inherit, size_t nargs, Lisp_Object *args) + int inherit, ptrdiff_t nargs, Lisp_Object *args) { - register size_t argnum; + ptrdiff_t argnum; register Lisp_Object val; for (argnum = 0; argnum < nargs; argnum++) @@ -2203,16 +2204,15 @@ val = args[argnum]; if (CHARACTERP (val)) { + int c = XFASTINT (val); unsigned char str[MAX_MULTIBYTE_LENGTH]; int len; if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) - len = CHAR_STRING (XFASTINT (val), str); + len = CHAR_STRING (c, str); else { - str[0] = (ASCII_CHAR_P (XINT (val)) - ? XINT (val) - : multibyte_char_to_unibyte (XINT (val))); + str[0] = ASCII_CHAR_P (c) ? c : multibyte_char_to_unibyte (c); len = 1; } (*insert_func) ((char *) str, len); @@ -2258,7 +2258,7 @@ and insert the result. usage: (insert &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { general_insert_function (insert, insert_from_string, 0, nargs, args); return Qnil; @@ -2277,7 +2277,7 @@ to unibyte for insertion. usage: (insert-and-inherit &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { general_insert_function (insert_and_inherit, insert_from_string, 1, nargs, args); @@ -2294,7 +2294,7 @@ to unibyte for insertion. usage: (insert-before-markers &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { general_insert_function (insert_before_markers, insert_from_string_before_markers, 0, @@ -2313,7 +2313,7 @@ to unibyte for insertion. usage: (insert-before-markers-and-inherit &rest ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { general_insert_function (insert_before_markers_and_inherit, insert_from_string_before_markers, 1, @@ -2332,16 +2332,17 @@ register EMACS_INT stringlen; register int i; register EMACS_INT n; - int len; + int c, len; unsigned char str[MAX_MULTIBYTE_LENGTH]; - CHECK_NUMBER (character); + CHECK_CHARACTER (character); CHECK_NUMBER (count); + c = XFASTINT (character); if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) - len = CHAR_STRING (XFASTINT (character), str); + len = CHAR_STRING (c, str); else - str[0] = XFASTINT (character), len = 1; + str[0] = c, len = 1; if (BUF_BYTES_MAX / len < XINT (count)) error ("Maximum buffer size would be exceeded"); n = XINT (count) * len; @@ -2784,17 +2785,20 @@ int maybe_byte_combining = COMBINING_NO; EMACS_INT last_changed = 0; int multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + int fromc, toc; restart: validate_region (&start, &end); - CHECK_NUMBER (fromchar); - CHECK_NUMBER (tochar); + CHECK_CHARACTER (fromchar); + CHECK_CHARACTER (tochar); + fromc = XFASTINT (fromchar); + toc = XFASTINT (tochar); if (multibyte_p) { - len = CHAR_STRING (XFASTINT (fromchar), fromstr); - if (CHAR_STRING (XFASTINT (tochar), tostr) != len) + len = CHAR_STRING (fromc, fromstr); + if (CHAR_STRING (toc, tostr) != len) error ("Characters in `subst-char-in-region' have different byte-lengths"); if (!ASCII_BYTE_P (*tostr)) { @@ -2811,8 +2815,8 @@ else { len = 1; - fromstr[0] = XFASTINT (fromchar); - tostr[0] = XFASTINT (tochar); + fromstr[0] = fromc; + tostr[0] = toc; } pos = XINT (start); @@ -3084,14 +3088,11 @@ } else { - EMACS_INT c; - nc = oc; val = CHAR_TABLE_REF (table, oc); - if (CHARACTERP (val) - && (c = XINT (val), CHAR_VALID_P (c, 0))) + if (CHARACTERP (val)) { - nc = c; + nc = XFASTINT (val); str_len = CHAR_STRING (nc, buf); str = buf; } @@ -3385,7 +3386,7 @@ also `current-message'. usage: (message FORMAT-STRING &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { if (NILP (args[0]) || (STRINGP (args[0]) @@ -3413,7 +3414,7 @@ message; let the minibuffer contents show. usage: (message-box FORMAT-STRING &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { if (NILP (args[0])) { @@ -3470,7 +3471,7 @@ message; let the minibuffer contents show. usage: (message-or-box FORMAT-STRING &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { #ifdef HAVE_MENUS if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) @@ -3494,11 +3495,11 @@ Remaining arguments form a sequence of PROPERTY VALUE pairs for text properties to add to the result. usage: (propertize STRING &rest PROPERTIES) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object properties, string; struct gcpro gcpro1, gcpro2; - size_t i; + ptrdiff_t i; /* Number of args must be odd. */ if ((nargs & 1) == 0) @@ -3583,13 +3584,13 @@ specifier truncates the string to the given width. usage: (format STRING &rest OBJECTS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - EMACS_INT n; /* The number of the next arg to substitute */ + ptrdiff_t n; /* The number of the next arg to substitute */ char initial_buffer[4000]; char *buf = initial_buffer; EMACS_INT bufsize = sizeof initial_buffer; - EMACS_INT max_bufsize = STRING_BYTES_MAX + 1; + EMACS_INT max_bufsize = STRING_BYTES_BOUND + 1; char *p; Lisp_Object buf_save_value IF_LINT (= {0}); register char *format, *end, *format_start; @@ -3634,7 +3635,7 @@ /* Allocate the info and discarded tables. */ { - EMACS_INT i; + ptrdiff_t i; if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) memory_full (SIZE_MAX); SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen); @@ -3673,7 +3674,7 @@ while (format != end) { /* The values of N and FORMAT when the loop body is entered. */ - EMACS_INT n0 = n; + ptrdiff_t n0 = n; char *format0 = format; /* Bytes needed to represent the output of this conversion. */ === modified file 'src/eval.c' --- src/eval.c 2011-06-15 18:36:00 +0000 +++ src/eval.c 2011-06-15 18:52:30 +0000 @@ -32,10 +32,6 @@ #include "xterm.h" #endif -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - /* This definition is duplicated in alloc.c and keyboard.c. */ /* Putting it in lisp.h makes cc bomb out! */ @@ -139,7 +135,7 @@ int handling_signal; -static Lisp_Object funcall_lambda (Lisp_Object, size_t, Lisp_Object *); +static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); static void unwind_to_catch (struct catchtag *, Lisp_Object) NO_RETURN; static int interactive_p (int); static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); @@ -1053,7 +1049,7 @@ Lisp_Object *temps, tem, lexenv; register Lisp_Object elt, varlist; int count = SPECPDL_INDEX (); - register size_t argnum; + ptrdiff_t argnum; struct gcpro gcpro1, gcpro2; USE_SAFE_ALLOCA; @@ -1609,8 +1605,8 @@ and ARGS as second argument. */ Lisp_Object -internal_condition_case_n (Lisp_Object (*bfun) (size_t, Lisp_Object *), - size_t nargs, +internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *), + ptrdiff_t nargs, Lisp_Object *args, Lisp_Object handlers, Lisp_Object (*hfun) (Lisp_Object)) @@ -1995,7 +1991,7 @@ { char buf[4000]; size_t size = sizeof buf; - size_t size_max = STRING_BYTES_MAX + 1; + size_t size_max = STRING_BYTES_BOUND + 1; size_t mlen = strlen (m); char *buffer = buf; size_t used; @@ -2337,7 +2333,7 @@ { /* Pass a vector of evaluated arguments. */ Lisp_Object *vals; - register size_t argnum = 0; + ptrdiff_t argnum = 0; USE_SAFE_ALLOCA; SAFE_ALLOCA_LISP (vals, XINT (numargs)); @@ -2467,9 +2463,9 @@ Then return the value FUNCTION returns. Thus, (apply '+ 1 2 '(3 4)) returns 10. usage: (apply FUNCTION &rest ARGUMENTS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - register size_t i, numargs; + ptrdiff_t i, numargs; register Lisp_Object spread_arg; register Lisp_Object *funcall_args; Lisp_Object fun, retval; @@ -2551,7 +2547,7 @@ /* Run hook variables in various ways. */ static Lisp_Object -funcall_nil (size_t nargs, Lisp_Object *args) +funcall_nil (ptrdiff_t nargs, Lisp_Object *args) { Ffuncall (nargs, args); return Qnil; @@ -2572,10 +2568,10 @@ Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hooks &rest HOOKS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object hook[1]; - register size_t i; + ptrdiff_t i; for (i = 0; i < nargs; i++) { @@ -2601,7 +2597,7 @@ Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args HOOK &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, funcall_nil); } @@ -2621,13 +2617,13 @@ Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-success HOOK &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, Ffuncall); } static Lisp_Object -funcall_not (size_t nargs, Lisp_Object *args) +funcall_not (ptrdiff_t nargs, Lisp_Object *args) { return NILP (Ffuncall (nargs, args)) ? Qt : Qnil; } @@ -2646,13 +2642,13 @@ Do not use `make-local-variable' to make a hook variable buffer-local. Instead, use `add-hook' and specify t for the LOCAL argument. usage: (run-hook-with-args-until-failure HOOK &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return NILP (run_hook_with_args (nargs, args, funcall_not)) ? Qt : Qnil; } static Lisp_Object -run_hook_wrapped_funcall (size_t nargs, Lisp_Object *args) +run_hook_wrapped_funcall (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object tmp = args[0], ret; args[0] = args[1]; @@ -2670,7 +2666,7 @@ As soon as a call to WRAP-FUNCTION returns non-nil, `run-hook-wrapped' aborts and returns that value. usage: (run-hook-wrapped HOOK WRAP-FUNCTION &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return run_hook_with_args (nargs, args, run_hook_wrapped_funcall); } @@ -2683,8 +2679,8 @@ except that it isn't necessary to gcpro ARGS[0]. */ Lisp_Object -run_hook_with_args (size_t nargs, Lisp_Object *args, - Lisp_Object (*funcall) (size_t nargs, Lisp_Object *args)) +run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, + Lisp_Object (*funcall) (ptrdiff_t nargs, Lisp_Object *args)) { Lisp_Object sym, val, ret = Qnil; struct gcpro gcpro1, gcpro2, gcpro3; @@ -2957,16 +2953,16 @@ Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y). usage: (funcall FUNCTION &rest ARGUMENTS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object fun, original_fun; Lisp_Object funcar; - size_t numargs = nargs - 1; + ptrdiff_t numargs = nargs - 1; Lisp_Object lisp_numargs; Lisp_Object val; struct backtrace backtrace; register Lisp_Object *internal_args; - register size_t i; + ptrdiff_t i; QUIT; if ((consing_since_gc > gc_cons_threshold @@ -3120,14 +3116,13 @@ apply_lambda (Lisp_Object fun, Lisp_Object args) { Lisp_Object args_left; - size_t numargs; + ptrdiff_t i, numargs; register Lisp_Object *arg_vector; struct gcpro gcpro1, gcpro2, gcpro3; - register size_t i; register Lisp_Object tem; USE_SAFE_ALLOCA; - numargs = XINT (Flength (args)); + numargs = XFASTINT (Flength (args)); SAFE_ALLOCA_LISP (arg_vector, numargs); args_left = args; @@ -3163,12 +3158,12 @@ FUN must be either a lambda-expression or a compiled-code object. */ static Lisp_Object -funcall_lambda (Lisp_Object fun, size_t nargs, +funcall_lambda (Lisp_Object fun, ptrdiff_t nargs, register Lisp_Object *arg_vector) { Lisp_Object val, syms_left, next, lexenv; int count = SPECPDL_INDEX (); - size_t i; + ptrdiff_t i; int optional, rest; if (CONSP (fun)) @@ -3585,7 +3580,7 @@ } else { - size_t i; + ptrdiff_t i; for (i = 0; i < backlist->nargs; i++) { if (i) write_string (" ", -1); @@ -3645,7 +3640,7 @@ mark_backtrace (void) { register struct backtrace *backlist; - register size_t i; + ptrdiff_t i; for (backlist = backtrace_list; backlist; backlist = backlist->next) { === modified file 'src/fileio.c' --- src/fileio.c 2011-06-06 19:43:39 +0000 +++ src/fileio.c 2011-06-15 19:29:18 +0000 @@ -643,7 +643,7 @@ if (!make_temp_name_count_initialized_p) { - make_temp_name_count = (unsigned) time (NULL); + make_temp_name_count = time (NULL); make_temp_name_count_initialized_p = 1; } @@ -3109,6 +3109,21 @@ return Qnil; } +/* Reposition FD to OFFSET, based on WHENCE. This acts like lseek + except that it also tests for OFFSET being out of lseek's range. */ +static off_t +emacs_lseek (int fd, EMACS_INT offset, int whence) +{ + /* Use "&" rather than "&&" to suppress a bogus GCC warning; see + . */ + if (! ((TYPE_MINIMUM (off_t) <= offset) & (offset <= TYPE_MAXIMUM (off_t)))) + { + errno = EINVAL; + return -1; + } + return lseek (fd, offset, whence); +} + DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, 1, 5, 0, @@ -3317,7 +3332,7 @@ nread = emacs_read (fd, read_buf, 1024); if (nread >= 0) { - if (lseek (fd, st.st_size - (1024 * 3), 0) < 0) + if (lseek (fd, st.st_size - (1024 * 3), SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); nread += emacs_read (fd, read_buf + nread, 1024 * 3); @@ -3361,7 +3376,7 @@ specpdl_ptr--; /* Rewind the file for the actual read done later. */ - if (lseek (fd, 0, 0) < 0) + if (lseek (fd, 0, SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); } @@ -3428,7 +3443,7 @@ if (XINT (beg) != 0) { - if (lseek (fd, XINT (beg), 0) < 0) + if (emacs_lseek (fd, XINT (beg), SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); } @@ -3500,7 +3515,7 @@ break; /* How much can we scan in the next step? */ trial = min (curpos, sizeof buffer); - if (lseek (fd, curpos - trial, 0) < 0) + if (emacs_lseek (fd, curpos - trial, SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); @@ -3618,7 +3633,7 @@ /* First read the whole file, performing code conversion into CONVERSION_BUFFER. */ - if (lseek (fd, XINT (beg), 0) < 0) + if (emacs_lseek (fd, XINT (beg), SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); @@ -3817,7 +3832,7 @@ if (XINT (beg) != 0 || !NILP (replace)) { - if (lseek (fd, XINT (beg), 0) < 0) + if (emacs_lseek (fd, XINT (beg), SEEK_SET) < 0) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); } @@ -4549,9 +4564,9 @@ long ret; if (NUMBERP (append)) - ret = lseek (desc, XINT (append), 1); + ret = emacs_lseek (desc, XINT (append), SEEK_CUR); else - ret = lseek (desc, 0, 2); + ret = lseek (desc, 0, SEEK_END); if (ret < 0) { #ifdef CLASH_DETECTION === modified file 'src/floatfns.c' --- src/floatfns.c 2011-05-05 06:31:14 +0000 +++ src/floatfns.c 2011-06-13 02:27:16 +0000 @@ -507,7 +507,7 @@ if (y & 1) acc *= x; x *= x; - y = (unsigned)y >> 1; + y >>= 1; } } XSETINT (val, acc); === modified file 'src/fns.c' --- src/fns.c 2011-06-07 01:39:26 +0000 +++ src/fns.c 2011-06-14 23:18:53 +0000 @@ -99,6 +99,10 @@ return lispy_val; } +/* Heuristic on how many iterations of a tight loop can be safely done + before it's time to do a QUIT. This must be a power of 2. */ +enum { QUIT_COUNT_HEURISTIC = 1 << 16 }; + /* Random data-structure functions */ DEFUN ("length", Flength, Slength, 1, 1, 0, @@ -110,7 +114,6 @@ (register Lisp_Object sequence) { register Lisp_Object val; - register int i; if (STRINGP (sequence)) XSETFASTINT (val, SCHARS (sequence)); @@ -124,19 +127,20 @@ XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK); else if (CONSP (sequence)) { - i = 0; - while (CONSP (sequence)) + EMACS_INT i = 0; + + do { - sequence = XCDR (sequence); - ++i; - - if (!CONSP (sequence)) - break; - - sequence = XCDR (sequence); - ++i; - QUIT; + ++i; + if ((i & (QUIT_COUNT_HEURISTIC - 1)) == 0) + { + if (MOST_POSITIVE_FIXNUM < i) + error ("List too long"); + QUIT; + } + sequence = XCDR (sequence); } + while (CONSP (sequence)); CHECK_LIST_END (sequence, sequence); @@ -159,22 +163,38 @@ which is at least the number of distinct elements. */) (Lisp_Object list) { - Lisp_Object tail, halftail, length; - int len = 0; + Lisp_Object tail, halftail; + double hilen = 0; + uintmax_t lolen = 1; + + if (! CONSP (list)) + return 0; /* halftail is used to detect circular lists. */ - halftail = list; - for (tail = list; CONSP (tail); tail = XCDR (tail)) + for (tail = halftail = list; ; ) { - if (EQ (tail, halftail) && len != 0) - break; - len++; - if ((len & 1) == 0) - halftail = XCDR (halftail); + tail = XCDR (tail); + if (! CONSP (tail)) + break; + if (EQ (tail, halftail)) + break; + lolen++; + if ((lolen & 1) == 0) + { + halftail = XCDR (halftail); + if ((lolen & (QUIT_COUNT_HEURISTIC - 1)) == 0) + { + QUIT; + if (lolen == 0) + hilen += UINTMAX_MAX + 1.0; + } + } } - XSETINT (length, len); - return length; + /* If the length does not fit into a fixnum, return a float. + On all known practical machines this returns an upper bound on + the true length. */ + return hilen ? make_float (hilen + lolen) : make_fixnum_or_float (lolen); } DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0, @@ -344,7 +364,7 @@ return i1 < SCHARS (s2) ? Qt : Qnil; } -static Lisp_Object concat (size_t nargs, Lisp_Object *args, +static Lisp_Object concat (ptrdiff_t nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special); /* ARGSUSED */ @@ -374,7 +394,7 @@ Each argument may be a list, vector or string. The last argument is not copied, just used as the tail of the new list. usage: (append &rest SEQUENCES) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_Cons, 1); } @@ -384,7 +404,7 @@ The result is a string whose elements are the elements of all the arguments. Each argument may be a string or a list or vector of characters (integers). usage: (concat &rest SEQUENCES) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_String, 0); } @@ -394,7 +414,7 @@ The result is a vector whose elements are the elements of all the arguments. Each argument may be a list, vector or string. usage: (vconcat &rest SEQUENCES) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { return concat (nargs, args, Lisp_Vectorlike, 0); } @@ -416,7 +436,7 @@ if (BOOL_VECTOR_P (arg)) { Lisp_Object val; - int size_in_chars + ptrdiff_t size_in_chars = ((XBOOL_VECTOR (arg)->size + BOOL_VECTOR_BITS_PER_CHAR - 1) / BOOL_VECTOR_BITS_PER_CHAR); @@ -436,13 +456,13 @@ a string and has text properties to be copied. */ struct textprop_rec { - int argnum; /* refer to ARGS (arguments of `concat') */ + ptrdiff_t argnum; /* refer to ARGS (arguments of `concat') */ EMACS_INT from; /* refer to ARGS[argnum] (argument string) */ EMACS_INT to; /* refer to VAL (the target string) */ }; static Lisp_Object -concat (size_t nargs, Lisp_Object *args, +concat (ptrdiff_t nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special) { Lisp_Object val; @@ -452,7 +472,7 @@ EMACS_INT toindex_byte = 0; register EMACS_INT result_len; register EMACS_INT result_len_byte; - register size_t argnum; + ptrdiff_t argnum; Lisp_Object last_tail; Lisp_Object prev; int some_multibyte; @@ -463,7 +483,7 @@ here, and copy the text properties after the concatenation. */ struct textprop_rec *textprops = NULL; /* Number of elements in textprops. */ - int num_textprops = 0; + ptrdiff_t num_textprops = 0; USE_SAFE_ALLOCA; tail = Qnil; @@ -504,6 +524,7 @@ as well as the number of characters. */ EMACS_INT i; Lisp_Object ch; + int c; EMACS_INT this_len_byte; if (VECTORP (this) || COMPILEDP (this)) @@ -511,9 +532,10 @@ { ch = AREF (this, i); CHECK_CHARACTER (ch); - this_len_byte = CHAR_BYTES (XINT (ch)); + c = XFASTINT (ch); + this_len_byte = CHAR_BYTES (c); result_len_byte += this_len_byte; - if (! ASCII_CHAR_P (XINT (ch)) && ! CHAR_BYTE8_P (XINT (ch))) + if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) some_multibyte = 1; } else if (BOOL_VECTOR_P (this) && XBOOL_VECTOR (this)->size > 0) @@ -523,9 +545,10 @@ { ch = XCAR (this); CHECK_CHARACTER (ch); - this_len_byte = CHAR_BYTES (XINT (ch)); + c = XFASTINT (ch); + this_len_byte = CHAR_BYTES (c); result_len_byte += this_len_byte; - if (! ASCII_CHAR_P (XINT (ch)) && ! CHAR_BYTE8_P (XINT (ch))) + if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c)) some_multibyte = 1; } else if (STRINGP (this)) @@ -631,23 +654,16 @@ { int c; if (STRING_MULTIBYTE (this)) - { - FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, this, - thisindex, - thisindex_byte); - XSETFASTINT (elt, c); - } + FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, this, + thisindex, + thisindex_byte); else { - XSETFASTINT (elt, SREF (this, thisindex)); thisindex++; - if (some_multibyte - && !ASCII_CHAR_P (XINT (elt)) - && XINT (elt) < 0400) - { - c = BYTE8_TO_CHAR (XINT (elt)); - XSETINT (elt, c); - } + c = SREF (this, thisindex); thisindex++; + if (some_multibyte && !ASCII_CHAR_P (c)) + c = BYTE8_TO_CHAR (c); } + XSETFASTINT (elt, c); } else if (BOOL_VECTOR_P (this)) { @@ -679,12 +695,13 @@ } else { - CHECK_NUMBER (elt); + int c; + CHECK_CHARACTER (elt); + c = XFASTINT (elt); if (some_multibyte) - toindex_byte += CHAR_STRING (XINT (elt), - SDATA (val) + toindex_byte); + toindex_byte += CHAR_STRING (c, SDATA (val) + toindex_byte); else - SSET (val, toindex_byte++, XINT (elt)); + SSET (val, toindex_byte++, c); toindex++; } } @@ -1269,7 +1286,7 @@ doc: /* Take cdr N times on LIST, return the result. */) (Lisp_Object n, Lisp_Object list) { - register int i, num; + EMACS_INT i, num; CHECK_NUMBER (n); num = XINT (n); for (i = 0; i < num && !NILP (list); i++) @@ -1734,7 +1751,7 @@ Lisp_Object front, back; register Lisp_Object len, tem; struct gcpro gcpro1, gcpro2; - register int length; + EMACS_INT length; front = list; len = Flength (list); @@ -2220,9 +2237,9 @@ doc: /* Concatenate any number of lists by altering them. Only the last argument is not altered, and need not be a list. usage: (nconc &rest LISTS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { - register size_t argnum; + ptrdiff_t argnum; register Lisp_Object tail, tem, val; val = tail = Qnil; @@ -2345,9 +2362,8 @@ { Lisp_Object len; register EMACS_INT leni; - int nargs; + ptrdiff_t i, nargs; register Lisp_Object *args; - register EMACS_INT i; struct gcpro gcpro1; Lisp_Object ret; USE_SAFE_ALLOCA; @@ -2526,8 +2542,8 @@ while (loads-- > 0) { - Lisp_Object load = (NILP (use_floats) ? - make_number ((int) (100.0 * load_ave[loads])) + Lisp_Object load = (NILP (use_floats) + ? make_number (100.0 * load_ave[loads]) : make_float (load_ave[loads])); ret = Fcons (load, ret); } @@ -2751,7 +2767,7 @@ doc: /* Apply the value of WIDGET's PROPERTY to the widget itself. ARGS are passed as extra arguments to the function. usage: (widget-apply WIDGET PROPERTY &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { /* This function can GC. */ Lisp_Object newargs[3]; @@ -3356,7 +3372,7 @@ /* Function prototypes. */ static struct Lisp_Hash_Table *check_hash_table (Lisp_Object); -static size_t get_key_arg (Lisp_Object, size_t, Lisp_Object *, char *); +static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *); static void maybe_resize_hash_table (struct Lisp_Hash_Table *); static int sweep_weak_table (struct Lisp_Hash_Table *, int); @@ -3383,13 +3399,9 @@ EMACS_INT next_almost_prime (EMACS_INT n) { - if (n % 2 == 0) - n += 1; - if (n % 3 == 0) - n += 2; - if (n % 7 == 0) - n += 4; - return n; + for (n |= 1; ; n += 2) + if (n % 3 != 0 && n % 5 != 0 && n % 7 != 0) + return n; } @@ -3399,10 +3411,10 @@ 0. This function is used to extract a keyword/argument pair from a DEFUN parameter list. */ -static size_t -get_key_arg (Lisp_Object key, size_t nargs, Lisp_Object *args, char *used) +static ptrdiff_t +get_key_arg (Lisp_Object key, ptrdiff_t nargs, Lisp_Object *args, char *used) { - size_t i; + ptrdiff_t i; for (i = 1; i < nargs; i++) if (!used[i - 1] && EQ (args[i - 1], key)) @@ -4300,12 +4312,12 @@ is nil. usage: (make-hash-table &rest KEYWORD-ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object test, size, rehash_size, rehash_threshold, weak; Lisp_Object user_test, user_hash; char *used; - size_t i; + ptrdiff_t i; /* The vector `used' is used to keep track of arguments that have been consumed. */ === modified file 'src/font.c' --- src/font.c 2011-06-06 19:43:39 +0000 +++ src/font.c 2011-06-14 18:57:19 +0000 @@ -3829,10 +3829,10 @@ language system must contain `mark' feature. usage: (font-spec ARGS...) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object spec = font_make_spec (); - size_t i; + ptrdiff_t i; for (i = 0; i < nargs; i += 2) { === modified file 'src/fontset.c' --- src/fontset.c 2011-06-06 19:43:39 +0000 +++ src/fontset.c 2011-06-13 04:55:03 +0000 @@ -1851,7 +1851,7 @@ face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, pos + 100, 0, -1); } - if (! CHAR_VALID_P (c, 0)) + if (! CHAR_VALID_P (c)) return Qnil; face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil); face = FACE_FROM_ID (f, face_id); === modified file 'src/frame.c' --- src/frame.c 2011-06-12 10:16:46 +0000 +++ src/frame.c 2011-06-14 18:57:19 +0000 @@ -2807,7 +2807,7 @@ /* Record in these vectors all the parms specified. */ Lisp_Object *parms; Lisp_Object *values; - size_t i, p; + ptrdiff_t i, p; int left_no_change = 0, top_no_change = 0; int icon_left_no_change = 0, icon_top_no_change = 0; int size_changed = 0; === modified file 'src/keyboard.c' --- src/keyboard.c 2011-06-06 05:48:28 +0000 +++ src/keyboard.c 2011-06-14 18:57:19 +0000 @@ -448,7 +448,7 @@ #endif static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object, Lisp_Object, const char *const *, - Lisp_Object *, unsigned); + Lisp_Object *, EMACS_INT); static Lisp_Object make_lispy_switch_frame (Lisp_Object); static int help_char_p (Lisp_Object); static void save_getcjmp (jmp_buf); @@ -1901,7 +1901,7 @@ } static Lisp_Object -safe_run_hook_funcall (size_t nargs, Lisp_Object *args) +safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args) { eassert (nargs == 1); if (CONSP (Vinhibit_quit)) @@ -2906,9 +2906,13 @@ goto exit; if ((STRINGP (KVAR (current_kboard, Vkeyboard_translate_table)) - && SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c)) + && UNSIGNED_CMP (XFASTINT (c), <, + SCHARS (KVAR (current_kboard, + Vkeyboard_translate_table)))) || (VECTORP (KVAR (current_kboard, Vkeyboard_translate_table)) - && ASIZE (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c)) + && UNSIGNED_CMP (XFASTINT (c), <, + ASIZE (KVAR (current_kboard, + Vkeyboard_translate_table)))) || (CHAR_TABLE_P (KVAR (current_kboard, Vkeyboard_translate_table)) && CHARACTERP (c))) { @@ -2955,9 +2959,7 @@ save the echo area contents for it to refer to. */ if (INTEGERP (c) && ! NILP (Vinput_method_function) - && (unsigned) XINT (c) >= ' ' - && (unsigned) XINT (c) != 127 - && (unsigned) XINT (c) < 256) + && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127) { previous_echo_area_message = Fcurrent_message (); Vinput_method_previous_message = previous_echo_area_message; @@ -2982,9 +2984,7 @@ /* Don't run the input method within a key sequence, after the first event of the key sequence. */ && NILP (prev_event) - && (unsigned) XINT (c) >= ' ' - && (unsigned) XINT (c) != 127 - && (unsigned) XINT (c) < 256) + && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127) { Lisp_Object keys; int key_count, key_count_reset; @@ -5391,7 +5391,7 @@ Qfunction_key, KVAR (current_kboard, Vsystem_key_alist), 0, &KVAR (current_kboard, system_key_syms), - (unsigned) -1); + TYPE_MAXIMUM (EMACS_INT)); } return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET, @@ -6410,7 +6410,7 @@ static Lisp_Object modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object symbol_kind, Lisp_Object name_alist_or_stem, const char *const *name_table, - Lisp_Object *symbol_table, unsigned int table_size) + Lisp_Object *symbol_table, EMACS_INT table_size) { Lisp_Object value; Lisp_Object symbol_int; === modified file 'src/lisp.h' --- src/lisp.h 2011-06-11 21:31:32 +0000 +++ src/lisp.h 2011-06-14 18:57:19 +0000 @@ -60,6 +60,21 @@ # define EMACS_UINT unsigned EMACS_INT #endif +/* Use pD to format ptrdiff_t values, which suffice for indexes into + buffers and strings. Emacs never allocates objects larger than + PTRDIFF_MAX bytes, as they cause problems with pointer subtraction. + In C99, pD can always be "t"; configure it here for the sake of + pre-C99 libraries such as glibc 2.0 and Solaris 8. */ +#if PTRDIFF_MAX == INT_MAX +# define pD "" +#elif PTRDIFF_MAX == LONG_MAX +# define pD "l" +#elif PTRDIFF_MAX == LLONG_MAX +# define pD "ll" +#else +# define pD "t" +#endif + /* Extra internal type checking? */ #ifdef ENABLE_CHECKING @@ -765,11 +780,19 @@ #endif /* not GC_CHECK_STRING_BYTES */ -/* A string cannot contain more bytes than a fixnum can represent, - nor can it be so long that C pointer arithmetic stops working on - the string plus a terminating null. */ -#define STRING_BYTES_MAX \ - min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1) +/* An upper bound on the number of bytes in a Lisp string, not + counting the terminating null. This a tight enough bound to + prevent integer overflow errors that would otherwise occur during + string size calculations. A string cannot contain more bytes than + a fixnum can represent, nor can it be so long that C pointer + arithmetic stops working on the string plus its terminating null. + Although the actual size limit (see STRING_BYTES_MAX in alloc.c) + may be a bit smaller than STRING_BYTES_BOUND, calculating it here + would expose alloc.c internal details that we'd rather keep + private. The cast to ptrdiff_t ensures that STRING_BYTES_BOUND is + signed. */ +#define STRING_BYTES_BOUND \ + min (MOST_POSITIVE_FIXNUM, (ptrdiff_t) min (SIZE_MAX, PTRDIFF_MAX) - 1) /* Mark STR as a unibyte string. */ #define STRING_SET_UNIBYTE(STR) \ @@ -888,8 +911,18 @@ #endif /* not __GNUC__ */ +/* Compute A OP B, using the unsigned comparison operator OP. A and B + should be integer expressions. This is not the same as + mathemeatical comparison; for example, UNSIGNED_CMP (0, <, -1) + returns 1. For efficiency, prefer plain unsigned comparison if A + and B's sizes both fit (after integer promotion). */ +#define UNSIGNED_CMP(a, op, b) \ + (max (sizeof ((a) + 0), sizeof ((b) + 0)) <= sizeof (unsigned) \ + ? ((a) + (unsigned) 0) op ((b) + (unsigned) 0) \ + : ((a) + (uintmax_t) 0) op ((b) + (uintmax_t) 0)) + /* Nonzero iff C is an ASCII character. */ -#define ASCII_CHAR_P(c) ((unsigned) (c) < 0x80) +#define ASCII_CHAR_P(c) UNSIGNED_CMP (c, <, 0x80) /* Almost equivalent to Faref (CT, IDX) with optimization for ASCII characters. Do not check validity of CT. */ @@ -908,8 +941,7 @@ /* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and 8-bit European characters. Do not check validity of CT. */ #define CHAR_TABLE_SET(CT, IDX, VAL) \ - (((IDX) >= 0 && ASCII_CHAR_P (IDX) \ - && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii)) \ + (ASCII_CHAR_P (IDX) && SUB_CHAR_TABLE_P (XCHAR_TABLE (CT)->ascii) \ ? XSUB_CHAR_TABLE (XCHAR_TABLE (CT)->ascii)->contents[IDX] = VAL \ : char_table_set (CT, IDX, VAL)) @@ -1007,7 +1039,7 @@ Lisp_Object (*a7) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); Lisp_Object (*aUNEVALLED) (Lisp_Object args); - Lisp_Object (*aMANY) (size_t, Lisp_Object *); + Lisp_Object (*aMANY) (ptrdiff_t, Lisp_Object *); } function; short min_args, max_args; const char *symbol_name; @@ -1447,7 +1479,7 @@ area containing INTEGER potential Lisp_Objects. */ unsigned int dogc : 1; void *pointer; - int integer; + ptrdiff_t integer; }; @@ -1576,7 +1608,7 @@ #define SET_GLYPH(glyph, char, face) ((glyph).ch = (char), (glyph).face_id = (face)) /* Return 1 if GLYPH contains valid character code. */ -#define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (GLYPH_CHAR (glyph), 1) +#define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (GLYPH_CHAR (glyph)) /* Glyph Code from a display vector may either be an integer which @@ -1590,7 +1622,7 @@ (CONSP (gc) ? XINT (XCDR (gc)) : INTEGERP (gc) ? (XINT (gc) >> CHARACTERBITS) : DEFAULT_FACE_ID) /* Return 1 if glyph code from display vector contains valid character code. */ -#define GLYPH_CODE_CHAR_VALID_P(gc) CHAR_VALID_P (GLYPH_CODE_CHAR (gc), 1) +#define GLYPH_CODE_CHAR_VALID_P(gc) CHAR_VALID_P (GLYPH_CODE_CHAR (gc)) #define GLYPH_CODE_P(gc) ((CONSP (gc) && INTEGERP (XCAR (gc)) && INTEGERP (XCDR (gc))) || INTEGERP (gc)) @@ -1864,7 +1896,7 @@ /* Note that the weird token-substitution semantics of ANSI C makes this work for MANY and UNEVALLED. */ -#define DEFUN_ARGS_MANY (size_t, Lisp_Object *) +#define DEFUN_ARGS_MANY (ptrdiff_t, Lisp_Object *) #define DEFUN_ARGS_UNEVALLED (Lisp_Object) #define DEFUN_ARGS_0 (void) #define DEFUN_ARGS_1 (Lisp_Object) @@ -2129,7 +2161,7 @@ volatile Lisp_Object *var; /* Number of consecutive protected variables. */ - size_t nvars; + ptrdiff_t nvars; #ifdef DEBUG_GCPRO int level; @@ -2778,7 +2810,7 @@ extern Lisp_Object make_float (double); extern void display_malloc_warning (void); extern int inhibit_garbage_collection (void); -extern Lisp_Object make_save_value (void *, int); +extern Lisp_Object make_save_value (void *, ptrdiff_t); extern void free_marker (Lisp_Object); extern void free_cons (struct Lisp_Cons *); extern void init_alloc_once (void); @@ -2890,9 +2922,9 @@ EXFUN (Frun_hook_with_args, MANY); EXFUN (Frun_hook_with_args_until_failure, MANY); extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object); -extern Lisp_Object run_hook_with_args (size_t nargs, Lisp_Object *args, +extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args, Lisp_Object (*funcall) - (size_t nargs, Lisp_Object *args)); + (ptrdiff_t nargs, Lisp_Object *args)); EXFUN (Fprogn, UNEVALLED); EXFUN (Finteractive_p, 0); EXFUN (Fthrow, 2) NO_RETURN; @@ -2924,7 +2956,7 @@ extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object)); -extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (size_t, Lisp_Object *), size_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); +extern Lisp_Object internal_condition_case_n (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, Lisp_Object, Lisp_Object (*) (Lisp_Object)); extern void specbind (Lisp_Object, Lisp_Object); extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); extern Lisp_Object unbind_to (int, Lisp_Object); @@ -2934,7 +2966,7 @@ extern void do_autoload (Lisp_Object, Lisp_Object); extern Lisp_Object un_autoload (Lisp_Object); extern void init_eval_once (void); -extern Lisp_Object safe_call (size_t, Lisp_Object *); +extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object *); extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); extern void init_eval (void); @@ -3316,7 +3348,7 @@ #endif extern void unmark_byte_stack (void); extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object, - Lisp_Object, int, Lisp_Object *); + Lisp_Object, ptrdiff_t, Lisp_Object *); /* Defined in macros.c */ extern Lisp_Object Qexecute_kbd_macro; @@ -3671,18 +3703,19 @@ #define SAFE_ALLOCA_LISP(buf, nelt) \ do { \ - int size_ = (nelt) * sizeof (Lisp_Object); \ - if (size_ < MAX_ALLOCA) \ - buf = (Lisp_Object *) alloca (size_); \ - else \ + if ((nelt) < MAX_ALLOCA / sizeof (Lisp_Object)) \ + buf = (Lisp_Object *) alloca ((nelt) * sizeof (Lisp_Object)); \ + else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \ { \ Lisp_Object arg_; \ - buf = (Lisp_Object *) xmalloc (size_); \ + buf = (Lisp_Object *) xmalloc ((nelt) * sizeof (Lisp_Object)); \ arg_ = make_save_value (buf, nelt); \ XSAVE_VALUE (arg_)->dogc = 1; \ sa_must_free = 1; \ record_unwind_protect (safe_alloca_unwind, arg_); \ } \ + else \ + memory_full (SIZE_MAX); \ } while (0) === modified file 'src/lread.c' --- src/lread.c 2011-05-12 07:07:06 +0000 +++ src/lread.c 2011-06-13 05:18:27 +0000 @@ -1203,12 +1203,15 @@ #ifdef DOS_NT fmode = "rb"; #endif /* DOS_NT */ - stat (SSDATA (efound), &s1); - SSET (efound, SBYTES (efound) - 1, 0); - result = stat (SSDATA (efound), &s2); - SSET (efound, SBYTES (efound) - 1, 'c'); + result = stat (SSDATA (efound), &s1); + if (result == 0) + { + SSET (efound, SBYTES (efound) - 1, 0); + result = stat (SSDATA (efound), &s2); + SSET (efound, SBYTES (efound) - 1, 'c'); + } - if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) + if (result == 0 && s1.st_mtime < s2.st_mtime) { /* Make the progress messages mention that source is newer. */ newer = 1; === modified file 'src/mem-limits.h' --- src/mem-limits.h 2011-05-23 00:22:43 +0000 +++ src/mem-limits.h 2011-06-14 04:49:24 +0000 @@ -33,8 +33,6 @@ # endif #endif -typedef unsigned long SIZE; - extern char *start_of_data (void); #if defined USE_LSB_TAG #define EXCEEDS_LISP_PTR(ptr) 0 === modified file 'src/print.c' --- src/print.c 2011-05-31 06:05:00 +0000 +++ src/print.c 2011-06-08 21:43:46 +0000 @@ -2004,7 +2004,7 @@ case Lisp_Misc_Save_Value: strout ("#pointer, XSAVE_VALUE (obj)->integer); strout (buf, -1, -1, printcharfun); === modified file 'src/process.c' --- src/process.c 2011-06-11 21:31:32 +0000 +++ src/process.c 2011-06-14 18:57:19 +0000 @@ -1272,11 +1272,11 @@ syntax. usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) - (size_t nargs, register Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object buffer, name, program, proc, current_dir, tem; register unsigned char **new_argv; - register size_t i; + ptrdiff_t i; int count = SPECPDL_INDEX (); buffer = args[1]; @@ -2436,7 +2436,7 @@ \(serial-process-configure :port "\\\\.\\COM13" :bytesize 7) usage: (serial-process-configure &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { struct Lisp_Process *p; Lisp_Object contact = Qnil; @@ -2554,7 +2554,7 @@ \(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil) usage: (make-serial-process &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { int fd = -1; Lisp_Object proc, contact, port; @@ -2832,7 +2832,7 @@ information, is available via the `process-contact' function. usage: (make-network-process &rest ARGS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object proc; Lisp_Object contact; @@ -3148,7 +3148,7 @@ for (lres = res; lres; lres = lres->ai_next) { - size_t optn; + ptrdiff_t optn; int optbits; #ifdef WINDOWSNT === modified file 'src/puresize.h' --- src/puresize.h 2011-01-25 04:08:28 +0000 +++ src/puresize.h 2011-06-09 19:08:29 +0000 @@ -86,7 +86,6 @@ && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) #else /* not VIRT_ADDR_VARIES */ -/* When PNTR_COMPARISON_TYPE is not the default (unsigned int). */ extern char my_edata[]; @@ -94,4 +93,3 @@ ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata) #endif /* VIRT_ADDRESS_VARIES */ - === modified file 'src/sound.c' --- src/sound.c 2011-04-15 08:47:25 +0000 +++ src/sound.c 2011-06-13 06:49:00 +0000 @@ -1447,7 +1447,7 @@ } else if (FLOATP (attrs[SOUND_VOLUME])) { - ui_volume_tmp = (unsigned long) XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; + ui_volume_tmp = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; } /* Based on some experiments I have conducted, a value of 100 or less === modified file 'src/unexelf.c' --- src/unexelf.c 2011-03-30 00:19:27 +0000 +++ src/unexelf.c 2011-06-13 05:55:57 +0000 @@ -391,6 +391,7 @@ extern void fatal (const char *msgid, ...); #include +#include #include #include #include @@ -784,7 +785,7 @@ fprintf (stderr, "new_data2_incr %x\n", new_data2_incr); #endif - if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size) + if ((uintptr_t) new_bss_addr < (uintptr_t) old_bss_addr + old_bss_size) fatal (".bss shrank when undumping???\n", 0, 0); /* Set the output file to the right size. Allocate a buffer to hold === modified file 'src/vm-limit.c' --- src/vm-limit.c 2011-01-25 04:08:28 +0000 +++ src/vm-limit.c 2011-06-14 04:49:24 +0000 @@ -166,9 +166,9 @@ check_memory_limits (void) { #ifdef REL_ALLOC - extern POINTER (*real_morecore) (SIZE); + extern POINTER (*real_morecore) (long); #endif - extern POINTER (*__morecore) (SIZE); + extern POINTER (*__morecore) (long); register POINTER cp; unsigned long five_percent; @@ -297,4 +297,3 @@ /* Force data limit to be recalculated on each run. */ lim_data = 0; } - === modified file 'src/widget.c' --- src/widget.c 2011-06-11 21:31:32 +0000 +++ src/widget.c 2011-06-13 08:00:15 +0000 @@ -516,14 +516,11 @@ struct frame *s = ew->emacs_frame.frame; s->output_data.x->normal_gc - = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), - (unsigned long)0, (XGCValues *)0); + = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); s->output_data.x->reverse_gc - = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), - (unsigned long)0, (XGCValues *)0); + = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); s->output_data.x->cursor_gc - = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), - (unsigned long)0, (XGCValues *)0); + = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0); s->output_data.x->black_relief.gc = 0; s->output_data.x->white_relief.gc = 0; } @@ -582,8 +579,7 @@ = XCreatePixmapFromBitmapData (XtDisplay(ew), RootWindowOfScreen (XtScreen (ew)), setup_frame_cursor_bits, 2, 2, - (unsigned long)0, (unsigned long)1, - ew->core.depth); + 0, 1, ew->core.depth); /* Normal video */ gc_values.foreground = ew->emacs_frame.foreground_pixel; === modified file 'src/xdisp.c' --- src/xdisp.c 2011-06-10 06:55:18 +0000 +++ src/xdisp.c 2011-06-14 18:57:19 +0000 @@ -1335,7 +1335,7 @@ int c; c = STRING_CHAR_AND_LENGTH (str, *len); - if (!CHAR_VALID_P (c, 1)) + if (!CHAR_VALID_P (c)) /* We may not change the length here because other places in Emacs don't use this function, i.e. they silently accept invalid characters. */ @@ -2138,7 +2138,7 @@ redisplay during the evaluation. */ Lisp_Object -safe_call (size_t nargs, Lisp_Object *args) +safe_call (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object val; @@ -5819,7 +5819,8 @@ display. Then, set IT->dpvec to these glyphs. */ Lisp_Object gc; int ctl_len; - int face_id, lface_id = 0 ; + int face_id; + EMACS_INT lface_id = 0; int escape_glyph; /* Handle control characters with ^. */ @@ -6374,7 +6375,7 @@ it->face_id = it->dpvec_face_id; else { - int lface_id = GLYPH_CODE_FACE (gc); + EMACS_INT lface_id = GLYPH_CODE_FACE (gc); if (lface_id > 0) it->face_id = merge_faces (it->f, Qt, lface_id, it->saved_face_id); @@ -16570,7 +16571,7 @@ DEFUN ("trace-to-stderr", Ftrace_to_stderr, Strace_to_stderr, 1, MANY, "", doc: /* Like `format', but print result to stderr. usage: (trace-to-stderr STRING &rest OBJECTS) */) - (size_t nargs, Lisp_Object *args) + (ptrdiff_t nargs, Lisp_Object *args) { Lisp_Object s = Fformat (nargs, args); fprintf (stderr, "%s", SDATA (s)); @@ -19379,7 +19380,8 @@ else if (CHARACTERP (eoltype)) { unsigned char *tmp = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH); - eol_str_len = CHAR_STRING (XINT (eoltype), tmp); + int c = XFASTINT (eoltype); + eol_str_len = CHAR_STRING (c, tmp); eol_str = tmp; } else === modified file 'src/xfaces.c' --- src/xfaces.c 2011-05-28 22:39:39 +0000 +++ src/xfaces.c 2011-06-13 05:15:27 +0000 @@ -6223,7 +6223,8 @@ */ int -merge_faces (struct frame *f, Lisp_Object face_name, int face_id, int base_face_id) +merge_faces (struct frame *f, Lisp_Object face_name, EMACS_INT face_id, + int base_face_id) { Lisp_Object attrs[LFACE_VECTOR_SIZE]; struct face *base_face; === modified file 'src/xfns.c' --- src/xfns.c 2011-06-14 21:08:20 +0000 +++ src/xfns.c 2011-06-15 18:07:38 +0000 @@ -1074,8 +1074,7 @@ if (FRAME_X_WINDOW (f) != 0 && f->border_width > 0) { BLOCK_INPUT; - XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - (unsigned long)pix); + XSetWindowBorder (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), pix); UNBLOCK_INPUT; if (FRAME_VISIBLE_P (f)) === modified file 'src/xterm.c' --- src/xterm.c 2011-06-11 21:31:32 +0000 +++ src/xterm.c 2011-06-13 16:08:46 +0000 @@ -1697,16 +1697,18 @@ a least-squares matching, which is what X uses for closest color matching with StaticColor visuals. */ int nearest, i; - unsigned long nearest_delta = ~ (unsigned long) 0; + int max_color_delta = 255; + int max_delta = 3 * max_color_delta; + int nearest_delta = max_delta + 1; int ncells; const XColor *cells = x_color_cells (dpy, &ncells); for (nearest = i = 0; i < ncells; ++i) { - long dred = (color->red >> 8) - (cells[i].red >> 8); - long dgreen = (color->green >> 8) - (cells[i].green >> 8); - long dblue = (color->blue >> 8) - (cells[i].blue >> 8); - unsigned long delta = dred * dred + dgreen * dgreen + dblue * dblue; + int dred = (color->red >> 8) - (cells[i].red >> 8); + int dgreen = (color->green >> 8) - (cells[i].green >> 8); + int dblue = (color->blue >> 8) - (cells[i].blue >> 8); + int delta = dred * dred + dgreen * dgreen + dblue * dblue; if (delta < nearest_delta) { @@ -6442,8 +6444,7 @@ keys". It seems there's no cleaner way. Test IsModifierKey to avoid handling mode_switch incorrectly. */ - || ((unsigned) (keysym) >= XK_Select - && (unsigned)(keysym) < XK_KP_Space) + || (XK_Select <= keysym && keysym < XK_KP_Space) #endif #ifdef XK_dead_circumflex || orig_keysym == XK_dead_circumflex @@ -6496,10 +6497,8 @@ should be treated similarly to Mode_switch by Emacs. */ #if defined XK_ISO_Lock && defined XK_ISO_Last_Group_Lock - || ((unsigned)(orig_keysym) - >= XK_ISO_Lock - && (unsigned)(orig_keysym) - <= XK_ISO_Last_Group_Lock) + || (XK_ISO_Lock <= orig_keysym + && orig_keysym <= XK_ISO_Last_Group_Lock) #endif )) { @@ -10275,7 +10274,7 @@ = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, gray_bitmap_bits, gray_bitmap_width, gray_bitmap_height, - (unsigned long) 1, (unsigned long) 0, 1); + 1, 0, 1); } #ifdef HAVE_X_I18N ------------------------------------------------------------ revno: 104598 committer: Paul Eggert branch nick: trunk timestamp: Wed 2011-06-15 11:50:18 -0700 message: * lib/ftoastr.c, lib/stdio.in.h, lib/verify.h: Merge from gnulib. diff: === modified file 'ChangeLog' --- ChangeLog 2011-06-14 21:08:20 +0000 +++ ChangeLog 2011-06-15 18:50:18 +0000 @@ -1,3 +1,7 @@ +2011-06-15 Paul Eggert + + * lib/ftoastr.c, lib/stdio.in.h, lib/verify.h: Merge from gnulib. + 2011-06-14 Jan Djärv * configure.in: Add emacsgtkfixed.o to GTK_OBJ if HAVE_GTK3. === modified file 'lib/ftoastr.c' --- lib/ftoastr.c 2011-01-09 01:20:28 +0000 +++ lib/ftoastr.c 2011-06-15 18:50:18 +0000 @@ -40,14 +40,15 @@ # define FLOAT_MIN LDBL_MIN # define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND # define FTOASTR ldtoastr -# define STRTOF strtold +# if HAVE_C99_STRTOLD +# define STRTOF strtold +# endif #elif LENGTH == 2 # define FLOAT double # define FLOAT_DIG DBL_DIG # define FLOAT_MIN DBL_MIN # define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND # define FTOASTR dtoastr -# define STRTOF strtod #else # define LENGTH 1 # define FLOAT float @@ -55,14 +56,15 @@ # define FLOAT_MIN FLT_MIN # define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND # define FTOASTR ftoastr -# define STRTOF strtof +# if HAVE_STRTOF +# define STRTOF strtof +# endif #endif /* On pre-C99 hosts, approximate strtof and strtold with strtod. This may generate one or two extra digits, but that's better than not - working at all. Assume that strtof works if strtold does. */ -#if LENGTH != 2 && ! HAVE_C99_STRTOLD -# undef STRTOF + working at all. */ +#ifndef STRTOF # define STRTOF strtod #endif === modified file 'lib/stdio.in.h' --- lib/stdio.in.h 2011-05-29 21:52:18 +0000 +++ lib/stdio.in.h 2011-06-15 18:50:18 +0000 @@ -461,25 +461,6 @@ _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); # endif _GL_CXXALIASWARN (fseeko); -# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@ - /* Provide an fseek function that is consistent with fseeko. */ - /* In order to avoid that fseek gets defined as a macro here, the - developer can request the 'fseek' module. */ -# if !GNULIB_defined_fseek_function -# undef fseek -# define fseek rpl_fseek -static inline int _GL_ARG_NONNULL ((1)) -rpl_fseek (FILE *fp, long offset, int whence) -{ -# if @REPLACE_FSEEKO@ - return rpl_fseeko (fp, offset, whence); -# else - return fseeko (fp, offset, whence); -# endif -} -# define GNULIB_defined_fseek_function 1 -# endif -# endif #elif defined GNULIB_POSIXCHECK # define _GL_FSEEK_WARN /* Category 1, above. */ # undef fseek @@ -539,25 +520,6 @@ _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); # endif _GL_CXXALIASWARN (ftello); -# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@ - /* Provide an ftell function that is consistent with ftello. */ - /* In order to avoid that ftell gets defined as a macro here, the - developer can request the 'ftell' module. */ -# if !GNULIB_defined_ftell_function -# undef ftell -# define ftell rpl_ftell -static inline long _GL_ARG_NONNULL ((1)) -rpl_ftell (FILE *f) -{ -# if @REPLACE_FTELLO@ - return rpl_ftello (f); -# else - return ftello (f); -# endif -} -# define GNULIB_defined_ftell_function 1 -# endif -# endif #elif defined GNULIB_POSIXCHECK # define _GL_FTELL_WARN /* Category 1, above. */ # undef ftell === modified file 'lib/verify.h' --- lib/verify.h 2011-05-29 21:52:18 +0000 +++ lib/verify.h 2011-06-15 18:50:18 +0000 @@ -221,10 +221,18 @@ contexts, e.g., the top level. */ /* Verify requirement R at compile-time, as an integer constant expression. - Return 1. */ + Return 1. This is equivalent to verify_expr (R, 1). + + verify_true is obsolescent; please use verify_expr instead. */ # define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") +/* Verify requirement R at compile-time. Return the value of the + expression E. */ + +# define verify_expr(R, E) \ + (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) + /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ ------------------------------------------------------------ revno: 104597 committer: Chong Yidong branch nick: trunk timestamp: Wed 2011-06-15 14:45:28 -0400 message: * doc/lispref/text.texi (Special Properties): Clarify role of font-lock-face. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-06-15 17:30:41 +0000 +++ doc/lispref/ChangeLog 2011-06-15 18:45:28 +0000 @@ -1,3 +1,7 @@ +2011-06-15 Chong Yidong + + * text.texi (Special Properties): Clarify role of font-lock-face. + 2011-06-15 Lars Magne Ingebrigtsen * processes.texi (Process Information): Renamed `process-alive-p' === modified file 'doc/lispref/text.texi' --- doc/lispref/text.texi 2011-05-29 22:41:06 +0000 +++ doc/lispref/text.texi 2011-06-15 18:45:28 +0000 @@ -3003,18 +3003,18 @@ @item font-lock-face @kindex font-lock-face @r{(text property)} -The @code{font-lock-face} property is equivalent to the @code{face} -property when Font Lock mode is enabled. When Font Lock mode is disabled, +This property specifies a value for the @code{face} property that Font +Lock mode should apply to the underlying text. It is one of the +fontification methods used by Font Lock mode, and is useful for +special modes that implement their own highlighting. +@xref{Precalculated Fontification}. When Font Lock mode is disabled, @code{font-lock-face} has no effect. -The @code{font-lock-face} property is useful for special modes that -implement their own highlighting. @xref{Precalculated Fontification}. - @item mouse-face @kindex mouse-face @r{(text property)} -The property @code{mouse-face} is used instead of @code{face} when the -mouse is on or near the character. For this purpose, ``near'' means -that all text between the character and where the mouse is have the same +This property is used instead of @code{face} when the mouse is on or +near the character. For this purpose, ``near'' means that all text +between the character and where the mouse is have the same @code{mouse-face} property value. @item fontified ------------------------------------------------------------ revno: 104596 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-06-15 14:40:00 -0400 message: * lisp/pcmpl-rpm.el (pcomplete/rpm): Minor simplification. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 18:39:04 +0000 +++ lisp/ChangeLog 2011-06-15 18:40:00 +0000 @@ -1,5 +1,7 @@ 2011-06-15 Stefan Monnier + * pcmpl-rpm.el (pcomplete/rpm): Minor simplification. + * emacs-lisp/debug.el (debug): Don't leave the buffer in Debugger. * abbrev.el (define-abbrev-table): Don't add a table multiple times. === modified file 'lisp/pcmpl-rpm.el' --- lisp/pcmpl-rpm.el 2011-01-25 04:08:28 +0000 +++ lisp/pcmpl-rpm.el 2011-06-15 18:40:00 +0000 @@ -313,9 +313,9 @@ (if (pcomplete-match "^-" 0) (pcomplete-opt "v") (pcomplete-here - (if (eq mode 'test) - (pcomplete-dirs-or-entries "\\.tar\\'") - (pcomplete-dirs-or-entries "\\.spec\\'")))))) + (pcomplete-dirs-or-entries (if (eq mode 'test) + "\\.tar\\'" + "\\.spec\\'")))))) (t (error "You must select a mode: -q, -i, -U, --verify, etc")))))) ------------------------------------------------------------ revno: 104595 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-06-15 14:39:04 -0400 message: * lisp/emacs-lisp/debug.el (debug): Don't leave the buffer in Debugger. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 18:33:33 +0000 +++ lisp/ChangeLog 2011-06-15 18:39:04 +0000 @@ -1,13 +1,14 @@ 2011-06-15 Stefan Monnier + * emacs-lisp/debug.el (debug): Don't leave the buffer in Debugger. + * abbrev.el (define-abbrev-table): Don't add a table multiple times. 2011-06-15 Alan Mackenzie - * progmodes/cc-fonts.el (c-font-lock-declarations): 1: Whilst - checking for declarators, disable knr checking to speed up for - normal files. 2: Refactor, replacing a sequence of nested if - forms by a cond form. + * progmodes/cc-fonts.el (c-font-lock-declarations): 1: Whilst checking + for declarators, disable knr checking to speed up for normal files. + 2: Refactor, replacing a sequence of nested if forms by a cond form. 2011-06-15 Lars Magne Ingebrigtsen === modified file 'lisp/emacs-lisp/debug.el' --- lisp/emacs-lisp/debug.el 2011-05-31 15:41:14 +0000 +++ lisp/emacs-lisp/debug.el 2011-06-15 18:39:04 +0000 @@ -238,13 +238,14 @@ (kill-buffer debugger-buffer))) ;; Restore the previous state of the debugger-buffer, in case we were ;; in a recursive invocation of the debugger. - (when (and debugger-previous-state - (buffer-live-p debugger-buffer)) + (when (buffer-live-p debugger-buffer) (with-current-buffer debugger-buffer (let ((inhibit-read-only t)) (erase-buffer) - (insert (nth 1 debugger-previous-state)) - (funcall (nth 0 debugger-previous-state))))) + (if (null debugger-previous-state) + (fundamental-mode) + (insert (nth 1 debugger-previous-state)) + (funcall (nth 0 debugger-previous-state)))))) (with-timeout-unsuspend debugger-with-timeout-suspend) (set-match-data debugger-outer-match-data))) ;; Put into effect the modified values of these variables ------------------------------------------------------------ revno: 104594 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-06-15 14:36:00 -0400 message: * src/eval.c (Fdefvaralias): Also mark the target as variable-special-p. diff: === modified file 'lisp/emacs-lisp/smie.el' --- lisp/emacs-lisp/smie.el 2011-03-11 20:04:22 +0000 +++ lisp/emacs-lisp/smie.el 2011-06-15 18:36:00 +0000 @@ -84,6 +84,26 @@ ;; - Maybe accept two juxtaposed non-terminals in the BNF under the condition ;; that the first always ends with a terminal, or that the second always ;; starts with a terminal. +;; - Permit EBNF-style notation. +;; - If the grammar has conflicts, the only way is to make the lexer return +;; different tokens for the different cases. This extra work performed by +;; the lexer can be costly and unnecessary: we perform this extra work every +;; time we find the conflicting token, regardless of whether or not the +;; difference between the various situations is relevant to the current +;; situation. E.g. we may try to determine whether a ";" is a ";-operator" +;; or a ";-separator" in a case where we're skipping over a "begin..end" pair +;; where the difference doesn't matter. For frequently occurring tokens and +;; rarely occurring conflicts, this can be a significant performance problem. +;; We could try and let the lexer return a "set of possible tokens +;; plus a refinement function" and then let parser call the refinement +;; function if needed. +;; - Make it possible to better specify the behavior in the face of +;; syntax errors. IOW provide some control over the choice of precedence +;; levels within the limits of the constraints. E.g. make it possible for +;; the grammar to specify that "begin..end" has lower precedence than +;; "Module..EndModule", so that if a "begin" is missing, scanning from the +;; "end" will stop at "Module" rather than going past it (and similarly, +;; scanning from "Module" should not stop at a spurious "end"). ;;; Code: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-14 21:08:20 +0000 +++ src/ChangeLog 2011-06-15 18:36:00 +0000 @@ -1,3 +1,7 @@ +2011-06-15 Stefan Monnier + + * eval.c (Fdefvaralias): Also mark the target as variable-special-p. + 2011-06-14 Jan Djärv * xfns.c (x_set_scroll_bar_default_width): Remove argument to === modified file 'src/eval.c' --- src/eval.c 2011-06-06 19:43:39 +0000 +++ src/eval.c 2011-06-15 18:36:00 +0000 @@ -772,6 +772,7 @@ } sym->declared_special = 1; + XSYMBOL (base_variable)->declared_special = 1; sym->redirect = SYMBOL_VARALIAS; SET_SYMBOL_ALIAS (sym, XSYMBOL (base_variable)); sym->constant = SYMBOL_CONSTANT_P (base_variable); ------------------------------------------------------------ revno: 104593 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-06-15 14:33:33 -0400 message: * lisp/abbrev.el (define-abbrev-table): Don't add a table multiple times. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 18:24:25 +0000 +++ lisp/ChangeLog 2011-06-15 18:33:33 +0000 @@ -1,3 +1,7 @@ +2011-06-15 Stefan Monnier + + * abbrev.el (define-abbrev-table): Don't add a table multiple times. + 2011-06-15 Alan Mackenzie * progmodes/cc-fonts.el (c-font-lock-declarations): 1: Whilst @@ -7,7 +11,7 @@ 2011-06-15 Lars Magne Ingebrigtsen - * subr.el (process-live-p): Renamed from `process-alive-p' for + * subr.el (process-live-p): Rename from `process-alive-p' for consistency with other `-live-p' functions. 2011-06-15 Stefan Monnier @@ -75,8 +79,8 @@ (view-return-to-alist-update): Make obsolete. (view-mode-enter): Rename second argument to QUIT-RESTORE. Rewrite using quit-restore window parameters. - (view-mode-exit): Rename second argument to EXIT-ONLY. Rewrite - using quit-restore-window. + (view-mode-exit): Rename second argument to EXIT-ONLY. + Rewrite using quit-restore-window. (View-exit, View-exit-and-edit, View-leave, View-quit) (View-quit-all, View-kill-and-leave): Call view-mode-exit with appropriate arguments. @@ -96,8 +100,8 @@ (display-buffer-in-side-window, normalize-buffer-to-display) (display-buffer-normalize-specifiers-1) (display-buffer-normalize-specifiers-2) - (display-buffer-normalize-specifiers, display-buffer-frame): New - functions. + (display-buffer-normalize-specifiers, display-buffer-frame): + New functions. (display-buffer): Major rewrite. (display-buffer-other-window, display-buffer-other-frame) (pop-to-buffer, switch-to-buffer-other-window) @@ -133,8 +137,8 @@ was inadvertently removed in change from 2011-06-11. Declare as obsolete. - * calendar/calendar.el (calendar-generate-window): Use - window-iso-combined-p instead of combination of one-window-p and + * calendar/calendar.el (calendar-generate-window): + Use window-iso-combined-p instead of combination of one-window-p and window-safely-shrinkable-p. 2011-06-12 Glenn Morris @@ -179,15 +183,15 @@ (bw-adjust-window): Remove. (balance-windows-area-adjust): New function with functionality of bw-adjust-window but using resize-window. - (set-window-text-height): Rewrite doc-string. Use - normalize-live-window and resize-window. - (enlarge-window-horizontally, shrink-window-horizontally): Rename - argument to DELTA. + (set-window-text-height): Rewrite doc-string. + Use normalize-live-window and resize-window. + (enlarge-window-horizontally, shrink-window-horizontally): + Rename argument to DELTA. (window-buffer-height): New function. (fit-window-to-buffer, shrink-window-if-larger-than-buffer): Rewrite using new window resize routines. - (kill-buffer-and-window, mouse-autoselect-window-select): Use - ignore-errors instead of condition-case. + (kill-buffer-and-window, mouse-autoselect-window-select): + Use ignore-errors instead of condition-case. (quit-window): Call delete-frame instead of delete-windows-on for the only buffer on frame. @@ -198,8 +202,8 @@ * files.el (read-buffer-to-switch) (switch-to-buffer-other-window) - (switch-to-buffer-other-frame, display-buffer-other-frame): Move - to window.el. + (switch-to-buffer-other-frame, display-buffer-other-frame): + Move to window.el. * simple.el (get-next-valid-buffer, last-buffer, next-buffer) (previous-buffer): Move to window.el. @@ -215,8 +219,8 @@ (switch-to-next-buffer): New functions. (get-next-valid-buffer, last-buffer, next-buffer): Move here from simple.el. Call switch-to-next-buffer. - (previous-buffer): Move here from simple.el. Call - switch-to-prev-buffer. + (previous-buffer): Move here from simple.el. + Call switch-to-prev-buffer. (bury-buffer): Move here from buffer.c. Switch to previous buffer when window cannot be deleted. (unbury-buffer): Move here from bindings.el. @@ -225,8 +229,8 @@ (read-buffer-to-switch, switch-to-buffer-other-window) (switch-to-buffer-other-frame): Move here from files.el. (normalize-buffer-to-switch-to): New functions. - (switch-to-buffer): Move here from buffer.c. Use - read-buffer-to-switch and normalize-buffer-to-switch-to. + (switch-to-buffer): Move here from buffer.c. + Use read-buffer-to-switch and normalize-buffer-to-switch-to. 2011-06-10 Martin Rudalics @@ -241,8 +245,8 @@ (window-split-min-size): New function. (split-window-keep-point): Mention split-window-above-each-other instead of split-window-vertically. - (split-window-above-each-other, split-window-vertically): Rename - split-window-vertically to split-window-above-each-other and + (split-window-above-each-other, split-window-vertically): + Rename split-window-vertically to split-window-above-each-other and provide defalias for old definition. (split-window-side-by-side, split-window-horizontally): Rename split-window-horizontally to split-window-side-by-side and provide @@ -301,10 +305,10 @@ 2011-06-08 Martin Rudalics - * window.el (one-window-p): Move down in code. Rewrite - doc-string. - (window-current-scroll-bars): Rewrite doc-string. Normalize - live window argument. + * window.el (one-window-p): Move down in code. + Rewrite doc-string. + (window-current-scroll-bars): Rewrite doc-string. + Normalize live window argument. (walk-windows, get-window-with-predicate, count-windows): Rewrite doc-string. Use window-list-1. (window-in-direction-2, window-in-direction, get-mru-window): @@ -343,20 +347,20 @@ (image-transform-properties): Return quickly in the normal case. (image-animate-loop): Rename from image-animate-max-time. - * image.el (image-animate-max-time): Moved to image-mode.el. + * image.el (image-animate-max-time): Move to image-mode.el. (create-animated-image): Remove unnecessary function. (image-animate): Rename from image-animate-start. New arg. - (image-animate-stop): Removed; just use image-animate-timer. + (image-animate-stop): Remove; just use image-animate-timer. (image-animate-timer): Use car-safe. (image-animate-timeout): Rename argument. 2011-06-07 Martin Rudalics * window.el (get-lru-window, get-largest-window): Move here from - window.c. Rename first argument to ALL-FRAMES. Rephrase - doc-strings. - (get-buffer-window-list): Rewrite using window-list-1. Rephrase - doc-string. + window.c. Rename first argument to ALL-FRAMES. + Rephrase doc-strings. + (get-buffer-window-list): Rewrite using window-list-1. + Rephrase doc-string. (window-safe-min-height, window-safe-min-width): New constants. (window-size-ignore, window-min-size, window-min-size-1) (window-sizable, window-sizable-p, window-size-fixed-1) @@ -379,8 +383,8 @@ (walk-window-tree-1, walk-window-tree, walk-window-subtree) (windows-with-parameter, window-with-parameter) (window-atom-root, make-window-atom, window-atom-check-1) - (window-atom-check, window-side-check, window-check): New - functions. + (window-atom-check, window-side-check, window-check): + New functions. (ignore-window-parameters, window-sides, window-sides-vertical) (window-sides-slots): New variables. (window-size-fixed): Move down in code. Minor doc-string fix. @@ -418,8 +422,8 @@ 2011-06-05 Roland Winkler - * textmodes/bibtex.el (bibtex-search-entry-globally): New - variable. + * textmodes/bibtex.el (bibtex-search-entry-globally): + New variable. (bibtex-search-entry): Use it. 2011-06-05 Roland Winkler === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-31 04:24:03 +0000 +++ lisp/abbrev.el 2011-06-15 18:33:33 +0000 @@ -935,7 +935,8 @@ (unless table (setq table (make-abbrev-table)) (set tablename table) - (push tablename abbrev-table-name-list)) + (unless (memq tablename abbrev-table-name-list) + (push tablename abbrev-table-name-list))) ;; We used to just pass them to `make-abbrev-table', but that fails ;; if the table was pre-existing as is the case if it was created by ;; loading the user's abbrev file. ------------------------------------------------------------ revno: 104592 committer: Alan Mackenzie branch nick: trunk timestamp: Wed 2011-06-15 18:24:25 +0000 message: progmodes/cc-fonts.el (c-font-lock-declarations): 1: Whilst checking for declarators, disable knr checking to speed up for normal files. 2: Refactor, replacing a sequence of nested if forms by a cond form. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 17:30:41 +0000 +++ lisp/ChangeLog 2011-06-15 18:24:25 +0000 @@ -1,3 +1,10 @@ +2011-06-15 Alan Mackenzie + + * progmodes/cc-fonts.el (c-font-lock-declarations): 1: Whilst + checking for declarators, disable knr checking to speed up for + normal files. 2: Refactor, replacing a sequence of nested if + forms by a cond form. + 2011-06-15 Lars Magne Ingebrigtsen * subr.el (process-live-p): Renamed from `process-alive-p' for === modified file 'lisp/progmodes/cc-fonts.el' --- lisp/progmodes/cc-fonts.el 2011-02-13 20:25:15 +0000 +++ lisp/progmodes/cc-fonts.el 2011-06-15 18:24:25 +0000 @@ -1045,12 +1045,6 @@ ;; The position of the next token after the closing paren of ;; the last detected cast. last-cast-end - ;; Start of containing declaration (if any); limit for searching - ;; backwards for it. - decl-start decl-search-lim - ;; Start of containing declaration (if any); limit for searching - ;; backwards for it. - decl-start decl-search-lim ;; The result from `c-forward-decl-or-cast-1'. decl-or-cast ;; The maximum of the end positions of all the checked type @@ -1188,109 +1182,107 @@ (setq decl-or-cast (c-forward-decl-or-cast-1 match-pos context last-cast-end)) - (if (not decl-or-cast) - ;; Are we at a declarator? Try to go back to the declaration - ;; to check this. Note that `c-beginning-of-decl-1' is slow, - ;; so we cache its result between calls. - (let (paren-state bod-res encl-pos is-typedef) - (goto-char start-pos) - (save-excursion - (unless (and decl-search-lim - (eq decl-search-lim - (save-excursion - (c-syntactic-skip-backward "^;" nil t) - (point)))) - (setq decl-search-lim - (and (c-syntactic-skip-backward "^;" nil t) (point))) - (setq bod-res (car (c-beginning-of-decl-1 decl-search-lim))) - (if (and (eq bod-res 'same) - (progn - (c-backward-syntactic-ws) - (eq (char-before) ?\}))) - (c-beginning-of-decl-1 decl-search-lim)) - (setq decl-start (point)))) - - (save-excursion - (goto-char decl-start) - ;; We're now putatively at the declaration. - (setq paren-state (c-parse-state)) - ;; At top level or inside a "{"? - (if (or (not (setq encl-pos - (c-most-enclosing-brace paren-state))) - (eq (char-after encl-pos) ?\{)) - (progn - (when (looking-at c-typedef-key) ; "typedef" - (setq is-typedef t) - (goto-char (match-end 0)) - (c-forward-syntactic-ws)) - ;; At a real declaration? - (if (memq (c-forward-type t) '(t known found)) - (progn - (c-font-lock-declarators limit t is-typedef) - nil) - ;; False alarm. Return t to go on to the next check. - (goto-char start-pos) - t)) - t))) - - (if (eq decl-or-cast 'cast) - ;; Save the position after the previous cast so we can feed - ;; it to `c-forward-decl-or-cast-1' in the next round. That - ;; helps it discover cast chains like "(a) (b) c". - (setq last-cast-end (point)) - - ;; Set `max-type-decl-end' or `max-type-decl-end-before-token' - ;; under the assumption that we're after the first type decl - ;; expression in the declaration now. That's not really true; - ;; we could also be after a parenthesized initializer - ;; expression in C++, but this is only used as a last resort - ;; to slant ambiguous expression/declarations, and overall - ;; it's worth the risk to occasionally fontify an expression - ;; as a declaration in an initializer expression compared to - ;; getting ambiguous things in normal function prototypes - ;; fontified as expressions. - (if inside-macro - (when (> (point) max-type-decl-end-before-token) - (setq max-type-decl-end-before-token (point))) - (when (> (point) max-type-decl-end) - (setq max-type-decl-end (point)))) - - ;; Back up to the type to fontify the declarator(s). - (goto-char (car decl-or-cast)) - - (let ((decl-list - (if context - ;; Should normally not fontify a list of - ;; declarators inside an arglist, but the first - ;; argument in the ';' separated list of a "for" - ;; statement is an exception. - (when (eq (char-before match-pos) ?\() - (save-excursion - (goto-char (1- match-pos)) - (c-backward-syntactic-ws) - (and (c-simple-skip-symbol-backward) - (looking-at c-paren-stmt-key)))) - t))) - - ;; Fix the `c-decl-id-start' or `c-decl-type-start' property - ;; before the first declarator if it's a list. - ;; `c-font-lock-declarators' handles the rest. - (when decl-list - (save-excursion - (c-backward-syntactic-ws) - (unless (bobp) - (c-put-char-property (1- (point)) 'c-type - (if (cdr decl-or-cast) - 'c-decl-type-start - 'c-decl-id-start))))) - - (c-font-lock-declarators - (point-max) decl-list (cdr decl-or-cast)))) - - ;; A cast or declaration has been successfully identified, so do - ;; all the fontification of types and refs that's been recorded. - (c-fontify-recorded-types-and-refs) - nil)) + (cond + ((eq decl-or-cast 'cast) + ;; Save the position after the previous cast so we can feed + ;; it to `c-forward-decl-or-cast-1' in the next round. That + ;; helps it discover cast chains like "(a) (b) c". + (setq last-cast-end (point)) + (c-fontify-recorded-types-and-refs) + nil) + + (decl-or-cast + ;; We've found a declaration. + + ;; Set `max-type-decl-end' or `max-type-decl-end-before-token' + ;; under the assumption that we're after the first type decl + ;; expression in the declaration now. That's not really true; + ;; we could also be after a parenthesized initializer + ;; expression in C++, but this is only used as a last resort + ;; to slant ambiguous expression/declarations, and overall + ;; it's worth the risk to occasionally fontify an expression + ;; as a declaration in an initializer expression compared to + ;; getting ambiguous things in normal function prototypes + ;; fontified as expressions. + (if inside-macro + (when (> (point) max-type-decl-end-before-token) + (setq max-type-decl-end-before-token (point))) + (when (> (point) max-type-decl-end) + (setq max-type-decl-end (point)))) + + ;; Back up to the type to fontify the declarator(s). + (goto-char (car decl-or-cast)) + + (let ((decl-list + (if context + ;; Should normally not fontify a list of + ;; declarators inside an arglist, but the first + ;; argument in the ';' separated list of a "for" + ;; statement is an exception. + (when (eq (char-before match-pos) ?\() + (save-excursion + (goto-char (1- match-pos)) + (c-backward-syntactic-ws) + (and (c-simple-skip-symbol-backward) + (looking-at c-paren-stmt-key)))) + t))) + + ;; Fix the `c-decl-id-start' or `c-decl-type-start' property + ;; before the first declarator if it's a list. + ;; `c-font-lock-declarators' handles the rest. + (when decl-list + (save-excursion + (c-backward-syntactic-ws) + (unless (bobp) + (c-put-char-property (1- (point)) 'c-type + (if (cdr decl-or-cast) + 'c-decl-type-start + 'c-decl-id-start))))) + + (c-font-lock-declarators + (point-max) decl-list (cdr decl-or-cast))) + + ;; A declaration has been successfully identified, so do all the + ;; fontification of types and refs that've been recorded. + (c-fontify-recorded-types-and-refs) + nil) + + (t + ;; Are we at a declarator? Try to go back to the declaration + ;; to check this. If we get there, check whether a "typedef" + ;; is there, then fontify the declarators accordingly. + (let ((decl-search-lim (max (- (point) 50000) (point-min))) + paren-state bod-res encl-pos is-typedef + c-recognize-knr-p) ; Strictly speaking, bogus, but it + ; speeds up lisp.h tremendously. + (save-excursion + (setq bod-res (car (c-beginning-of-decl-1 decl-search-lim))) + (if (and (eq bod-res 'same) + (progn + (c-backward-syntactic-ws) + (eq (char-before) ?\}))) + (c-beginning-of-decl-1 decl-search-lim)) + + ;; We're now putatively at the declaration. + (setq paren-state (c-parse-state)) + ;; At top level or inside a "{"? + (if (or (not (setq encl-pos + (c-most-enclosing-brace paren-state))) + (eq (char-after encl-pos) ?\{)) + (progn + (when (looking-at c-typedef-key) ; "typedef" + (setq is-typedef t) + (goto-char (match-end 0)) + (c-forward-syntactic-ws)) + ;; At a real declaration? + (if (memq (c-forward-type t) '(t known found)) + (progn + (c-font-lock-declarators limit t is-typedef) + nil) + ;; False alarm. Return t to go on to the next check. + (goto-char start-pos) + t)) + t)))))) ;; It was a false alarm. Check if we're in a label (or other ;; construct with `:' except bitfield) instead. ------------------------------------------------------------ revno: 104591 committer: Lars Magne Ingebrigtsen branch nick: trunk timestamp: Wed 2011-06-15 19:30:41 +0200 message: Renamed `process-alive-p' to `process-live-p' for consistency with other `-live-p' functions. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-06-06 19:43:39 +0000 +++ doc/lispref/ChangeLog 2011-06-15 17:30:41 +0000 @@ -1,3 +1,8 @@ +2011-06-15 Lars Magne Ingebrigtsen + + * processes.texi (Process Information): Renamed `process-alive-p' + to `process-live-p' for consistency with other `-live-p' functions. + 2011-06-03 Paul Eggert Document wide integers better. === modified file 'doc/lispref/processes.texi' --- doc/lispref/processes.texi 2011-05-31 18:40:00 +0000 +++ doc/lispref/processes.texi 2011-06-15 17:30:41 +0000 @@ -859,7 +859,7 @@ closed the connection, or Emacs did @code{delete-process}. @end defun -@defun process-alive-p process +@defun process-live-p process This function returns nin-@code{nil} if @var{process} is alive. A process is considered alive if its status is @code{run}, @code{open}, @code{listen}, @code{connect} or @code{stop}. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 17:20:36 +0000 +++ lisp/ChangeLog 2011-06-15 17:30:41 +0000 @@ -1,3 +1,8 @@ +2011-06-15 Lars Magne Ingebrigtsen + + * subr.el (process-live-p): Renamed from `process-alive-p' for + consistency with other `-live-p' functions. + 2011-06-15 Stefan Monnier * window.el (same-window-buffer-names, same-window-regexps) === modified file 'lisp/subr.el' --- lisp/subr.el 2011-06-02 18:04:44 +0000 +++ lisp/subr.el 2011-06-15 17:30:41 +0000 @@ -1805,7 +1805,7 @@ (forward-line 1)) (nreverse lines))))) -(defun process-alive-p (process) +(defun process-live-p (process) "Returns non-nil if PROCESS is alive. A process is considered alive if its status is `run', `open', `listen', `connect' or `stop'." ------------------------------------------------------------ revno: 104590 committer: Stefan Monnier branch nick: trunk timestamp: Wed 2011-06-15 13:20:36 -0400 message: Don't encourage the use of display-buffer-alist from Elisp code. * lisp/window.el (same-window-buffer-names, same-window-regexps) (special-display-frame-alist, special-display-popup-frame) (special-display-function, special-display-buffer-names) (special-display-regexps, pop-up-frame-alist) (pop-up-frame-function, pop-up-frames, display-buffer-reuse-frames) (pop-up-windows, split-window-preferred-function) (split-height-threshold, split-width-threshold, even-window-heights) (display-buffer-mark-dedicated): Fix obsolescence info. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 14:47:57 +0000 +++ lisp/ChangeLog 2011-06-15 17:20:36 +0000 @@ -1,3 +1,15 @@ +2011-06-15 Stefan Monnier + + * window.el (same-window-buffer-names, same-window-regexps) + (special-display-frame-alist, special-display-popup-frame) + (special-display-function, special-display-buffer-names) + (special-display-regexps, pop-up-frame-alist) + (pop-up-frame-function, pop-up-frames, display-buffer-reuse-frames) + (pop-up-windows, split-window-preferred-function) + (split-height-threshold, split-width-threshold, even-window-heights) + (display-buffer-mark-dedicated): Don't encourage the use of + display-buffer-alist from Elisp code. + 2011-06-15 Dan Nicolaescu * progmodes/python.el (python-mode): Derive from prog-mode. === modified file 'lisp/window.el' --- lisp/window.el 2011-06-15 07:09:47 +0000 +++ lisp/window.el 2011-06-15 17:20:36 +0000 @@ -5581,7 +5581,7 @@ :group 'windows) (make-obsolete-variable 'same-window-buffer-names - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom same-window-regexps nil "List of regexps saying which buffers should appear in the \"same\" window. @@ -5599,7 +5599,7 @@ :group 'windows) (make-obsolete-variable 'same-window-regexps - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun same-window-p (buffer-name) "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window. @@ -5645,7 +5645,7 @@ :group 'frames) (make-obsolete-variable 'special-display-frame-alist - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun special-display-popup-frame (buffer &optional args) "Display BUFFER in a special frame and return the window chosen. @@ -5693,7 +5693,7 @@ (frame-selected-window frame)))))) (make-obsolete 'special-display-popup-frame - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom special-display-function 'special-display-popup-frame "Function to call for displaying special buffers. @@ -5712,7 +5712,7 @@ :group 'frames) (make-obsolete-variable 'special-display-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom special-display-buffer-names nil "List of names of buffers that should be displayed specially. @@ -5779,7 +5779,7 @@ :group 'frames) (make-obsolete-variable 'special-display-buffer-names - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") ;;;###autoload (put 'special-display-buffer-names 'risky-local-variable t) @@ -5850,7 +5850,7 @@ :group 'frames) (make-obsolete-variable 'special-display-regexps - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun special-display-p (buffer-name) "Return non-nil if a buffer named BUFFER-NAME gets a special frame. @@ -5902,7 +5902,7 @@ :group 'frames) (make-obsolete-variable 'pop-up-frame-alist - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-frame-function (lambda () (make-frame pop-up-frame-alist)) @@ -5914,7 +5914,7 @@ :group 'frames) (make-obsolete-variable 'pop-up-frame-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-frames 'unset ; nil "Whether `display-buffer' should make a separate frame. @@ -5934,7 +5934,7 @@ :group 'frames) (make-obsolete-variable 'pop-up-frames - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom display-buffer-reuse-frames 'unset ; nil "Set and non-nil means `display-buffer' should reuse frames. @@ -5946,7 +5946,7 @@ :group 'frames) (make-obsolete-variable 'display-buffer-reuse-frames - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-windows 'unset ; t "Set and non-nil means `display-buffer' should make a new window." @@ -5955,7 +5955,7 @@ :group 'windows) (make-obsolete-variable 'pop-up-windows - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-window-preferred-function 'split-window-sensibly "Function called by `display-buffer' to split a window. @@ -5984,7 +5984,7 @@ :group 'windows) (make-obsolete-variable 'split-window-preferred-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-height-threshold 80 "Minimum height for splitting a window to display a buffer. @@ -5998,7 +5998,7 @@ :group 'windows) (make-obsolete-variable 'split-height-threshold - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-width-threshold 160 "Minimum width for splitting a window to display a buffer. @@ -6010,7 +6010,7 @@ :group 'windows) (make-obsolete-variable 'split-width-threshold - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom even-window-heights t "If non-nil `display-buffer' will try to even window heights. @@ -6022,7 +6022,7 @@ :group 'windows) (make-obsolete-variable 'even-window-heights - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defvar display-buffer-mark-dedicated 'unset ; nil "Set and non-nil means `display-buffer' marks the windows it creates as dedicated. @@ -6030,7 +6030,7 @@ `window-dedicated-p' flag.") (make-obsolete-variable 'display-buffer-mark-dedicated - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun window-splittable-p (window &optional horizontal) "Return non-nil if `split-window-sensibly' may split WINDOW. ------------------------------------------------------------ revno: 104589 committer: Dan Nicolaescu branch nick: trunk timestamp: Wed 2011-06-15 07:47:57 -0700 message: * lisp/progmodes/cfengine.el (cfengine-mode): Derive from prog-mode. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 14:07:48 +0000 +++ lisp/ChangeLog 2011-06-15 14:47:57 +0000 @@ -3,6 +3,7 @@ * progmodes/python.el (python-mode): Derive from prog-mode. * progmodes/ps-mode.el (ps-mode): * progmodes/mixal-mode.el (mixal-mode): + * progmodes/cfengine.el (cfengine-mode): * progmodes/ld-script.el (ld-script-mode): Likewise. 2011-06-15 Martin Rudalics === modified file 'lisp/progmodes/cfengine.el' --- lisp/progmodes/cfengine.el 2011-01-26 08:36:39 +0000 +++ lisp/progmodes/cfengine.el 2011-06-15 14:47:57 +0000 @@ -198,7 +198,7 @@ t)) ;;;###autoload -(define-derived-mode cfengine-mode fundamental-mode "Cfengine" +(define-derived-mode cfengine-mode prog-mode "Cfengine" "Major mode for editing cfengine input. There are no special keybindings by default. ------------------------------------------------------------ revno: 104588 committer: Dan Nicolaescu branch nick: trunk timestamp: Wed 2011-06-15 07:11:04 -0700 message: Remove some macros that are either not used anymore or don't really need documenting here. diff: === modified file 'admin/CPP-DEFINES' --- admin/CPP-DEFINES 2011-03-27 02:27:11 +0000 +++ admin/CPP-DEFINES 2011-06-15 14:11:04 +0000 @@ -53,8 +53,6 @@ COFF FIRST_PTY_LETTER HAVE_PTYS -HAVE_TERMIO -HAVE_TERMIOS INTERRUPT_INPUT NARROWPROTO SEPCHAR @@ -175,7 +173,6 @@ HAVE_SYS_TIMEB_H HAVE_SYS_TIME_H HAVE_TCATTR -HAVE_TERMIOS_H HAVE_TIMEVAL HAVE_TM_ZONE HAVE_TZSET @@ -258,14 +255,9 @@ USG_SUBTTY_WORKS VALBITS WRETCODE -XINT XOS_NEEDS_TIME_H -XPNTR -XSET -XUINT _AIX _ARCH_PPC64 -_CALLBACK_ _FILE_OFFSET_BITS _LP64 _MALLOC_INTERNAL @@ -273,21 +265,6 @@ _VARARGS_ _WINSOCKAPI_ _WINSOCK_H -__ELF__ -__FreeBSD__ -__GNUC__ -__GNU_LIBRARY__ -__GNUC_MINOR__ -__NetBSD__ -__OpenBSD__ -__STDC__ -__arch64__ -__cplusplus -__hpux -__ia64__ -__linux__ -__mc68000__ -__mips__ _longjmp _setjmp _start @@ -323,9 +300,7 @@ getpid getuid gmtime -i386 index -init_process isatty kill link @@ -333,7 +308,6 @@ localtime logb lseek -m68k malloc mkdir mktemp ------------------------------------------------------------ revno: 104587 committer: Dan Nicolaescu branch nick: trunk timestamp: Wed 2011-06-15 07:07:48 -0700 message: Derive some programming modes from prog-mode. * lisp/progmodes/python.el (python-mode): Derive from prog-mode. * lisp/progmodes/ps-mode.el (ps-mode): * lisp/progmodes/mixal-mode.el (mixal-mode): * lisp/progmodes/ld-script.el (ld-script-mode): Likewise. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-15 07:09:47 +0000 +++ lisp/ChangeLog 2011-06-15 14:07:48 +0000 @@ -1,3 +1,10 @@ +2011-06-15 Dan Nicolaescu + + * progmodes/python.el (python-mode): Derive from prog-mode. + * progmodes/ps-mode.el (ps-mode): + * progmodes/mixal-mode.el (mixal-mode): + * progmodes/ld-script.el (ld-script-mode): Likewise. + 2011-06-15 Martin Rudalics * window.el (display-buffer-alist): Trim default value to avoid === modified file 'lisp/progmodes/ld-script.el' --- lisp/progmodes/ld-script.el 2011-05-12 16:46:53 +0000 +++ lisp/progmodes/ld-script.el 2011-06-15 14:07:48 +0000 @@ -168,7 +168,7 @@ "Default font-lock-keywords for `ld-script-mode'.") ;;;###autoload -(define-derived-mode ld-script-mode nil "LD-Script" +(define-derived-mode ld-script-mode prog-mode "LD-Script" "A major mode to edit GNU ld script files" (set (make-local-variable 'comment-start) "/* ") (set (make-local-variable 'comment-end) " */") === modified file 'lisp/progmodes/mixal-mode.el' --- lisp/progmodes/mixal-mode.el 2011-05-23 17:57:17 +0000 +++ lisp/progmodes/mixal-mode.el 2011-06-15 14:07:48 +0000 @@ -1103,7 +1103,7 @@ (error "mixvm.el needs to be loaded to run `mixvm'"))) ;;;###autoload -(define-derived-mode mixal-mode fundamental-mode "mixal" +(define-derived-mode mixal-mode prog-mode "mixal" "Major mode for the mixal asm language." (set (make-local-variable 'comment-start) "*") (set (make-local-variable 'comment-start-skip) "^\\*[ \t]*") === modified file 'lisp/progmodes/ps-mode.el' --- lisp/progmodes/ps-mode.el 2011-04-22 18:44:26 +0000 +++ lisp/progmodes/ps-mode.el 2011-06-15 14:07:48 +0000 @@ -485,7 +485,7 @@ ;; PostScript mode. ;;;###autoload -(define-derived-mode ps-mode fundamental-mode "PostScript" +(define-derived-mode ps-mode prog-mode "PostScript" "Major mode for editing PostScript with GNU Emacs. Entry to this mode calls `ps-mode-hook'. === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2011-05-24 03:38:35 +0000 +++ lisp/progmodes/python.el 2011-06-15 14:07:48 +0000 @@ -2420,7 +2420,7 @@ (defvar python-mode-running) ;Dynamically scoped var. ;;;###autoload -(define-derived-mode python-mode fundamental-mode "Python" +(define-derived-mode python-mode prog-mode "Python" "Major mode for editing Python files. Turns on Font Lock mode unconditionally since it is currently required for correct parsing of the source. ------------------------------------------------------------ revno: 104586 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-06-15 06:18:57 -0400 message: Auto-commit of generated files. diff: === modified file 'autogen/configure' --- autogen/configure 2011-06-09 10:18:21 +0000 +++ autogen/configure 2011-06-15 10:18:57 +0000 @@ -10483,6 +10483,7 @@ HAVE_GTK=no +GTK_OBJ= if test "${with_gtk3}" = "yes"; then GLIB_REQUIRED=2.28 GTK_REQUIRED=3.0 @@ -10588,6 +10589,7 @@ $as_echo "#define HAVE_GTK3 1" >>confdefs.h + GTK_OBJ=emacsgtkfixed.o fi if test "$pkg_check_gtk" != "yes"; then @@ -10697,7 +10699,6 @@ fi fi -GTK_OBJ= if test x"$pkg_check_gtk" = xyes; then @@ -10726,7 +10727,7 @@ $as_echo "#define USE_GTK 1" >>confdefs.h - GTK_OBJ=gtkutil.o + GTK_OBJ="gtkutil.o $GTK_OBJ" USE_X_TOOLKIT=none if $PKG_CONFIG --atleast-version=2.10 gtk+-2.0; then : ------------------------------------------------------------ revno: 104585 committer: martin rudalics branch nick: trunk timestamp: Wed 2011-06-15 09:09:47 +0200 message: Don't let display-buffer pop up new frames by default (bug#8857). * window.el (display-buffer-alist): Trim default value to avoid popping up a new frame (Bug#8857) or reusing an arbitrary window on another frame. (display-buffer): Do not fall back on popping up a new frame in batch mode (Bug#8857). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-14 05:06:26 +0000 +++ lisp/ChangeLog 2011-06-15 07:09:47 +0000 @@ -1,3 +1,11 @@ +2011-06-15 Martin Rudalics + + * window.el (display-buffer-alist): Trim default value to avoid + popping up a new frame (Bug#8857) or reusing an arbitrary window + on another frame. + (display-buffer): Do not fall back on popping up a new frame in + batch mode (Bug#8857). + 2011-06-14 Chong Yidong * cus-theme.el (describe-theme-1): Use custom-theme-p. === modified file 'lisp/window.el' --- lisp/window.el 2011-06-13 08:21:09 +0000 +++ lisp/window.el 2011-06-15 07:09:47 +0000 @@ -3505,9 +3505,7 @@ reuse-window (reuse-window nil same visible) pop-up-window (pop-up-window (largest . nil) (lru . nil)) - pop-up-frame - (pop-up-frame) - reuse-window (reuse-window nil other visible) + reuse-window (reuse-window other other nil) (reuse-window-even-sizes . t))) "List associating buffer identifiers with display specifiers. The car of each element of this list is built from a set of cons @@ -5303,12 +5301,12 @@ ;; Try reusing a window not showing BUFFER on any visible or ;; iconified frame. (display-buffer-reuse-window buffer '(nil other 0)) - ;; Try making a new frame. - (display-buffer-pop-up-frame buffer) - ;; Try using weakly dedicated windows. + ;; Try making a new frame (but not in batch mode). + (and (not noninteractive) (display-buffer-pop-up-frame buffer)) + ;; Try using a weakly dedicated window. (display-buffer-reuse-window buffer '(nil nil t) '((reuse-window-dedicated . weak))) - ;; Try using strongly dedicated windows. + ;; Try using a strongly dedicated window. (display-buffer-reuse-window buffer '(nil nil t) '((reuse-window-dedicated . t))))))) ------------------------------------------------------------ revno: 104584 fixes bug(s): http://debbugs.gnu.org/8505 committer: Jan D. branch nick: trunk timestamp: Tue 2011-06-14 23:08:20 +0200 message: Fix resize and change of scroll bar width for Gtk3. * configure.in: Add emacsgtkfixed.o to GTK_OBJ if HAVE_GTK3. * src/emacsgtkfixed.c, src/emacsgtkfixed.h: New files. * src/gtkutil.c: Include src/emacsgtkfixed.h if HAVE_GTK3. (int_gtk_range_get_value): Move to the scroll bar part of the file. (style_changed_cb): Call update_theme_scrollbar_width and call x_set_scroll_bar_default_width and xg_frame_set_char_size for all frames. (xg_create_frame_widgets): Call emacs_fixed_new if HAVE_GTK3 (Bug#8505). Call gtk_window_set_resizable if HAVE_GTK3. (x_wm_set_size_hint): Call emacs_fixed_set_min_size with min width and height if HAVE_GTK3 (Bug#8505). (scroll_bar_width_for_theme): New variable. (update_theme_scrollbar_width): New function. (xg_get_default_scrollbar_width): Move code to update_theme_scrollbar_width, just return scroll_bar_width_for_theme. (xg_initialize): Call update_theme_scrollbar_width. * src/gtkutil.h (xg_get_default_scrollbar_width): Remove argument. * src/xfns.c (x_set_scroll_bar_default_width): Remove argument to xg_get_default_scrollbar_width. diff: === modified file 'ChangeLog' --- ChangeLog 2011-06-08 16:26:45 +0000 +++ ChangeLog 2011-06-14 21:08:20 +0000 @@ -1,3 +1,7 @@ +2011-06-14 Jan Djärv + + * configure.in: Add emacsgtkfixed.o to GTK_OBJ if HAVE_GTK3. + 2011-06-08 Paul Eggert * lib/gnulib.mk, m4/gnulib-common.m4: Merge from gnulib. === modified file 'configure.in' --- configure.in 2011-06-07 04:16:37 +0000 +++ configure.in 2011-06-14 21:08:20 +0000 @@ -1819,6 +1819,7 @@ HAVE_GTK=no +GTK_OBJ= if test "${with_gtk3}" = "yes"; then GLIB_REQUIRED=2.28 GTK_REQUIRED=3.0 @@ -1830,6 +1831,7 @@ AC_MSG_ERROR($GTK_PKG_ERRORS) fi AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.]) + GTK_OBJ=emacsgtkfixed.o fi if test "$pkg_check_gtk" != "yes"; then @@ -1847,7 +1849,6 @@ fi fi -GTK_OBJ= if test x"$pkg_check_gtk" = xyes; then AC_SUBST(GTK_CFLAGS) @@ -1865,7 +1866,7 @@ else HAVE_GTK=yes AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.]) - GTK_OBJ=gtkutil.o + GTK_OBJ="gtkutil.o $GTK_OBJ" USE_X_TOOLKIT=none if $PKG_CONFIG --atleast-version=2.10 gtk+-2.0; then : === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-12 10:16:46 +0000 +++ src/ChangeLog 2011-06-14 21:08:20 +0000 @@ -1,3 +1,27 @@ +2011-06-14 Jan Djärv + + * xfns.c (x_set_scroll_bar_default_width): Remove argument to + xg_get_default_scrollbar_width. + + * gtkutil.c: Include emacsgtkfixed.h if HAVE_GTK3. + (int_gtk_range_get_value): Move to the scroll bar part of the file. + (style_changed_cb): Call update_theme_scrollbar_width and call + x_set_scroll_bar_default_width and xg_frame_set_char_size for + all frames (Bug#8505). + (xg_create_frame_widgets): Call emacs_fixed_new if HAVE_GTK3 (Bug#8505). + Call gtk_window_set_resizable if HAVE_GTK3. + (x_wm_set_size_hint): Call emacs_fixed_set_min_size with min width + and height if HAVE_GTK3 (Bug#8505). + (scroll_bar_width_for_theme): New variable. + (update_theme_scrollbar_width): New function. + (xg_get_default_scrollbar_width): Move code to + update_theme_scrollbar_width, just return scroll_bar_width_for_theme. + (xg_initialize): Call update_theme_scrollbar_width. + + * gtkutil.h (xg_get_default_scrollbar_width): Remove argument. + + * emacsgtkfixed.c, emacsgtkfixed.h: New files. + 2011-06-12 Martin Rudalics * frame.c (make_frame): Call other_buffer_safely instead of === added file 'src/emacsgtkfixed.c' --- src/emacsgtkfixed.c 1970-01-01 00:00:00 +0000 +++ src/emacsgtkfixed.c 2011-06-14 21:08:20 +0000 @@ -0,0 +1,123 @@ +/* A Gtk Widget that inherits GtkFixed, but can be shrinked. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs 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. + +GNU Emacs 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 GNU Emacs. If not, see . */ + +#include "emacsgtkfixed.h" + + +struct _EmacsFixedPrivate +{ + int minwidth, minheight; +}; + + +static void emacs_fixed_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural); +static void emacs_fixed_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural); +G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) + +static void +emacs_fixed_class_init (EmacsFixedClass *klass) +{ + GtkWidgetClass *widget_class; + GtkFixedClass *fixed_class; + + widget_class = (GtkWidgetClass*) klass; + fixed_class = (GtkFixedClass*) klass; + + widget_class->get_preferred_width = emacs_fixed_get_preferred_width; + widget_class->get_preferred_height = emacs_fixed_get_preferred_height; + g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); +} + +static GType +emacs_fixed_child_type (GtkFixed *container) +{ + return GTK_TYPE_WIDGET; +} + +static void +emacs_fixed_init (EmacsFixed *fixed) +{ + fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED, + EmacsFixedPrivate); + fixed->priv->minwidth = fixed->priv->minheight = 0; +} + +/** + * emacs_fixed_new: + * + * Creates a new #EmacsFixed. + * + * Returns: a new #EmacsFixed. + */ +GtkWidget* +emacs_fixed_new (void) +{ + return g_object_new (EMACS_TYPE_FIXED, NULL); +} + +static GtkWidgetClass * +get_parent_class (EmacsFixed *fixed) +{ + EmacsFixedClass *klass = EMACS_FIXED_GET_CLASS (fixed); + GtkFixedClass *parent_class = g_type_class_peek_parent (klass); + return (GtkWidgetClass*) parent_class; +} + +static void +emacs_fixed_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + EmacsFixed *fixed = EMACS_FIXED (widget); + EmacsFixedPrivate *priv = fixed->priv; + GtkWidgetClass *widget_class = get_parent_class (fixed); + widget_class->get_preferred_width (widget, minimum, natural); + if (minimum) *minimum = priv->minwidth; +} + +static void +emacs_fixed_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + EmacsFixed *fixed = EMACS_FIXED (widget); + EmacsFixedPrivate *priv = fixed->priv; + GtkWidgetClass *widget_class = get_parent_class (fixed); + widget_class->get_preferred_height (widget, minimum, natural); + if (minimum) *minimum = priv->minheight; +} + +void +emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height) +{ + EmacsFixedPrivate *priv = widget->priv; + GtkWidgetClass *widget_class = get_parent_class (widget); + int mw, nw, mh, nh; + + widget_class->get_preferred_height (GTK_WIDGET (widget), &mh, &nh); + widget_class->get_preferred_width (GTK_WIDGET (widget), &mw, &nw); + + /* Gtk complains if min size is less than natural size. */ + if (width <= nw) priv->minwidth = width; + if (height <= nh) priv->minheight = height; +} === added file 'src/emacsgtkfixed.h' --- src/emacsgtkfixed.h 1970-01-01 00:00:00 +0000 +++ src/emacsgtkfixed.h 2011-06-14 21:08:20 +0000 @@ -0,0 +1,58 @@ +/* A Gtk Widget that inherits GtkFixed, but can be shrinked. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs 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. + +GNU Emacs 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 GNU Emacs. If not, see . */ + +#ifndef EMACSGTKFIXED_H +#define EMACSGTKFIXED_H + +#include + +G_BEGIN_DECLS + +#define EMACS_TYPE_FIXED (emacs_fixed_get_type ()) +#define EMACS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_FIXED, EmacsFixed)) +#define EMACS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_FIXED, EmacsFixedClass)) +#define EMACS_IS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_FIXED)) +#define EMACS_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_FIXED)) +#define EMACS_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_FIXED, EmacsFixedClass)) + +typedef struct _EmacsFixed EmacsFixed; +typedef struct _EmacsFixedPrivate EmacsFixedPrivate; +typedef struct _EmacsFixedClass EmacsFixedClass; + +struct _EmacsFixed +{ + GtkFixed container; + + /*< private >*/ + EmacsFixedPrivate *priv; +}; + + +struct _EmacsFixedClass +{ + GtkFixedClass parent_class; +}; + +extern GtkWidget *emacs_fixed_new (void); +extern void emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height); +extern GType emacs_fixed_get_type (void); + +G_END_DECLS + +#endif /* EMACSGTKFIXED_H */ === modified file 'src/gtkutil.c' --- src/gtkutil.c 2011-06-05 22:20:42 +0000 +++ src/gtkutil.c 2011-06-14 21:08:20 +0000 @@ -42,6 +42,7 @@ #ifdef HAVE_GTK3 #include +#include "emacsgtkfixed.h" #endif #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ @@ -88,12 +89,7 @@ #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) -/* Get the current value of the range, truncated to an integer. */ -static int -int_gtk_range_get_value (GtkRange *range) -{ - return gtk_range_get_value (range); -} +static void update_theme_scrollbar_width (void); /*********************************************************************** @@ -1015,6 +1011,7 @@ struct input_event event; GdkDisplay *gdpy = (GdkDisplay *) user_data; const char *display_name = gdk_display_get_name (gdpy); + Display *dpy = GDK_DISPLAY_XDISPLAY (gdpy); EVENT_INIT (event); event.kind = CONFIG_CHANGED_EVENT; @@ -1022,6 +1019,24 @@ /* Theme doesn't change often, so intern is called seldom. */ event.arg = intern ("theme-name"); kbd_buffer_store_event (&event); + + update_theme_scrollbar_width (); + + /* If scroll bar width changed, we need set the new size on all frames + on this display. */ + if (dpy) + { + Lisp_Object rest, frame; + FOR_EACH_FRAME (rest, frame) + { + FRAME_PTR f = XFRAME (frame); + if (FRAME_X_DISPLAY (f) == dpy) + { + x_set_scroll_bar_default_width (f); + xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f)); + } + } + } } /* Called when a delete-event occurs on WIDGET. */ @@ -1069,7 +1084,12 @@ wvbox = gtk_vbox_new (FALSE, 0); whbox = gtk_hbox_new (FALSE, 0); - wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ + +#ifdef HAVE_GTK3 + wfixed = emacs_fixed_new (); +#else + wfixed = gtk_fixed_new (); +#endif if (! wtop || ! wvbox || ! whbox || ! wfixed) { @@ -1162,6 +1182,7 @@ gtk_widget_modify_style (wfixed, style); #else gtk_widget_set_can_focus (wfixed, TRUE); + gtk_window_set_resizable (GTK_WINDOW (wtop), TRUE); #endif #ifdef USE_GTK_TOOLTIP @@ -1265,6 +1286,18 @@ size_hints.min_width = base_width + min_cols * size_hints.width_inc; size_hints.min_height = base_height + min_rows * size_hints.height_inc; +#ifdef HAVE_GTK3 + /* Gtk3 ignores min width/height and overwrites them with its own idea + of min width/height. Put out min values to the widget so Gtk + gets the same value we want it to be. Without this, a user can't + shrink an Emacs frame. + */ + if (FRAME_GTK_WIDGET (f)) + emacs_fixed_set_min_size (EMACS_FIXED (FRAME_GTK_WIDGET (f)), + size_hints.min_width, + size_hints.min_height); +#endif + /* These currently have a one to one mapping with the X values, but I don't think we should rely on that. */ hint_flags |= GDK_HINT_WIN_GRAVITY; @@ -3250,6 +3283,10 @@ int xg_ignore_gtk_scrollbar; +/* The width of the scroll bar for the current theme. */ + +static int scroll_bar_width_for_theme; + /* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they may be larger than 32 bits. Keep a mapping from integer index to widget pointers to get around the 32 bit limitation. */ @@ -3326,8 +3363,8 @@ return 0; } -int -xg_get_default_scrollbar_width (FRAME_PTR f) +static void +update_theme_scrollbar_width (void) { #ifdef HAVE_GTK3 GtkAdjustment *vadj; @@ -3336,13 +3373,22 @@ #endif GtkWidget *wscroll; int w = 0, b = 0; + vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); + g_object_ref_sink (G_OBJECT (wscroll)); gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); gtk_widget_destroy (wscroll); + g_object_unref (G_OBJECT (wscroll)); w += 2*b; if (w < 16) w = 16; - return w; + scroll_bar_width_for_theme = w; +} + +int +xg_get_default_scrollbar_width (void) +{ + return scroll_bar_width_for_theme; } /* Return the scrollbar id for X Window WID on display DPY. @@ -3528,6 +3574,15 @@ } } +/* Get the current value of the range, truncated to an integer. */ + +static int +int_gtk_range_get_value (GtkRange *range) +{ + return gtk_range_get_value (range); +} + + /* Set the thumb size and position of scroll bar BAR. We are currently displaying PORTION out of a whole WHOLE, and our position POSITION. */ @@ -4680,6 +4735,7 @@ (GTK_TYPE_MENU_SHELL)); gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK, "cancel", 0); + update_theme_scrollbar_width (); } #endif /* USE_GTK */ === modified file 'src/gtkutil.h' --- src/gtkutil.h 2011-06-05 19:04:51 +0000 +++ src/gtkutil.h 2011-06-14 21:08:20 +0000 @@ -135,7 +135,7 @@ int position, int whole); extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); -extern int xg_get_default_scrollbar_width (FRAME_PTR f); +extern int xg_get_default_scrollbar_width (void); extern void update_frame_tool_bar (FRAME_PTR f); extern void free_frame_tool_bar (FRAME_PTR f); === modified file 'src/xfns.c' --- src/xfns.c 2011-06-11 21:31:32 +0000 +++ src/xfns.c 2011-06-14 21:08:20 +0000 @@ -1701,7 +1701,7 @@ int wid = FRAME_COLUMN_WIDTH (f); #ifdef USE_TOOLKIT_SCROLL_BARS #ifdef USE_GTK - int minw = xg_get_default_scrollbar_width (f); + int minw = xg_get_default_scrollbar_width (); #else int minw = 16; #endif ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.