changeset 109793:b60dcdd855f0

Merge from mainline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sun, 08 Aug 2010 22:52:25 +0000
parents 1f8f03cfcd2b (current diff) eb66d5d15b09 (diff)
children a8075662572b
files lisp/vc/diff-mode.el
diffstat 113 files changed, 1930 insertions(+), 1011 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,8 @@
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* configure.in: Check for util.h.
+	Use -Wimplicit-function-declaration if compiler supports it.
+
 2010-08-05  Eli Zaretskii  <eliz@gnu.org>
 
 	* configure.in (UNEXEC_OBJ): Rename unexec.o => unexcoff.o.
--- a/admin/CPP-DEFINES	Fri Aug 06 03:43:29 2010 +0000
+++ b/admin/CPP-DEFINES	Sun Aug 08 22:52:25 2010 +0000
@@ -100,7 +100,6 @@
 DATA_SEG_BITS
 DATA_START
 DBL_MIN_REPLACEMENT
-DECLARE_GETPWUID_WITH_UID_T
 DEFAULT_SOUND_DEVICE
 DEVICE_SEP
 DIRECTORY_SEP
--- a/configure	Fri Aug 06 03:43:29 2010 +0000
+++ b/configure	Sun Aug 08 22:52:25 2010 +0000
@@ -1,11 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.66 for emacs 24.0.50.
+# Generated by GNU Autoconf 2.65 for emacs 24.0.50.
 #
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -316,7 +316,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -356,19 +356,19 @@
 fi # as_fn_arith
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -530,7 +530,7 @@
 exec 6>&1
 
 # Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -950,7 +950,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -976,7 +976,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
+      as_fn_error "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1180,7 +1180,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1196,7 +1196,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
+      as_fn_error "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1226,8 +1226,8 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
     ;;
 
   *=*)
@@ -1235,7 +1235,7 @@
     # Reject names that are not valid shell variable names.
     case $ac_envvar in #(
       '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
     esac
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
@@ -1253,13 +1253,13 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
+  as_fn_error "missing argument to $ac_option"
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
@@ -1282,7 +1282,7 @@
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1296,8 +1296,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1312,9 +1312,9 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
+  as_fn_error "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
+  as_fn_error "pwd does not report name of working directory"
 
 
 # Find the source files, if location was not specified.
@@ -1353,11 +1353,11 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1397,7 +1397,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
+  -q, --quiet, --silent   do not print \`checking...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1613,9 +1613,9 @@
 if $ac_init_version; then
   cat <<\_ACEOF
 emacs configure 24.0.50
-generated by GNU Autoconf 2.66
-
-Copyright (C) 2010 Free Software Foundation, Inc.
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1755,10 +1755,10 @@
 ac_fn_c_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -1821,7 +1821,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -1885,7 +1885,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1907,18 +1907,15 @@
 
 } # ac_fn_c_check_header_compile
 
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
+# ac_fn_c_check_decl LINENO SYMBOL VAR
+# ------------------------------------
+# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
 ac_fn_c_check_decl ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
+$as_echo_n "checking whether $2 is declared... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1927,12 +1924,8 @@
 int
 main ()
 {
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
+#ifndef $2
+  (void) $2;
 #endif
 
   ;
@@ -1961,7 +1954,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1991,7 +1984,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
 $as_echo_n "checking for $2.$3... " >&6; }
-if eval "test \"\${$4+set}\"" = set; then :
+if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2047,7 +2040,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2115,7 +2108,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=no"
@@ -2164,7 +2157,7 @@
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.66.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   $ $0 $@
 
@@ -2274,9 +2267,11 @@
   {
     echo
 
-    $as_echo "## ---------------- ##
+    cat <<\_ASBOX
+## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##"
+## ---------------- ##
+_ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -2310,9 +2305,11 @@
 )
     echo
 
-    $as_echo "## ----------------- ##
+    cat <<\_ASBOX
+## ----------------- ##
 ## Output variables. ##
-## ----------------- ##"
+## ----------------- ##
+_ASBOX
     echo
     for ac_var in $ac_subst_vars
     do
@@ -2325,9 +2322,11 @@
     echo
 
     if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
+      cat <<\_ASBOX
+## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##"
+## ------------------- ##
+_ASBOX
       echo
       for ac_var in $ac_subst_files
       do
@@ -2341,9 +2340,11 @@
     fi
 
     if test -s confdefs.h; then
-      $as_echo "## ----------- ##
+      cat <<\_ASBOX
+## ----------- ##
 ## confdefs.h. ##
-## ----------- ##"
+## ----------- ##
+_ASBOX
       echo
       cat confdefs.h
       echo
@@ -2398,12 +2399,7 @@
 ac_site_file1=NONE
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
+  ac_site_file1=$CONFIG_SITE
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
   ac_site_file2=$prefix/etc/config.site
@@ -2418,11 +2414,7 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
+    . "$ac_site_file"
   fi
 done
 
@@ -2503,7 +2495,7 @@
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
@@ -2677,7 +2669,7 @@
 	    g | gt | gtk  )	val=gtk ;;
 	    gtk3  )	val=gtk3 ;;
 	    * )
-as_fn_error $? "\`--with-x-toolkit=$withval' is invalid;
+as_fn_error "\`--with-x-toolkit=$withval' is invalid;
 this option's value should be \`yes', \`no', \`lucid', \`athena', \`motif', \`gtk' or
 \`gtk3'.  \`yes' and \`gtk' are synonyms. \`athena' and \`lucid' are synonyms." "$LINENO" 5
 	    ;;
@@ -2956,7 +2948,7 @@
 	stringfreelist) ac_gc_check_string_free_list=1 ;;
 	xmallocoverrun)	ac_xmalloc_overrun=1 ;;
 	conslist)	ac_gc_check_cons_list=1 ;;
-	*)	as_fn_error $? "unknown check category $check" "$LINENO" 5 ;;
+	*)	as_fn_error "unknown check category $check" "$LINENO" 5 ;;
 	esac
 done
 IFS="$ac_save_IFS"
@@ -3074,22 +3066,16 @@
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -3103,7 +3089,7 @@
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 $as_echo_n "checking build system type... " >&6; }
@@ -3114,16 +3100,16 @@
 test "x$ac_build_alias" = x &&
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
 $as_echo "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
 esac
 build=$ac_cv_build
 ac_save_IFS=$IFS; IFS='-'
@@ -3148,7 +3134,7 @@
   ac_cv_host=$ac_cv_build
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
@@ -3156,7 +3142,7 @@
 $as_echo "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
 esac
 host=$ac_cv_host
 ac_save_IFS=$IFS; IFS='-'
@@ -3450,7 +3436,7 @@
 
 
 if test $unported = yes; then
-  as_fn_error $? "Emacs hasn't been ported to \`${canonical}' systems.
+  as_fn_error "Emacs hasn't been ported to \`${canonical}' systems.
 Check \`etc/MACHINES' for recognized configuration names." "$LINENO" 5
 fi
 
@@ -3764,8 +3750,8 @@
 
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -3879,8 +3865,9 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
@@ -3922,8 +3909,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest conftest$ac_cv_exeext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -3980,9 +3967,9 @@
     else
 	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
+as_fn_error "cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
+See \`config.log' for more details." "$LINENO" 5; }
     fi
   fi
 fi
@@ -4033,8 +4020,8 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
@@ -4451,8 +4438,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -4513,7 +4500,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_GREP=$GREP
@@ -4579,7 +4566,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_EGREP=$EGREP
@@ -4711,7 +4698,8 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -4877,6 +4865,38 @@
 unset has_option
 unset SAVE_CFLAGS
 
+### Use -Wimplicit-function-declaration if the compiler supports it
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands -Wimplicit-function-declaration" >&5
+$as_echo_n "checking whether gcc understands -Wimplicit-function-declaration... " >&6; }
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wimplicit-function-declaration"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  has_option=yes
+else
+  has_option=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_option" >&5
+$as_echo "$has_option" >&6; }
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
+
 
 
 #### Some other nice autoconf tests.
@@ -5008,8 +5028,8 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
 fi
 
 ac_ext=c
@@ -5446,7 +5466,7 @@
   if test "x${with_makeinfo}" = "xno"; then
     MAKEINFO=off
   elif test ! -e $srcdir/info/emacs; then
-    as_fn_error $? "You do not seem to have makeinfo >= 4.6, and your
+    as_fn_error "You do not seem to have makeinfo >= 4.6, and your
 source tree does not seem to have pre-built manuals in the \`info' directory.
 Either install a suitable version of makeinfo, or re-run configure
 with the \`--without-makeinfo' option to build without the manuals. " "$LINENO" 5
@@ -5600,7 +5620,7 @@
     if test "x$GCC" = "xyes"; then
       C_SWITCH_MACHINE="-fno-common"
     else
-      as_fn_error $? "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
+      as_fn_error "What gives?  Fix me if DEC Unix supports ELF now." "$LINENO" 5
     fi
   else
     UNEXEC_OBJ=unexalpha.o
@@ -5878,7 +5898,7 @@
   ## Some platforms don't use any of these files, so it is not
   ## appropriate to put this test outside the if block.
   test -e $CRT_DIR/crtn.o || test -e $CRT_DIR/crt0.o || \
-    as_fn_error $? "crt*.o not found in specified location." "$LINENO" 5
+    as_fn_error "crt*.o not found in specified location." "$LINENO" 5
 
 fi
 
@@ -5933,7 +5953,8 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -6124,7 +6145,7 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       if test "$emacs_alsa_subdir" != yes; then
-        as_fn_error $? "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
+        as_fn_error "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
       fi
       ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
     fi
@@ -6155,11 +6176,12 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h utmp.h dirent.h
+  sys/utsname.h pwd.h utmp.h dirent.h util.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -7001,7 +7023,7 @@
 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
@@ -7009,7 +7031,7 @@
 all:
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
 case `${MAKE-make} -f conftest.make 2>/dev/null` in
   *@@@%%%=?*=@@@%%%*)
     eval ac_cv_prog_make_${ac_make}_set=yes;;
@@ -7145,7 +7167,7 @@
   have_x=disabled
 else
   case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #(
+    *\'*) as_fn_error "cannot use X directory names containing '" "$LINENO" 5;; #(
     *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
@@ -7163,7 +7185,7 @@
 	@echo libdir='${LIBDIR}'
 _ACEOF
   if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
     for ac_var in incroot usrlibdir libdir; do
       eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
     done
@@ -7432,7 +7454,7 @@
 if test "x$ac_cv_header_AppKit_AppKit_h" = x""yes; then :
   HAVE_NS=yes
 else
-  as_fn_error $? "\`--with-ns' was specified, but the include
+  as_fn_error "\`--with-ns' was specified, but the include
   files are missing or cannot be compiled." "$LINENO" 5
 fi
 
@@ -7548,7 +7570,7 @@
    if test "$HAVE_XSERVER" = true ||
       test -n "$DISPLAY" ||
       test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
-        as_fn_error $? "You seem to be running X, but no X development libraries
+        as_fn_error "You seem to be running X, but no X development libraries
 were found.  You should install the relevant development files for X
 and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
 sure you have development files for image handling, i.e.
@@ -7671,7 +7693,8 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -7777,7 +7800,6 @@
 main ()
 {
   char *data, *data2, *data3;
-  const char *cdata2;
   int i, pagesize;
   int fd, fd2;
 
@@ -7802,10 +7824,10 @@
   fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
   if (fd2 < 0)
     return 4;
-  cdata2 = "";
-  if (write (fd2, cdata2, 1) != 1)
+  data2 = "";
+  if (write (fd2, data2, 1) != 1)
     return 5;
-  data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
+  data2 = mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
   if (data2 == MAP_FAILED)
     return 6;
   for (i = 0; i < pagesize; ++i)
@@ -8178,7 +8200,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -8459,7 +8482,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 
@@ -8565,7 +8588,7 @@
   fi
 
   if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
-     as_fn_error $? "$GTK_PKG_ERRORS" "$LINENO" 5
+     as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
   fi
 fi
 fi
@@ -8592,7 +8615,7 @@
 
   if test "${GTK_COMPILES}" != "yes"; then
     if test "$USE_X_TOOLKIT" != "maybe"; then
-      as_fn_error $? "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
+      as_fn_error "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
     fi
   else
     HAVE_GTK=yes
@@ -8722,7 +8745,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -9087,7 +9111,7 @@
       USE_X_TOOLKIT=LUCID
       LUCID_LIBW=-lXaw
     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
-      as_fn_error $? "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
+      as_fn_error "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
     else
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no; do not use toolkit by default" >&5
 $as_echo "no; do not use toolkit by default" >&6; }
@@ -10264,7 +10288,8 @@
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -10516,7 +10541,7 @@
     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
 
   if test "X${MISSING}" != X; then
-    as_fn_error $? "The following required libraries were not found:
+    as_fn_error "The following required libraries were not found:
     $MISSING
 Maybe some development libraries/packages are missing?
 If you don't want to link with them give
@@ -10851,7 +10876,8 @@
   for ac_func in _getb67 GETB67 getb67; do
     as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
 
 cat >>confdefs.h <<_ACEOF
 #define CRAY_STACKSEG_END $ac_func
@@ -10915,7 +10941,7 @@
 
 
 if test x"$ac_cv_func_alloca_works" != xyes; then
-   as_fn_error $? "a system implementation of alloca is required " "$LINENO" 5
+   as_fn_error "a system implementation of alloca is required " "$LINENO" 5
 fi
 
 # fmod, logb, and frexp are found in -lm on most systems.
@@ -11111,7 +11137,7 @@
 
 
   if test $ac_cv_prog_liblockfile = yes; then
-    as_fn_error $? "Shared liblockfile found but can't link against it.
+    as_fn_error "Shared liblockfile found but can't link against it.
 This probably means that movemail could lose mail.
 There may be a \`development' package to install containing liblockfile." "$LINENO" 5
   fi
@@ -11200,7 +11226,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11231,7 +11258,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -11283,8 +11311,8 @@
 static time_t time_t_min;
 
 /* Values we'll use to set the TZ environment variable.  */
-static const char *tz_strings[] = {
-  (const char *) 0, "TZ=GMT0", "TZ=JST-9",
+static char *tz_strings[] = {
+  (char *) 0, "TZ=GMT0", "TZ=JST-9",
   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
 };
 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
@@ -11301,7 +11329,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
 
   tm.tm_year = 98;
   tm.tm_mon = 3;
@@ -11314,14 +11342,16 @@
 }
 
 static int
-mktime_test1 (time_t now)
+mktime_test1 (now)
+     time_t now;
 {
   struct tm *lt;
   return ! (lt = localtime (&now)) || mktime (lt) == now;
 }
 
 static int
-mktime_test (time_t now)
+mktime_test (now)
+     time_t now;
 {
   return (mktime_test1 (now)
 	  && mktime_test1 ((time_t) (time_t_max - now))
@@ -11345,7 +11375,8 @@
 }
 
 static int
-bigtime_test (int j)
+bigtime_test (j)
+     int j;
 {
   struct tm tm;
   time_t now;
@@ -11389,7 +11420,7 @@
      instead of "TZ=America/Vancouver" in order to detect the bug even
      on systems that don't support the Olson extension, or don't have the
      full zoneinfo tables installed.  */
-  putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0");
+  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
 
   t = mktime (&tm);
 
@@ -11424,7 +11455,7 @@
   for (i = 0; i < N_STRINGS; i++)
     {
       if (tz_strings[i])
-	putenv ((char*) tz_strings[i]);
+	putenv (tz_strings[i]);
 
       for (t = 0; t <= time_t_max - delta; t += delta)
 	if (! mktime_test (t))
@@ -11476,7 +11507,7 @@
 
 # Make sure getloadavg.c is where it belongs, at configure-time.
 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
-  as_fn_error $? "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
+  as_fn_error "$srcdir/$ac_config_libobj_dir/getloadavg.c is missing" "$LINENO" 5
 
 ac_save_LIBS=$LIBS
 
@@ -12345,7 +12376,7 @@
 fi
 
 if test "$have_tputs_et_al" != true; then
-  as_fn_error $? "I couldn't find termcap functions (tputs and friends).
+  as_fn_error "I couldn't find termcap functions (tputs and friends).
 Maybe some development libraries/packages are missing?  Try installing
 libncurses-dev(el), libterminfo-dev(el) or similar." "$LINENO" 5
 fi
@@ -13492,7 +13523,8 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -13866,14 +13898,14 @@
    && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
    && test x"`echo $CFLAGS | grep '\-O[23]'`" != x \
    && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
-   as_fn_error $? "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5
+   as_fn_error "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5
 fi
 
 #### Find out which version of Emacs this is.
 version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \
 	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
 if test x"${version}" = x; then
-  as_fn_error $? "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
+  as_fn_error "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5
 fi
 if test x"${version}" != x"$PACKAGE_VERSION"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: version mismatch between \`${srcdir}/configure.in' and \`${srcdir}/src/emacs.c'." >&5
@@ -14431,7 +14463,6 @@
 
 ac_libobjs=
 ac_ltlibobjs=
-U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -14593,19 +14624,19 @@
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
+# script with status $?, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -14801,7 +14832,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -14855,7 +14886,7 @@
 # values after options handling.
 ac_log="
 This file was extended by emacs $as_me 24.0.50, which was
-generated by GNU Autoconf 2.66.  Invocation command line was
+generated by GNU Autoconf 2.65.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -14921,10 +14952,10 @@
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 emacs config.status 24.0.50
-configured by $0, generated by GNU Autoconf 2.66,
+configured by $0, generated by GNU Autoconf 2.65,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2009 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -14978,7 +15009,7 @@
     ac_need_defaults=false;;
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error $? "ambiguous option: \`$1'
+    as_fn_error "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
@@ -14987,7 +15018,7 @@
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
+  -*) as_fn_error "unrecognized option: \`$1'
 Try \`$0 --help' for more information." ;;
 
   *) as_fn_append ac_config_targets " $1"
@@ -15055,7 +15086,7 @@
     "leim/Makefile") CONFIG_FILES="$CONFIG_FILES leim/Makefile" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac
 done
 
@@ -15093,7 +15124,7 @@
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -15127,7 +15158,7 @@
 fi
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
+  ac_cs_awk_cr='\r'
 else
   ac_cs_awk_cr=$ac_cr
 fi
@@ -15144,7 +15175,7 @@
   echo "_ACEOF"
 } >conf$$files.sh &&
 . ./conf$$files.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
 rm -f conf$$files.sh
 
 {
@@ -15152,18 +15183,18 @@
   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
   if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -15258,28 +15289,20 @@
 else
   cat
 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
 s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
 s/^[^=]*=[	 ]*$//
 }'
 fi
@@ -15307,7 +15330,7 @@
   if test -z "$ac_t"; then
     break
   elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -15392,7 +15415,7 @@
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
 fi # test -n "$CONFIG_HEADERS"
 
 
@@ -15405,7 +15428,7 @@
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
@@ -15433,7 +15456,7 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
@@ -15460,7 +15483,7 @@
 
     case $ac_tag in
     *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
     esac
     ;;
   esac
@@ -15596,22 +15619,22 @@
 else
   $AWK -f "$tmp/subs.awk" | $SHELL
 fi >$tmp/out \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
+which seems to be undefined.  Please make sure it is defined." >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
   rm -f "$tmp/stdin"
   case $ac_file in
   -) cat "$tmp/out" && rm -f "$tmp/out";;
   *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
   esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
   #
@@ -15622,19 +15645,19 @@
       $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
     } >"$tmp/config.h" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
     if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
       mv "$tmp/config.h" "$ac_file" \
-	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+	|| as_fn_error "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error $? "could not create -" "$LINENO" 5
+      || as_fn_error "could not create -" "$LINENO" 5
   fi
  ;;
 
@@ -15671,7 +15694,7 @@
 ac_clean_files=$ac_clean_files_save
 
 test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
 
 # configure is writing to config.log, and then calls config.status.
@@ -15692,7 +15715,7 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
+  $ac_cs_success || as_fn_exit $?
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
--- a/configure.in	Fri Aug 06 03:43:29 2010 +0000
+++ b/configure.in	Sun Aug 08 22:52:25 2010 +0000
@@ -770,6 +770,20 @@
 CFLAGS="$SAVE_CFLAGS"
 unset has_option
 unset SAVE_CFLAGS
+
+### Use -Wimplicit-function-declaration if the compiler supports it
+AC_MSG_CHECKING([whether gcc understands -Wimplicit-function-declaration])
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wimplicit-function-declaration"
+AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
+if test $has_option = yes; then
+   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
+fi
+AC_MSG_RESULT($has_option)
+CFLAGS="$SAVE_CFLAGS"
+unset has_option
+unset SAVE_CFLAGS
+
 AC_SUBST(C_WARNINGS_SWITCH)
 
 
@@ -1210,7 +1224,7 @@
   linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
   stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
   sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
-  sys/utsname.h pwd.h utmp.h dirent.h)
+  sys/utsname.h pwd.h utmp.h dirent.h util.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
 AC_TRY_COMPILE([#include <sys/personality.h>], [personality (PER_LINUX32)],
--- a/doc/lispref/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/lispref/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,17 @@
+2010-08-08  Christoph  <cschol2112@googlemail.com>
+
+	* control.texi (Handling Errors) <error-message-string>: Fix arg name.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* modes.texi (Defining Minor Modes): Use C-backspace, not C-delete.
+	Suggested by Štěpán Němec <stepnem@gmail.com>.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.texi (High-Level Completion): Document args of
+	`read-buffer-function' (bug#5625).
+
 2010-07-29  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* frames.texi (Layout Parameters): Add doc for tool-bar-position.
--- a/doc/lispref/control.texi	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/lispref/control.texi	Sun Aug 08 22:52:25 2010 +0000
@@ -1039,7 +1039,7 @@
 @xref{Definition of signal}.
 @end defspec
 
-@defun error-message-string error-description
+@defun error-message-string error-descriptor
 This function returns the error message string for a given error
 descriptor.  It is useful if you want to handle an error by printing the
 usual error message for that error.  @xref{Definition of signal}.
--- a/doc/lispref/minibuf.texi	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/lispref/minibuf.texi	Sun Aug 08 22:52:25 2010 +0000
@@ -1222,10 +1222,11 @@
 @end defun
 
 @defopt read-buffer-function
-This variable specifies how to read buffer names.  For example, if you
-set this variable to @code{iswitchb-read-buffer}, all Emacs commands
-that call @code{read-buffer} to read a buffer name will actually use the
-@code{iswitchb} package to read it.
+This variable specifies how to read buffer names.  The function is
+called with the arguments passed to @code{read-buffer}.  For example,
+if you set this variable to @code{iswitchb-read-buffer}, all Emacs
+commands that call @code{read-buffer} to read a buffer name will
+actually use the @code{iswitchb} package to read it.
 @end defopt
 
 @defopt read-buffer-completion-ignore-case
--- a/doc/lispref/modes.texi	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/lispref/modes.texi	Sun Aug 08 22:52:25 2010 +0000
@@ -1494,7 +1494,7 @@
  ;; The indicator for the mode line.
  " Hungry"
  ;; The minor mode bindings.
- '(([C-delete] . hungry-electric-delete))
+ '(([C-backspace] . hungry-electric-delete))
  :group 'hunger)
 @end smallexample
 
@@ -1526,8 +1526,8 @@
  :lighter " Hungry"
  ;; The minor mode bindings.
  :keymap
- '(([C-delete] . hungry-electric-delete)
-   ([C-M-delete]
+ '(([C-backspace] . hungry-electric-delete)
+   ([C-M-backspace]
     . (lambda ()
         (interactive)
         (hungry-electric-delete t))))
--- a/doc/misc/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/misc/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,13 @@
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* org.texi (Footnotes, Tables in HTML export): Fix typos.
+
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc.texi (Making Selections, Selecting Subformulas)
+	(Customizing Calc): Mention how to use faces to emphasize selected
+	sub-formulas.
+
 2010-08-05  Michael Albinus  <michael.albinus@gmx.de>
 
 	* tramp.texi (External packages): File attributes cache flushing
--- a/doc/misc/calc.texi	Fri Aug 06 03:43:29 2010 +0000
+++ b/doc/misc/calc.texi	Sun Aug 08 22:52:25 2010 +0000
@@ -21513,7 +21513,11 @@
 
 @noindent
 Every character not part of the sub-formula @samp{b} has been changed
-to a dot.  The @samp{*} next to the line number is to remind you that
+to a dot. (If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the characters
+not part of the sub-formula are de-emphasized by using a less
+noticeable face instead of using dots. @pxref{Displaying Selections}.)
+The @samp{*} next to the line number is to remind you that
 the formula has a portion of it selected.  (In this case, it's very
 obvious, but it might not always be.  If Embedded mode is enabled,
 the word @samp{Sel} also appears in the mode line because the stack
@@ -21726,6 +21730,9 @@
 @noindent
 @kindex j d
 @pindex calc-show-selections
+@vindex calc-highlight-selections-with-faces
+@vindex calc-selected-face
+@vindex calc-nonselected-face
 The @kbd{j d} (@code{calc-show-selections}) command controls how
 selected sub-formulas are displayed.  One of the alternatives is
 illustrated in the above examples; if we press @kbd{j d} we switch
@@ -21740,6 +21747,13 @@
         . . . .                   2 x + 1
 @end group
 @end smallexample
+If the customizable variable
+@code{calc-highlight-selections-with-faces} is non-nil, then the
+non-selected portion of the formula will be de-emphasized by using a
+less noticeable face (@code{calc-nonselected-face}) instead of dots
+and the selected sub-formula will be highlighted by using a more
+noticeable face (@code{calc-selected-face}) instead of @samp{#}
+signs. (@pxref{Customizing Calc}.)
 
 @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
 @subsection Operating on Selections
@@ -34911,7 +34925,7 @@
 
 Calc is controlled by many variables, most of which can be reset
 from within Calc.  Some variables are less involved with actual
-calculation, and can be set outside of Calc using Emacs's
+calculation and can be set outside of Calc using Emacs's
 customization facilities.  These variables are listed below.
 Typing @kbd{M-x customize-variable RET @var{variable-name} RET}
 will bring up a buffer in which the variable's value can be redefined.
@@ -35197,6 +35211,22 @@
 and @code{calc-embedded-open-close-plain-alist}.
 @end defvar
 
+@defvar calc-highlight-selections-with-faces
+@defvarx calc-selected-face
+@defvarx calc-nonselected-face
+The variable @code{calc-highlight-selections-with-faces} 
+determines how selected sub-formulas are distinguished.
+If @code{calc-highlight-selections-with-faces} is nil, then 
+a selected sub-formula is distinguished either by changing every
+character not part of the sub-formula with a dot or by changing every
+character in the sub-formula with a @samp{#} sign.  
+If @code{calc-highlight-selections-with-faces} is t,
+then a selected sub-formula is distinguished either by displaying the
+non-selected portion of the formula with @code{calc-nonselected-face} 
+or by displaying the selected sub-formula with
+@code{calc-nonselected-face}. (@pxref{Displaying Selections}.)
+@end defvar
+
 @defvar calc-multiplication-has-precedence
 The variable @code{calc-multiplication-has-precedence} determines
 whether multiplication has precedence over division in algebraic
--- a/etc/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/etc/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,13 @@
+2010-08-08  Ken Brown  <kbrown@cornell.edu>
+
+	* PROBLEMS: Mention problem with Cygwin 1.5.19.
+
+2010-08-07  Eli Zaretskii  <eliz@gnu.org>
+
+	* NEWS: Mention the Hebrew translation.
+
+	* tutorials/TUTORIAL.he: Don't use acronyms.
+
 2010-08-05  Eli Zaretskii  <eliz@gnu.org>
 
 	* AUTHORS: Rename unexec.o => unexcoff.o.
--- a/etc/NEWS	Fri Aug 06 03:43:29 2010 +0000
+++ b/etc/NEWS	Sun Aug 08 22:52:25 2010 +0000
@@ -51,6 +51,11 @@
 This is only useful for Emacs developers to debug certain types of bugs.
 These is not a new feature; only the configure flag is new.
 
+---
+** New translation of the Emacs Tutorial in Hebrew is available
+Type `C-u C-h t' to choose it in case your language setup doesn't
+automatically select it.
+
 
 * Startup Changes in Emacs 24.1
 
@@ -187,7 +192,10 @@
 default, is now similar to other X applications.  In particular, kill
 and yank use the clipboard, in addition to the primary selection.
 
-*** `select-active-regions' now defaults to t.
+*** `select-active-regions' now defaults to `lazy'.
+This means that any active region made with shift-selection or mouse
+dragging, or acted on by Emacs (e.g. with M-w or C-w), is
+automatically added to the primary window selection.
 
 *** `x-select-enable-clipboard' now defaults to t.
 
@@ -258,6 +266,9 @@
 **** vc-bzr handles Author:, Date: and Fixes:
 **** vc-mtn handles Author: and Date:
 
+*** Pressing g in a *vc-diff* buffer reruns vc-diff, so it will
+produce an up to date diff.
+
 ** Directory local variables can apply to file-less buffers.
 For example, adding "(diff-mode . ((mode . whitespace)))" to your
 .dir-locals.el file, will turn on `whitespace-mode' for *vc-diff* buffers.
--- a/etc/PROBLEMS	Fri Aug 06 03:43:29 2010 +0000
+++ b/etc/PROBLEMS	Sun Aug 08 22:52:25 2010 +0000
@@ -2344,6 +2344,14 @@
 As of Emacs 22.1, there have been stability problems with Cygwin
 builds of Emacs using GCC 3.  Cygwin users are advised to use GCC 4.
 
+*** Building Emacs 23.3 and later will fail under Cygwin 1.5.19
+
+This is a consequence of a change to src/dired.c on 2010-07-27.  The
+issue is that Cygwin 1.5.19 did not have d_ino in 'struct dirent'.
+See
+
+  http://lists.gnu.org/archive/html/emacs-devel/2010-07/msg01266.html
+
 *** Building the native MS-Windows port fails due to unresolved externals
 
 The linker error messages look like this:
--- a/etc/tutorials/TUTORIAL.he	Fri Aug 06 03:43:29 2010 +0000
+++ b/etc/tutorials/TUTORIAL.he	Sun Aug 08 22:52:25 2010 +0000
@@ -16,8 +16,8 @@
 לדוגמה:
 <<שורות ריקות תתווספנה סביב השורה הב××” ×¢"×™ help-with-tutorial>>
 [×מצע העמוד הוש×ר ריק למטרות לימודיות. הטקסט ממשיך להלן]
->>  הקישו עתה C-v (הצג העמוד הב×) ×¢"מ ×œ×”×ª×§×“× ×œ×¢×ž×•×“ הב×. (קדימה, נסו ×–×ת
-    ע"י לחיצה והחזקה של מקש CONTROL והקשה על v.)
+>>  הקישו עתה C-v (הצג העמוד הב×) על-מנת ×œ×”×ª×§×“× ×œ×¢×ž×•×“ הב×. (קדימה, נסו
+    ×–×ת ×¢"×™ לחיצה והחזקה של מקש CONTROL והקשה על v.)
     מעתה והל××”, ×¢×œ×™×›× ×œ×¢×©×•×ª ×–×ת בכל ×¤×¢× ×©×ª×¡×™×™×ž×• ×œ×§×¨×•× ×ת המוצג על המסך.
 
 שימו לב לחפיפה של שתי שורות ×›×שר ××ª× ×¢×•×‘×¨×™× ×ž×ž×¡×š למשך, מה שמבטיח רציפות
@@ -28,7 +28,7 @@
 (החזיקו מקש META והקישו v ×ו הקישו ‭<ESC>v‬ ×× ×ין במקלדת מקש META
 ×ו EDIT ×ו ALT).
 
->>  נסו עתה כמה ×¤×¢×ž×™× ×œ×”×§×™×© M-v ו××—"×› C-v.
+>>  נסו עתה כמה ×¤×¢×ž×™× ×œ×”×§×™×© M-v ו×חר-כך C-v.
 
 
 * ×¡×™×›×•× ×¢×“ ×›×ן
@@ -42,7 +42,7 @@
 		כך שהטקסט ליד הסמן ×™×™×ž×¦× ×‘×ž×¨×›×– התצוגה
 		(שימו לב: CONTROL-L ×•×œ× CONTROL-1.)
 
->> מצ×ו ×ת הסמן ×¢"×’ התצוגה וזכרו ×ת הטקסט לידו. ל×חר מכן הקישו C-l.
+>> מצ×ו ×ת הסמן על-גבי התצוגה וזכרו ×ת הטקסט לידו. ל×חר מכן הקישו C-l.
    מצ×ו ×ת הסמן שנית ושימו לב ×©×”×•× ×¢×“×™×™×Ÿ ליד ×ותו הטקסט, ×בל עכשיו
    ×”×•× ×‘×ž×¨×›×– התצוגה.
    ×× ×ª×§×™×©×• C-l שוב, קטע הטקסט ×”×–×” יזוז לקצה העליון של התצוגה. הקישו
@@ -55,7 +55,7 @@
 ------------------
 
 תנועה ×‘×¢×ž×•×“×™× ×©×œ×ž×™× ×”×™× ×” שימושית, ×בל כיצד ניתן להגיע ×œ×ž×§×•× ×¡×¤×¦×™×¤×™
-בתוך הטקסט ש-ע"ג התצוגה?
+בתוך הטקסט שעל-גבי התצוגה?
 
 ניתן לעשות ×–×ת בכמה דרכי×. ×פשר למשל להשתמש במקשי החצי×, ××•×œ× ×™×”×™×”
 ×–×” יעיל יותר ×× ×ª×—×–×™×§×• ×ת ×”×™×“×™×™× ×ž×¢×œ החלק הסטנדרטי של המקלדת ותשתמשו
@@ -70,8 +70,8 @@
 				 :
 			השורה הב××”, C-n
 
->> השתמשו במקשי C-n ו-C-p ×¢"מ להגיע לשורה ×”×מצעית של הדי×גרמה.
-   הקישו C-l כדי למרכז ×ת הדי×גרמה ×¢"×’ התצוגה.
+>> השתמשו במקשי C-n ו-C-p על-מנת להגיע לשורה ×”×מצעית של הדי×גרמה.
+   הקישו C-l כדי למרכז ×ת הדי×גרמה על-גבי התצוגה.
 
 קל יותר לזכור ×ת ×”×ž×§×©×™× ×”×œ×œ×• ב×מצעות ×”×ž×œ×™× ×©×”× ×ž×™×™×¦×’×™×:
 P מ-previous (קוד×), N מ-Next (הב×), B מ-Backward (×חורה)
@@ -83,8 +83,8 @@
    שימו לב מה עושה C-p ×›×שר הסמן × ×ž×¦× ×‘×מצע השורה.
 
 כל שורה של טקטס מסתיימת בתו מיוחד ×”× ×§×¨× Newline. תו ×–×” מפריד בין
-השורה לזו ש×חריה. (ב-ד"×›, השורה ×”×חרונה בקובץ ×ª×¡×ª×™×™× ××£ ×”×™× ×‘-Newline,
-×ך Emacs ×ינו זקוק לכך.)
+השורה לזו ש×חריה. (בדרך כלל, השורה ×”×חרונה בקובץ ×ª×¡×ª×™×™× ××£ ×”×™×
+ב-Newline, ×ך Emacs ×ינו זקוק לכך.)
 
 >> נסו C-b בתחילת שורה. ×”×•× ×™×’×¨×•× ×œ×¡×ž×Ÿ לנוע לסוף השורה הקודמת. ×–×ת,
    ×ž×©×•× ×©×”×•× × ×¢ ×חורה וחולף על-פני תו ×”-Newline.
@@ -297,8 +297,8 @@
 >> הקישו טקסט עד שתגיעו לקצה השורה, ו××– תמשיכו להקיש עוד טקסט.
    כתוצ××”, תר×ו שמופיעה שורת המשך.
 
->> עתה הקישו <DelBack> ע"מ למחוק טקסט עד שהשורה תיעשה קצרה מספיק
-   ותת××™× ×œ×©×•×¨×” בודדת ×¢"×’ התצוגה. שורת ההמשך תיעל×.
+>> עתה הקישו <DelBack> על-מנת למחוק טקסט עד שהשורה תיעשה קצרה מספיק
+   ותת××™× ×œ×©×•×¨×” בודדת על-גבי התצוגה. שורת ההמשך תיעל×.
 
 ניתן למחוק ×ת תו ×”-Newline כמו כל תו ×חר. מחיקת ×”-Newline בין שתי
 שורות תמזג ×ת השורות לשורה ×חת. ×× ×”×©×•×¨×” המשולבת תהיה ×רוכה מרוחב
@@ -312,7 +312,7 @@
 זכרו ×›×™ לרוב הפקודות ב-Emacs ×פשר לציין מספר חזרות. ×’× ×ª×•×™ טקסט
 ×©×™×™×›×™× ×œ×§×‘×•×¦×ª פקודות זו. חזרה על תו טקסט מכניסה ×ותו מספר פעמי×.
 
->> נסו ×–×ת עכשיו -- הקישו ‪C-u 8 *‬ ×¢"מ להכניס ********.
+>> נסו ×–×ת עכשיו -- הקישו ‪C-u 8 *‬ על-מנת להכניס ********.
 
 ובכן, ×œ×ž×“×ª× ×ת ×”×ופן הבסיסי ביותר להדפיס משהו ב-Emacs ולתקן שגי×ות.
 ×פשר למחוק ×’× ×ž×œ×™× ×•××£ שורות שלמות. להלן ×¡×™×›×•× ×¤×§×•×“×•×ª המחיקה:
@@ -432,7 +432,7 @@
 * קבצי×
 -------
 
-×¢"מ שהטקסט ×©×¢×¨×›×ª× ×™×™×©×ž×¨, יש ×œ×©×™× ×ותו בקובץ. ×חרת, ×”×•× ×™×™×¢×œ× ×‘×¨×’×¢
+על-מנת שהטקסט ×©×¢×¨×›×ª× ×™×™×©×ž×¨, יש ×œ×©×™× ×ותו בקובץ. ×חרת, ×”×•× ×™×™×¢×œ× ×‘×¨×’×¢
 שתצ×ו מ-Emacs. כדי ×œ×©×™× ×ת הטקס בקובץ, יש "לפתוח" ("find") ×ת הקובץ
 לפני ×©×ž×ª×—×™×œ×™× ×œ×”×§×™×© טקסט. (×©× ×חר לכך ×”×•× "לפקוד" ×ת הקובץ - "visit".)
 
@@ -469,7 +469,7 @@
 C-x C-f לעבודה ×•×ª×ž×¦× ×•×ª×¤×ª×— ×ת הקובץ שבחרת×. המיני-חוצץ × ×¢×œ× ×›×שר
 פקודת ×”-C-x C-f ×ª×¡×™×™× ×ת עבודתה.
 
-זמן קצר ×חר-כך תוכן הקובץ יופיע ×¢"×’ התצוגה ותוכלו לבצע בו שינויי×.
+זמן קצר ×חר-כך תוכן הקובץ יופיע על-גבי התצוגה ותוכלו לבצע בו שינויי×.
 כשתחליטו לשמור ×ת השינויי×, הקישו ×ת הפקודה הב××”:
 
 	â€C-x C-s    שמור ×ת הקובץ
@@ -479,13 +479,13 @@
 ל×יבוד. ×”×©× ×”×—×“×© נוצר ×¢"×™ הוספת "~" בסוף ×”×©× ×”×ž×§×•×¨×™ של הקובץ.
 
 כשהשמירה מסתיימת, Emacs מציג בשורה התחתונה ×ת ×©× ×”×§×•×‘×¥ שנשמר. נסו
-לשמור ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª ×¢"מ להימנע מל×בד יותר מדי מהעבודה ×©×œ×›× ×× ×”×ž×—×©×‘
+לשמור ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª על-מנת להימנע מל×בד יותר מדי מהעבודה ×©×œ×›× ×× ×”×ž×—×©×‘
 ייפול (ר××” להלן פיסקה על שמירה ×וטומטית).
 
 >> הקישו C-x C-s כדי לשמור ×ת העותק ×©×œ×›× ×©×œ השיעור.
    כתוצ××”, תופיע ההודעה "Wrote ... TUTORIAL.he" בתחתית התצוגה.
 
-ניתן לפתוח קובץ ×§×™×™× ×¢"מ לצפות בו ×ו לערוך ×ותו. ניתן ×’× ×œ×¤×ª×•×— קובץ
+ניתן לפתוח קובץ ×§×™×™× ×¢×œ-מנת לצפות בו ×ו לערוך ×ותו. ניתן ×’× ×œ×¤×ª×•×— קובץ
 ש×ינו קיי×. זו הדרך ליצור ×§×‘×¦×™× ×—×“×©×™× ×‘×¢×–×¨×ª Emacs: פתחו ×ת הקובץ
 שיהיה תחילה ריק ו××– התחילו להקיש טקסט לתוכו. כשתפעילו ×ת פקודת השמירה,
 Emacs ייצור ×ת הקובץ ×¢× ×”×˜×§×¡×˜ שהקשת×. מ×ותו רגע ו×ילך, תוכלו לחשוב
@@ -537,7 +537,7 @@
 שהופיעו בשורה התחתונה במהלך ×¢×‘×•×“×ª×›× ×‘×ª×•×š Emacs.
 
 >> הקישו C-x b *Messages* <Return>‎ כדי לצפות בחוצץ של הודעות.
-   ×חר-כך הקישו C-x b TUTORIAL.he <Return>‎ ×¢"מ לחזור לשיעור ×–×”.
+   ×חר-כך הקישו C-x b TUTORIAL.he <Return>‎ על-מנת לחזור לשיעור ×–×”.
 
 ×× ×¢×©×™×ª× ×©×™× ×•×™×™× ×‘×˜×§×¡×˜ של קובץ ו×חר-כך ×¤×ª×—×ª× ×§×•×‘×¥ ×חר, ×ין הדבר שומר
 ×ת ×”×©×™× ×•×™×™× ×©×¢×©×™×ª× ×œ×§×•×‘×¥ הר×שון. ×”×©×™× ×•×™×™× ×”×œ×œ×• נש××¨×™× ×‘×ª×•×š Emacs, בתוך
@@ -577,7 +577,7 @@
 לפקודה מיוחדת כדי לעבור מ-Emacs לתוכנית ×חרת. ×פשר לעשות ×–×ת בעזרת
 העכבר ×ו פקודות של מנהל החלונות. ×ול×, ×›×שר ××ª× ×ž×©×ª×ž×©×™× ×‘×ª×¦×•×’×”
 טקסטו×לית שמסוגלת להציג רק תוכנית ×חת בו-זמנית, תצטרכו "להשעות"
-("suspend") ×ת Emacs ×¢"מ לעבור לתוכנית ×חרת.
+("suspend") ×ת Emacs על-מנת לעבור לתוכנית ×חרת.
 
 הפקודה C-z יוצ×ת מ-Emacs *ב×ופן זמני* -- כך שתוכלו לשוב ×ליו מ×וחר
 יותר ולהמשיך מ×ותה נקודה. ×›×שר Emacs רץ על תצוגת טקסט, C-z "משעה" ×ת
@@ -587,7 +587,8 @@
 
 הרגע הנכון להשתמש ב-C-x C-c ×”×•× ×›×שר ××ª× ×¢×•×ž×“×™× ×œ×”×ª× ×ª×§ (log out).
 כמו-כן, תצטרכו להשתמש בו כדי לצ×ת מ-Emacs שהופעל ×¢"×™ תוכניות ×חרות
-כגון קרי×ת דו×"ל -- תוכניות ×לו ×œ× ×ª×ž×™×“ יודעות להסתדר ×¢× ×”×©×¢×™×™×ª Emacs.
+כגון קרי×ת דו×ר ×לקטרוני -- תוכניות ×לו ×œ× ×ª×ž×™×“ יודעות להסתדר ×¢×
+השעיית Emacs.
 
 קיימות פקודות C-x רבות מ×ד. להלן רשימת ×לו שכבר למדת×:
 
@@ -624,7 +625,7 @@
 ----------------
 
 ×©×™× ×•×™×™× ×©×¢×¨×›×ª× ×‘×§×•×‘×¥ ×בל ×˜×¨× ×©×ž×¨×ª× ×¢×œ×•×œ×™× ×œ×œ×›×ª ל×יבוד ×× ×”×ž×—×©×‘ שלכ×
-נתקע. ×¢"מ להגן ×¢×œ×™×›× ×ž×¤× ×™ סכנה זו, Emacs שומר ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª כל קובץ
+נתקע. על-מנת להגן ×¢×œ×™×›× ×ž×¤× ×™ סכנה זו, Emacs שומר ×œ×¢×ª×™× ×ž×–×•×ž× ×•×ª כל קובץ
 ×©× ×ž×¦× ×‘×¢×¨×™×›×”. השמירה ×”×וטומטית ×”×–×ת נעשית לקובץ נפרד ששמו מתחיל
 ×•×ž×¡×ª×™×™× ×‘×ª×• #. לדוגמ×, ×× ×”×™× ×›× ×¢×•×¨×›×™× ×§×•×‘×¥ ×‘×©× "hello.c", קובץ השמירה
 ×”×וטומטית שיווצר עבורו ×™×™×§×¨× "#hello.c#". שמירה רגילה של הקובץ על ידכ×
@@ -774,7 +775,7 @@
 
 ×× ×‘×ž×”×œ×š החיפוש תקישו על <Delback>, תר×ו שהתו ×”×חרון של המחרוזת
 המבוקשת נמחק והחיפוש חוזר ×œ×ž×§×•× ×”×§×•×“× ×‘×• נמצ××” המחרוזת ×œ×œ× ×”×ª×• ×”×חרון.
-למשל, × × ×™×— ×©×”×§×©×ª× "ס" ×¢"מ ×œ×ž×¦×•× ×ת ×”×ž×§×•× ×”×‘× ×‘×• מופיעה ×”×ות "ס". ××
+למשל, × × ×™×— ×©×”×§×©×ª× "ס" על-מנת ×œ×ž×¦×•× ×ת ×”×ž×§×•× ×”×‘× ×‘×• מופיעה ×”×ות "ס". ××
 עכשיו תקישו "מ", הסמן יזוז ×œ×ž×§×•× ×‘×• × ×ž×¦× "סמ". עתה הקישו <Delback>.
 ×”-"מ" נמחק מהמחרוזת והסמן חוזר ×œ×ž×§×•× ×‘×• ×”×•× ×ž×¦× ×ת "ס" לר×שונה.
 
@@ -803,8 +804,8 @@
 >> הקישו C-M-v כדי לגלול ×ת החלון התחתון.
    (×× ×‘×ž×§×œ×“×ª ×©×œ×›× ×ין מקש META ×מיתי, הקישו ‎<ESC> C-v כתחליף.)
 
->> הקישו C-x o â€("o" ×”×•× ×¨×ž×– ל-"other", "×חר") ×¢"מ להעביר ×ת הסמן לחלון
-   התחתון.
+>> הקישו C-x o â€("o" ×”×•× ×¨×ž×– ל-"other", "×חר") על-מנת להעביר ×ת הסמן
+   לחלון התחתון.
 >> הקישו C-v ו-M-v בחלון התחתון כדי לגלול ×ותו.
    המשיכו ×œ×§×¨×•× ×”×•×¨×ות ×לו בחלון העליון.
 
@@ -930,7 +931,7 @@
 
 כתוצ××”, יוצגו ×”×©× ×•×”×ª×™×¢×•×“ של הפונקציה בחלון Emacs נפרד. כשתסיימו לקרו×
 ×ת התיעוד, הקישו C-x 1 כדי לסלק ×ת חלון העזרה. ×œ× ×—×™×™×‘×™× ×œ×¢×©×•×ª ×–×ת
-מיד. ×פשר לבצע קצת עריכה תוך שימוש בתיעוד המוצג ורק ××—"×› להקיש C-x 1.
+מיד. ×פשר לבצע קצת עריכה תוך שימוש בתיעוד המוצג ורק ×חר-כך להקיש C-x 1.
 
 הנה עוד כמה פקודות עזרה שימושיות:
 
--- a/lib-src/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/lib-src/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,16 @@
+2010-08-07  Juanma Barranquero  <lekktu@gmail.com>
+
+	* ebrowse.c (usage, version, mark_virtual):
+	Remove duplicate declarations.
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* emacsclient.c: Move socket related #includes together with the
+	rest of the #includes.  Move a WINDOWSNT includes closer together.
+	(HAVE_CONFIG_H): Remove.
+	(NO_RETURN): Remove, defined in config.h.
+	(main): Convert definition to standard C.
+
 2010-07-29  Juanma Barranquero  <lekktu@gmail.com>
 
 	* make-docfile.c (write_c_args): Warn for old-style empty arglist ().
--- a/lib-src/ebrowse.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/lib-src/ebrowse.c	Sun Aug 08 22:52:25 2010 +0000
@@ -492,8 +492,6 @@
 void insert_keyword (char *, int);
 void re_init_scanner (void);
 void init_scanner (void);
-void usage (int);
-void version (void);
 void process_file (char *);
 void add_search_path (char *);
 FILE *open_file (char *);
@@ -504,7 +502,6 @@
 struct member *find_member (struct sym *, char *, int, int, unsigned);
 struct member *add_member (struct sym *, char *, int, int, unsigned);
 void mark_virtual (struct sym *);
-void mark_virtual (struct sym *);
 struct sym *make_namespace (char *, struct sym *);
 char *sym_scope (struct sym *);
 char *sym_scope_1 (struct sym *);
--- a/lib-src/emacsclient.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/lib-src/emacsclient.c	Sun Aug 08 22:52:25 2010 +0000
@@ -18,9 +18,7 @@
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #ifdef WINDOWSNT
 
@@ -32,6 +30,8 @@
 # include <stdlib.h>
 # include <windows.h>
 # include <commctrl.h>
+# include <io.h>
+# include <winsock2.h>
 
 # define NO_SOCKETS_IN_FILE_SYSTEM
 
@@ -45,8 +45,12 @@
 
 # ifdef HAVE_INET_SOCKETS
 #  include <netinet/in.h>
+#  ifdef HAVE_SOCKETS
+#    include <sys/types.h>
+#    include <sys/socket.h>
+#    include <sys/un.h>
+#  endif /* HAVE_SOCKETS */
 # endif
-
 # include <arpa/inet.h>
 
 # define INVALID_SOCKET -1
@@ -67,19 +71,15 @@
 #include <stdio.h>
 #include "getopt.h"
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
 #endif
 
-#ifdef WINDOWSNT
-# include <io.h>
-#else /* not WINDOWSNT */
-# include <pwd.h>
-#endif /* not WINDOWSNT */
+#include <pwd.h>
 #include <sys/stat.h>
-
 #include <signal.h>
 #include <errno.h>
 
+
 
 char *getenv (const char *), *getwd (char *);
 #ifdef HAVE_GETCWD
@@ -114,10 +114,6 @@
 #define TRUE 1
 #endif
 
-#ifndef NO_RETURN
-#define NO_RETURN
-#endif
-
 /* Additional space when allocating buffers for filenames, etc.  */
 #define EXTRA_SPACE 100
 
@@ -702,9 +698,7 @@
 #if !defined (HAVE_SOCKETS) || !defined (HAVE_INET_SOCKETS)
 
 int
-main (argc, argv)
-     int argc;
-     char **argv;
+main (int argc, char **argv)
 {
   main_argv = argv;
   progname = argv[0];
@@ -716,14 +710,6 @@
 
 #else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
 
-#ifdef WINDOWSNT
-# include <winsock2.h>
-#else
-# include <sys/types.h>
-# include <sys/socket.h>
-# include <sys/un.h>
-#endif
-
 #define AUTH_KEY_LENGTH      64
 #define SEND_BUFFER_SIZE   4096
 
--- a/lisp/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,174 @@
+2010-08-08  Chong Yidong  <cyd@stupidchicken.com>
+
+	* mouse.el (mouse-drag-track): Remove accidentally-removed check
+	for `double' value of mouse-1-click-follows-link (Bug#6807).
+
+2010-08-08  Johan Bockgård  <bojohan@gnu.org>
+
+	* replace.el (replace-highlight): Bind isearch-forward and
+	isearch-error, ensuring that highlighting is updated if the user
+	switches the search direction (Bug#6808).
+
+	* isearch.el (isearch-lazy-highlight-forward): New var.
+	(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search):
+	(isearch-lazy-highlight-update): Use it.
+
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* international/mule.el (define-charset): Store NAME as :base
+	property.
+	(ctext-non-standard-encodings-table): Pay attention to charset
+	aliases.
+	(ctext-pre-write-conversion): Sort ctext-standard-encodings by the
+	current priority.  Force using the designation of the specific
+	charset by adding `charset' text property.  Improve the whole
+	algorithm.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* emulation/pc-select.el (pc-selection-mode-hook)
+	(copy-region-as-kill-nomark, beginning-of-buffer-mark)
+	(pc-selection-mode): Fix typos in docstrings.
+
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* language/cyrillic.el: Don't add "microsoft-cp1251" to
+	ctext-non-standard-encodings-alist here.
+
+	* international/mule.el (ctext-non-standard-encodings-alist): Add
+	"koi8-r" and "microsoft-cp1251".
+	(ctext-standard-encodings): New variable.
+	(ctext-non-standard-encodings-table): List only elements for
+	non-standard encodings.
+	(ctext-pre-write-conversion): Adjusted for the above change.
+	Check ctext-standard-encodings.
+
+	* international/mule-conf.el (compound-text): Doc fix.
+	(ctext-no-compositions): Doc fix.
+	(compound-text-with-extensions): Doc fix.
+
+2010-08-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* simple.el (exchange-dot-and-mark): Mark obsolete, finally.
+
+2010-08-03  Juanma Barranquero  <lekktu@gmail.com>
+
+	* progmodes/which-func.el (which-func-format): Split help-echo text
+	into lines, like other mode-line tooltips.
+
+	* server.el (server-start): When using TCP sockets, force IPv4
+	and use a literal 127.0.0.1 for localhost.  (Related to bug#6781.)
+
+2010-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (complete-symbol): Run completion-at-point as a fallback.
+
+2010-08-02  Juanma Barranquero  <lekktu@gmail.com>
+
+	* term.el (term-delimiter-argument-list): Reflow docstring.
+	(term-read-input-ring, term-write-input-ring, term-send-input)
+	(term-bol, term-erase-in-display, serial-supported-or-barf):
+	Fix typos in docstrings.
+
+2010-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* bindings.el (function-key-map): Add a S-tab => backtab fallback.
+
+2010-08-01  Juanma Barranquero  <lekktu@gmail.com>
+
+	* dabbrev.el (dabbrev-completion): Fix typo in docstring.
+
+2010-08-01  MON KEY  <monkey@sandpframing.com>  (tiny change)
+
+	* emacs-lisp/syntax.el (syntax-ppss-toplevel-pos):
+	Fix typo in docstring (bug#6747).
+
+2010-08-08  Leo  <sdl.web@gmail.com>
+
+	* eshell/esh-io.el (eshell-get-target): Better detection of
+	read-only file (Bug#6762).
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* align.el (align-default-spacing): Doc fix.
+	(align-region-heuristic, align-regexp): Fix typos in docstrings.
+
+2010-08-08  Ulf Jasper  <ulf.jasper@web.de>
+
+	* calendar/icalendar.el (icalendar-uid-format): Doc fix.
+	(icalendar--split-value): Fixed splitting regexp. (Bug#6766)
+	(icalendar--get-weekday-numbers): New
+	(icalendar--create-uid, icalendar-export-region)
+	(icalendar--parse-summary-and-rest): Code formatting.
+	(icalendar--convert-recurring-to-diary): Handle multiple byday
+	values in weekly rules. (Bug#6766)
+
+2010-08-08  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc/calc.el (calc-trail-mode,calc-refresh): Use `face' property
+	to italicize headers.
+	(calc-highlight-selections-with-faces): New variable.
+	(calc-selected-face, calc-nonselected-face): New faces.
+
+	* calc/calccomp.el (math-comp-highlight-string): Use
+	`calc-highlight-selections-with-faces' to determine how to highlight
+	sub-formulas.
+
+	* calc/calc-sel.el (calc-show-selections): Change message to when
+	using faces to highlight selections.
+
+2010-08-07  Michael R. Mauger  <mmaug@yahoo.com>
+
+	* progmodes/sql.el (sql-mode-sqlite-font-lock-keywords): Added
+	SQLite 3 keywords, functions and datatypes.
+	(sql-interactive-mode): Removed `comint-process-echoes' set to t
+	(Bug#6686).
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (select-active-regions): Move to keyboard.c.
+	(deactivate-mark): Used saved-region-selection.
+	(select-active-region): Function removed.
+	(activate-mark, set-mark, push-mark-command)
+	(handle-shift-selection): Don't call it.
+	(keyboard-quit): Avoid adding the region to the window selection.
+
+	* mouse.el (mouse-drag-track): Remove hacks to deal with old
+	select-active-regions implementation.
+	(mouse-yank-at-click): Doc fix.
+
+	* cus-start.el: Add custom declaration for select-active-regions.
+
+2010-08-07  Eli Zaretskii  <eliz@gnu.org>
+
+	* simple.el (delete-forward-char): Doc fix.
+
+	* tutorial.el (help-with-tutorial): Hack safe file-local variables
+	after reading the tutorial.
+
+2010-08-06  Alan Mackenzie  <bug-cc-mode@gnu.org>
+
+	* progmodes/cc-cmds.el (c-mask-paragraph, c-fill-paragraph): Fix
+	for the case that a C style comment has its delimiters alone on
+	their respective lines.
+
+2010-08-06  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-handle-start-file-process ): Set connection
+	property "vec".
+	(tramp-process-sentinel): Use it for flushing the cache.  We
+	cannot do it via the process buffer, the buffer could be deleted
+	already when running the sentinel.
+
+2010-08-06  Jürgen Hötzel  <juergen@archlinux.org>  (tiny change)
+
+	* comint.el (comint-mode): Make directory tracking functions
+	functional on remote files.  (Bug#6764)
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc/diff-mode.el (diff-mode-shared-map): Bind g to revert-buffer.
+
 2010-08-05  Eli Zaretskii  <eliz@gnu.org>
 
 	* emacs-lisp/find-gc.el (find-gc-source-files): Rename
--- a/lisp/align.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/align.el	Sun Aug 08 22:52:25 2010 +0000
@@ -140,8 +140,8 @@
   "An integer that represents the default amount of padding to use.
 If `align-to-tab-stop' is non-nil, this will represent the number of
 tab stops to use for alignment, rather than the number of spaces.
-Each alignment rule can optionally override both this variable.  See
-`align-mode-alist'."
+Each alignment rule can optionally override both this variable and
+`align-to-tab-stop'.  See `align-rules-list'."
   :type 'integer
   :group 'align)
 
@@ -157,8 +157,8 @@
 sections (whenever `align-region-separate' is non-nil, and not a
 string), this heuristic is used to determine how far before and after
 point we should search in looking for a region separator.  Larger
-values can mean slower perform in large files, although smaller values
-may cause unexpected behavior at times."
+values can mean slower performance in large files, although smaller
+values may cause unexpected behavior at times."
   :type 'integer
   :group 'align)
 
@@ -926,7 +926,7 @@
     Joe (123) 456-7890
 
 There is no predefined rule to handle this, but you could easily do it
-using a REGEXP like \"(\". All you would have to do is to mark the
+using a REGEXP like \"(\".  All you would have to do is to mark the
 region, call `align-regexp' and type in that regular expression."
   (interactive
    (append
--- a/lisp/bindings.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/bindings.el	Sun Aug 08 22:52:25 2010 +0000
@@ -1054,6 +1054,9 @@
 ;; so we can't distinguish those two keys, but usually we consider C-SPC
 ;; (rather than C-@) as the "canonical" binding.
 (define-key function-key-map [?\C-@] [?\C-\s])
+;; Many keyboards don't have a `backtab' key, so by convention the user
+;; can use S-tab instead to access that binding.
+(define-key function-key-map [S-tab] [backtab])
 
 (define-key global-map [mouse-movement] 'ignore)
 
--- a/lisp/calc/calc-sel.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/calc/calc-sel.el	Sun Aug 08 22:52:25 2010 +0000
@@ -309,6 +309,8 @@
        (setq n (1+ n))))
    (calc-clear-command-flag 'position-point)))
 
+(defvar calc-highlight-selections-with-faces)
+
 (defun calc-show-selections (arg)
   (interactive "P")
   (calc-wrapper
@@ -330,8 +332,12 @@
 		(setcar (nthcdr 2 calc-selection-cache-entry) nil)
 		(calc-change-current-selection sel)))))
    (message (if calc-show-selections
-		"Displaying only selected part of formulas"
-	      "Displaying all but selected part of formulas"))))
+                (if calc-highlight-selections-with-faces
+                    "De-emphasizing all but selected part of formulas"
+                  "Displaying only selected part of formulas")
+              (if calc-highlight-selections-with-faces
+                  "Emphasizing selected part of formulas"
+                "Displaying all but selected part of formulas")))))
 
 ;; The variables calc-final-point-line and calc-final-point-column
 ;; are declared in calc.el, and are used throughout.
--- a/lisp/calc/calc.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/calc/calc.el	Sun Aug 08 22:52:25 2010 +0000
@@ -425,6 +425,27 @@
   :group 'calc
   :type 'integer)
 
+(defcustom calc-highlight-selections-with-faces
+  nil
+  "If non-nil, use a separate face to indicate selected sub-formulas.
+If `calc-show-selections' is non-nil, then selected sub-formulas are shown
+by displaying the rest of the formula in `calc-nonselected-face'.  
+If `calc-show-selections' is nil, then selected sub-formulas are shown
+by displaying the sub-formula in `calc-selected-face'."
+  :group 'calc
+  :type 'boolean)
+
+(defface calc-nonselected-face
+  '((t :inherit shadow       
+       :slant italic))
+  "Face used to show the non-selected portion of a formula."
+  :group 'calc)
+
+(defface calc-selected-face
+  '((t :weight bold))
+  "Face used to show the selected portion of a formula."
+  :group 'calc)
+
 (defvar calc-bug-address "jay.p.belanger@gmail.com"
   "Address of the maintainer of Calc, for use by `report-calc-bug'.")
 
@@ -1385,8 +1406,7 @@
     (set (make-local-variable 'calc-main-buffer) buf))
   (when (= (buffer-size) 0)
     (let ((buffer-read-only nil))
-      (insert (propertize (concat "Emacs Calculator Trail\n")
-			  'font-lock-face 'italic))))
+      (insert (propertize "Emacs Calculator Trail\n" 'face 'italic))))
   (run-mode-hooks 'calc-trail-mode-hook))
 
 (defun calc-create-buffer ()
@@ -1976,7 +1996,7 @@
 	 (erase-buffer)
 	 (when calc-show-banner
 	   (insert (propertize "--- Emacs Calculator Mode ---\n"
-			       'font-lock-face 'italic)))
+			       'face 'italic)))
 	 (while thing
 	   (goto-char (point-min))
 	   (when calc-show-banner
--- a/lisp/calc/calccomp.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/calc/calccomp.el	Sun Aug 08 22:52:25 2010 +0000
@@ -1339,12 +1339,15 @@
 
 (defun math-comp-highlight-string (s)
   (setq s (copy-sequence s))
-  (let ((i (length s)))
-    (while (>= (setq i (1- i)) 0)
-      (or (memq (aref s i) '(32 ?\n))
-	  (aset s i (if calc-show-selections ?\. ?\#)))))
-  s)
-
+  (if calc-highlight-selections-with-faces
+      (if (not calc-show-selections)
+          (propertize s 'face 'calc-selected-face)
+        (propertize s 'face 'calc-nonselected-face))
+    (let ((i (length s)))
+      (while (>= (setq i (1- i)) 0)
+        (or (memq (aref s i) '(32 ?\n))
+            (aset s i (if calc-show-selections ?\. ?\#)))))
+    s))
 
 ;; The variable math-comp-sel-tag is local to calc-find-selected-part
 ;; in calc-sel.el, but is used by math-comp-sel-flat-term and
--- a/lisp/calendar/icalendar.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/calendar/icalendar.el	Sun Aug 08 22:52:25 2010 +0000
@@ -212,15 +212,15 @@
 
 (defcustom icalendar-uid-format
   "emacs%t%c"
-  "Format of unique ID code (UID) for each iCalendar object.  
-The following specifiers are available: 
+  "Format of unique ID code (UID) for each iCalendar object.
+The following specifiers are available:
 %c COUNTER, an integer value that is increased each time a uid is
-   generated. This may be necessary for systems which do not
+   generated.  This may be necessary for systems which do not
    provide time-resolution finer than a second.
 %h HASH, a hash value of the diary entry,
 %s DTSTART, the start date (excluding time) of the diary entry,
 %t TIMESTAMP, a unique creation timestamp,
-%u USERNAME, the user-login-name.
+%u USERNAME, the variable `user-login-name'.
 
 For example, a value of \"%s_%h@mydomain.com\" will generate a
 UID code for each entry composed of the time of the event, a hash
@@ -427,7 +427,7 @@
         (goto-char (point-min))
         (while
             (re-search-forward
-             "\\([A-Za-z0-9-]+\\)=\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\);?"
+             "\\([A-Za-z0-9-]+\\)=\\(\\([^;:]+\\)\\|\"\\([^\"]+\\)\"\\);?"
              nil t)
           (setq param-name (intern (match-string 1)))
           (setq param-value (match-string 2))
@@ -744,6 +744,20 @@
     ;; Error:
     -1))
 
+(defun icalendar--get-weekday-numbers (abbrevweekdays)
+  "Return the list of numbers for the comma-separated ABBREVWEEKDAYS."
+  (when abbrevweekdays
+    (let* ((num -1)
+           (weekday-alist (mapcar (lambda (day)
+                                    (progn
+                                      (setq num (1+ num))
+                                      (cons (downcase day) num)))
+                                  icalendar--weekday-array)))
+      (delq nil
+            (mapcar (lambda (abbrevday)
+                      (cdr (assoc abbrevday weekday-alist)))
+                    (split-string (downcase abbrevweekdays) ","))))))
+
 (defun icalendar--get-weekday-abbrev (weekday)
   "Return the abbreviated WEEKDAY."
   (catch 'found
@@ -912,21 +926,21 @@
 `icalendar--uid-count'.  Returns the UID string."
   (let ((uid icalendar-uid-format))
     
-    (setq uid (replace-regexp-in-string 
-	       "%c" 
+    (setq uid (replace-regexp-in-string
+	       "%c"
 	       (format "%d" icalendar--uid-count)
                uid t t))
     (setq icalendar--uid-count (1+ icalendar--uid-count))
-    (setq uid (replace-regexp-in-string 
+    (setq uid (replace-regexp-in-string
 	       "%t"
 	       (format "%d%d%d" (car (current-time))
 		       (cadr (current-time))
-		       (car (cddr (current-time)))) 
+		       (car (cddr (current-time))))
 	       uid t t))
-    (setq uid (replace-regexp-in-string 
-	       "%h" 
+    (setq uid (replace-regexp-in-string
+	       "%h"
 	       (format "%d" (abs (sxhash entry-full))) uid t t))
-    (setq uid (replace-regexp-in-string 
+    (setq uid (replace-regexp-in-string
 	       "%u" (or user-login-name "UNKNOWN_USER") uid t t))
     (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents)
                        (substring contents (match-beginning 1) (match-end 1))
@@ -1008,7 +1022,7 @@
                 (if url
                     (setq contents (concat contents "\nURL:" url))))
 
-	      (setq header (concat "\nBEGIN:VEVENT\nUID:" 
+	      (setq header (concat "\nBEGIN:VEVENT\nUID:"
 				   (icalendar--create-uid entry-full contents)))
               (setq result (concat result header contents "\nEND:VEVENT")))
           ;; handle errors
@@ -1126,7 +1140,7 @@
                (list "%u"
                      (concat "\\(" icalendar-import-format-url "\\)??"))))
 	;; Need the \' regexp in order to detect multi-line items
-        (setq s (concat "\\`" 
+        (setq s (concat "\\`"
 			   (icalendar--rris "%s" "\\(.*?\\)" s nil t)
                         "\\'"))
         (if (string-match s summary-and-rest)
@@ -2057,39 +2071,47 @@
           ))
       )
     (cond ((string-equal frequency "WEEKLY")
-           (if (not start-t)
-               (progn
-                 ;; weekly and all-day
-                 (icalendar--dmsg "weekly all-day")
-                 (if until
-                     (setq result
-                           (format
-                            (concat "%%%%(and "
-                                    "(diary-cyclic %d %s) "
-                                    "(diary-block %s %s))")
-                            (* interval 7)
-                            dtstart-conv
-                            dtstart-conv
-                            (if count until-1-conv until-conv)
-                            ))
-                   (setq result
-                         (format "%%%%(and (diary-cyclic %d %s))"
-                                 (* interval 7)
-                                 dtstart-conv))))
-             ;; weekly and not all-day
-             (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
-                    (weekday
-                     (icalendar--get-weekday-number byday)))
+	   (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
+		  (weekdays
+		   (icalendar--get-weekday-numbers byday))
+		  (weekday-clause
+		   (when (> (length weekdays) 1)
+		     (format "(memq (calendar-day-of-week date) '%s) "
+			     weekdays))))
+	     (if (not start-t)
+		 (progn
+		   ;; weekly and all-day
+		   (icalendar--dmsg "weekly all-day")
+		   (if until
+		       (setq result
+			     (format
+			      (concat "%%%%(and "
+				      "%s"
+				      "(diary-block %s %s))")
+			      (or weekday-clause
+				  (format "(diary-cyclic %d %s) "
+					  (* interval 7)
+					  dtstart-conv))
+			      (if count until-1-conv until-conv)
+			      ))
+		       (setq result
+			     (format "%%%%(and %s(diary-cyclic %d %s))"
+				     (or weekday-clause "")
+				     (if weekday-clause 1 (* interval 7))
+				     dtstart-conv))))
+               ;; weekly and not all-day
                (icalendar--dmsg "weekly not-all-day")
                (if until
                    (setq result
                          (format
                           (concat "%%%%(and "
-                                  "(diary-cyclic %d %s) "
+                                  "%s"
                                   "(diary-block %s %s)) "
                                   "%s%s%s")
-                          (* interval 7)
-                          dtstart-conv
+			  (or weekday-clause
+			      (format "(diary-cyclic %d %s) "
+				      (* interval 7)
+				      dtstart-conv))
                           dtstart-conv
                           until-conv
                           (or start-t "")
@@ -2100,10 +2122,11 @@
                  ;; DTEND;VALUE=DATE-TIME:20030919T113000
                  (setq result
                        (format
-                        "%%%%(and (diary-cyclic %s %s)) %s%s%s"
-                        (* interval 7)
-                        dtstart-conv
-                        (or start-t "")
+                        "%%%%(and %s(diary-cyclic %d %s)) %s%s%s"
+			(or weekday-clause "")
+			(if weekday-clause 1 (* interval 7))
+			dtstart-conv
+			(or start-t "")
                         (if end-t "-" "") (or end-t "")))))))
           ;; yearly
           ((string-equal frequency "YEARLY")
--- a/lisp/comint.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/comint.el	Sun Aug 08 22:52:25 2010 +0000
@@ -674,6 +674,9 @@
   (make-local-variable 'comint-process-echoes)
   (make-local-variable 'comint-file-name-chars)
   (make-local-variable 'comint-file-name-quote-list)
+  ;; dir tracking on remote files
+  (set (make-local-variable 'comint-file-name-prefix)
+       (or (file-remote-p default-directory) ""))
   (make-local-variable 'comint-accum-marker)
   (setq comint-accum-marker (make-marker))
   (make-local-variable 'font-lock-defaults)
--- a/lisp/cus-start.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/cus-start.el	Sun Aug 08 22:52:25 2010 +0000
@@ -197,6 +197,11 @@
 	     (help-char keyboard character)
 	     (help-event-list keyboard (repeat (sexp :format "%v")))
 	     (menu-prompting menu boolean)
+	     (select-active-regions killing
+				    (choice (const :tag "lazy" lazy)
+					    (const :tag "always" t)
+					    (const :tag "off" nil))
+				    "24.1")
 	     (suggest-key-bindings keyboard (choice (const :tag "off" nil)
 						    (integer :tag "time" 2)
 						    (other :tag "on")))
--- a/lisp/dabbrev.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/dabbrev.el	Sun Aug 08 22:52:25 2010 +0000
@@ -377,7 +377,7 @@
 function pointed out by `dabbrev-friend-buffer-function' to find the
 completions.
 
-If the prefix argument is 16 (which comes from \\[prefix-argument] \\[prefix-argument]),
+If the prefix argument is 16 (which comes from \\[universal-argument] \\[universal-argument]),
 then it searches *all* buffers."
   (interactive "*P")
   (dabbrev--reset-global-variables)
--- a/lisp/emacs-lisp/syntax.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/emacs-lisp/syntax.el	Sun Aug 08 22:52:25 2010 +0000
@@ -52,7 +52,7 @@
 
 (defun syntax-ppss-toplevel-pos (ppss)
   "Get the latest syntactically outermost position found in a syntactic scan.
-PPSS is a scan state, as returned by `partial-parse-sexp' or `syntax-ppss'.
+PPSS is a scan state, as returned by `parse-partial-sexp' or `syntax-ppss'.
 An \"outermost position\" means one that it is outside of any syntactic entity:
 outside of any parentheses, comments, or strings encountered in the scan.
 If no such position is recorded in PPSS (because the end of the scan was
--- a/lisp/emulation/pc-select.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/emulation/pc-select.el	Sun Aug 08 22:52:25 2010 +0000
@@ -110,7 +110,7 @@
   :group 'pc-select)
 
 (defcustom pc-selection-mode-hook nil
-  "The hook to run when pc-selection-mode is toggled."
+  "The hook to run when PC Selection mode is toggled."
   :type 'hook
   :group 'pc-select)
 
@@ -261,7 +261,7 @@
 (provide 'pc-select)
 
 (defun copy-region-as-kill-nomark (beg end)
-  "Save the region as if killed; but don't kill it; deactivate mark.
+  "Save the region as if killed, but don't kill it; deactivate mark.
 If `interprogram-cut-function' is non-nil, also save the text for a window
 system cut and paste.
 
@@ -569,7 +569,7 @@
 ;;;;;;;;;;;;;;;;;;;;
 
 (defun backward-char-mark (&optional arg)
-"Ensure mark is active; move point left ARG characters (right if ARG negative).
+  "Ensure mark is active; move point left ARG characters (right if ARG negative).
 On attempt to pass beginning or end of buffer, stop and signal error."
   (interactive "p")
   (pc-select-ensure-mark)
@@ -633,7 +633,7 @@
 
 
 (defun scroll-up-mark (&optional arg)
-"Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
+  "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
 A near full screen is `next-screen-context-lines' less than a full screen.
 Negative ARG means scroll downward.
 When calling from a program, supply a number as argument or nil.
@@ -654,7 +654,7 @@
 of the accessible part of the buffer.
 
 Don't use this command in Lisp programs!
-\(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
+\(goto-char (point-min)) is faster and avoids clobbering the mark."
   (interactive "P")
   (pc-select-ensure-mark)
   (let ((size (- (point-max) (point-min))))
@@ -841,7 +841,7 @@
 
 ;;;###autoload
 (define-minor-mode pc-selection-mode
-  "Change mark behavior to emulate Motif, MAC or MS-Windows cut and paste style.
+  "Change mark behavior to emulate Motif, Mac or MS-Windows cut and paste style.
 
 This mode enables Delete Selection mode and Transient Mark mode.
 
--- a/lisp/erc/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/erc/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,11 @@
+2010-08-08  Fran Litterio  <flitterio@gmail.com>
+
+	* erc-backend.el (erc-server-filter-function): Call
+	erc-log-irc-protocol.
+
+	* erc.el (erc-toggle-debug-irc-protocol): Bind
+	erc-toggle-debug-irc-protocol to t.
+
 2010-05-07  Chong Yidong  <cyd@stupidchicken.com>
 
 	* Version 23.2 released.
--- a/lisp/erc/erc-backend.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/erc/erc-backend.el	Sun Aug 08 22:52:25 2010 +0000
@@ -574,6 +574,7 @@
                       nil
                     (substring erc-server-filter-data
                                (match-end 0))))
+            (erc-log-irc-protocol line nil)
             (erc-parse-server-response process line)))))))
 
 (defsubst erc-server-reconnect-p (event)
--- a/lisp/erc/erc.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/erc/erc.el	Sun Aug 08 22:52:25 2010 +0000
@@ -2306,14 +2306,14 @@
 	  (insert (erc-make-notice "This buffer displays all IRC protocol traffic exchanged with each server.\n"))
 	  (insert (erc-make-notice "Kill this buffer to terminate protocol logging.\n\n")))
 	(use-local-map (make-sparse-keymap))
-	(local-set-key (kbd "RET") 'erc-toggle-debug-irc-protocol))
+	(local-set-key (kbd "t") 'erc-toggle-debug-irc-protocol))
       (add-hook 'kill-buffer-hook
 		#'(lambda () (setq erc-debug-irc-protocol nil))
 		nil 'local)
       (goto-char (point-max))
       (let ((inhibit-read-only t))
 	(insert (erc-make-notice
-		 (format "IRC protocol logging %s at %s -- Press ENTER to toggle logging.\n"
+		 (format "IRC protocol logging %s at %s -- Press `t' to toggle logging.\n"
 			 (if erc-debug-irc-protocol "disabled" "enabled")
 			 (current-time-string))))))
     (setq erc-debug-irc-protocol (not erc-debug-irc-protocol))
--- a/lisp/eshell/esh-io.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/eshell/esh-io.el	Sun Aug 08 22:52:25 2010 +0000
@@ -343,8 +343,9 @@
 	(let* ((exists (get-file-buffer target))
 	       (buf (find-file-noselect target t)))
 	  (with-current-buffer buf
-	    (if buffer-read-only
+	    (if buffer-file-read-only
 		(error "Cannot write to read-only file `%s'" target))
+	    (setq buffer-read-only nil)
 	    (set (make-local-variable 'eshell-output-file-buffer)
 		 (if (eq exists buf) 0 t))
 	    (cond ((eq mode 'overwrite)
--- a/lisp/international/mule-conf.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/international/mule-conf.el	Sun Aug 08 22:52:25 2010 +0000
@@ -1410,9 +1410,10 @@
   :flags '(ascii-at-eol ascii-at-cntl designation single-shift composition))
 
 (define-coding-system 'compound-text
-  "Compound text based generic encoding for decoding unknown messages.
-
-This coding system does not support extended segments of CTEXT."
+  "Compound text based generic encoding.
+This coding system is an extension of X's \"Compound Text Encoding\".
+It encodes many characters using the normal ISO-2022 designation sequences,
+but it doesn't support extended segments of CTEXT."
   :coding-type 'iso-2022
   :mnemonic ?x
   :charset-list 'iso-2022
@@ -1432,7 +1433,7 @@
 ;; not have a mime-charset property, to prevent it from showing up
 ;; close to the beginning of coding systems ordered by priority.
 (define-coding-system 'ctext-no-compositions
- "Compound text based generic encoding for decoding unknown messages.
+ "Compound text based generic encoding.
 
 Like `compound-text', but does not produce escape sequences for compositions."
   :coding-type 'iso-2022
@@ -1445,8 +1446,9 @@
 (define-coding-system 'compound-text-with-extensions
  "Compound text encoding with ICCCM Extended Segment extensions.
 
-See the variable `ctext-non-standard-encodings-alist' for the
-detail about how extended segments are handled.
+See the variables `ctext-standard-encodings' and
+`ctext-non-standard-encodings-alist' for the detail about how
+extended segments are handled.
 
 This coding system should be used only for X selections.  It is inappropriate
 for decoding and encoding files, process I/O, etc."
--- a/lisp/international/mule.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/international/mule.el	Sun Aug 08 22:52:25 2010 +0000
@@ -282,6 +282,7 @@
 	(plist-put props :short-name (symbol-name name)))
     (or (plist-get props :long-name)
 	(plist-put props :long-name (plist-get props :short-name)))
+    (plist-put props :base name)
     ;; We can probably get a worthwhile amount in purespace.
     (setq props
 	  (mapcar (lambda (elt)
@@ -1465,7 +1466,9 @@
   '(("big5-0" big5 2 big5)
     ("ISO8859-14" iso-8859-14 1 latin-iso8859-14)
     ("ISO8859-15" iso-8859-15 1 latin-iso8859-15)
-    ("gbk-0" gbk 2 chinese-gbk)))
+    ("gbk-0" gbk 2 chinese-gbk)
+    ("koi8-r" koi8-r 1 koi8-r)
+    ("microsoft-cp1251" windows-1251 1 windows-1251)))
   "Alist of non-standard encoding names vs the corresponding usages in CTEXT.
 
 It controls how extended segments of a compound text are handled
@@ -1554,6 +1557,20 @@
       (goto-char (point-min))
       (- (point-max) (point)))))
 
+(defvar ctext-standard-encodings
+  '(ascii latin-jisx0201 katakana-jisx0201
+	  latin-iso8859-1 latin-iso8859-2 latin-iso8859-3 latin-iso8859-4
+	  greek-iso8859-7 arabic-iso8859-6 hebrew-iso8859-8 cyrillic-iso8859-5
+	  latin-iso8859-9
+	  chinese-gb2312 japanese-jisx0208 korean-ksc5601)
+  "List of approved standard encodings (i.e. charsets) of X's Compound Text.
+Coding-system `compound-text-with-extensions' encodes a character
+belonging to any of those charsets using the normal ISO2022
+designation sequence unless the current language environment or
+the variable `ctext-non-standard-encodings' decide to use an extended
+segment of CTEXT for that character.  See also the documentation
+of `ctext-non-standard-encodings-alist'.")
+
 ;; Return an alist of CHARSET vs CTEXT-USAGE-INFO generated from
 ;; `ctext-non-standard-encodings' and a list specified by the key
 ;; `ctext-non-standard-encodings' for the currrent language
@@ -1565,115 +1582,94 @@
 ;; is encoded using UTF-8 encoding extention.
 
 (defun ctext-non-standard-encodings-table ()
-  (let (table)
-    ;; Setup charsets specified by the key
-    ;; `ctext-non-standard-encodings' for the current language
-    ;; environment and in `ctext-non-standard-encodings'.
-    (dolist (encoding (append
-			(get-language-info current-language-environment
-					   'ctext-non-standard-encodings)
-			ctext-non-standard-encodings))
-      (let* ((slot (assoc encoding ctext-non-standard-encodings-alist))
+  (let* ((table (append ctext-non-standard-encodings
+			(copy-sequence
+			 (get-language-info current-language-environment
+					    'ctext-non-standard-encodings))))
+	 (tail table)
+	 elt)
+    (while tail
+      (setq elt (car tail))
+      (let* ((slot (assoc elt ctext-non-standard-encodings-alist))
 	     (charset (nth 3 slot)))
 	(if (charsetp charset)
-	    (push (cons charset slot) table)
-	  (dolist (cs charset)
-	    (push (cons cs slot) table)))))
-
-    ;; Next prepend charsets for ISO2022 designation sequence.
-    (dolist (charset charset-list)
-      (let ((final (plist-get (charset-plist charset) :iso-final-char)))
-	(if (and (integerp final)
-		 (>= final #x40) (<= final #x7e)
-		 ;; Exclude ascii and chinese-cns11643-X.
-		 (not (eq charset 'ascii))
-		 (not (string-match "cns11643" (symbol-name charset))))
-	    (push (cons charset nil) table))))
-
-    ;; Returned reversed list so that the charsets specified by the
-    ;; key `ctext-non-standard-encodings' for the current language
-    ;; have the highest priority.
-    (nreverse table)))
+	    (setcar tail
+		    (cons (plist-get (charset-plist charset) :base) slot))
+	  (setcar tail (cons (car charset) slot))
+	  (dolist (cs (cdr charset))
+	    (setcdr tail
+		    (cons (cons (plist-get (charset-plist (car cs)) :base) slot)
+			  (cdr tail)))
+	    (setq tail (cdr tail))))
+	(setq tail (cdr tail))))
+    table))
 
 (defun ctext-pre-write-conversion (from to)
   "Encode characters between FROM and TO as Compound Text w/Extended Segments.
 
-If FROM is a string, or if the current buffer is not the one set up for us
-by `encode-coding-string', generate a new temp buffer, insert the text,
-and convert it in the temporary buffer.  Otherwise, convert in-place."
+If FROM is a string, generate a new temp buffer, insert the text,
+and convert it in the temporary buffer.  Otherwise, convert
+in-place."
   (save-match-data
     ;; Setup a working buffer if necessary.
     (when (stringp from)
       (set-buffer (generate-new-buffer " *temp"))
       (set-buffer-multibyte (multibyte-string-p from))
-      (insert from))
-
-    ;; Now we can encode the whole buffer.
-    (let ((encoding-table (ctext-non-standard-encodings-table))
-	  last-coding-system-used
-	  last-pos last-encoding-info
-	  encoding-info end-pos ch)
-      (goto-char (setq last-pos (point-min)))
-      (setq end-pos (point-marker))
-      (while (re-search-forward "[^\000-\177]+" nil t)
-	;; Found a sequence of non-ASCII characters.
-	(setq last-pos (match-beginning 0)
-	      ch (char-after last-pos)
-	      last-encoding-info (catch 'tag
-				   (dolist (elt encoding-table)
-				     (if (encode-char ch (car elt))
-					 (throw 'tag (cdr elt))))
-				   'utf-8))
-	(set-marker end-pos (match-end 0))
-	(goto-char (1+ last-pos))
-	(catch 'tag
-	  (while t
-	    (setq encoding-info
-		  (if (< (point) end-pos)
-		      (catch 'tag
-			(setq ch (following-char))
-			(dolist (elt encoding-table)
-			  (if (encode-char ch (car elt))
-			      (throw 'tag (cdr elt))))
-			'utf-8)))
-	    (unless (eq last-encoding-info encoding-info)
-	      (cond ((consp last-encoding-info)
-		     ;; Encode the previous range using an extended
-		     ;; segment.
-		     (let ((encoding-name (car last-encoding-info))
-			   (coding-system (nth 1 last-encoding-info))
-			   (noctets (nth 2 last-encoding-info))
-			   len)
-		       (encode-coding-region last-pos (point) coding-system)
-		       (setq len (+ (length encoding-name) 1
-				    (- (point) last-pos)))
-		       ;; According to the spec of CTEXT, it is not
-		       ;; necessary to produce this extra designation
-		       ;; sequence, but some buggy application
-		       ;; (e.g. crxvt-gb) requires it.
-		       (insert "\e(B")
-		       (save-excursion
-			 (goto-char last-pos)
-			 (insert (format "\e%%/%d" noctets))
-			 (insert-byte (+ (/ len 128) 128) 1)
-			 (insert-byte (+ (% len 128) 128) 1)
-			 (insert encoding-name)
-			 (insert 2))))
-		    ((eq last-encoding-info 'utf-8)
-		     ;; Encode the previous range using UTF-8 encoding
-		     ;; extention.
-		     (encode-coding-region last-pos (point) 'mule-utf-8)
-		     (save-excursion
-		       (goto-char last-pos)
-		       (insert "\e%G"))
-		     (insert "\e%@")))
-	      (setq last-pos (point)
-		    last-encoding-info encoding-info))
-	    (if (< (point) end-pos)
-		(forward-char 1)
-	      (throw 'tag nil)))))
-      (set-marker end-pos nil)
-      (goto-char (point-min))))
+      (insert from)
+      (setq from 1 to (point-max)))
+    (save-restriction
+      (narrow-to-region from to)
+      (goto-char from)
+      (let ((encoding-table (ctext-non-standard-encodings-table))
+	    (charset-list (sort-charsets
+			   (copy-sequence ctext-standard-encodings)))
+	    (end-pos (make-marker))
+	    last-coding-system-used
+	    last-pos charset encoding-info)
+	(dolist (elt encoding-table)
+	  (push (car elt) charset-list))
+	(setq end-pos (point-marker))
+	(while (re-search-forward "[^\0-\177]+" nil t)
+	  ;; Found a sequence of non-ASCII characters.
+	  (set-marker end-pos (match-end 0))
+	  (goto-char (match-beginning 0))
+	  (setq last-pos (point)
+		charset (char-charset (following-char) charset-list))
+	  (forward-char 1)
+	  (while (and (< (point) end-pos)
+		      (eq charset (char-charset (following-char) charset-list)))
+	    (forward-char 1))
+	  (if charset
+	      (if (setq encoding-info (cdr (assq charset encoding-table)))
+		  ;; Encode this range using an extended segment.
+		  (let ((encoding-name (car encoding-info))
+			(coding-system (nth 1 encoding-info))
+			(noctets (nth 2 encoding-info))
+			len)
+		    (encode-coding-region last-pos (point) coding-system)
+		    (setq len (+ (length encoding-name) 1
+				 (- (point) last-pos)))
+		    ;; According to the spec of CTEXT, it is not
+		    ;; necessary to produce this extra designation
+		    ;; sequence, but some buggy application
+		    ;; (e.g. crxvt-gb) requires it.
+		    (insert "\e(B")
+		    (save-excursion
+		      (goto-char last-pos)
+		      (insert (format "\e%%/%d" noctets))
+		      (insert-byte (+ (/ len 128) 128) 1)
+		      (insert-byte (+ (% len 128) 128) 1)
+		      (insert encoding-name)
+		      (insert 2)))
+		;; Encode this range as characters in CHARSET.
+		(put-text-property last-pos (point) 'charset charset))
+	    ;; Encode this range using UTF-8 encoding extention.
+	    (encode-coding-region last-pos (point) 'mule-utf-8)
+	    (save-excursion
+	      (goto-char last-pos)
+	      (insert "\e%G"))
+	    (insert "\e%@")))
+	(goto-char (point-min)))))
   ;; Must return nil, as build_annotations_2 expects that.
   nil)
 
--- a/lisp/isearch.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/isearch.el	Sun Aug 08 22:52:25 2010 +0000
@@ -2581,6 +2581,7 @@
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
 (defvar isearch-lazy-highlight-space-regexp nil)
+(defvar isearch-lazy-highlight-forward nil)
 
 (defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -2620,7 +2621,9 @@
                  (not (= (window-start)
                          isearch-lazy-highlight-window-start))
                  (not (= (window-end)   ; Window may have been split/joined.
-                         isearch-lazy-highlight-window-end))))
+			 isearch-lazy-highlight-window-end))
+		 (not (eq isearch-forward
+			  isearch-lazy-highlight-forward))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t) ;kill old loop & remove overlays
     (when (not isearch-error)
@@ -2635,7 +2638,8 @@
 	    isearch-lazy-highlight-case-fold-search isearch-case-fold-search
 	    isearch-lazy-highlight-regexp	isearch-regexp
             isearch-lazy-highlight-wrapped      nil
-	    isearch-lazy-highlight-space-regexp search-whitespace-regexp)
+	    isearch-lazy-highlight-space-regexp search-whitespace-regexp
+	    isearch-lazy-highlight-forward      isearch-forward)
       (unless (equal isearch-string "")
 	(setq isearch-lazy-highlight-timer
 	      (run-with-idle-timer lazy-highlight-initial-delay nil
@@ -2651,7 +2655,8 @@
 	    (search-invisible nil)	; don't match invisible text
 	    (retry t)
 	    (success nil)
-	    (bound (if isearch-forward
+	    (isearch-forward isearch-lazy-highlight-forward)
+	    (bound (if isearch-lazy-highlight-forward
 		       (min (or isearch-lazy-highlight-end-limit (point-max))
 			    (if isearch-lazy-highlight-wrapped
 				isearch-lazy-highlight-start
@@ -2687,7 +2692,7 @@
 	    (select-window isearch-lazy-highlight-window))
 	(save-excursion
 	  (save-match-data
-	    (goto-char (if isearch-forward
+	    (goto-char (if isearch-lazy-highlight-forward
 			   isearch-lazy-highlight-end
 			 isearch-lazy-highlight-start))
 	    (while looping
@@ -2700,7 +2705,7 @@
 		    (let ((mb (match-beginning 0))
 			  (me (match-end 0)))
 		      (if (= mb me)	;zero-length match
-			  (if isearch-forward
+			  (if isearch-lazy-highlight-forward
 			      (if (= mb (if isearch-lazy-highlight-wrapped
 					    isearch-lazy-highlight-start
 					  (window-end)))
@@ -2720,7 +2725,7 @@
 			  (overlay-put ov 'priority 1000)
 			  (overlay-put ov 'face lazy-highlight-face)
 			  (overlay-put ov 'window (selected-window))))
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (setq isearch-lazy-highlight-end (point))
 			(setq isearch-lazy-highlight-start (point)))))
 
@@ -2730,7 +2735,7 @@
 			(setq looping nil
 			      nomore  t)
 		      (setq isearch-lazy-highlight-wrapped t)
-		      (if isearch-forward
+		      (if isearch-lazy-highlight-forward
 			  (progn
 			    (setq isearch-lazy-highlight-end (window-start))
 			    (goto-char (max (or isearch-lazy-highlight-start-limit (point-min))
--- a/lisp/language/cyrillic.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/language/cyrillic.el	Sun Aug 08 22:52:25 2010 +0000
@@ -239,13 +239,6 @@
 	   (documentation . "Support for Tajik using KOI8-T."))
  '("Cyrillic"))
 
-(let ((elt `("microsoft-cp1251" windows-1251 1
-	     ,(get 'encode-windows-1251 'translation-table)))
-      (slot (assoc "microsoft-cp1251" ctext-non-standard-encodings-alist)))
-  (if slot
-      (setcdr slot (cdr elt))
-    (push elt ctext-non-standard-encodings-alist)))
-
 (set-language-info-alist
  "Bulgarian" `((coding-system windows-1251)
 	       (coding-priority windows-1251)
--- a/lisp/mouse.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/mouse.el	Sun Aug 08 22:52:25 2010 +0000
@@ -697,9 +697,6 @@
 	(window-system)
 	(sit-for 1))
     (push-mark)
-    ;; If `select-active-regions' is non-nil, `set-mark' sets the
-    ;; primary selection to the buffer's region, overriding the role
-    ;; of `copy-region-as-kill'; that's why we did the copy first.
     (set-mark (point))
     (if (numberp end) (goto-char end))
     (mouse-set-region-1)))
@@ -905,10 +902,6 @@
 `mouse-drag-region'."
   (mouse-minibuffer-check start-event)
   (setq mouse-selection-click-count-buffer (current-buffer))
-  ;; We must call deactivate-mark before repositioning point.
-  ;; Otherwise, for `select-active-regions' non-nil, we get the wrong
-  ;; selection if the user drags a region, clicks elsewhere to
-  ;; reposition point, then middle-clicks to paste the selection.
   (deactivate-mark)
   (let* ((original-window (selected-window))
          ;; We've recorded what we needed from the current buffer and
@@ -936,6 +929,9 @@
                        ;; intangible text.
                        (mouse-on-link-p start-posn)))
 	 (click-count (1- (event-click-count start-event)))
+	 (remap-double-click (and on-link
+				  (eq mouse-1-click-follows-link 'double)
+				  (= click-count 1)))
 	 ;; Suppress automatic hscrolling, because that is a nuisance
 	 ;; when setting point near the right fringe (but see below).
 	 (automatic-hscrolling-saved automatic-hscrolling)
@@ -948,6 +944,8 @@
     (if (< (point) start-point)
 	(goto-char start-point))
     (setq start-point (point))
+    (if remap-double-click
+	(setq click-count 0))
 
     ;; Activate the region, using `mouse-start-end' to determine where
     ;; to put point and mark (e.g., double-click will select a word).
@@ -955,10 +953,7 @@
 	  (if (eq transient-mark-mode 'lambda)
 	      '(only)
 	    (cons 'only transient-mark-mode)))
-    (let ((range (mouse-start-end start-point start-point click-count))
-	  ;; Prevent `push-mark' from clobbering the primary selection
-	  ;; if the user clicks without dragging.
-	  (select-active-regions nil))
+    (let ((range (mouse-start-end start-point start-point click-count)))
       (goto-char (nth 0 range))
       (push-mark nil t t)
       (goto-char (nth 1 range)))
@@ -1017,23 +1012,16 @@
 
 	    ;; If point has moved, finish the drag.
 	    (let* (last-command this-command)
-	      ;; Copy the region so that `select-active-regions' can
-	      ;; override `copy-region-as-kill'.
 	      (and mouse-drag-copy-region
 		   do-mouse-drag-region-post-process
 		   (let (deactivate-mark)
-		     (copy-region-as-kill (mark) (point))))
-	      ;; For `select-active-regions' non-nil, ensure that
-	      ;; further alterations of the region (e.g. via
-	      ;; shift-selection) continue to update PRIMARY.
-	      (select-active-region))
+		     (copy-region-as-kill (mark) (point)))))
 
 	  ;; If point hasn't moved, run the binding of the
 	  ;; terminating up-event.
 	  (if do-multi-click
 	      (goto-char start-point)
-	    (let (select-active-regions)
-	      (deactivate-mark)))
+	    (deactivate-mark))
 	  (when (and (functionp fun)
 		     (= start-hscroll (window-hscroll start-window))
 		     ;; Don't run the up-event handler if the window
@@ -1251,9 +1239,7 @@
 and set mark at the beginning.
 Prefix arguments are interpreted as with \\[yank].
 If `mouse-yank-at-point' is non-nil, insert at point
-regardless of where you click.
-If `select-active-regions' is non-nil, the mark is deactivated
-before inserting the text."
+regardless of where you click."
   (interactive "e\nP")
   ;; Give temporary modes such as isearch a chance to turn off.
   (run-hooks 'mouse-leave-buffer-hook)
--- a/lisp/net/tramp.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/net/tramp.el	Sun Aug 08 22:52:25 2010 +0000
@@ -4506,10 +4506,10 @@
 (defun tramp-process-sentinel (proc event)
   "Flush file caches."
   (unless (memq (process-status proc) '(run open))
-    (with-current-buffer (process-buffer proc)
-      (with-parsed-tramp-file-name default-directory nil
-	(tramp-message v 5 "Sentinel called: `%s' `%s'" proc event)
-        (tramp-flush-directory-property v "")))))
+    (let ((vec (tramp-get-connection-property proc "vector" nil)))
+      (when vec
+	(tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event)
+        (tramp-flush-directory-property vec "")))))
 
 ;; We use BUFFER also as connection buffer during setup. Because of
 ;; this, its original contents must be saved, and restored once
@@ -4556,6 +4556,7 @@
 	       v 'file-error "pty association is not supported for `%s'" name)))
 	  (let ((p (tramp-get-connection-process v)))
 	    ;; Set sentinel and query flag for this process.
+	    (tramp-set-connection-property p "vector" v)
 	    (set-process-sentinel p 'tramp-process-sentinel)
 	    (tramp-set-process-query-on-exit-flag p t)
 	    ;; Return process.
--- a/lisp/progmodes/cc-cmds.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/progmodes/cc-cmds.el	Sun Aug 08 22:52:25 2010 +0000
@@ -4001,6 +4001,14 @@
 				       (goto-char ender-start)
 				       (current-column)))
 		       (point-rel (- ender-start here))
+		       (sentence-ends-comment
+			(save-excursion
+			  (goto-char ender-start)
+			  (and (search-backward-regexp
+				(c-sentence-end) (c-point 'bol) t)
+			       (goto-char (match-end 0))
+			  (looking-at "[ \t]*")
+			  (= (match-end 0) ender-start))))
 		       spaces)
 
 		  (save-excursion
@@ -4043,7 +4051,9 @@
 			      (setq spaces
 				    (max
 				     (min spaces
-					  (if sentence-end-double-space 2 1))
+					  (if (and sentence-ends-comment
+						   sentence-end-double-space)
+					      2 1))
 				     1)))
 			  ;; Insert the filler first to keep marks right.
 			  (insert-char ?x spaces t)
@@ -4253,8 +4263,11 @@
   (let ((fill-paragraph-function
 	 ;; Avoid infinite recursion.
 	 (if (not (eq fill-paragraph-function 'c-fill-paragraph))
-	     fill-paragraph-function)))
-    (c-mask-paragraph t nil 'fill-paragraph arg))
+	     fill-paragraph-function))
+	(start-point (point-marker)))
+    (c-mask-paragraph
+     t nil (lambda () (fill-region-as-paragraph (point-min) (point-max) arg)))
+    (goto-char start-point))
   ;; Always return t.  This has the effect that if filling isn't done
   ;; above, it isn't done at all, and it's therefore effectively
   ;; disabled in normal code.
--- a/lisp/progmodes/sql.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/progmodes/sql.el	Sun Aug 08 22:52:25 2010 +0000
@@ -1961,7 +1961,51 @@
 function `regexp-opt'.  Therefore, take a look at the source before
 you define your own `sql-mode-mysql-font-lock-keywords'.")
 
-(defvar sql-mode-sqlite-font-lock-keywords nil
+(defvar sql-mode-sqlite-font-lock-keywords
+  (eval-when-compile
+    (list
+     ;; SQLite Keyword
+     (sql-font-lock-keywords-builder 'font-lock-keyword-face nil
+"abort" "action" "add" "after" "all" "alter" "analyze" "and" "as"
+"asc" "attach" "autoincrement" "before" "begin" "between" "by"
+"cascade" "case" "cast" "check" "collate" "column" "commit" "conflict"
+"constraint" "create" "cross" "current_date" "current_time"
+"current_timestamp" "database" "default" "deferrable" "deferred"
+"delete" "desc" "detach" "distinct" "drop" "each" "else" "end"
+"escape" "except" "exclusive" "exists" "explain" "fail" "for"
+"foreign" "from" "full" "glob" "group" "having" "if" "ignore"
+"immediate" "in" "index" "indexed" "initially" "inner" "insert"
+"instead" "intersect" "into" "is" "isnull" "join" "key" "left" "like"
+"limit" "match" "natural" "no" "not" "notnull" "null" "of" "offset"
+"on" "or" "order" "outer" "plan" "pragma" "primary" "query" "raise"
+"references" "regexp" "reindex" "release" "rename" "replace"
+"restrict" "right" "rollback" "row" "savepoint" "select" "set" "table"
+"temp" "temporary" "then" "to" "transaction" "trigger" "union"
+"unique" "update" "using" "vacuum" "values" "view" "virtual" "when"
+"where"
+)
+     ;; SQLite Data types
+     (sql-font-lock-keywords-builder 'font-lock-type-face nil
+"int" "integer" "tinyint" "smallint" "mediumint" "bigint" "unsigned"
+"big" "int2" "int8" "character" "varchar" "varying" "nchar" "native "
+"nvarchar" "text" "clob" "blob" "real" "double" "precision" "float"
+"numeric" "decimal" "boolean" "date" "datetime"
+)
+     ;; SQLite Functions
+     (sql-font-lock-keywords-builder 'font-lock-builtin-face nil
+;; Core functions
+"abs" "changes" "coalesce" "glob" "ifnull" "hex" "last_insert_rowid"
+"length" "like" "load_extension" "lower" "ltrim" "max" "min" "nullif"
+"quote" "random" "randomblob" "replace" "round" "rtrim" "soundex"
+"sqlite_compileoption_get" "sqlite_compileoption_used"
+"sqlite_source_id" "sqlite_version" "substr" "total_changes" "trim"
+"typeof" "upper" "zeroblob"
+;; Date/time functions
+"time" "julianday" "strftime"
+;; Aggregate functions
+"avg" "count" "group_concat" "max" "min" "sum" "total"
+)))
+
   "SQLite SQL keywords used by font-lock.
 
 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
@@ -2951,7 +2995,6 @@
        (sql-get-product-feature sql-product :prompt-length))
   (make-local-variable 'sql-input-ring-separator)
   (make-local-variable 'sql-input-ring-file-name)
-  (setq comint-process-echoes t)
   ;; Run the mode hook (along with comint's hooks).
   (run-mode-hooks 'sql-interactive-mode-hook)
   ;; Set comint based on user overrides.
--- a/lisp/progmodes/which-func.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/progmodes/which-func.el	Sun Aug 08 22:52:25 2010 +0000
@@ -145,7 +145,9 @@
 		 local-map ,which-func-keymap
 		 face which-func
 		 ;;mouse-face highlight	; currently not evaluated :-(
-		 help-echo "mouse-1: go to beginning, mouse-2: toggle rest visibility, mouse-3: go to end")
+		 help-echo "mouse-1: go to beginning\n\
+mouse-2: toggle rest visibility\n\
+mouse-3: go to end")
     "]")
   "Format for displaying the function in the mode line."
   :group 'which-func
--- a/lisp/replace.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/replace.el	Sun Aug 08 22:52:25 2010 +0000
@@ -1979,7 +1979,9 @@
       (let ((isearch-string string)
 	    (isearch-regexp regexp)
 	    (search-whitespace-regexp nil)
-	    (isearch-case-fold-search case-fold))
+	    (isearch-case-fold-search case-fold)
+	    (isearch-forward t)
+	    (isearch-error nil))
 	;; Set isearch-word to nil because word-replace is regexp-based,
 	;; so `isearch-search-fun' should not use `word-search-forward'.
 	(if (and isearch-word isearch-regexp) (setq isearch-word nil))
--- a/lisp/server.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/server.el	Sun Aug 08 22:52:25 2010 +0000
@@ -563,9 +563,9 @@
 		       :coding 'raw-text-unix
 		       ;; The other args depend on the kind of socket used.
 		       (if server-use-tcp
-			   (list :family nil
+			   (list :family 'ipv4  ;; We're not ready for IPv6 yet
 				 :service t
-				 :host (or server-host 'local)
+				 :host (or server-host "127.0.0.1") ;; See bug#6781
 				 :plist '(:authenticated nil))
 			 (list :family 'local
 			       :service server-file
--- a/lisp/simple.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/simple.el	Sun Aug 08 22:52:25 2010 +0000
@@ -895,7 +895,7 @@
 	(t (delete-char (- n) killflag))))
 
 (defun delete-forward-char (n &optional killflag)
-  "Delete the previous N characters (following if N is negative).
+  "Delete the following N characters (previous if N is negative).
 If Transient Mark mode is enabled, the mark is active, and N is 1,
 delete the text in the region and deactivate the mark instead.
 To disable this, set `delete-active-region' to nil.
@@ -3666,29 +3666,28 @@
       (marker-position (mark-marker))
     (signal 'mark-inactive nil)))
 
-(defcustom select-active-regions t
-  "If non-nil, an active region automatically becomes the window selection."
-  :type 'boolean
-  :group 'killing
-  :version "24.1")
-
 (declare-function x-selection-owner-p "xselect.c" (&optional selection))
 
-;; Many places set mark-active directly, and several of them failed to also
-;; run deactivate-mark-hook.  This shorthand should simplify.
 (defsubst deactivate-mark (&optional force)
   "Deactivate the mark by setting `mark-active' to nil.
 Unless FORCE is non-nil, this function does nothing if Transient
 Mark mode is disabled.
 This function also runs `deactivate-mark-hook'."
   (when (or transient-mark-mode force)
-    ;; Copy the latest region into the primary selection, if desired.
-    (and select-active-regions
-	 mark-active
-	 (display-selections-p)
-	 (x-selection-owner-p 'PRIMARY)
-	 (x-set-selection 'PRIMARY (buffer-substring-no-properties
-				    (region-beginning) (region-end))))
+    (when (and select-active-regions
+	       (region-active-p)
+	       (display-selections-p))
+      ;; The var `saved-region-selection', if non-nil, is the text in
+      ;; the region prior to the last command modifying the buffer.
+      ;; Set the selection to that, or to the current region.
+      (cond (saved-region-selection
+	     (x-set-selection 'PRIMARY saved-region-selection)
+	     (setq saved-region-selection nil))
+	    ((/= (region-beginning) (region-end))
+	     (x-set-selection 'PRIMARY
+			      (buffer-substring-no-properties
+			       (region-beginning)
+			       (region-end))))))
     (if (and (null force)
 	     (or (eq transient-mark-mode 'lambda)
 		 (and (eq (car-safe transient-mark-mode) 'only)
@@ -3706,14 +3705,7 @@
   (when (mark t)
     (setq mark-active t)
     (unless transient-mark-mode
-      (setq transient-mark-mode 'lambda))
-    (select-active-region)))
-
-(defsubst select-active-region ()
-  "Set the PRIMARY X selection if `select-active-regions' is non-nil."
-  (and select-active-regions
-       (display-selections-p)
-       (x-set-selection 'PRIMARY (current-buffer))))
+      (setq transient-mark-mode 'lambda))))
 
 (defun set-mark (pos)
   "Set this buffer's mark to POS.  Don't use this function!
@@ -3736,7 +3728,6 @@
       (progn
 	(setq mark-active t)
 	(run-hooks 'activate-mark-hook)
-	(select-active-region)
 	(set-marker (mark-marker) pos (current-buffer)))
     ;; Normally we never clear mark-active except in Transient Mark mode.
     ;; But when we actually clear out the mark value too, we must
@@ -3820,7 +3811,6 @@
 	(push-mark nil nomsg t)
       (setq mark-active t)
       (run-hooks 'activate-mark-hook)
-      (select-active-region)
       (unless nomsg
 	(message "Mark activated")))))
 
@@ -3951,7 +3941,8 @@
     (setq mark-ring (cdr mark-ring)))
   (deactivate-mark))
 
-(defalias 'exchange-dot-and-mark 'exchange-point-and-mark)
+(define-obsolete-function-alias
+  'exchange-dot-and-mark 'exchange-point-and-mark "23.3")
 (defun exchange-point-and-mark (&optional arg)
   "Put the mark where point is now, and point where the mark is now.
 This command works even when the mark is not active,
@@ -4008,11 +3999,8 @@
 deactivate it, and restore the variable `transient-mark-mode' to
 its earlier value."
   (cond ((and shift-select-mode this-command-keys-shift-translated)
-         (if (and mark-active
-		  (eq (car-safe transient-mark-mode) 'only))
-	     ;; Another program may have grabbed the selection; make
-	     ;; sure we get it back now.
-	     (select-active-region)
+         (unless (and mark-active
+		      (eq (car-safe transient-mark-mode) 'only))
 	   (setq transient-mark-mode
                  (cons 'only
                        (unless (eq transient-mark-mode 'lambda)
@@ -5576,7 +5564,10 @@
 During execution of Lisp code, this character causes a quit directly.
 At top-level, as an editor command, this simply beeps."
   (interactive)
-  (deactivate-mark)
+  ;; Avoid adding the region to the window selection.
+  (setq saved-region-selection nil)
+  (let (select-active-regions)
+    (deactivate-mark))
   (if (fboundp 'kmacro-keyboard-quit)
       (kmacro-keyboard-quit))
   (setq defining-kbd-macro nil)
--- a/lisp/term.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/term.el	Sun Aug 08 22:52:25 2010 +0000
@@ -502,8 +502,8 @@
 (defvar term-delimiter-argument-list ()
   "List of characters to recognize as separate arguments in input.
 Strings comprising a character in this list will separate the arguments
-surrounding them, and also be regarded as arguments in their own right (unlike
-whitespace).  See `term-arguments'.
+surrounding them, and also be regarded as arguments in their own right
+\(unlike whitespace).  See `term-arguments'.
 Defaults to the empty list.
 
 For shells, a good value is (?\\| ?& ?< ?> ?\\( ?\\) ?\\;).
@@ -1516,7 +1516,7 @@
 ;; term-replace-by-expanded-history-before-point Workhorse function.
 
 (defun term-read-input-ring (&optional silent)
-  "Sets the buffer's `term-input-ring' from a history file.
+  "Set the buffer's `term-input-ring' from a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The history ring is of size `term-input-ring-size', regardless of file size.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1564,7 +1564,7 @@
 		 term-input-ring-index nil)))))
 
 (defun term-write-input-ring ()
-  "Writes the buffer's `term-input-ring' to a history file.
+  "Write the buffer's `term-input-ring' to a history file.
 The name of the file is given by the variable `term-input-ring-file-name'.
 The original contents of the file are lost if `term-input-ring' is not empty.
 If `term-input-ring-file-name' is nil this function does nothing.
@@ -1996,12 +1996,12 @@
   "Send input to process.
 After the process output mark, sends all text from the process mark to
 point as input to the process.  Before the process output mark, calls value
-of variable term-get-old-input to retrieve old input, copies it to the
+of variable `term-get-old-input' to retrieve old input, copies it to the
 process mark, and sends it.  A terminal newline is also inserted into the
 buffer and sent to the process.  The list of function names contained in the
 value of `term-input-filter-functions' is called on the input before sending
 it.  The input is entered into the input history ring, if the value of variable
-term-input-filter returns non-nil when called on the input.
+`term-input-filter' returns non-nil when called on the input.
 
 Any history reference may be expanded depending on the value of the variable
 `term-input-autoexpand'.  The list of function names contained in the value
@@ -2137,7 +2137,7 @@
   (term-send-string proc "\n"))
 
 (defun term-bol (arg)
-  "Goes to the beginning of line, then skips past the prompt, if any.
+  "Go to the beginning of line, then skip past the prompt, if any.
 If a prefix argument is given (\\[universal-argument]), then no prompt skip
 -- go straight to column 0.
 
@@ -3760,7 +3760,7 @@
       (goto-char saved-point))))
 
 (defun term-erase-in-display (kind)
-  "Erases (that is blanks out) part of the window.
+  "Erase (that is blank out) part of the window.
 If KIND is 0, erase from (point) to (point-max);
 if KIND is 1, erase from home to point; else erase from home to point-max."
   (term-handle-deferred-scroll)
@@ -4166,7 +4166,7 @@
 
 ;; I need a make-term that doesn't surround with *s -mm
 (defun term-ansi-make-term (name program &optional startfile &rest switches)
-"Make a term process NAME in a buffer, running PROGRAM.
+  "Make a term process NAME in a buffer, running PROGRAM.
 The name of the buffer is NAME.
 If there is already a running process in that buffer, it is not restarted.
 Optional third arg STARTFILE is the name of a file to send the contents of to
@@ -4267,7 +4267,7 @@
 for special serial ports that cannot be configured.")
 
 (defun serial-supported-or-barf ()
-  "Signal an error if serial processes are not supported"
+  "Signal an error if serial processes are not supported."
   (unless (fboundp 'make-serial-process)
     (error "Serial processes are not supported on this system")))
 
--- a/lisp/tutorial.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/tutorial.el	Sun Aug 08 22:52:25 2010 +0000
@@ -829,6 +829,8 @@
         (if old-tut-file
             (progn
               (insert-file-contents (tutorial--saved-file))
+	      (let ((enable-local-variables :safe))
+		(hack-local-variables))
               (goto-char (point-min))
               (setq old-tut-point
                     (string-to-number
@@ -844,6 +846,8 @@
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
           (insert-file-contents (expand-file-name filename tutorial-directory))
+	  (let ((enable-local-variables :safe))
+	    (hack-local-variables))
           (forward-line)
           (setq tutorial--point-before-chkeys (point-marker)))
 
--- a/lisp/vc/diff-mode.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/lisp/vc/diff-mode.el	Sun Aug 08 22:52:25 2010 +0000
@@ -141,6 +141,7 @@
     ;; Standard M-r is useful, so don't change M-r or M-R.
     ;;("r" . diff-restrict-view)
     ;;("R" . diff-reverse-direction)
+    ("g" . revert-buffer)
     ("q" . quit-window))
   "Basic keymap for `diff-mode', bound to various prefix keys.")
 
--- a/nt/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/nt/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,8 @@
+2010-08-08  Óscar Fuentes  <ofv@wanadoo.es>
+
+	* cmdproxy.c (main): Use _snprintf instead of wsprintf,
+	which has a 1024 char limit on Windows (bug#6647).
+
 2010-08-02  Juanma Barranquero  <lekktu@gmail.com>
 
 	* config.nt (TIME_WITH_SYS_TIME): Remove #undef, unused (bug#6754).
--- a/nt/cmdproxy.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/nt/cmdproxy.c	Sun Aug 08 22:52:25 2010 +0000
@@ -35,6 +35,9 @@
 #include <stdlib.h>  /* getenv */
 #include <string.h>  /* strlen */
 
+/* We don't want to include stdio.h because we are already duplicating
+   lots of it here */
+extern int _snprintf (char *buffer, size_t count, const char *format, ...);
 
 /*******  Mock C library routines  *********************************/
 
@@ -604,6 +607,7 @@
     {
       char * p;
       int    extra_arg_space = 0;
+      int    maxlen, remlen;
       int    run_command_dot_com;
 
       progname = getenv ("COMSPEC");
@@ -635,21 +639,27 @@
 	     case path contains spaces (fortunately it can't contain
 	     quotes, since they are illegal in path names).  */
 
-	  buf = p = alloca (strlen (progname) + extra_arg_space +
-			    strlen (cmdline) + 16);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (cmdline) + 16;
+	  buf = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\"", progname);
+	  p += _snprintf (p, remlen, "\"%s\"", progname);
+	  remlen = maxlen - (p - buf);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - buf);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf(p, " /e:%d /c %s", envsize, cmdline);
+	    _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline);
 	  else
-	    wsprintf(p, " /c %s", cmdline);
+	    _snprintf (p, remlen, " /c %s", cmdline);
+	  remlen = maxlen - (p - buf);
 	  cmdline = buf;
 	}
       else
@@ -669,19 +679,27 @@
 	  else
 	    path[0] = '\0';
 
-	  cmdline = p = alloca (strlen (progname) + extra_arg_space +
-				strlen (path) + 13);
+	  remlen = maxlen =
+	    strlen (progname) + extra_arg_space + strlen (path) + 13;
+	  cmdline = p = alloca (maxlen + 1);
 
 	  /* Quote progname in case it contains spaces.  */
-	  p += wsprintf (p, "\"%s\" %s", progname, path);
+	  p += _snprintf (p, remlen, "\"%s\" %s", progname, path);
+	  remlen = maxlen - (p - cmdline);
 
 	  /* Include pass_through_args verbatim; these are just switches
              so should not need quoting.  */
 	  for (argv = pass_through_args; *argv != NULL; ++argv)
-	    p += wsprintf (p, " %s", *argv);
+	    {
+	      p += _snprintf (p, remlen, " %s", *argv);
+	      remlen = maxlen - (p - cmdline);
+	    }
 
 	  if (run_command_dot_com)
-	    wsprintf (p, " /e:%d", envsize);
+	    {
+	      _snprintf (p, remlen, " /e:%d", envsize);
+	      remlen = maxlen - (p - cmdline);
+	    }
 	}
     }
 
--- a/src/.gdbinit	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/.gdbinit	Sun Aug 08 22:52:25 2010 +0000
@@ -535,6 +535,9 @@
   if ($g->overlaps_vertically_p)
     printf " OVL"
   end
+  if ($g->avoid_cursor_p)
+    printf " AVOID"
+  end
   if ($g->left_box_line_p)
     printf " ["
   end
--- a/src/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,240 @@
+2010-08-08  Kenichi Handa  <handa@m17n.org>
+
+	* charset.c: Include <stdlib.h>
+	(struct charset_sort_data): New struct.
+	(charset_compare): New function.
+	(Fsort_charsets): New funciton.
+	(syms_of_charset): Declare Fsort_charsets as a Lisp function.
+
+	* coding.c (decode_coding_iso_2022): Fix checking of dimension
+	number in CTEXT extended segment.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* w32fns.c (syms_of_w32fns) <x-max-tooltip-size>: Fix typo in docstring.
+	* xfns.c (syms_of_xfns) <x-max-tooltip-size>: Reflow docstring.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* fns.c (Fsubstring_no_properties, Fnthcdr, Ffeaturep)
+	(Fhash_table_size): Fix typos in docstrings.
+	(Fmake_hash_table): Doc fix.
+
+2010-08-08  Juanma Barranquero  <lekktu@gmail.com>
+
+	* minibuf.c (syms_of_minibuf) <read-buffer-function>:
+	Doc fix (bug#5625).
+
+2010-08-08  Ken Brown  <kbrown@cornell.edu>
+
+	* dired.c (DIRENTRY_NONEMPTY) [cygwin]: Use d_ino instead of
+	the MSDOS definition.
+
+2010-08-08  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Use const char* instead of char*.
+	* xterm.c (x_create_toolkit_scroll_bar):
+	* xfont.c (xfont_list_pattern):
+	* xfns.c (x_default_scroll_bar_color_parameter)
+	(xic_create_fontsetname, x_default_font_parameter)
+	(x_screen_planes):
+	* xdisp.c (c_string_pos, number_of_chars, reseat_to_string)
+	(store_mode_line_string, decode_mode_spec, display_string):
+	* menu.c (digest_single_submenu):
+	* keymap.h (initial_define_key, initial_define_lispy_key):
+	* keymap.c (initial_define_key, initial_define_lispy_key):
+	* image.c (image_error, image_keyword):
+	* gtkutil.h (xg_create_widget, xg_create_scroll_bar):
+	* gtkutil.c (xg_create_widget, xg_create_scroll_bar):
+	* ftfont.c (struct fc_charset_table, ftfont_spec_pattern)
+	(ftfont_list, ftfont_match):
+	* frame.c (frame_parm_table):
+	* font.h (font_intern_prop, font_parse_xlfd, font_parse_fcname)
+	(font_unparse_fcname, font_unparse_fcname, font_open_by_name)
+	(font_add_log, font_deferred_log):
+	* font.c (font_intern_prop, font_parse_xlfd, font_parse_fcname)
+	(font_unparse_fcname, font_unparse_fcname, font_open_by_name)
+	(font_add_log, font_deferred_log):
+	* emacs.c (argmatch):
+	* dispextern.h (struct it):
+	* coding.c (ENCODE_DESIGNATION):
+	* charset.c (define_charset_internal): Use const.
+
+	* s/freebsd.h (DECLARE_GETPWUID_WITH_UID_T): Remove, unused.
+
+	* xrdb.c: Remove include guard.  Remove
+	DECLARE_GETPWUID_WITH_UID_T conditional it had no effect.
+	Remove #if 0 code.  Replace malloc->xmalloc, free->xfree,
+	realloc->xrealloc instead of using #defines.
+
+2010-08-08  Eli Zaretskii  <eliz@gnu.org>
+
+	* cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line):
+	* editfns.c (Fline_beginning_position, Fline_end_position): State
+	in the doc strings that start and end of line are in the logical
+	order.
+
+	* xdisp.c (display_line): Move the handling of overlay arrow after
+	the call to find_row_edges.  (Bug#6699)
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* keyboard.c (command_loop_1):
+	* insdel.c (prepare_to_modify_buffer): Don't call validate_region.
+
+2010-08-07  Chong Yidong  <cyd@stupidchicken.com>
+
+	* insdel.c (prepare_to_modify_buffer): Save active region text to
+	Vsaved_region_selection.
+
+	* xselect.c (QPRIMARY): Move to keyboard.c.
+
+	* keyboard.c (Vselect_active_regions): Move from simple.el.
+	(Vsaved_region_selection, Qx_set_selection, QPRIMARY, Qlazy): New
+	vars.
+	(command_loop_1): Set window selection prior to deactivating the
+	mark.
+
+2010-08-07  Juanma Barranquero  <lekktu@gmail.com>
+
+	* alloc.c (lisp_malloc):
+	* buffer.c (set_buffer_internal, set_buffer_internal_1):
+	* charset.h (emacs_mule_charset):
+	* dispextern.h (inhibit_free_realized_faces, redraw_frame)
+	(redraw_garbaged_frames, scroll_cost, update_frame, scrolling)
+	(bitch_at_user):
+	* lisp.h (Fcheck_coding_system, Fget_text_property)
+	(Qfunction, Qcompletion_ignore_case, QCwidth, QCsize):
+	Remove duplicate declarations.
+
+2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* process.c: Simplify include logic.
+
+	* keyboard.h (quit_char): Add declaration.
+	* process.h (QCport, QCspeed, QCprocess, QCbytesize, QCstopbits)
+	(QCparity, Qodd, Qeven, QCflowcontrol, Qhw, Qsw, QCsummary): Add
+	declarations.
+	* sysdep.c:
+	* w32.c: Remove the above declarations.
+
+	Remove extern declarations in .c files, .h files have them.
+	* xterm.c:
+	* xdisp.c:
+	* msdos.c:
+	* image.c:
+	* gtkutil.c:
+	* fileio.c:
+	* eval.c: Remove declarations.
+
+	* frame.c (frame_params): Make const.
+
+	* lisp.h (fatal_error_signal, emacs_root_dir): Add declaration.
+
+	* emacs.c (emacs_copyright, emacs_version): Make static.
+	(Vinitial_window_system, Vauto_save_list_file_name)
+	(Vinhibit_redisplay): Remove declarations.
+	(main): Remove HAVE_SHM code, unused.  Remove _I386 conditional
+	for AIX.
+
+	Use const for some arrays and functions.
+	* xterm.h (xg_set_icon_from_xpm_data):
+	* xfns.c (xg_set_icon_from_xpm_data):
+	* term.c (fkeys):
+	* keyboard.c (lispy_accent_keys, lispy_function_keys)
+	(lispy_multimedia_keys, lispy_kana_keys, iso_lispy_function_keys)
+	(lispy_drag_n_drop_names, scroll_bar_parts, modify_event_symbol)
+	(frame.c frame_parms):
+	* emacs-icon.h (gnu_xpm_bits):
+	* callint.c (callint_argfuns): Use const.
+
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* sysdep.c: Move include term.h last of includes (Bug#6812).
+
+2010-08-06  Eli Zaretskii  <eliz@gnu.org>
+
+	* dispnew.c (realloc_glyph_pool): Zero out newly allocated glyphs.
+
+	* msdos.c (IT_display_cursor): Log cursor position on termscript.
+
+	* .gdbinit (pgx): Display the avoid_cursor_p flag.
+
+2010-08-06  Juanma Barranquero  <lekktu@gmail.com>
+
+	* makefile.w32-in ($(BLD)/xdisp.$(O)): Update dependencies.
+
+2010-08-06  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* xterm.h (x_get_focus_frame): Declare.
+
+	* keyboard.h (poll_for_input_1): Unconditionally declare.
+
+	* nsterm.h (x_set_menu_bar_lines): Declare.
+
+	* window.c: Don't include menu.h, it depends on lots of other .h-files.
+
+	* xfaces.c (x_create_gc, x_free_gc): Convert to ANSI C prototypes.
+
+	* window.c: Include menu.h.
+
+	* unexmacosx.c (print_region_list, print_regions)
+	(build_region_list, find_emacs_zone_regions)
+	(unexec_regions_merge, read_load_commands, dump_it)
+	(unexec_init_emacs_zone): Convert to ANSI C prototypes.
+
+	* term.c: Check HAVE_SYS_IOCTL_H.
+
+	* sysdep.c: Check HAVE_TERM_H.
+
+	* process.c: Check HAVE_UTIL_H.  Include nsterm.h if HAVE_NS.
+
+	* nsterm.m (ns_init_paths, ns_alloc_autorelease_pool)
+	(ns_ring_bell, ns_defined_color, hide_hourglass)
+	(x_display_pixel_height, x_display_pixel_width, syms_of_nsterm):
+	Convert to ANSI C prototypes.
+	(x_set_window_size, ns_draw_fringe_bitmap, judge): Move declarations
+	before code.
+
+	* nsterm.h : Include sysselect.h.
+	(x_sync, x_get_focus_frame, x_set_mouse_position)
+	(x_set_mouse_pixel_position, x_make_frame_visible)
+	(x_make_frame_invisible, x_iconify_frame, x_char_width, x_char_height)
+	(x_pixel_width, x_pixel_height, x_set_frame_alpha, x_set_tool_bar_lines)
+	(x_activate_menubar, free_frame_menubar, ns_init_paths, ns_select)
+	(syms_of_nsterm, syms_of_nsfns, syms_of_nsmenu, syms_of_nsselect):
+	Declare.
+
+	* nsmenu.m (popup_activated, name_is_separator)
+	(syms_of_nsmenu): Convert to ANSI C prototypes.
+	(runMenuAt): Prototypes and move declarations before code.
+
+	* nsimage.m (ns_load_image): Move NSTRACE after declarations.
+
+	* nsfont.m (ns_fallback_entity, syms_of_nsfont): Convert to ANSI C
+	prototypes.
+
+	* nsfns.m (have_menus_p, ns_display_info_for_name)
+	(x_set_cursor_type, ns_appkit_version_str)
+	(ns_appkit_version_int, ns_do_applescript)
+	(x_set_scroll_bar_default_width, x_sync, compute_tip_xy)
+	(syms_of_nsfns): Convert to ANSI C prototypes.
+
+	* menu.h (x_set_menu_bar_line): Declare.
+	(free_menubar_widget_value_tree et.al): Add HAVE_NS for these functions.
+
+	* lisp.h (fmod_float): Declare.
+
+	* image.c (xpm_scan, xpm_make_color_table_v)
+	(xpm_put_color_table_v, xpm_get_color_table_v)
+	(xpm_make_color_table_h, xpm_put_color_table_h)
+	(xpm_get_color_table_h, xpm_str_to_color_key, xpm_load_image)
+	(xpm_load): Convert to ANSI C prototypes.
+
+	* emacs.c: Include nsterm.h if HAVE_NS.
+
+	* bidi.c (bidi_dump_cached_states): Fix fprintf warning.
+
 2010-08-06  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* process.c: Remove HAVE_SOCKETS #ifdefs inside #ifdef
@@ -235,7 +472,7 @@
 	Only make handlebox_widget if NULL.
 	Check if tool bar goes to vbox or hbox depending on pos.
 	(xg_update_tool_bar_sizes): New function.
-	(update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
+	(update_frame_tool_bar): Remove old_req, new_req.  Do not get tool bar
 	height, call xg_update_tool_bar_sizes instead.
 	(free_frame_tool_bar): Remove from hbox or vbox depending on
 	toolbar_in_hbox,  Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
@@ -413,7 +650,7 @@
 
 	* xfaces.c (Qmouse_face): Remove declaration.
 	(face_color_gray_p, tty_defined_color, defined_color)
-	(face_color_gray_p, face_color_supported_p). Add const.
+	(face_color_gray_p, face_color_supported_p): Add const.
 
 	* xdisp.c (do_mouse_tracking): Remove declaration.
 	(add_to_log): Use const.
@@ -3815,8 +4052,8 @@
 	(syms_of_xsettings): Initialize current_font.
 	defsubr Sfont_get_system_normal_font.
 
-	* xsettings.h (Ffont_get_system_normal_font,
-	xsettings_get_system_normal_font): Declare.
+	* xsettings.h (Ffont_get_system_normal_font)
+	(xsettings_get_system_normal_font): Declare.
 
 	* xfns.c (extern xlwmenu_default_font): Remove.
 	(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
@@ -5618,7 +5855,7 @@
 	(store_symval_forwarding): Take into account the fact that Ints can
 	now have more than one tag.
 	* buffer.c (syms_of_buffer): Use LISP_INT_TAG.
-	buffer_slot_type_mismatch):
+	(buffer_slot_type_mismatch):
 	* xfaces.c (face_attr_equal_p):
 	* print.c (print_object):
 	* alloc.c (mark_maybe_object, mark_object, survives_gc_p):
--- a/src/alloc.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/alloc.c	Sun Aug 08 22:52:25 2010 +0000
@@ -448,7 +448,6 @@
 static struct mem_node mem_z;
 #define MEM_NIL &mem_z
 
-static POINTER_TYPE *lisp_malloc (size_t, enum mem_type);
 static struct Lisp_Vector *allocate_vectorlike (EMACS_INT);
 static void lisp_free (POINTER_TYPE *);
 static void mark_stack (void);
--- a/src/bidi.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/bidi.c	Sun Aug 08 22:52:25 2010 +0000
@@ -1774,6 +1774,6 @@
   fputs ("\n", stderr);
   fputs ("pos ", stderr);
   for (i = 0; i < bidi_cache_idx; i++)
-    fprintf (stderr, "%*d", ndigits, bidi_cache[i].charpos);
+    fprintf (stderr, "%*ld", ndigits, (long)bidi_cache[i].charpos);
   fputs ("\n", stderr);
 }
--- a/src/buffer.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/buffer.c	Sun Aug 08 22:52:25 2010 +0000
@@ -106,8 +106,6 @@
 int last_per_buffer_idx;
 
 EXFUN (Fset_buffer, 1);
-void set_buffer_internal (struct buffer *b);
-void set_buffer_internal_1 (struct buffer *b);
 static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
                                     int after, Lisp_Object arg1,
                                     Lisp_Object arg2, Lisp_Object arg3);
--- a/src/callint.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/callint.c	Sun Aug 08 22:52:25 2010 +0000
@@ -149,7 +149,7 @@
   return exp;
 }
 
-char *callint_argfuns[]
+static const char *callint_argfuns[]
     = {"", "point", "mark", "region-beginning", "region-end"};
 
 static void
--- a/src/charset.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/charset.c	Sun Aug 08 22:52:25 2010 +0000
@@ -28,6 +28,7 @@
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/types.h>
@@ -1265,7 +1266,7 @@
 static int
 define_charset_internal (Lisp_Object name,
 			 int dimension,
-			 unsigned char *code_space,
+			 const unsigned char *code_space,
 			 unsigned min_code, unsigned max_code,
 			 int iso_final, int iso_revision, int emacs_mule_id,
 			 int ascii_compatible, int supplementary,
@@ -2071,23 +2072,22 @@
     charset = CHAR_CHARSET (XINT (ch));
   else
     {
-      Lisp_Object charset_list;
-
       if (CONSP (restriction))
 	{
-	  for (charset_list = Qnil; CONSP (restriction);
-	       restriction = XCDR (restriction))
+	  int c = XFASTINT (ch);
+
+	  for (; CONSP (restriction); restriction = XCDR (restriction))
 	    {
-	      int id;
+	      struct charset *charset;
 
-	      CHECK_CHARSET_GET_ID (XCAR (restriction), id);
-	      charset_list = Fcons (make_number (id), charset_list);
+	      CHECK_CHARSET_GET_CHARSET (XCAR (restriction), charset);
+	      if (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset))
+		return XCAR (restriction);
 	    }
-	  charset_list = Fnreverse (charset_list);
+	  return Qnil;
 	}
-      else
-	charset_list = coding_system_charset_list (restriction);
-      charset = char_charset (XINT (ch), charset_list, NULL);
+      restriction = coding_system_charset_list (restriction);
+      charset = char_charset (XINT (ch), restriction, NULL);
       if (! charset)
 	return Qnil;
     }
@@ -2238,6 +2238,69 @@
   return make_number (id);
 }
 
+struct charset_sort_data
+{
+  Lisp_Object charset;
+  int id;
+  int priority;
+};
+
+static int
+charset_compare (const void *d1, const void *d2)
+{
+  const struct charset_sort_data *data1 = d1, *data2 = d2;
+  return (data1->priority - data2->priority);
+}
+
+DEFUN ("sort-charsets", Fsort_charsets, Ssort_charsets, 1, 1, 0,
+       doc: /* Sort charset list CHARSETS by a priority of each charset.
+Return the sorted list.  CHARSETS is modified by side effects.
+See also `charset-priority-list' and `set-charset-priority'.  */)
+     (Lisp_Object charsets)
+{
+  Lisp_Object len = Flength (charsets);
+  int n = XFASTINT (len), i, j, done;
+  Lisp_Object tail, elt, attrs;
+  struct charset_sort_data *sort_data;
+  int id, min_id, max_id;
+  USE_SAFE_ALLOCA;
+
+  if (n == 0)
+    return Qnil;
+  SAFE_ALLOCA (sort_data, struct charset_sort_data *, sizeof (*sort_data) * n);
+  for (tail = charsets, i = 0; CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      CHECK_CHARSET_GET_ATTR (elt, attrs);
+      sort_data[i].charset = elt;
+      sort_data[i].id = id = XINT (CHARSET_ATTR_ID (attrs));
+      if (i == 0)
+	min_id = max_id = id;
+      else if (id < min_id)
+	min_id = id;
+      else if (id > max_id)
+	max_id = id;
+    }
+  for (done = 0, tail = Vcharset_ordered_list, i = 0;
+       done < n && CONSP (tail); tail = XCDR (tail), i++)
+    {
+      elt = XCAR (tail);
+      id = XFASTINT (elt);
+      if (id >= min_id && id <= max_id)
+	for (j = 0; j < n; j++)
+	  if (sort_data[j].id == id)
+	    {
+	      sort_data[j].priority = i;
+	      done++;
+	    }
+    }
+  qsort (sort_data, n, sizeof *sort_data, charset_compare);
+  for (i = 0, tail = charsets; CONSP (tail); tail = XCDR (tail), i++)
+    XSETCAR (tail, sort_data[i].charset);
+  SAFE_FREE ();
+  return charsets;
+}
+
 
 void
 init_charset (void)
@@ -2340,6 +2403,7 @@
   defsubr (&Scharset_priority_list);
   defsubr (&Sset_charset_priority);
   defsubr (&Scharset_id_internal);
+  defsubr (&Ssort_charsets);
 
   DEFVAR_LISP ("charset-map-path", &Vcharset_map_path,
 	       doc: /* *List of directories to search for charset map files.  */);
--- a/src/charset.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/charset.h	Sun Aug 08 22:52:25 2010 +0000
@@ -517,8 +517,6 @@
 #define EMACS_MULE_LEADING_CODE_PRIVATE_21	0x9C /* 2/2 */
 #define EMACS_MULE_LEADING_CODE_PRIVATE_22	0x9D /* 2/2 */
 
-extern struct charset *emacs_mule_charset[256];
-
 
 
 extern Lisp_Object Qcharsetp;
--- a/src/cmds.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/cmds.c	Sun Aug 08 22:52:25 2010 +0000
@@ -113,7 +113,8 @@
 
 DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 1, "^p",
        doc: /* Move N lines forward (backward if N is negative).
-Precisely, if point is on line I, move to the start of line I + N.
+Precisely, if point is on line I, move to the start of line I + N
+\("start of line" in the logical order).
 If there isn't room, go as far as possible (no error).
 Returns the count of lines left to move.  If moving forward,
 that is N - number of lines moved; if backward, N + number moved.
@@ -157,7 +158,7 @@
 }
 
 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p",
-       doc: /* Move point to beginning of current line.
+       doc: /* Move point to beginning of current line (in the logical order).
 With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 
@@ -181,7 +182,7 @@
 }
 
 DEFUN ("end-of-line", Fend_of_line, Send_of_line, 0, 1, "^p",
-       doc: /* Move point to end of current line.
+       doc: /* Move point to end of current line (in the logical order).
 With argument N not nil or 1, move forward N - 1 lines first.
 If point reaches the beginning or end of buffer, it stops there.
 To ignore intangibility, bind `inhibit-point-motion-hooks' to t.
--- a/src/coding.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/coding.c	Sun Aug 08 22:52:25 2010 +0000
@@ -3902,7 +3902,7 @@
 		  int size;
 
 		  ONE_MORE_BYTE (dim);
-		  if (dim < 0 || dim > 4)
+		  if (dim < '0' || dim > '4')
 		    goto invalid_code;
 		  ONE_MORE_BYTE (M);
 		  if (M < 128)
@@ -4097,8 +4097,8 @@
 #define ENCODE_DESIGNATION(charset, reg, coding)			\
   do {									\
     unsigned char final_char = CHARSET_ISO_FINAL (charset);		\
-    char *intermediate_char_94 = "()*+";				\
-    char *intermediate_char_96 = ",-./";				\
+    const char *intermediate_char_94 = "()*+";				\
+    const char *intermediate_char_96 = ",-./";				\
     int revision = -1;							\
     int c;								\
 									\
--- a/src/config.in	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/config.in	Sun Aug 08 22:52:25 2010 +0000
@@ -731,6 +731,9 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the <util.h> header file. */
+#undef HAVE_UTIL_H
+
 /* Define to 1 if you have the `utimes' function. */
 #undef HAVE_UTIMES
 
--- a/src/dired.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/dired.c	Sun Aug 08 22:52:25 2010 +0000
@@ -65,8 +65,7 @@
 
 #endif /* HAVE_DIRENT_H */
 
-/* Some versions of Cygwin don't have d_ino in `struct dirent'.  */
-#if defined(MSDOS) || defined(__CYGWIN__)
+#ifdef MSDOS
 #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
 #else
 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
--- a/src/dispextern.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/dispextern.h	Sun Aug 08 22:52:25 2010 +0000
@@ -2050,7 +2050,7 @@
   /* C string to iterate over.  Non-null means get characters from
      this string, otherwise characters are read from current_buffer
      or it->string.  */
-  unsigned char *s;
+  const unsigned char *s;
 
   /* Number of characters in the string (s, or it->string) we iterate
      over.  */
@@ -2430,7 +2430,6 @@
 
 #define PRODUCE_GLYPHS(IT)                              \
   do {                                                  \
-    extern int inhibit_free_realized_faces;             \
     if ((IT)->glyph_row != NULL && (IT)->bidi_p)	\
       {							\
         if ((IT)->bidi_it.paragraph_dir == R2L)		\
@@ -3243,15 +3242,9 @@
 void prepare_desired_row (struct glyph_row *);
 int line_hash_code (struct glyph_row *);
 void set_window_update_flags (struct window *, int);
-void redraw_frame (struct frame *);
-void redraw_garbaged_frames (void);
-int scroll_cost (struct frame *, int, int, int);
-int update_frame (struct frame *, int, int);
 void update_single_window (struct window *, int);
-int scrolling (struct frame *);
 void do_pending_window_change (int);
 void change_frame_size (struct frame *, int, int, int, int, int);
-void bitch_at_user (void);
 void init_display (void);
 void syms_of_display (void);
 extern Lisp_Object Qredisplay_dont_pause;
--- a/src/dispnew.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/dispnew.c	Sun Aug 08 22:52:25 2010 +0000
@@ -1528,7 +1528,11 @@
       int size = needed * sizeof (struct glyph);
 
       if (pool->glyphs)
-	pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+	{
+	  pool->glyphs = (struct glyph *) xrealloc (pool->glyphs, size);
+	  memset (pool->glyphs + pool->nglyphs, 0,
+		  size - pool->nglyphs * sizeof (struct glyph));
+	}
       else
 	{
 	  pool->glyphs = (struct glyph *) xmalloc (size);
--- a/src/editfns.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/editfns.c	Sun Aug 08 22:52:25 2010 +0000
@@ -805,6 +805,9 @@
 With argument N not nil or 1, move forward N - 1 lines first.
 If scan reaches end of buffer, return that position.
 
+The returned position is of the first character in the logical order,
+i.e. the one that has the smallest character position.
+
 This function constrains the returned position to the current field
 unless that would be on a different line than the original,
 unconstrained result.  If N is nil or 1, and a front-sticky field
@@ -843,6 +846,9 @@
 With argument N not nil or 1, move forward N - 1 lines first.
 If scan reaches end of buffer, return that position.
 
+The returned position is of the last character in the logical order,
+i.e. the character whose buffer position is the largest one.
+
 This function constrains the returned position to the current field
 unless that would be on a different line than the original,
 unconstrained result.  If N is nil or 1, and a rear-sticky field ends
--- a/src/emacs-icon.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/emacs-icon.h	Sun Aug 08 22:52:25 2010 +0000
@@ -23,7 +23,7 @@
 /* Note that the GTK port uses gdk to display the icon, so Emacs need
    not have XPM support compiled in.  */
 #if (defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)) || defined (USE_GTK)
-static char * gnu_xpm_bits[] = {
+static const char * gnu_xpm_bits[] = {
 /* width height ncolors chars_per_pixel */
 "32 32 255 2",
 /* colors */
--- a/src/emacs.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/emacs.c	Sun Aug 08 22:52:25 2010 +0000
@@ -63,6 +63,10 @@
 #include "keyboard.h"
 #include "keymap.h"
 
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
 #ifdef HAVE_SETLOCALE
 #include <locale.h>
 #endif
@@ -87,8 +91,8 @@
 #endif
 #endif
 
-const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
-const char emacs_version[] = "24.0.50";
+static const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
+static const char emacs_version[] = "24.0.50";
 
 /* Make these values available in GDB, which doesn't see macros.  */
 
@@ -213,15 +217,6 @@
    output a warning in dump-emacs.  */
 #define MAX_HEAP_BSS_DIFF (1024*1024)
 
-
-#ifdef HAVE_WINDOW_SYSTEM
-extern Lisp_Object Vinitial_window_system;
-#endif /* HAVE_WINDOW_SYSTEM */
-
-extern Lisp_Object Vauto_save_list_file_name;
-
-extern Lisp_Object Vinhibit_redisplay;
-
 /* Nonzero means running Emacs without interactive terminal.  */
 
 int noninteractive;
@@ -634,7 +629,7 @@
    enough information to do it right.  */
 
 static int
-argmatch (char **argv, int argc, char *sstr, char *lstr, int minlen, char **valptr, int *skipptr)
+argmatch (char **argv, int argc, const char *sstr, const char *lstr, int minlen, char **valptr, int *skipptr)
 {
   char *p = NULL;
   int arglen;
@@ -860,23 +855,6 @@
     }
 #endif /* HAVE_PERSONALITY_LINUX32 */
 
-
-/* Map in shared memory, if we are using that.  */
-#ifdef HAVE_SHM
-  if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
-    {
-      map_in_data (0);
-      /* The shared memory was just restored, which clobbered this.  */
-      skip_args = 1;
-    }
-  else
-    {
-      map_in_data (1);
-      /* The shared memory was just restored, which clobbered this.  */
-      skip_args = 0;
-    }
-#endif
-
 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
   /* Extend the stack space available.
      Don't do that if dumping, since some systems (e.g. DJGPP)
@@ -1275,9 +1253,7 @@
 #ifdef AIX
 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU.  */
       signal (SIGXCPU, fatal_error_signal);
-#ifndef _I386
       signal (SIGIOINT, fatal_error_signal);
-#endif
       signal (SIGGRANT, fatal_error_signal);
       signal (SIGRETRACT, fatal_error_signal);
       signal (SIGSOUND, fatal_error_signal);
--- a/src/eval.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/eval.c	Sun Aug 08 22:52:25 2010 +0000
@@ -1629,7 +1629,6 @@
      That is a special case--don't do this in other situations.  */
   register struct handler *allhandlers = handlerlist;
   Lisp_Object conditions;
-  extern int waiting_for_input;
   Lisp_Object string;
   Lisp_Object real_error_symbol;
   struct backtrace *bp;
@@ -3432,7 +3431,6 @@
   register int i;
   Lisp_Object tail;
   Lisp_Object tem;
-  extern Lisp_Object Vprint_level;
   struct gcpro gcpro1;
 
   XSETFASTINT (Vprint_level, 3);
--- a/src/fileio.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/fileio.c	Sun Aug 08 22:52:25 2010 +0000
@@ -854,8 +854,6 @@
 
 	 To avoid this, we set default_directory to the root of the
 	 current drive.  */
-      extern char *emacs_root_dir (void);
-
       default_directory = build_string (emacs_root_dir ());
 #else
       default_directory = build_string ("/");
--- a/src/fns.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/fns.c	Sun Aug 08 22:52:25 2010 +0000
@@ -225,9 +225,8 @@
   return Qt;
 }
 
-DEFUN ("compare-strings", Fcompare_strings,
-       Scompare_strings, 6, 7, 0,
-doc: /* Compare the contents of two strings, converting to multibyte if needed.
+DEFUN ("compare-strings", Fcompare_strings, Scompare_strings, 6, 7, 0,
+       doc: /* Compare the contents of two strings, converting to multibyte if needed.
 In string STR1, skip the first START1 characters and stop at END1.
 In string STR2, skip the first START2 characters and stop at END2.
 END1 and END2 default to the full lengths of the respective strings.
@@ -1199,7 +1198,7 @@
 
 DEFUN ("substring-no-properties", Fsubstring_no_properties, Ssubstring_no_properties, 1, 3, 0,
        doc: /* Return a substring of STRING, without text properties.
-It starts at index FROM and ending before TO.
+It starts at index FROM and ends before TO.
 TO may be nil or omitted; then the substring runs to the end of STRING.
 If FROM is nil or omitted, the substring starts at the beginning of STRING.
 If FROM or TO is negative, it counts from the end.
@@ -1291,7 +1290,7 @@
 }
 
 DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
-       doc: /* Take cdr N times on LIST, returns the result.  */)
+       doc: /* Take cdr N times on LIST, return the result.  */)
   (Lisp_Object n, Lisp_Object list)
 {
   register int i, num;
@@ -1328,7 +1327,7 @@
 }
 
 DEFUN ("member", Fmember, Smember, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `equal'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -1346,7 +1345,7 @@
 }
 
 DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eq'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -1372,7 +1371,7 @@
 }
 
 DEFUN ("memql", Fmemql, Smemql, 2, 2, 0,
-doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
+       doc: /* Return non-nil if ELT is an element of LIST.  Comparison done with `eql'.
 The value is actually the tail of LIST whose car is ELT.  */)
   (register Lisp_Object elt, Lisp_Object list)
 {
@@ -2702,7 +2701,7 @@
 Lisp_Object Vfeatures, Qsubfeatures;
 
 DEFUN ("featurep", Ffeaturep, Sfeaturep, 1, 2, 0,
-       doc: /* Returns t if FEATURE is present in this Emacs.
+       doc: /* Return t if FEATURE is present in this Emacs.
 
 Use this to conditionalize execution of lisp code based on the
 presence or absence of Emacs or environment extensions.
@@ -4425,8 +4424,8 @@
 multiplying the old size with that factor.  Default is 1.5.
 
 :rehash-threshold THRESHOLD -- THRESHOLD must a float > 0, and <= 1.0.
-Resize the hash table when ratio of the number of entries in the
-table.  Default is 0.8.
+Resize the hash table when the ratio (number of entries / table size)
+is greater or equal than THRESHOLD.  Default is 0.8.
 
 :weakness WEAK -- WEAK must be one of nil, t, `key', `value',
 `key-or-value', or `key-and-value'.  If WEAK is not nil, the table
@@ -4549,7 +4548,7 @@
 DEFUN ("hash-table-size", Fhash_table_size, Shash_table_size, 1, 1, 0,
        doc: /* Return the size of TABLE.
 The size can be used as an argument to `make-hash-table' to create
-a hash table than can hold as many elements of TABLE holds
+a hash table than can hold as many elements as TABLE holds
 without need for resizing.  */)
   (Lisp_Object table)
 {
--- a/src/font.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/font.c	Sun Aug 08 22:52:25 2010 +0000
@@ -232,7 +232,7 @@
    STR.  */
 
 Lisp_Object
-font_intern_prop (char *str, int len, int force_symbol)
+font_intern_prop (const char *str, int len, int force_symbol)
 {
   int i;
   Lisp_Object tem;
@@ -981,7 +981,7 @@
    a fully specified XLFD.  */
 
 int
-font_parse_xlfd (char *name, Lisp_Object font)
+font_parse_xlfd (const char *name, Lisp_Object font)
 {
   int len = strlen (name);
   int i, j, n;
@@ -1306,7 +1306,7 @@
    This function tries to guess which format it is.  */
 
 int
-font_parse_fcname (char *name, Lisp_Object font)
+font_parse_fcname (const char *name, Lisp_Object font)
 {
   char *p, *q;
   char *size_beg = NULL, *size_end = NULL;
@@ -1563,7 +1563,7 @@
    FONT_SIZE_INDEX of FONT is 0, use PIXEL_SIZE instead.  */
 
 int
-font_unparse_fcname (Lisp_Object font, int pixel_size, char *name, int nbytes)
+font_unparse_fcname (Lisp_Object font, int pixel_size, const char *name, int nbytes)
 {
   Lisp_Object family, foundry;
   Lisp_Object tail, val;
@@ -1571,7 +1571,7 @@
   int i, len = 1;
   char *p;
   Lisp_Object styles[3];
-  char *style_names[3] = { "weight", "slant", "width" };
+  const char *style_names[3] = { "weight", "slant", "width" };
   char work[256];
 
   family = AREF (font, FONT_FAMILY_INDEX);
@@ -3506,7 +3506,7 @@
    found, return Qnil.  */
 
 Lisp_Object
-font_open_by_name (FRAME_PTR f, char *name)
+font_open_by_name (FRAME_PTR f, const char *name)
 {
   Lisp_Object args[2];
   Lisp_Object spec, ret;
@@ -5060,7 +5060,7 @@
    opening), ARG is the argument for the action, and RESULT is the
    result of the action.  */
 void
-font_add_log (char *action, Lisp_Object arg, Lisp_Object result)
+font_add_log (const char *action, Lisp_Object arg, Lisp_Object result)
 {
   Lisp_Object tail, val;
   int i;
@@ -5146,7 +5146,7 @@
    as font_add_log.  */
 
 void
-font_deferred_log (char *action, Lisp_Object arg, Lisp_Object result)
+font_deferred_log (const char *action, Lisp_Object arg, Lisp_Object result)
 {
   if (EQ (Vfont_log, Qt))
     return;
--- a/src/font.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/font.h	Sun Aug 08 22:52:25 2010 +0000
@@ -783,10 +783,10 @@
 extern void font_done_for_face (FRAME_PTR f, struct face *face);
 
 extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec);
-extern Lisp_Object font_open_by_name (FRAME_PTR f, char *name);
+extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name);
 extern void font_close_object (FRAME_PTR f, Lisp_Object font_object);
 
-extern Lisp_Object font_intern_prop (char *str, int len, int force_symbol);
+extern Lisp_Object font_intern_prop (const char *str, int len, int force_symbol);
 extern void font_update_sort_order (int *order);
 
 extern void font_parse_family_registry (Lisp_Object family,
@@ -795,12 +795,12 @@
 extern Lisp_Object font_spec_from_family_registry (Lisp_Object family,
                                                    Lisp_Object registry);
 
-extern int font_parse_xlfd (char *name, Lisp_Object font);
+extern int font_parse_xlfd (const char *name, Lisp_Object font);
 extern int font_unparse_xlfd (Lisp_Object font, int pixel_size,
                               char *name, int bytes);
-extern int font_parse_fcname (char *name, Lisp_Object font);
+extern int font_parse_fcname (const char *name, Lisp_Object font);
 extern int font_unparse_fcname (Lisp_Object font, int pixel_size,
-                                char *name, int bytes);
+                                const char *name, int bytes);
 extern int font_unparse_gtkname (Lisp_Object, struct frame *, char *, int);
 extern void register_font_driver (struct font_driver *driver, FRAME_PTR f);
 extern void free_font_driver_list (FRAME_PTR f);
@@ -856,8 +856,8 @@
 extern Lisp_Object QCfoundry, QCadstyle, QCregistry;
 
 extern Lisp_Object Vfont_log;
-extern void font_add_log (char *, Lisp_Object, Lisp_Object);
-extern void font_deferred_log (char *, Lisp_Object, Lisp_Object);
+extern void font_add_log (const char *, Lisp_Object, Lisp_Object);
+extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object);
 
 #define FONT_ADD_LOG(ACTION, ARG, RESULT)	\
   do {						\
--- a/src/frame.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/frame.c	Sun Aug 08 22:52:25 2010 +0000
@@ -2770,11 +2770,11 @@
    that is an index in this table.  */
 
 struct frame_parm_table {
-  char *name;
+  const char *name;
   Lisp_Object *variable;
 };
 
-static struct frame_parm_table frame_parms[] =
+static const struct frame_parm_table frame_parms[] =
 {
   {"auto-raise",		&Qauto_raise},
   {"auto-lower",		&Qauto_lower},
--- a/src/ftfont.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/ftfont.c	Sun Aug 08 22:52:25 2010 +0000
@@ -96,11 +96,11 @@
 static struct
 {
   /* registry name */
-  char *name;
+  const char *name;
   /* characters to distinguish the charset from the others */
   int uniquifier[6];
   /* additional constraint by language */
-  char *lang;
+  const char *lang;
   /* set on demand */
   FcCharSet *fc_charset;
 } fc_charset_table[] =
@@ -691,12 +691,8 @@
   return spec;
 }
 
-static FcPattern *ftfont_spec_pattern (Lisp_Object, char *,
-                                       struct OpenTypeSpec **,
-                                       char **langname);
-
 static FcPattern *
-ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **otspec, char **langname)
+ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **otspec, const char **langname)
 {
   Lisp_Object tmp, extra;
   FcPattern *pattern = NULL;
@@ -866,7 +862,7 @@
   char otlayout[15];		/* For "otlayout:XXXX" */
   struct OpenTypeSpec *otspec = NULL;
   int spacing = -1;
-  char *langname = NULL;
+  const char *langname = NULL;
 
   if (! fc_initialized)
     {
@@ -1057,7 +1053,7 @@
   FcResult result;
   char otlayout[15];		/* For "otlayout:XXXX" */
   struct OpenTypeSpec *otspec = NULL;
-  char *langname = NULL;
+  const char *langname = NULL;
 
   if (! fc_initialized)
     {
@@ -2630,7 +2626,7 @@
 
         if (strcmp (ftfont_booleans[i], keystr) == 0)
           {
-            char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
+            const char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
             if (INTEGERP (val)) str = XINT (val) != 0 ? "true" : "false";
             if (str == NULL) str = "true";
 
--- a/src/gtkutil.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/gtkutil.c	Sun Aug 08 22:52:25 2010 +0000
@@ -291,7 +291,6 @@
 {
   Lisp_Object specified_file = Qnil;
   Lisp_Object tail;
-  extern Lisp_Object QCfile;
 
   for (tail = XCDR (image);
        NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail));
@@ -2371,7 +2370,7 @@
    Returns the widget created.  */
 
 GtkWidget *
-xg_create_widget (char *type, char *name, FRAME_PTR f, widget_value *val,
+xg_create_widget (const char *type, const char *name, FRAME_PTR f, widget_value *val,
                   GCallback select_cb, GCallback deactivate_cb,
 		  GCallback highlight_cb)
 {
@@ -3234,7 +3233,7 @@
                       struct scroll_bar *bar,
                       GCallback scroll_callback,
                       GCallback end_callback,
-                      char *scroll_bar_name)
+                      const char *scroll_bar_name)
 {
   GtkWidget *wscroll;
   GtkWidget *webox;
--- a/src/gtkutil.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/gtkutil.h	Sun Aug 08 22:52:25 2010 +0000
@@ -135,8 +135,8 @@
 
 extern char *xg_get_font_name (FRAME_PTR f, char *);
 
-extern GtkWidget *xg_create_widget (char *type,
-                                    char *name,
+extern GtkWidget *xg_create_widget (const char *type,
+                                    const char *name,
                                     FRAME_PTR f,
                                     widget_value *val,
                                     GCallback select_cb,
@@ -163,7 +163,7 @@
                                   struct scroll_bar *bar,
                                   GCallback scroll_callback,
                                   GCallback end_callback,
-                                  char *scroll_bar_name);
+                                  const char *scroll_bar_name);
 extern void xg_remove_scroll_bar (FRAME_PTR f, int scrollbar_id);
 
 extern void xg_update_scrollbar_pos (FRAME_PTR f,
--- a/src/image.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/image.c	Sun Aug 08 22:52:25 2010 +0000
@@ -126,6 +126,9 @@
 
 Lisp_Object Vx_bitmap_file_path;
 
+/* The symbol `postscript' identifying images of this type.  */
+
+Lisp_Object Qpostscript;
 
 static void x_disable_image (struct frame *, struct image *);
 static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
@@ -595,7 +598,7 @@
 
 static Lisp_Object define_image_type (struct image_type *type, int loaded);
 static struct image_type *lookup_image_type (Lisp_Object symbol);
-static void image_error (char *format, Lisp_Object, Lisp_Object);
+static void image_error (const char *format, Lisp_Object, Lisp_Object);
 static void x_laplace (struct frame *, struct image *);
 static void x_emboss (struct frame *, struct image *);
 static int x_build_heuristic_mask (struct frame *, struct image *,
@@ -696,7 +699,7 @@
    therefore simply displays a message.  */
 
 static void
-image_error (char *format, Lisp_Object arg1, Lisp_Object arg2)
+image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
 {
   add_to_log (format, arg1, arg2);
 }
@@ -728,7 +731,7 @@
 struct image_keyword
 {
   /* Name of keyword.  */
-  char *name;
+  const char *name;
 
   /* The type of value allowed.  */
   enum image_value_type type;
@@ -1756,8 +1759,6 @@
   /* If not found, create a new image and cache it.  */
   if (img == NULL)
     {
-      extern Lisp_Object Qpostscript;
-
       BLOCK_INPUT;
       img = make_image (spec, hash);
       cache_image (f, img);
@@ -3658,9 +3659,10 @@
    length of the corresponding token, respectively.  */
 
 static int
-xpm_scan (s, end, beg, len)
-     const unsigned char **s, *end, **beg;
-     int *len;
+xpm_scan (const unsigned char **s,
+          const unsigned char *end,
+          const unsigned char **beg,
+          int *len)
 {
   int c;
 
@@ -3724,9 +3726,13 @@
    hash table is used.  */
 
 static Lisp_Object
-xpm_make_color_table_v (put_func, get_func)
-     void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
-     Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
+xpm_make_color_table_v (void (**put_func) (Lisp_Object,
+                                           const unsigned char *,
+                                           int,
+                                           Lisp_Object),
+                        Lisp_Object (**get_func) (Lisp_Object,
+                                                  const unsigned char *,
+                                                  int))
 {
   *put_func = xpm_put_color_table_v;
   *get_func = xpm_get_color_table_v;
@@ -3734,28 +3740,30 @@
 }
 
 static void
-xpm_put_color_table_v (color_table, chars_start, chars_len, color)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
-     Lisp_Object color;
+xpm_put_color_table_v (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len,
+                       Lisp_Object color)
 {
   XVECTOR (color_table)->contents[*chars_start] = color;
 }
 
 static Lisp_Object
-xpm_get_color_table_v (color_table, chars_start, chars_len)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
+xpm_get_color_table_v (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len)
 {
   return XVECTOR (color_table)->contents[*chars_start];
 }
 
 static Lisp_Object
-xpm_make_color_table_h (put_func, get_func)
-     void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
-     Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
+xpm_make_color_table_h (void (**put_func) (Lisp_Object,
+                                           const unsigned char *,
+                                           int,
+                                           Lisp_Object),
+                        Lisp_Object (**get_func) (Lisp_Object,
+                                                  const unsigned char *,
+                                                  int))
 {
   *put_func = xpm_put_color_table_h;
   *get_func = xpm_get_color_table_h;
@@ -3766,11 +3774,10 @@
 }
 
 static void
-xpm_put_color_table_h (color_table, chars_start, chars_len, color)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
-     Lisp_Object color;
+xpm_put_color_table_h (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len,
+                       Lisp_Object color)
 {
   struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
   unsigned hash_code;
@@ -3781,10 +3788,9 @@
 }
 
 static Lisp_Object
-xpm_get_color_table_h (color_table, chars_start, chars_len)
-     Lisp_Object color_table;
-     const unsigned char *chars_start;
-     int chars_len;
+xpm_get_color_table_h (Lisp_Object color_table,
+                       const unsigned char *chars_start,
+                       int chars_len)
 {
   struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
   int i = hash_lookup (table, make_unibyte_string (chars_start, chars_len),
@@ -3804,8 +3810,7 @@
 static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
 
 static int
-xpm_str_to_color_key (s)
-     const char *s;
+xpm_str_to_color_key (const char *s)
 {
   int i;
 
@@ -3818,10 +3823,10 @@
 }
 
 static int
-xpm_load_image (f, img, contents, end)
-     struct frame *f;
-     struct image *img;
-     const unsigned char *contents, *end;
+xpm_load_image (struct frame *f,
+                struct image *img,
+                const unsigned char *contents,
+                const unsigned char *end)
 {
   const unsigned char *s = contents, *beg, *str;
   unsigned char buffer[BUFSIZ];
@@ -4053,9 +4058,8 @@
 }
 
 static int
-xpm_load (f, img)
-     struct frame *f;
-     struct image *img;
+xpm_load (struct frame *f,
+          struct image *img)
 {
   int success_p = 0;
   Lisp_Object file_name;
@@ -7739,10 +7743,6 @@
 #define HAVE_GHOSTSCRIPT 1
 #endif /* HAVE_X_WINDOWS */
 
-/* The symbol `postscript' identifying images of this type.  */
-
-Lisp_Object Qpostscript;
-
 #ifdef HAVE_GHOSTSCRIPT
 
 static int gs_image_p (Lisp_Object object);
--- a/src/insdel.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/insdel.c	Sun Aug 08 22:52:25 2010 +0000
@@ -74,6 +74,8 @@
 
 Lisp_Object Qinhibit_modification_hooks;
 
+extern Lisp_Object Vselect_active_regions, Vsaved_region_selection;
+
 
 /* Check all markers in the current buffer, looking for something invalid.  */
 
@@ -2047,6 +2049,20 @@
 	   base_buffer->filename);
 #endif /* not CLASH_DETECTION */
 
+  /* If `select-active-regions' is non-nil, save the region text.  */
+  if (!NILP (Vselect_active_regions)
+      && !NILP (current_buffer->mark_active)
+      && !NILP (Vtransient_mark_mode)
+      && NILP (Vsaved_region_selection))
+    {
+      int b = XINT (Fmarker_position (current_buffer->mark));
+      int e = XINT (make_number (PT));
+      if (b < e)
+	Vsaved_region_selection = make_buffer_string (b, e, 0);
+      else if (b > e)
+	Vsaved_region_selection = make_buffer_string (e, b, 0);
+    }
+
   signal_before_change (start, end, preserve_ptr);
 
   if (current_buffer->newline_cache)
--- a/src/keyboard.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/keyboard.c	Sun Aug 08 22:52:25 2010 +0000
@@ -361,6 +361,15 @@
    X Windows wants this for selection ownership.  */
 unsigned long last_event_timestamp;
 
+/* If non-nil, active regions automatically become the window selection.  */
+Lisp_Object Vselect_active_regions;
+
+/* The text in the active region prior to modifying the buffer.
+   Used by the `select-active-regions' feature.  */
+Lisp_Object Vsaved_region_selection;
+
+Lisp_Object Qx_set_selection, QPRIMARY, Qlazy;
+
 Lisp_Object Qself_insert_command;
 Lisp_Object Qforward_char;
 Lisp_Object Qbackward_char;
@@ -613,7 +622,7 @@
                                         unsigned long);
 #endif
 static Lisp_Object modify_event_symbol (int, unsigned, Lisp_Object,
-                                        Lisp_Object, char **,
+                                        Lisp_Object, const char **,
                                         Lisp_Object *, unsigned);
 static Lisp_Object make_lispy_switch_frame (Lisp_Object);
 static void save_getcjmp (jmp_buf);
@@ -1781,11 +1790,29 @@
 	    Vtransient_mark_mode = Qnil;
 	  else if (EQ (Vtransient_mark_mode, Qonly))
 	    Vtransient_mark_mode = Qidentity;
+	  else if (EQ (Vselect_active_regions, Qlazy)
+		   ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+		   : (!NILP (Vselect_active_regions)
+		      && !NILP (Vtransient_mark_mode)))
+	    {
+	      /* Set window selection.  If `select-active-regions' is
+		 `lazy', only do it for temporarily active regions. */
+	      int beg = XINT (Fmarker_position (current_buffer->mark));
+	      int end = XINT (make_number (PT));
+	      if (beg < end)
+		call2 (Qx_set_selection, QPRIMARY,
+		       make_buffer_string (beg, end, 0));
+	      else if (beg > end)
+		call2 (Qx_set_selection, QPRIMARY,
+		       make_buffer_string (end, beg, 0));
+	    }
 
 	  if (!NILP (Vdeactivate_mark))
 	    call0 (Qdeactivate_mark);
 	  else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
 	    call1 (Vrun_hooks, intern ("activate-mark-hook"));
+
+	  Vsaved_region_selection = Qnil;
 	}
 
     finalize:
@@ -4724,7 +4751,7 @@
 /* This is a list of Lisp names for special "accent" characters.
    It parallels lispy_accent_codes.  */
 
-static char *lispy_accent_keys[] =
+static const char *lispy_accent_keys[] =
 {
   "dead-circumflex",
   "dead-grave",
@@ -4751,7 +4778,7 @@
 #ifdef HAVE_NTGUI
 #define FUNCTION_KEY_OFFSET 0x0
 
-char *lispy_function_keys[] =
+char const *lispy_function_keys[] =
   {
     0,                /* 0                      */
 
@@ -4945,7 +4972,7 @@
 
 /* Some of these duplicate the "Media keys" on newer keyboards,
    but they are delivered to the application in a different way.  */
-static char *lispy_multimedia_keys[] =
+static const char *lispy_multimedia_keys[] =
   {
     0,
     "browser-back",
@@ -5009,7 +5036,7 @@
    the XK_kana_A case below.  */
 #if 0
 #ifdef XK_kana_A
-static char *lispy_kana_keys[] =
+static const char *lispy_kana_keys[] =
   {
     /* X Keysym value */
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	/* 0x400 .. 0x40f */
@@ -5048,7 +5075,7 @@
 
 /* You'll notice that this table is arranged to be conveniently
    indexed by X Windows keysym values.  */
-static char *lispy_function_keys[] =
+static const char *lispy_function_keys[] =
   {
     /* X Keysym value */
 
@@ -5134,7 +5161,7 @@
 /* ISO 9995 Function and Modifier Keys; the first byte is 0xFE.  */
 #define ISO_FUNCTION_KEY_OFFSET 0xfe00
 
-static char *iso_lispy_function_keys[] =
+static const char *iso_lispy_function_keys[] =
   {
     0, 0, 0, 0, 0, 0, 0, 0,	/* 0xfe00 */
     0, 0, 0, 0, 0, 0, 0, 0,	/* 0xfe08 */
@@ -5157,14 +5184,14 @@
 
 Lisp_Object Vlispy_mouse_stem;
 
-static char *lispy_wheel_names[] =
+static const char *lispy_wheel_names[] =
 {
   "wheel-up", "wheel-down", "wheel-left", "wheel-right"
 };
 
 /* drag-n-drop events are generated when a set of selected files are
    dragged from another application and dropped onto an Emacs window.  */
-static char *lispy_drag_n_drop_names[] =
+static const char *lispy_drag_n_drop_names[] =
 {
   "drag-n-drop"
 };
@@ -5175,7 +5202,7 @@
 Lisp_Object Qtop, Qratio;
 
 /* An array of scroll bar parts, indexed by an enum scroll_bar_part value.  */
-Lisp_Object *scroll_bar_parts[] = {
+const Lisp_Object *scroll_bar_parts[] = {
   &Qabove_handle, &Qhandle, &Qbelow_handle,
   &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio
 };
@@ -6542,7 +6569,7 @@
 
 static Lisp_Object
 modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
-		     Lisp_Object name_alist_or_stem, char **name_table,
+		     Lisp_Object name_alist_or_stem, const char **name_table,
 		     Lisp_Object *symbol_table, unsigned int table_size)
 {
   Lisp_Object value;
@@ -11682,6 +11709,13 @@
   Qinput_method_function = intern_c_string ("input-method-function");
   staticpro (&Qinput_method_function);
 
+  Qx_set_selection = intern_c_string ("x-set-selection");
+  staticpro (&Qx_set_selection);
+  QPRIMARY = intern_c_string ("PRIMARY");
+  staticpro (&QPRIMARY);
+  Qlazy = intern_c_string ("lazy");
+  staticpro (&Qlazy);
+
   Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
   staticpro (&Qinput_method_exit_on_first_char);
   Qinput_method_use_echo_area = intern_c_string ("input-method-use-echo-area");
@@ -12289,6 +12323,28 @@
 and tool-bar buttons.  */);
   Venable_disabled_menus_and_buttons = Qnil;
 
+  DEFVAR_LISP ("select-active-regions",
+	       &Vselect_active_regions,
+	       doc: /* If non-nil, an active region automatically becomes the window selection.
+This takes effect only when Transient Mark mode is enabled.
+
+If the value is `lazy', Emacs only sets the window selection during
+`deactivate-mark'; unless the region is temporarily active
+(e.g. mouse-drags or shift-selection), in which case it sets the
+window selection after each command.
+
+For other non-nil value, Emacs sets the window selection after every
+command.  */);
+  Vselect_active_regions = Qlazy;
+
+  DEFVAR_LISP ("saved-region-selection",
+	       &Vsaved_region_selection,
+	       doc: /* Contents of active region prior to buffer modification.
+If `select-active-regions' is non-nil, Emacs sets this to the
+text in the region before modifying the buffer.  The next
+`deactivate-mark' call uses this to set the window selection.  */);
+  Vsaved_region_selection = Qnil;
+
   /* Create the initial keyboard. */
   initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
   init_kboard (initial_kboard);
--- a/src/keyboard.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/keyboard.h	Sun Aug 08 22:52:25 2010 +0000
@@ -485,6 +485,8 @@
    X Windows wants this for selection ownership.  */
 extern unsigned long last_event_timestamp;
 
+extern int quit_char;
+
 extern int parse_menu_item (Lisp_Object, int);
 
 extern void echo_now (void);
@@ -515,9 +517,7 @@
 extern void kbd_buffer_store_event_hold (struct input_event *,
                                          struct input_event *);
 extern void kbd_buffer_unget_event (struct input_event *);
-#ifdef POLL_FOR_INPUT
 extern void poll_for_input_1 (void);
-#endif
 extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
                             Lisp_Object, int);
 extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object,
--- a/src/keymap.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/keymap.c	Sun Aug 08 22:52:25 2010 +0000
@@ -174,13 +174,13 @@
    initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark");  */
 
 void
-initial_define_key (Lisp_Object keymap, int key, char *defname)
+initial_define_key (Lisp_Object keymap, int key, const char *defname)
 {
   store_in_keymap (keymap, make_number (key), intern_c_string (defname));
 }
 
 void
-initial_define_lispy_key (Lisp_Object keymap, char *keyname, char *defname)
+initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname)
 {
   store_in_keymap (keymap, intern_c_string (keyname), intern_c_string (defname));
 }
--- a/src/keymap.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/keymap.h	Sun Aug 08 22:52:25 2010 +0000
@@ -45,8 +45,8 @@
 extern void describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object,
                                char *, int, int, int, int);
 extern int current_minor_maps (Lisp_Object **, Lisp_Object **);
-extern void initial_define_key (Lisp_Object, int, char *);
-extern void initial_define_lispy_key (Lisp_Object, char *, char *);
+extern void initial_define_key (Lisp_Object, int, const char *);
+extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
 extern void syms_of_keymap (void);
 extern void keys_of_keymap (void);
 
--- a/src/lisp.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/lisp.h	Sun Aug 08 22:52:25 2010 +0000
@@ -2395,7 +2395,6 @@
 EXFUN (Fcoding_system_base, 1);
 EXFUN (Fcoding_system_eol_type, 1);
 EXFUN (Fcheck_coding_system, 1);
-EXFUN (Fcheck_coding_system, 1);
 EXFUN (Fread_coding_system, 2);
 EXFUN (Fread_non_nil_coding_system, 1);
 EXFUN (Ffind_operation_coding_system, MANY);
@@ -2548,6 +2547,7 @@
 EXFUN (Ftruncate, 2);
 extern void init_floatfns (void);
 extern void syms_of_floatfns (void);
+extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y);
 
 /* Defined in fringe.c */
 extern void syms_of_fringe (void);
@@ -2821,7 +2821,6 @@
 /* Defined in lread.c */
 extern Lisp_Object Vafter_load_alist;
 extern Lisp_Object Qvariable_documentation, Qstandard_input;
-extern Lisp_Object Qfunction;
 extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
 extern Lisp_Object Vobarray, initial_obarray, Vstandard_input;
 extern int load_in_progress;
@@ -3134,7 +3133,6 @@
 /* Defined in minibuf.c */
 
 extern Lisp_Object Qcompletion_ignore_case;
-extern Lisp_Object Qcompletion_ignore_case;
 extern Lisp_Object Vcompletion_regexp_list;
 extern Lisp_Object Vhistory_length;
 extern Lisp_Object Vminibuffer_list;
@@ -3299,6 +3297,7 @@
 extern Lisp_Object Vinstallation_directory;
 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
 extern Lisp_Object Qfile_name_handler_alist;
+extern void (*fatal_error_signal_hook) (void);
 EXFUN (Fkill_emacs, 1) NO_RETURN;
 #if HAVE_SETLOCALE
 void fixup_locale (void);
@@ -3415,7 +3414,6 @@
 EXFUN (Fprevious_single_property_change, 4);
 EXFUN (Fget_text_property, 3);
 EXFUN (Fput_text_property, 5);
-EXFUN (Fget_text_property, 3);
 EXFUN (Fprevious_char_property_change, 2);
 EXFUN (Fnext_char_property_change, 2);
 extern void report_interval_modification (Lisp_Object, Lisp_Object);
@@ -3538,8 +3536,8 @@
 extern Lisp_Object Qmode_line_inactive, Qvertical_border;
 extern Lisp_Object Qface;
 extern Lisp_Object Qnormal;
-extern Lisp_Object QCfamily, QCweight, QCslant, QCwidth;
-extern Lisp_Object QCheight, QCsize, QCname, QCwidth, QCforeground, QCbackground;
+extern Lisp_Object QCfamily, QCweight, QCslant;
+extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground;
 extern Lisp_Object Vface_alternative_font_family_alist;
 extern Lisp_Object Vface_font_rescale_alist;
 extern Lisp_Object Vface_ignored_fonts;
@@ -3590,6 +3588,11 @@
 void xd_read_queued_messages (void);
 void syms_of_dbusbind (void);
 #endif
+
+#ifdef DOS_NT
+/* Defined in msdos.c, w32.c */
+extern char *emacs_root_dir (void);
+#endif /* DOS_NT */
 
 /* Nonzero means Emacs has already been initialized.
    Used during startup to detect startup of dumped Emacs.  */
--- a/src/makefile.w32-in	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/makefile.w32-in	Sun Aug 08 22:52:25 2010 +0000
@@ -1506,6 +1506,7 @@
 	$(SRC)/systime.h \
 	$(SRC)/termchar.h \
 	$(SRC)/termhooks.h \
+	$(SRC)/termopts.h \
 	$(SRC)/w32gui.h \
 	$(SRC)/w32term.h \
 	$(SRC)/window.h
--- a/src/menu.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/menu.c	Sun Aug 08 22:52:25 2010 +0000
@@ -662,7 +662,7 @@
 	{
 	  /* Create a new pane.  */
 	  Lisp_Object pane_name, prefix;
-	  char *pane_string;
+	  const char *pane_string;
 
 	  panes_seen++;
 
--- a/src/menu.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/menu.h	Sun Aug 08 22:52:25 2010 +0000
@@ -21,13 +21,18 @@
 
 extern Lisp_Object Vmenu_updating_frame;
 
+extern void x_set_menu_bar_lines (struct frame *f,
+                                  Lisp_Object value,
+                                  Lisp_Object oldval);
+
 extern void init_menu_items (void);
 extern void finish_menu_items (void);
 extern void discard_menu_items (void);
 extern void save_menu_items (void);
 extern int parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void list_of_panes (Lisp_Object);
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
+  || defined (HAVE_NS)
 extern void free_menubar_widget_value_tree (widget_value *);
 extern void update_submenu_strings (widget_value *);
 extern void find_and_call_menu_selection (FRAME_PTR, int,
--- a/src/minibuf.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/minibuf.c	Sun Aug 08 22:52:25 2010 +0000
@@ -2080,7 +2080,8 @@
   staticpro (&Qread_expression_history);
 
   DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
-	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.  */);
+	       doc: /* If this is non-nil, `read-buffer' does its work by calling this function.
+The function is called with the arguments passed to `read-buffer'.  */);
   Vread_buffer_function = Qnil;
 
   DEFVAR_BOOL ("read-buffer-completion-ignore-case",
--- a/src/msdos.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/msdos.c	Sun Aug 08 22:52:25 2010 +0000
@@ -1453,7 +1453,6 @@
 	/* Look for a `help-echo' property.  */
 	{
 	  Lisp_Object help;
-	  extern Lisp_Object Qhelp_echo;
 
 	  /* Check overlays first.  */
 	  help = Qnil;
@@ -1593,14 +1592,16 @@
       ScreenSetCursor (current_pos_Y, current_pos_X);
       cursor_cleared = 0;
       if (tty->termscript)
-	fprintf (tty->termscript, "\nCURSOR ON");
+	fprintf (tty->termscript, "\nCURSOR ON (%dx%d)",
+		 current_pos_Y, current_pos_X);
     }
   else if (!on && !cursor_cleared)
     {
       ScreenSetCursor (-1, -1);
       cursor_cleared = 1;
       if (tty->termscript)
-	fprintf (tty->termscript, "\nCURSOR OFF");
+	fprintf (tty->termscript, "\nCURSOR OFF (%dx%d)",
+		 current_pos_Y, current_pos_X);
     }
 }
 
--- a/src/nsfns.m	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsfns.m	Sun Aug 08 22:52:25 2010 +0000
@@ -125,7 +125,7 @@
 
 /* Nonzero if we can use mouse menus. */
 int
-have_menus_p ()
+have_menus_p (void)
 {
   return NSApp != nil;
 }
@@ -240,8 +240,7 @@
 /* Return the X display structure for the display named NAME.
    Open a new connection if necessary.  */
 struct ns_display_info *
-ns_display_info_for_name (name)
-     Lisp_Object name;
+ns_display_info_for_name (Lisp_Object name)
 {
   Lisp_Object names;
   struct ns_display_info *dpyinfo;
@@ -925,9 +924,7 @@
 
 /* This is the same as the xfns.c definition.  */
 void
-x_set_cursor_type (f, arg, oldval)
-     FRAME_PTR f;
-     Lisp_Object arg, oldval;
+x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
 {
   set_frame_cursor_types (f, arg);
 
@@ -949,7 +946,7 @@
 #define Xstr(x) Str(x)
 
 static Lisp_Object
-ns_appkit_version_str ()
+ns_appkit_version_str (void)
 {
   char tmp[80];
 
@@ -968,7 +965,7 @@
    have into a single int.  For a better picture of the implementation
    running, use ns_appkit_version_str.*/
 static int
-ns_appkit_version_int ()
+ns_appkit_version_int (void)
 {
 #ifdef NS_IMPL_GNUSTEP
   return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
@@ -2004,8 +2001,7 @@
    string or a number containing the resulting script value.  Otherwise,
    1 is returned. */
 static int
-ns_do_applescript (script, result)
-     Lisp_Object script, *result;
+ns_do_applescript (Lisp_Object script, Lisp_Object *result)
 {
   NSAppleEventDescriptor *desc;
   NSDictionary* errorDict;
@@ -2108,8 +2104,7 @@
 
 
 void
-x_set_scroll_bar_default_width (f)
-     struct frame *f;
+x_set_scroll_bar_default_width (struct frame *f)
 {
   int wid = FRAME_COLUMN_WIDTH (f);
   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT;
@@ -2189,7 +2184,7 @@
 
 
 void
-x_sync (Lisp_Object frame)
+x_sync (struct frame *f)
 {
   /* XXX Not implemented XXX */
   return;
@@ -2367,11 +2362,14 @@
 
 /* TODO: move to xdisp or similar */
 static void
-compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
-     struct frame *f;
-     Lisp_Object parms, dx, dy;
-     int width, height;
-     int *root_x, *root_y;
+compute_tip_xy (struct frame *f,
+                Lisp_Object parms,
+                Lisp_Object dx,
+                Lisp_Object dy,
+                int width,
+                int height,
+                int *root_x,
+                int *root_y)
 {
   Lisp_Object left, top;
   EmacsView *view = FRAME_NS_VIEW (f);
@@ -2595,7 +2593,7 @@
 
 
 void
-syms_of_nsfns ()
+syms_of_nsfns (void)
 {
   int i;
 
--- a/src/nsfont.m	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsfont.m	Sun Aug 08 22:52:25 2010 +0000
@@ -223,7 +223,7 @@
 
 /* Default font entity. */
 static Lisp_Object
-ns_fallback_entity ()
+ns_fallback_entity (void)
 {
   return ns_descriptor_to_entity ([[NSFont userFixedPitchFontOfSize: 0]
       fontDescriptor], Qnil, NULL);
@@ -1510,7 +1510,7 @@
 
 
 void
-syms_of_nsfont ()
+syms_of_nsfont (void)
 {
   nsfont_driver.type = Qns;
   register_font_driver (&nsfont_driver, NULL);
--- a/src/nsimage.m	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsimage.m	Sun Aug 08 22:52:25 2010 +0000
@@ -83,11 +83,11 @@
 ns_load_image (struct frame *f, struct image *img,
                Lisp_Object spec_file, Lisp_Object spec_data)
 {
-  NSTRACE (ns_load_image);
-
   EmacsImage *eImg;
   NSSize size;
 
+  NSTRACE (ns_load_image);
+
   if (NILP (spec_data))
     {
       eImg = [EmacsImage allocInitFromFile: spec_file];
--- a/src/nsmenu.m	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsmenu.m	Sun Aug 08 22:52:25 2010 +0000
@@ -105,7 +105,7 @@
 
 
 int
-popup_activated ()
+popup_activated (void)
 {
   return popup_activated_flag;
 }
@@ -509,8 +509,7 @@
 
 /* Utility (from macmenu.c): is this item a separator? */
 static int
-name_is_separator (name)
-     const char *name;
+name_is_separator ( const char *name)
 {
   const char *start = name;
 
@@ -737,19 +736,21 @@
                  keymaps: (int)keymaps
 {
   EmacsView *view = FRAME_NS_VIEW (f);
+  NSEvent *e, *event;
+  long retVal;
+
 /*   p = [view convertPoint:p fromView: nil]; */
   p.y = NSHeight ([view frame]) - p.y;
-  NSEvent *e = [[view window] currentEvent];
-  NSEvent *event = [NSEvent mouseEventWithType: NSRightMouseDown
-                                      location: p
-                                 modifierFlags: 0
-                                     timestamp: [e timestamp]
-                                  windowNumber: [[view window] windowNumber]
-                                       context: [e context]
-                                   eventNumber: 0/*[e eventNumber] */
-                                    clickCount: 1
-                                      pressure: 0];
-  long retVal;
+  e = [[view window] currentEvent];
+   event = [NSEvent mouseEventWithType: NSRightMouseDown
+                              location: p
+                         modifierFlags: 0
+                             timestamp: [e timestamp]
+                          windowNumber: [[view window] windowNumber]
+                               context: [e context]
+                           eventNumber: 0/*[e eventNumber] */
+                            clickCount: 1
+                              pressure: 0];
 
   context_menu_value = -1;
   [NSMenu popUpContextMenu: self withEvent: event forView: view];
@@ -1801,7 +1802,7 @@
    ========================================================================== */
 
 void
-syms_of_nsmenu ()
+syms_of_nsmenu (void)
 {
   defsubr (&Sx_popup_dialog);
   defsubr (&Sns_reset_menu);
--- a/src/nsterm.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsterm.h	Sun Aug 08 22:52:25 2010 +0000
@@ -21,6 +21,7 @@
 #include "frame.h"
 #include "character.h"
 #include "font.h"
+#include "sysselect.h"
 
 #ifdef HAVE_NS
 
@@ -712,7 +713,9 @@
 extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg);
 
 extern int
-ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
+ns_defined_color (struct frame *f,
+                  const char *name,
+                  XColor *color_def, int alloc,
                   char makeIndex);
 extern void
 ns_query_color (void *col, XColor *color_def, int setPixel);
@@ -742,10 +745,34 @@
 extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
                                     Lisp_Object header);
 
-/* two more prototypes that should be moved to a more general include file */
+/* More prototypes that should be moved to a more general include file */
 extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
 extern void x_set_window_size (struct frame *f, int change_grav,
                               int cols, int rows);
+extern void x_sync (struct frame *);
+extern Lisp_Object x_get_focus_frame (struct frame *);
+extern void x_set_mouse_position (struct frame *f, int h, int v);
+extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
+extern void x_iconify_frame (struct frame *f);
+extern int x_char_width (struct frame *f);
+extern int x_char_height (struct frame *f);
+extern int x_pixel_width (struct frame *f);
+extern int x_pixel_height (struct frame *f);
+extern void x_set_frame_alpha (struct frame *f);
+extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_tool_bar_lines (struct frame *f,
+                                  Lisp_Object value,
+                                  Lisp_Object oldval);
+extern void x_activate_menubar (struct frame *);
+extern void free_frame_menubar (struct frame *);
+
+extern void ns_init_paths (void);
+extern void syms_of_nsterm (void);
+extern void syms_of_nsfns (void);
+extern void syms_of_nsmenu (void);
+extern void syms_of_nsselect (void);
 
 /* From nsimage.m, needed in image.c */
 struct image;
@@ -764,6 +791,8 @@
 extern int x_display_pixel_width (struct ns_display_info *);
 
 /* This in nsterm.m */
+extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
+                      fd_set *exceptfds, struct timeval *timeout);
 extern unsigned long ns_get_rgb_color (struct frame *f,
                                        float r, float g, float b, float a);
 extern NSPoint last_mouse_motion_position;
--- a/src/nsterm.m	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/nsterm.m	Sun Aug 08 22:52:25 2010 +0000
@@ -296,7 +296,7 @@
 
 
 void
-ns_init_paths ()
+ns_init_paths (void)
 /* --------------------------------------------------------------------------
    Used to allow emacs to find its resources under Emacs.app
    Called from emacs.c at startup.
@@ -479,7 +479,7 @@
 
 
 void *
-ns_alloc_autorelease_pool ()
+ns_alloc_autorelease_pool (void)
 /* --------------------------------------------------------------------------
      Allocate a pool for temporary objects (callable from C)
    -------------------------------------------------------------------------- */
@@ -790,7 +790,7 @@
 
 
 static void
-ns_ring_bell ()
+ns_ring_bell (struct frame *f)
 /* --------------------------------------------------------------------------
      "Beep" routine
    -------------------------------------------------------------------------- */
@@ -1186,12 +1186,14 @@
      difference between the real width and Emacs' imagined one.  For
      right-hand bars, don't worry about it since the extra is never used.
      (Obviously doesn't work for vertically split windows tho..) */
-  NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
-    ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
-                  - NS_SCROLL_BAR_WIDTH (f), 0)
-    : NSMakePoint (0, 0);
-  [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
-  [view setBoundsOrigin: origin];
+  {
+    NSPoint origin = FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)
+      ? NSMakePoint (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)
+                     - NS_SCROLL_BAR_WIDTH (f), 0)
+      : NSMakePoint (0, 0);
+    [view setFrame: NSMakeRect (0, 0, pixelwidth, pixelheight)];
+    [view setBoundsOrigin: origin];
+  }
 
   change_frame_size (f, rows, cols, 0, 1, 0); /* pretend, delay, safe */
   FRAME_PIXEL_WIDTH (f) = pixelwidth;
@@ -1507,7 +1509,10 @@
 
 
 int
-ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
+ns_defined_color (struct frame *f,
+                  const char *name,
+                  XColor *color_def,
+                  int alloc,
                   char makeIndex)
 /* --------------------------------------------------------------------------
          Return 1 if named color found, and set color_def rgb accordingly.
@@ -2184,9 +2189,8 @@
       int yAdjust = rowY - FRAME_INTERNAL_BORDER_WIDTH (f) < 5 ?
         -FRAME_INTERNAL_BORDER_WIDTH (f) : 0;
       int yIncr = FRAME_PIXEL_HEIGHT (f) - (p->by+yAdjust + p->ny) < 5 ?
-        FRAME_INTERNAL_BORDER_WIDTH (f) : 0;
-      if (yAdjust)
-        yIncr += FRAME_INTERNAL_BORDER_WIDTH (f);
+        FRAME_INTERNAL_BORDER_WIDTH (f) : 0
+        + (yAdjust ? FRAME_INTERNAL_BORDER_WIDTH (f) : 0);
       NSRect r = NSMakeRect (p->bx+xAdjust, p->by+yAdjust, p->nx, p->ny+yIncr);
       NSRectClip (r);
       [ns_lookup_indexed_color(face->background, f) set];
@@ -2375,7 +2379,7 @@
 
 
 void
-hide_hourglass ()
+hide_hourglass (void)
 {
   if (!hourglass_shown_p)
     return;
@@ -3406,16 +3410,14 @@
    ========================================================================== */
 
 int
-x_display_pixel_height (dpyinfo)
-     struct ns_display_info *dpyinfo;
+x_display_pixel_height (struct ns_display_info *dpyinfo)
 {
   NSScreen *screen = [NSScreen mainScreen];
   return [screen frame].size.height;
 }
 
 int
-x_display_pixel_width (dpyinfo)
-     struct ns_display_info *dpyinfo;
+x_display_pixel_width (struct ns_display_info *dpyinfo)
 {
   NSScreen *screen = [NSScreen mainScreen];
   return [screen frame].size.width;
@@ -5743,9 +5745,10 @@
   NSTRACE (judge);
   if (condemned)
     {
+      EmacsView *view;
       BLOCK_INPUT;
       /* ensure other scrollbar updates after deletion */
-      EmacsView *view = (EmacsView *)FRAME_NS_VIEW (frame);
+      view = (EmacsView *)FRAME_NS_VIEW (frame);
       if (view != nil)
         view->scrollbarsNeedingUpdate++;
       [self removeFromSuperview];
@@ -6122,7 +6125,7 @@
 
 
 void
-syms_of_nsterm ()
+syms_of_nsterm (void)
 {
   NSTRACE (syms_of_nsterm);
 
--- a/src/process.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/process.c	Sun Aug 08 22:52:25 2010 +0000
@@ -64,21 +64,15 @@
 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
 #include <fcntl.h>
 #endif /* HAVE_PTYS and no O_NDELAY */
+#if defined(HAVE_NET_IF_H)
+#include <net/if.h>
+#endif /* HAVE_NET_IF_H */
 #endif /* HAVE_SYS_IOCTL_H */
 
 #ifdef NEED_BSDTTY
 #include <bsdtty.h>
 #endif
 
-/* Can we use SIOCGIFCONF and/or SIOCGIFADDR */
-#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_NET_IF_H)
-/* sys/ioctl.h may have been included already */
-#ifndef SIOCGIFADDR
-#include <sys/ioctl.h>
-#endif
-#include <net/if.h>
-#endif
-
 #ifdef HAVE_SYS_WAIT
 #include <sys/wait.h>
 #endif
@@ -89,6 +83,10 @@
 #include <resolv.h>
 #endif
 
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+
 #endif	/* subprocesses */
 
 #include "lisp.h"
@@ -116,7 +114,9 @@
 #if defined (USE_GTK) || defined (HAVE_GCONF)
 #include "xgselect.h"
 #endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
 extern int timers_run;
 
 Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
@@ -6355,8 +6355,7 @@
 {
   int old_errno = errno;
   Lisp_Object proc;
-  register struct Lisp_Process *p;
-  extern EMACS_TIME *input_available_clear_time;
+  struct Lisp_Process *p;
 
   SIGNAL_THREAD_CHECK (signo);
 
--- a/src/process.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/process.h	Sun Aug 08 22:52:25 2010 +0000
@@ -166,6 +166,9 @@
 extern Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
 extern Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtpgid, Qcstime;
 extern Lisp_Object Qtime, Qctime;
+extern Lisp_Object QCport, QCspeed, QCprocess;
+extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
+extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
 
 extern Lisp_Object list_system_processes (void);
 extern Lisp_Object system_process_attributes (Lisp_Object);
--- a/src/s/freebsd.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/s/freebsd.h	Sun Aug 08 22:52:25 2010 +0000
@@ -28,7 +28,6 @@
 #define PENDING_OUTPUT_COUNT(FILE) ((FILE)->_p - (FILE)->_bf._base)
 
 #define HAVE_GETLOADAVG 1
-#define DECLARE_GETPWUID_WITH_UID_T
 
 /* This silences a few compilation warnings.  */
 #undef BSD_SYSTEM
--- a/src/sysdep.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/sysdep.c	Sun Aug 08 22:52:25 2010 +0000
@@ -96,8 +96,6 @@
 #include <memory.h>
 #endif /* USG */
 
-extern int quit_char;
-
 #include "keyboard.h"
 #include "frame.h"
 #include "window.h"
@@ -107,11 +105,12 @@
 #include "dispextern.h"
 #include "process.h"
 #include "cm.h"  /* for reset_sys_modes */
-
-/* For serial_configure and serial_open.  */
-extern Lisp_Object QCport, QCspeed, QCprocess;
-extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
-extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
+#ifdef HAVE_TERM_H
+/* Include this last.  If it is ncurses header file, it adds a lot of
+   defines that interfere with stuff in other headers.  Someone responsible
+   for ncurses messed up bigtime.  See bug#6812.  */
+#include <term.h>
+#endif
 
 #ifdef WINDOWSNT
 #include <direct.h>
--- a/src/term.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/term.c	Sun Aug 08 22:52:25 2010 +0000
@@ -34,6 +34,9 @@
 #if HAVE_TERMIOS_H
 #include <termios.h>		/* For TIOCNOTTY. */
 #endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
 
 #include <signal.h>
 #include <stdarg.h>
@@ -1263,7 +1266,7 @@
      other keys (as on the IBM PC keyboard) they get overridden.
   */
 
-static struct fkey_table keys[] =
+static const struct fkey_table keys[] =
 {
   {"kh", "home"},	/* termcap */
   {"kl", "left"},	/* termcap */
@@ -2903,7 +2906,6 @@
 	/* Look for a `help-echo' property.  */
 	{
 	  Lisp_Object help;
-	  extern Lisp_Object Qhelp_echo;
 
 	  /* Check overlays first.  */
 	  help = Qnil;
--- a/src/unexmacosx.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/unexmacosx.c	Sun Aug 08 22:52:25 2010 +0000
@@ -305,7 +305,7 @@
 }
 
 static void
-print_region_list ()
+print_region_list (void)
 {
   struct region_t *r;
 
@@ -316,7 +316,7 @@
 }
 
 static void
-print_regions ()
+print_regions (void)
 {
   task_t target_task = mach_task_self ();
   vm_address_t address = (vm_address_t) 0;
@@ -346,7 +346,7 @@
    cannot be omitted because they some regions created at run time are
    read-only.  */
 static void
-build_region_list ()
+build_region_list (void)
 {
   task_t target_task = mach_task_self ();
   vm_address_t address = (vm_address_t) 0;
@@ -465,7 +465,7 @@
 }
 
 static void
-find_emacs_zone_regions ()
+find_emacs_zone_regions (void)
 {
   num_unexec_regions = 0;
 
@@ -495,7 +495,7 @@
 }
 
 static void
-unexec_regions_merge ()
+unexec_regions_merge (void)
 {
   int i, n;
   unexec_region_info r;
@@ -627,7 +627,7 @@
    the global array lca.  Store the total number of load commands in
    global variable nlc.  */
 static void
-read_load_commands ()
+read_load_commands (void)
 {
   int i;
 
@@ -684,8 +684,8 @@
 	}
     }
 
-  printf ("Highest address of load commands in input file: %#8x\n",
-	  infile_lc_highest_addr);
+  printf ("Highest address of load commands in input file: %#8lx\n",
+	  (unsigned long)infile_lc_highest_addr);
 
   printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n",
 	  text_seg_lowest_offset);
@@ -1143,7 +1143,7 @@
 /* Loop through all load commands and dump them.  Then write the Mach
    header.  */
 static void
-dump_it ()
+dump_it (void)
 {
   int i;
   long linkedit_delta = 0;
@@ -1253,7 +1253,7 @@
 
 
 void
-unexec_init_emacs_zone ()
+unexec_init_emacs_zone (void)
 {
   emacs_zone = malloc_create_zone (0, 0);
   malloc_set_zone_name (emacs_zone, "EmacsZone");
--- a/src/w32.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/w32.c	Sun Aug 08 22:52:25 2010 +0000
@@ -140,10 +140,6 @@
 
 /* For serial_configure and serial_open.  */
 #include "process.h"
-/* From process.c  */
-extern Lisp_Object QCport, QCspeed, QCprocess;
-extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
-extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
 
 typedef HRESULT (WINAPI * ShGetFolderPath_fn)
   (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
--- a/src/w32fns.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/w32fns.c	Sun Aug 08 22:52:25 2010 +0000
@@ -7053,7 +7053,7 @@
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
 	       doc: /* Maximum size for tooltips.
-Value is a pair (COLUMNS . ROWS). Text larger than this is clipped.  */);
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
--- a/src/window.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/window.c	Sun Aug 08 22:52:25 2010 +0000
@@ -51,7 +51,6 @@
 #include "nsterm.h"
 #endif
 
-
 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
 Lisp_Object Qdisplay_buffer;
 Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
--- a/src/xdisp.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xdisp.c	Sun Aug 08 22:52:25 2010 +0000
@@ -430,7 +430,7 @@
 Lisp_Object Qrect, Qcircle, Qpoly;
 
 /* Tool bar styles */
-Lisp_Object Qtext, Qboth, Qboth_horiz, Qtext_image_horiz;
+Lisp_Object Qboth, Qboth_horiz, Qtext_image_horiz;
 
 /* Non-zero means print newline to stdout before next mini-buffer
    message.  */
@@ -992,12 +992,12 @@
 static int display_mode_lines (struct window *);
 static int display_mode_line (struct window *, enum face_id, Lisp_Object);
 static int display_mode_element (struct it *, int, int, int, Lisp_Object, Lisp_Object, int);
-static int store_mode_line_string (char *, Lisp_Object, int, int, int, Lisp_Object);
-static char *decode_mode_spec (struct window *, int, int, int,
-                               Lisp_Object *);
+static int store_mode_line_string (const char *, Lisp_Object, int, int, int, Lisp_Object);
+static const char *decode_mode_spec (struct window *, int, int, int,
+				     Lisp_Object *);
 static void display_menu_bar (struct window *);
 static int display_count_lines (int, int, int, int, int *);
-static int display_string (unsigned char *, Lisp_Object, Lisp_Object,
+static int display_string (const unsigned char *, Lisp_Object, Lisp_Object,
                            EMACS_INT, EMACS_INT, struct it *, int, int, int, int);
 static void compute_line_metrics (struct it *);
 static void run_redisplay_end_trigger_hook (struct it *);
@@ -1020,7 +1020,7 @@
 static void load_overlay_strings (struct it *, int);
 static int init_from_display_pos (struct it *, struct window *,
                                   struct display_pos *);
-static void reseat_to_string (struct it *, unsigned char *,
+static void reseat_to_string (struct it *, const unsigned char *,
                               Lisp_Object, int, int, int, int);
 static enum move_it_result
        move_it_in_display_line_to (struct it *, EMACS_INT, int,
@@ -1035,8 +1035,8 @@
 static struct text_pos string_pos_nchars_ahead (struct text_pos,
                                                 Lisp_Object, int);
 static struct text_pos string_pos (int, Lisp_Object);
-static struct text_pos c_string_pos (int, unsigned char *, int);
-static int number_of_chars (unsigned char *, int);
+static struct text_pos c_string_pos (int, const unsigned char *, int);
+static int number_of_chars (const unsigned char *, int);
 static void compute_stop_pos (struct it *);
 static void compute_string_pos (struct text_pos *, struct text_pos,
                                 Lisp_Object);
@@ -1548,7 +1548,7 @@
    means recognize multibyte characters.  */
 
 static struct text_pos
-c_string_pos (int charpos, unsigned char *s, int multibyte_p)
+c_string_pos (int charpos, const unsigned char *s, int multibyte_p)
 {
   struct text_pos pos;
 
@@ -1580,7 +1580,7 @@
    non-zero means recognize multibyte characters.  */
 
 static int
-number_of_chars (unsigned char *s, int multibyte_p)
+number_of_chars (const unsigned char *s, int multibyte_p)
 {
   int nchars;
 
@@ -5581,7 +5581,7 @@
    calling this function.  */
 
 static void
-reseat_to_string (struct it *it, unsigned char *s, Lisp_Object string,
+reseat_to_string (struct it *it, const unsigned char *s, Lisp_Object string,
 		  int charpos, int precision, int field_width, int multibyte)
 {
   /* No region in strings.  */
@@ -10195,7 +10195,6 @@
       int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
       int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
       int hmargin, vmargin, relief, idx, end;
-      extern Lisp_Object QCrelief, QCmargin, QCconversion;
 
       /* If image is a vector, choose the image according to the
 	 button state.  */
@@ -11353,6 +11352,8 @@
 	  && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val)))
 	{
 	  if (FRAME_WINDOW_P (it->f)
+	      /* FIXME: if ROW->reversed_p is set, this should test
+		 the right fringe, not the left one.  */
 	      && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0)
 	    {
 #ifdef HAVE_WINDOW_SYSTEM
@@ -17381,8 +17382,8 @@
 	  row->ends_at_zv_p = 1;
 	  /* A row that displays right-to-left text must always have
 	     its last face extended all the way to the end of line,
-	     even if this row ends in ZV, because we still write to th
-	     screen left to right.  */
+	     even if this row ends in ZV, because we still write to
+	     the screen left to right.  */
 	  if (row->reversed_p)
 	    extend_face_to_end_of_line (it);
 	  break;
@@ -17799,6 +17800,26 @@
       row->truncated_on_left_p = 1;
     }
 
+  /* Remember the position at which this line ends.
+
+     BIDI Note: any code that needs MATRIX_ROW_START/END_CHARPOS
+     cannot be before the call to find_row_edges below, since that is
+     where these positions are determined. */
+  row->end = it->current;
+  if (!it->bidi_p)
+    {
+      row->minpos = row->start.pos;
+      row->maxpos = row->end.pos;
+    }
+  else
+    {
+      /* ROW->minpos and ROW->maxpos must be the smallest and
+	 `1 + the largest' buffer positions in ROW.  But if ROW was
+	 bidi-reordered, these two positions can be anywhere in the
+	 row, so we must determine them now.  */
+      find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
+    }
+
   /* If the start of this line is the overlay arrow-position, then
      mark this glyph row as the one containing the overlay arrow.
      This is clearly a mess with variable size fonts.  It would be
@@ -17844,22 +17865,6 @@
   /* Compute pixel dimensions of this line.  */
   compute_line_metrics (it);
 
-  /* Remember the position at which this line ends.  */
-  row->end = it->current;
-  if (!it->bidi_p)
-    {
-      row->minpos = row->start.pos;
-      row->maxpos = row->end.pos;
-    }
-  else
-    {
-      /* ROW->minpos and ROW->maxpos must be the smallest and
-	 `1 + the largest' buffer positions in ROW.  But if ROW was
-	 bidi-reordered, these two positions can be anywhere in the
-	 row, so we must determine them now.  */
-      find_row_edges (it, row, min_pos, min_bpos, max_pos, max_bpos);
-    }
-
   /* Record whether this row ends inside an ellipsis.  */
   row->ends_in_ellipsis_p
     = (it->method == GET_FROM_DISPLAY_VECTOR
@@ -18533,7 +18538,7 @@
 		  {
 		    int multibyte;
 		    int bytepos, charpos;
-		    unsigned char *spec;
+		    const unsigned char *spec;
 		    Lisp_Object string;
 
 		    bytepos = percent_position;
@@ -18803,7 +18808,7 @@
  */
 
 static int
-store_mode_line_string (char *string, Lisp_Object lisp_string, int copy_string,
+store_mode_line_string (const char *string, Lisp_Object lisp_string, int copy_string,
 			int field_width, int precision, Lisp_Object props)
 {
   int len;
@@ -19219,7 +19224,7 @@
 
 static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
 
-static char *
+static const char *
 decode_mode_spec (struct window *w, register int c, int field_width,
 		  int precision, Lisp_Object *string)
 {
@@ -19779,7 +19784,7 @@
    Value is the number of columns displayed.  */
 
 static int
-display_string (unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string,
+display_string (const unsigned char *string, Lisp_Object lisp_string, Lisp_Object face_string,
 		EMACS_INT face_string_pos, EMACS_INT start, struct it *it,
 		int field_width, int precision, int max_x, int multibyte)
 {
--- a/src/xfaces.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xfaces.c	Sun Aug 08 22:52:25 2010 +0000
@@ -742,10 +742,9 @@
 /* NS emulation of GCs */
 
 static INLINE GC
-x_create_gc (f, mask, xgcv)
-     struct frame *f;
-     unsigned long mask;
-     XGCValues *xgcv;
+x_create_gc (struct frame *f,
+             unsigned long mask,
+             XGCValues *xgcv)
 {
   GC gc = xmalloc (sizeof (*gc));
   if (gc)
@@ -754,9 +753,7 @@
 }
 
 static INLINE void
-x_free_gc (f, gc)
-     struct frame *f;
-     GC gc;
+x_free_gc (struct frame *f, GC gc)
 {
   xfree (gc);
 }
--- a/src/xfns.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xfns.c	Sun Aug 08 22:52:25 2010 +0000
@@ -501,7 +501,7 @@
 static Lisp_Object x_default_scroll_bar_color_parameter (struct frame *,
                                                          Lisp_Object,
                                                          Lisp_Object,
-                                                         char *, char *,
+                                                         const char *, const char *,
                                                          int);
 
 
@@ -762,10 +762,10 @@
 }
 
 int
-xg_set_icon_from_xpm_data (FRAME_PTR f, char **data)
+xg_set_icon_from_xpm_data (FRAME_PTR f, const char **data)
 {
   int result = 0;
-  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) data);
+  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
 
   if (!pixbuf)
     return 0;
@@ -1003,7 +1003,7 @@
 
   if (FRAME_X_DISPLAY_INFO (f)->invisible_cursor == 0)
     FRAME_X_DISPLAY_INFO (f)->invisible_cursor = make_invisible_cursor (f);
-  
+
   if (cursor != x->text_cursor
       && x->text_cursor != 0)
     XFreeCursor (dpy, x->text_cursor);
@@ -1767,7 +1767,7 @@
 static Lisp_Object
 x_default_scroll_bar_color_parameter (struct frame *f,
 				      Lisp_Object alist, Lisp_Object prop,
-				      char *xprop, char *xclass,
+				      const char *xprop, const char *xclass,
 				      int foreground_p)
 {
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
@@ -2138,7 +2138,7 @@
 	}
       if (! xfs)
 	{
-	  char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
+	  const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*";
 
 	  missing_list = NULL;
 	  xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort,
@@ -3011,7 +3011,7 @@
 
   if (! FONTP (font) && ! STRINGP (font))
     {
-      char *names[]
+      const char *names[]
 	= {
 #ifdef HAVE_XFT
 	    /* This will find the normal Xft font.  */
@@ -3740,7 +3740,7 @@
   (Lisp_Object terminal)
 {
   struct x_display_info *dpyinfo = check_x_display_info (terminal);
-  char *vendor = ServerVendor (dpyinfo->display);
+  const char *vendor = ServerVendor (dpyinfo->display);
 
   if (! vendor) vendor = "";
   return build_string (vendor);
@@ -3934,7 +3934,7 @@
 
 static struct visual_class
 {
-  char *name;
+  const char *name;
   int class;
 }
 visual_classes[] =
@@ -5598,7 +5598,7 @@
   font_param = Ffont_get (font, intern (":name"));
   if (STRINGP (font_param))
     default_name = xstrdup (SDATA (font_param));
-  else 
+  else
     {
       font_param = Fframe_parameter (frame, Qfont_param);
       if (STRINGP (font_param))
@@ -5609,7 +5609,7 @@
     default_name = xstrdup (x_last_font_name);
 
   /* Convert fontconfig names to Gtk names, i.e. remove - before number */
-  if (default_name) 
+  if (default_name)
     {
       char *p = strrchr (default_name, '-');
       if (p)
@@ -5870,8 +5870,8 @@
   Vx_cursor_fore_pixel = Qnil;
 
   DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
-    doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
-Text larger than this is clipped.  */);
+    doc: /* Maximum size for tooltips.
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
   DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
--- a/src/xfont.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xfont.c	Sun Aug 08 22:52:25 2010 +0000
@@ -334,7 +334,7 @@
 }
 
 static Lisp_Object
-xfont_list_pattern (Display *display, char *pattern,
+xfont_list_pattern (Display *display, const char *pattern,
 		    Lisp_Object registry, Lisp_Object script)
 {
   Lisp_Object list = Qnil;
--- a/src/xrdb.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xrdb.c	Sun Aug 08 22:52:25 2010 +0000
@@ -20,9 +20,7 @@
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef emacs
 #include <config.h>
-#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -52,36 +50,11 @@
 
 extern char *getenv (const char *);
 
-/* This does cause trouble on AIX.  I'm going to take the comment at
-   face value.  */
-#if 0
-extern short getuid ();		/* If this causes portability problems,
-				   I think we should just delete it; it'll
-				   default to `int' anyway.  */
-#endif
-
-#ifdef DECLARE_GETPWUID_WITH_UID_T
-extern struct passwd *getpwuid (uid_t);
-extern struct passwd *getpwnam (const char *);
-#else
 extern struct passwd *getpwuid (uid_t);
 extern struct passwd *getpwnam (const char *);
-#endif
 
 extern char *get_system_name (void);
 
-/* Make sure not to #include anything after these definitions.  Let's
-   not step on anyone's prototypes.  */
-#ifdef emacs
-/* darwin.h may have already defined these.  */
-#undef malloc
-#undef realloc
-#undef free
-#define malloc xmalloc
-#define realloc xrealloc
-#define free xfree
-#endif
-
 char *x_get_string_resource (XrmDatabase rdb, const char *name,
 			     const char *class);
 static int file_p (const char *filename);
@@ -114,7 +87,7 @@
 
   if (result)
     {
-      char *copy = (char *) malloc (strlen (result) + 1);
+      char *copy = (char *) xmalloc (strlen (result) + 1);
       strcpy (copy, result);
       return copy;
     }
@@ -159,7 +132,7 @@
   char *lang = getenv ("LANG");
 
   int path_size = 100;
-  char *path = (char *) malloc (path_size);
+  char *path = (char *) xmalloc (path_size);
   int path_len = 0;
 
   const char *p = string;
@@ -210,7 +183,7 @@
 	      case 'l':
 		if (! lang)
 		  {
-		    free (path);
+		    xfree (path);
 		    return NULL;
 		  }
 
@@ -220,7 +193,7 @@
 
 	      case 't':
 	      case 'c':
-		free (path);
+		xfree (path);
 		return NULL;
 	      }
 	}
@@ -231,7 +204,7 @@
       if (path_len + next_len + 1 > path_size)
 	{
 	  path_size = (path_len + next_len + 1) * 2;
-	  path = (char *) realloc (path, path_size);
+	  path = (char *) xrealloc (path, path_size);
 	}
 
       memcpy (path + path_len, next, next_len);
@@ -257,7 +230,7 @@
       if (path_len + suffix_len + 1 > path_size)
 	{
 	  path_size = (path_len + suffix_len + 1);
-	  path = (char *) realloc (path, path_size);
+	  path = (char *) xrealloc (path, path_size);
 	}
 
       memcpy (path + path_len, suffix, suffix_len);
@@ -268,7 +241,7 @@
 
   if (! file_p (path))
     {
-      free (path);
+      xfree (path);
       return NULL;
     }
 
@@ -298,7 +271,7 @@
   if (ptr == NULL)
     return xstrdup ("/");
 
-  copy = (char *) malloc (strlen (ptr) + 2);
+  copy = (char *) xmalloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
   strcat (copy, "/");
 
@@ -370,7 +343,7 @@
   if (path)
     {
       db = XrmGetFileDatabase (path);
-      free (path);
+      xfree (path);
     }
 
   return db;
@@ -409,12 +382,12 @@
 	   || (file = search_magic_path (free_it, class, "%N", 0)))))
     {
       XrmDatabase db = XrmGetFileDatabase (file);
-      free (file);
-      free (free_it);
+      xfree (file);
+      xfree (free_it);
       return db;
     }
 
-  free (free_it);
+  xfree (free_it);
   return NULL;
 }
 
@@ -439,12 +412,12 @@
       char *xdefault;
 
       home = gethomedir ();
-      xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults"));
+      xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
       strcpy (xdefault, home);
       strcat (xdefault, ".Xdefaults");
       db = XrmGetFileDatabase (xdefault);
-      free (home);
-      free (xdefault);
+      xfree (home);
+      xfree (xdefault);
     }
 
 #ifdef HAVE_XSCREENRESOURCESTRING
@@ -471,7 +444,7 @@
     {
       home = gethomedir ();
       host = get_system_name ();
-      path = (char *) malloc (strlen (home)
+      path = (char *) xmalloc (strlen (home)
 			      + sizeof (".Xdefaults-")
 			      + strlen (host));
       sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
@@ -480,8 +453,8 @@
 
   db = XrmGetFileDatabase (p);
 
-  free (path);
-  free (home);
+  xfree (path);
+  xfree (home);
 
   return db;
 }
@@ -586,7 +559,7 @@
 
   /* Figure out what the "customization string" is, so we can use it
      to decode paths.  */
-  free (x_customization_string);
+  xfree (x_customization_string);
   x_customization_string
     = x_get_customization_string (user_database, myname, myclass);
 
--- a/src/xselect.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xselect.c	Sun Aug 08 22:52:25 2010 +0000
@@ -2916,7 +2916,7 @@
 \"*selectionTimeout\" resource.  */);
   x_selection_timeout = 0;
 
-  QPRIMARY   = intern_c_string ("PRIMARY");	staticpro (&QPRIMARY);
+  /* QPRIMARY is defined in keyboard.c.  */
   QSECONDARY = intern_c_string ("SECONDARY");	staticpro (&QSECONDARY);
   QSTRING    = intern_c_string ("STRING");	staticpro (&QSTRING);
   QINTEGER   = intern_c_string ("INTEGER");	staticpro (&QINTEGER);
--- a/src/xterm.c	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xterm.c	Sun Aug 08 22:52:25 2010 +0000
@@ -22,11 +22,7 @@
 /* Xt features made by Fred Pierresteguy.  */
 
 #include <config.h>
-
-/* On 4.3 these lose if they come after xterm.h.  */
-/* Putting these at the beginning seems to be standard for other .c files.  */
 #include <signal.h>
-
 #include <stdio.h>
 #include <setjmp.h>
 
@@ -107,11 +103,6 @@
 #include "../lwlib/xlwmenu.h"
 #endif
 
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-
-extern void free_frame_menubar (struct frame *);
-#endif
-
 #ifdef USE_X_TOOLKIT
 #if !defined(NO_EDITRES)
 #define HACK_EDITRES
@@ -4380,7 +4371,7 @@
 static void
 x_create_toolkit_scroll_bar (struct frame *f, struct scroll_bar *bar)
 {
-  char *scroll_bar_name = SCROLL_BAR_NAME;
+  const char *scroll_bar_name = SCROLL_BAR_NAME;
 
   BLOCK_INPUT;
   xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
@@ -7628,7 +7619,6 @@
       /* If DPYINFO is null, this means we didn't open the display
 	 in the first place, so don't try to close it.  */
       {
-        extern void (*fatal_error_signal_hook) (void);
 	fatal_error_signal_hook = x_fatal_error_signal;
 	XtCloseDisplay (dpy);
 	fatal_error_signal_hook = NULL;
--- a/src/xterm.h	Fri Aug 06 03:43:29 2010 +0000
+++ b/src/xterm.h	Sun Aug 08 22:52:25 2010 +0000
@@ -1058,10 +1058,11 @@
 /* Defined in xfns.c */
 
 extern struct x_display_info * check_x_display_info (Lisp_Object frame);
+extern Lisp_Object x_get_focus_frame (struct frame *);
 
 #ifdef USE_GTK
 extern int xg_set_icon (struct frame *, Lisp_Object);
-extern int xg_set_icon_from_xpm_data (struct frame *, char**);
+extern int xg_set_icon_from_xpm_data (struct frame *, const char**);
 #endif /* USE_GTK */
 
 extern void x_real_positions (struct frame *, int *, int *);
--- a/test/ChangeLog	Fri Aug 06 03:43:29 2010 +0000
+++ b/test/ChangeLog	Sun Aug 08 22:52:25 2010 +0000
@@ -1,3 +1,20 @@
+2010-08-08  Ulf Jasper  <ulf.jasper@web.de>
+
+	* icalendar-testsuite.el (icalendar-testsuite-run): Added internal tests.
+	(icalendar-testsuite--trim, icalendar-testsuite--compare-strings)
+	(icalendar-testsuite--run-internal-tests): New.
+	(icalendar-testsuite--test-convert-ordinary-to-ical)
+	(icalendar-testsuite--test-convert-block-to-ical)
+	(icalendar-testsuite--test-convert-anniversary-to-ical)
+	(icalendar-testsuite--test-parse-vtimezone)
+	(icalendar-testsuite--do-test-export): Code formatting.
+	(icalendar-testsuite--test-parse-vtimezone): Doc fix.
+	(icalendar-testsuite--do-test-import)
+	(icalendar-testsuite--do-test-cycle): Use icalendar-testsuite--compare-strings
+	(icalendar-testsuite--run-import-tests): Comment added.
+	(icalendar-testsuite--run-import-tests)
+	(icalendar-testsuite--run-real-world-tests): Fixed expected results.
+
 2010-06-25  Chong Yidong  <cyd@stupidchicken.com>
 
 	* redisplay-testsuite.el (test-redisplay-3): New test.
--- a/test/icalendar-testsuite.el	Fri Aug 06 03:43:29 2010 +0000
+++ b/test/icalendar-testsuite.el	Sun Aug 08 22:52:25 2010 +0000
@@ -33,6 +33,7 @@
 (defun icalendar-testsuite-run ()
   "Run icalendar test suite."
   (interactive)
+  (icalendar-testsuite--run-internal-tests)
   (icalendar-testsuite--run-function-tests)
   (icalendar-testsuite--run-import-tests)
   (icalendar-testsuite--run-export-tests)
@@ -41,6 +42,44 @@
   (message "All icalendar tests finished successfully."))
 
 ;; ======================================================================
+;; internal
+;; ======================================================================
+(defun icalendar-testsuite--trim (string)
+  "Remove leading and trailing whitespace from STRING."
+  (replace-regexp-in-string "[ \t\n]+\\'" ""
+                            (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
+
+(defun icalendar-testsuite--compare-strings (str1 str2)
+  "Compare strings STR1 and STR2.
+Return t if strings are equal, else return substring indicating first difference.
+FIXME: make this a little smarter."
+  (let* ((s1 (icalendar-testsuite--trim str1))
+         (s2 (icalendar-testsuite--trim str2))
+         (result (compare-strings s1 0 nil s2 0 nil))
+         (len (length str2)))
+    (if (numberp result)
+        (if (> result 0)
+            (concat "..." (substring str2 (- result 1)
+                                     (min len (+ (- result 1) 3))) "...")
+          (concat "..." (substring str2 (- (+ result 1))
+                                   (min len  (+ (- (+ result 1)) 3))) "..."))
+      t)))
+
+(defun icalendar-testsuite--run-internal-tests ()
+  "Run icalendar-testsuite internal tests."
+  (assert (equal t (icalendar-testsuite--compare-strings " abcde" "abcde ")))
+  (assert
+   (string= "...def..."
+            (icalendar-testsuite--compare-strings "abcxe" "abcdefghijklmn")))
+  (assert (string= "...xe..."
+                   (icalendar-testsuite--compare-strings "abcde" "abcxe")))
+  (assert (string= "...ddd..."
+           (icalendar-testsuite--compare-strings "abc" "abcdddddd")))
+  (assert (string= "......"
+                   (icalendar-testsuite--compare-strings "abcdefghij" "abc"))))
+  
+
+;; ======================================================================
 ;; Test methods for functions
 ;; ======================================================================
 (defun icalendar-testsuite--run-function-tests ()
@@ -260,7 +299,7 @@
     (assert (string= "subject" (cadr result)))
   
     ;; with time
-    (setq result (icalendar--convert-ordinary-to-ical 
+    (setq result (icalendar--convert-ordinary-to-ical
                   "&?" "&2010 2 15 12:34-23:45 s"))
     (assert (= 2 (length result)))
     (assert (string=  (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
@@ -269,7 +308,7 @@
     (assert (string= "s" (cadr result)))
 
     ;; with time, again -- test bug#5549
-    (setq result (icalendar--convert-ordinary-to-ical 
+    (setq result (icalendar--convert-ordinary-to-ical
                   "x?" "x2010 2 15 0:34-1:45 s"))
     (assert (= 2 (length result)))
     (assert (string=  (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
@@ -312,7 +351,7 @@
   "Test method for `icalendar--convert-block-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-block-to-ical 
+    (setq result (icalendar--convert-block-to-ical
                   "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -325,7 +364,7 @@
   "Test method for `icalendar--convert-cyclic-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-block-to-ical 
+    (setq result (icalendar--convert-block-to-ical
                   "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -338,7 +377,7 @@
   "Test method for `icalendar--convert-anniversary-to-ical'."
   (let* ((calendar-date-style 'iso)
          result)
-    (setq result (icalendar--convert-anniversary-to-ical 
+    (setq result (icalendar--convert-anniversary-to-ical
                   "" "%%(diary-anniversary 1964 6 30) g"))
     (assert (= 2 (length result)))
     (assert (string= (concat
@@ -386,6 +425,7 @@
     ))
 
 (defun icalendar-testsuite--test-parse-vtimezone ()
+  "Test method for `icalendar--parse-vtimezone'."
   (let (vtimezone result)
     (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
 TZID:thename
@@ -406,7 +446,8 @@
     (setq result (icalendar--parse-vtimezone vtimezone))
     (assert (string= "thename" (car result)))
     (message (cdr result))
-    (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" (cdr result)))
+    (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
+                     (cdr result)))
     (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
 TZID:anothername
 BEGIN:STANDARD
@@ -457,7 +498,7 @@
         (icalendar-testsuite--do-test-export input-iso expected-output)))
     (when input-european
       (let ((calendar-month-name-array
-             ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
+             ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
               "September" "Oktober" "November" "Dezember"])
             (calendar-day-name-array
              ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
@@ -511,12 +552,18 @@
 \\s-*$"
                                     nil t)))
         (error
-         "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s"
+         "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s"
          input
          (or (and (match-beginning 1)
-                  (buffer-substring-no-properties (match-beginning 1) (match-end 1)))
+                  (buffer-substring-no-properties (match-beginning 1)
+                                                  (match-end 1)))
              "<nil>")
-         (or expected-output "<nil>"))))
+         (or expected-output "<nil>")
+         (icalendar-testsuite--compare-strings   (or (and (match-beginning 1)
+                  (buffer-substring-no-properties (match-beginning 1)
+                                                  (match-end 1)))
+             "<nil>")
+         (or expected-output "<nil>")))))
     (kill-buffer (find-buffer-visiting temp-file))
     (delete-file temp-file)))
 
@@ -571,11 +618,13 @@
     (icalendar-import-buffer temp-file t t)
     (save-excursion
       (find-file temp-file)
-      (let ((result (buffer-substring-no-properties (point-min) (point-max))))
-        (unless (string-match (concat "^\\s-*" expected-output "\\s-*$")
-                              result)
-          (error "Import test failed! Found `%s'\nbut expected `%s'" result
-                 expected-output)))
+      (let* ((result (buffer-substring-no-properties (point-min) (point-max)))
+             (difference
+              (icalendar-testsuite--compare-strings result
+                                                    expected-output)))
+        (if (stringp difference)
+          (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
+                 result expected-output difference)))
       (kill-buffer (find-buffer-visiting temp-file))
       (delete-file temp-file))))
 
@@ -626,9 +675,12 @@
       (when (re-search-forward "\nUID:.*\n" nil t)
         (replace-match "\n"))
       (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
-        (unless (string-equal org-input cycled)
-          (error "Import test failed! Found `%s'\nbut expected `%s'" cycled
-                 org-input))))
+        (let ((difference (icalendar-testsuite--compare-strings cycled
+                                                                org-input)))
+          (if (stringp difference)
+              (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
+                     cycled org-input difference)))
+        ))
 
     ;; clean up -- Note this is done only if test is passed
     (kill-buffer (find-buffer-visiting temp-diary))
@@ -660,6 +712,7 @@
    "&9/19/2003 non-recurring allday")
 
   (icalendar-testsuite--test-import
+   ;; do not remove the trailing blank after "long"!
    "SUMMARY:long 
  summary
 DTSTART;VALUE=DATE:20030919"
@@ -678,9 +731,17 @@
 DTEND;VALUE=DATE:20040828
 DTSTAMP:20031103T011641Z
 "
-   "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien"
-   "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien"
-   "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien")
+   "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE
+"
+   "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE
+"
+   "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
+ Status: TENTATIVE
+ Class: PRIVATE")
 
   (icalendar-testsuite--test-import
    "UID
@@ -702,9 +763,15 @@
 LAST-MODIFIED
  :20041118T013640Z
 "
-   "&2004/11/23 14:00-14:30 folded summary"
-   "&23/11/2004 14:00-14:30 folded summary"
-   "&11/23/2004 14:00-14:30 folded summary")
+   "&2004/11/23 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&23/11/2004 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&11/23/2004 14:00-14:30 folded summary
+ Status: TENTATIVE
+ Class: PRIVATE")
   (icalendar-testsuite--test-import
    "UID
  :6161a312-3902-11d9-b512-f764153bb28b
@@ -723,9 +790,15 @@
 DTSTAMP
  :20041118T013641Z
 "
-   "&2004/11/23 14:45-15:45 another example"
-   "&23/11/2004 14:45-15:45 another example"
-   "&11/23/2004 14:45-15:45 another example")
+   "&2004/11/23 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&23/11/2004 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE"
+   "&11/23/2004 14:45-15:45 another example
+ Status: TENTATIVE
+ Class: PRIVATE")
 
   (icalendar-testsuite--test-import
    "SUMMARY:rrule daily
@@ -890,10 +963,55 @@
 SEQUENCE:1
 CREATED:20041127T183329
 "
-   "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29))  Urlaub"
-   "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001))  Urlaub"
-   "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001))  Urlaub")
-  )
+   "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29))  Urlaub
+ Class: PUBLIC"
+   "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001))  Urlaub
+ Class: PUBLIC"
+   "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001))  Urlaub
+ Class: PUBLIC")
+
+  ;;bug#6766 -- multiple byday values in a weekly rrule
+  (icalendar-testsuite--test-import
+"CLASS:PUBLIC
+DTEND;TZID=America/New_York:20100421T120000
+DTSTAMP:20100525T141214Z
+DTSTART;TZID=America/New_York:20100421T113000
+RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
+SEQUENCE:1
+STATUS:CONFIRMED
+SUMMARY:Scrum
+TRANSP:OPAQUE
+UID:8814e3f9-7482-408f-996c-3bfe486a1262
+END:VEVENT
+BEGIN:VEVENT
+CLASS:PUBLIC
+DTSTAMP:20100525T141214Z
+DTSTART;VALUE=DATE:20100422
+DTEND;VALUE=DATE:20100423
+RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
+SEQUENCE:1
+SUMMARY:Tues + Thurs thinking
+TRANSP:OPAQUE
+UID:8814e3f9-7482-408f-996c-3bfe486a1263
+"
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
+ Class: PUBLIC"
+
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
+ Class: PUBLIC"
+
+"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
+ Status: CONFIRMED
+ Class: PUBLIC
+&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
+ Class: PUBLIC")
+)
 
 ;; ======================================================================
 ;; Export tests
@@ -1104,11 +1222,13 @@
    "&9/5/2003 10:30-15:30 On-Site Interview
  Desc: 10:30am - Blah
  Location: Cccc
- Organizer: MAILTO:aaaaaaa@aaaaaaa.com"
+ Organizer: MAILTO:aaaaaaa@aaaaaaa.com
+ Status: CONFIRMED"
    "&5/9/2003 10:30-15:30 On-Site Interview
  Desc: 10:30am - Blah
  Location: Cccc
- Organizer: MAILTO:aaaaaaa@aaaaaaa.com")
+ Organizer: MAILTO:aaaaaaa@aaaaaaa.com
+ Status: CONFIRMED")
 
   ;; 2003-06-18 a
   (icalendar-testsuite--test-import
@@ -1146,11 +1266,13 @@
    "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
  Desc: 753 Zeichen hier radiert
  Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
- Organizer: MAILTO:xxx@xxxxx.com"
+ Organizer: MAILTO:xxx@xxxxx.com
+ Status: CONFIRMED"
    "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
  Desc: 753 Zeichen hier radiert
  Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
- Organizer: MAILTO:xxx@xxxxx.com")
+ Organizer: MAILTO:xxx@xxxxx.com
+ Status: CONFIRMED")
 
   ;; 2003-06-18 b -- uses timezone
   (icalendar-testsuite--test-import
@@ -1188,7 +1310,7 @@
 \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
 LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
-DESCRIPTION:Viele Zeichen standen hier früher
+DESCRIPTION:Viele Zeichen standen hier früher
 SEQUENCE:0
 PRIORITY:5
 CLASS:
@@ -1211,12 +1333,12 @@
 END:VCALENDAR"
    nil
    "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
- Desc: Viele Zeichen standen hier früher
+ Desc: Viele Zeichen standen hier früher
  Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
  Organizer: MAILTO:bbb@bbbbb.com
  Status: CONFIRMED"
    "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
- Desc: Viele Zeichen standen hier früher
+ Desc: Viele Zeichen standen hier früher
  Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
  Organizer: MAILTO:bbb@bbbbb.com
  Status: CONFIRMED")
@@ -1661,9 +1783,13 @@
  :20050128T011209Z"
    nil
    "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
- Desc: abcdef"
+ Desc: abcdef
+ Status: CONFIRMED
+ Class: PRIVATE"
    "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
- Desc: abcdef")
+ Desc: abcdef
+ Status: CONFIRMED
+ Class: PRIVATE")
 
   ;; 2005-03-01 lt
   (icalendar-testsuite--test-import