Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 104000. ------------------------------------------------------------ revno: 104000 author: Teodor Zlatanov committer: Katsumi Yamaoka branch nick: trunk timestamp: Mon 2011-04-25 04:32:07 +0000 message: gnus-registry.el (gnus-registry-ignore-group-p): Don't call `gnus-parameter-registry-ignore' if the *Group* buffer doesn't exist. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-04-24 22:12:21 +0000 +++ lisp/gnus/ChangeLog 2011-04-25 04:32:07 +0000 @@ -1,3 +1,8 @@ +2011-04-25 Teodor Zlatanov + + * gnus-registry.el (gnus-registry-ignore-group-p): Don't call + `gnus-parameter-registry-ignore' if the *Group* buffer doesn't exist. + 2011-04-23 Glenn Morris * gnus-sum.el (gnus-extra-headers): Bump :version. === modified file 'lisp/gnus/gnus-registry.el' --- lisp/gnus/gnus-registry.el 2011-04-23 00:08:28 +0000 +++ lisp/gnus/gnus-registry.el 2011-04-25 04:32:07 +0000 @@ -678,6 +678,7 @@ ;; `gnus-registry-ignored-groups' is a list of lists ;; (it can be a list of regexes) (and (listp (nth 0 gnus-registry-ignored-groups)) + (get-buffer "*Group*") ; in automatic tests this is false (gnus-parameter-registry-ignore group)) (gnus-grep-in-list group ------------------------------------------------------------ revno: 103999 committer: Ted Zlatanov branch nick: quickfixes timestamp: Sun 2011-04-24 20:31:45 -0500 message: Bug fixes and certificate and hostname verification for the Emacs GnuTLS support. * lisp/net/gnutls.el (gnutls-negotiate): Add hostname, verify-flags, verify-error, and verify-hostname-error parameters. Check whether default trustfile exists before going to use it. Add missing argument to gnutls-message-maybe call. Return return value. Reported by Claudio Bley . (open-gnutls-stream): Add usage example. * lisp/net/network-stream.el (network-stream-open-starttls): Give host parameter to `gnutls-negotiate'. (gnutls-negotiate): Adjust `gnutls-negotiate' declaration. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-25 00:31:41 +0000 +++ lisp/ChangeLog 2011-04-25 01:31:45 +0000 @@ -1,3 +1,16 @@ +2011-04-24 Teodor Zlatanov + + * net/gnutls.el (gnutls-negotiate): Add hostname, verify-flags, + verify-error, and verify-hostname-error parameters. Check whether + default trustfile exists before going to use it. Add missing + argument to gnutls-message-maybe call. Return return value. + Reported by Claudio Bley . + (open-gnutls-stream): Add usage example. + + * net/network-stream.el (network-stream-open-starttls): Give host + parameter to `gnutls-negotiate'. + (gnutls-negotiate): Adjust `gnutls-negotiate' declaration. + 2011-04-24 Daniel Colascione * progmodes/cc-engine.el (c-forward-decl-or-cast-1): Use === modified file 'lisp/net/gnutls.el' --- lisp/net/gnutls.el 2011-01-25 04:08:28 +0000 +++ lisp/net/gnutls.el 2011-04-25 01:31:45 +0000 @@ -25,7 +25,8 @@ ;;; Commentary: ;; This package provides language bindings for the GnuTLS library -;; using the corresponding core functions in gnutls.c. +;; using the corresponding core functions in gnutls.c. It should NOT +;; be used directly, only through open-protocol-stream. ;; Simple test: ;; @@ -59,26 +60,76 @@ Fourth arg SERVICE is name of the service desired, or an integer specifying a port number to connect to. +Usage example: + + \(with-temp-buffer + \(open-gnutls-stream \"tls\" + \(current-buffer) + \"your server goes here\" + \"imaps\")) + This is a very simple wrapper around `gnutls-negotiate'. See its documentation for the specific parameters you can use to open a GnuTLS connection, including specifying the credential type, trust and key files, and priority string." - (let ((proc (open-network-stream name buffer host service))) - (gnutls-negotiate proc 'gnutls-x509pki))) + (gnutls-negotiate (open-network-stream name buffer host service) + 'gnutls-x509pki + host)) + +(put 'gnutls-error + 'error-conditions + '(error gnutls-error)) +(put 'gnutls-error + 'error-message "GnuTLS error") (declare-function gnutls-boot "gnutls.c" (proc type proplist)) -(defun gnutls-negotiate (proc type &optional priority-string - trustfiles keyfiles) - "Negotiate a SSL/TLS connection. +(defun gnutls-negotiate (proc type hostname &optional priority-string + trustfiles keyfiles verify-flags + verify-error verify-hostname-error) + "Negotiate a SSL/TLS connection. Returns proc. Signals gnutls-error. TYPE is `gnutls-x509pki' (default) or `gnutls-anon'. Use nil for the default. PROC is a process returned by `open-network-stream'. +HOSTNAME is the remote hostname. It must be a valid string. PRIORITY-STRING is as per the GnuTLS docs, default is \"NORMAL\". TRUSTFILES is a list of CA bundles. -KEYFILES is a list of client keys." +KEYFILES is a list of client keys. + +When VERIFY-HOSTNAME-ERROR is not nil, an error will be raised +when the hostname does not match the presented certificate's host +name. The exact verification algorithm is a basic implementation +of the matching described in RFC2818 (HTTPS), which takes into +account wildcards, and the DNSName/IPAddress subject alternative +name PKIX extension. See GnuTLS' gnutls_x509_crt_check_hostname +for details. When VERIFY-HOSTNAME-ERROR is nil, only a warning +will be issued. + +When VERIFY-ERROR is not nil, an error will be raised when the +peer certificate verification fails as per GnuTLS' +gnutls_certificate_verify_peers2. Otherwise, only warnings will +be shown about the verification failure. + +VERIFY-FLAGS is a numeric OR of verification flags only for +`gnutls-x509pki' connections. See GnuTLS' x509.h for details; +here's a recent version of the list. + + GNUTLS_VERIFY_DISABLE_CA_SIGN = 1, + GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT = 2, + GNUTLS_VERIFY_DO_NOT_ALLOW_SAME = 4, + GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT = 8, + GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 = 16, + GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 32, + GNUTLS_VERIFY_DISABLE_TIME_CHECKS = 64, + GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS = 128, + GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT = 256 + +It must be omitted, a number, or nil; if omitted or nil it +defaults to GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT." (let* ((type (or type 'gnutls-x509pki)) + (default-trustfile "/etc/ssl/certs/ca-certificates.crt") (trustfiles (or trustfiles - '("/etc/ssl/certs/ca-certificates.crt"))) + (when (file-exists-p default-trustfile) + (list default-trustfile)))) (priority-string (or priority-string (cond ((eq type 'gnutls-anon) @@ -86,15 +137,23 @@ ((eq type 'gnutls-x509pki) "NORMAL")))) (params `(:priority ,priority-string + :hostname ,hostname :loglevel ,gnutls-log-level :trustfiles ,trustfiles :keyfiles ,keyfiles + :verify-flags ,verify-flags + :verify-error ,verify-error + :verify-hostname-error ,verify-hostname-error :callbacks nil)) ret) (gnutls-message-maybe (setq ret (gnutls-boot proc type params)) - "boot: %s") + "boot: %s" params) + + (when (gnutls-errorp ret) + ;; This is a error from the underlying C code. + (signal 'gnutls-error (list proc ret))) proc)) === modified file 'lisp/net/network-stream.el' --- lisp/net/network-stream.el 2011-04-12 22:18:02 +0000 +++ lisp/net/network-stream.el 2011-04-25 01:31:45 +0000 @@ -46,7 +46,8 @@ (require 'starttls) (declare-function gnutls-negotiate "gnutls" - (proc type &optional priority-string trustfiles keyfiles)) + (proc type host &optional priority-string trustfiles keyfiles + verify-flags verify-error verify-hostname-error)) ;;;###autoload (defun open-network-stream (name buffer host service &rest parameters) @@ -197,7 +198,7 @@ (network-stream-command stream starttls-command eoc)) ;; The server said it was OK to begin STARTTLS negotiations. (if (fboundp 'open-gnutls-stream) - (gnutls-negotiate stream nil) + (gnutls-negotiate stream nil host) (unless (starttls-negotiate stream) (delete-process stream))) (if (memq (process-status stream) '(open run)) ------------------------------------------------------------ revno: 103998 committer: Ted Zlatanov branch nick: quickfixes timestamp: Sun 2011-04-24 20:30:51 -0500 message: Add GnuTLS support for W32 and certificate and hostname verification in GnuTLS. * src/gnutls.c: Renamed global_initialized to gnutls_global_initialized. Added internals for the :verify-hostname-error, :verify-error, and :verify-flags parameters of `gnutls-boot' and documented those parameters in the docstring. Start callback support. (emacs_gnutls_handshake): Add Woe32 support. Retry handshake unless a fatal error occured. Call gnutls_alert_send_appropriate on error. Return error code. (emacs_gnutls_write): Call emacs_gnutls_handle_error. (emacs_gnutls_read): Likewise. (Fgnutls_boot): Return handshake error code. (emacs_gnutls_handle_error): New function. (wsaerror_to_errno): Likewise. * src/gnutls.h: Add GNUTLS_STAGE_CALLBACKS enum to denote we're in the callbacks stage. * src/w32.c (emacs_gnutls_pull): New function for GnuTLS on Woe32. (emacs_gnutls_push): Likewise. * src/w32.h (emacs_gnutls_pull): Add prototype. (emacs_gnutls_push): Likewise. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 16:59:37 +0000 +++ src/ChangeLog 2011-04-25 01:30:51 +0000 @@ -1,3 +1,38 @@ +2011-04-24 Teodor Zlatanov + + * gnutls.h: Add GNUTLS_STAGE_CALLBACKS enum to denote we're in the + callbacks stage. + + * gnutls.c: Renamed global_initialized to + gnutls_global_initialized. Added internals for the + :verify-hostname-error, :verify-error, and :verify-flags + parameters of `gnutls-boot' and documented those parameters in the + docstring. Start callback support. + (emacs_gnutls_handshake): Add Woe32 support. Retry handshake + unless a fatal error occured. Call gnutls_alert_send_appropriate + on error. Return error code. + (emacs_gnutls_write): Call emacs_gnutls_handle_error. + (emacs_gnutls_read): Likewise. + (Fgnutls_boot): Return handshake error code. + (emacs_gnutls_handle_error): New function. + (wsaerror_to_errno): Likewise. + + * w32.h (emacs_gnutls_pull): Add prototype. + (emacs_gnutls_push): Likewise. + + * w32.c (emacs_gnutls_pull): New function for GnuTLS on Woe32. + (emacs_gnutls_push): Likewise. + +2011-04-24 Claudio Bley (tiny change) + + * process.c (wait_reading_process_output): Check if GnuTLS + buffered some data internally if no FDs are set for TLS + connections. + + * makefile.w32-in (OBJ2): Add gnutls.$(O). + (LIBS): Link to USER_LIBS. + ($(BLD)/gnutls.$(0)): New target. + 2011-04-24 Eli Zaretskii * xdisp.c (handle_single_display_spec): Rename the === modified file 'src/gnutls.c' --- src/gnutls.c 2011-04-16 19:16:40 +0000 +++ src/gnutls.c 2011-04-25 01:30:51 +0000 @@ -26,11 +26,20 @@ #ifdef HAVE_GNUTLS #include +#ifdef WINDOWSNT +#include +#include "w32.h" +#endif + +static int +emacs_gnutls_handle_error (gnutls_session_t, int err); + +Lisp_Object Qgnutls_log_level; Lisp_Object Qgnutls_code; Lisp_Object Qgnutls_anon, Qgnutls_x509pki; Lisp_Object Qgnutls_e_interrupted, Qgnutls_e_again, Qgnutls_e_invalid_session, Qgnutls_e_not_ready_for_handshake; -int global_initialized; +int gnutls_global_initialized; /* The following are for the property list of `gnutls-boot'. */ Lisp_Object Qgnutls_bootprop_priority; @@ -38,8 +47,27 @@ Lisp_Object Qgnutls_bootprop_keyfiles; Lisp_Object Qgnutls_bootprop_callbacks; Lisp_Object Qgnutls_bootprop_loglevel; - -static void +Lisp_Object Qgnutls_bootprop_hostname; +Lisp_Object Qgnutls_bootprop_verify_flags; +Lisp_Object Qgnutls_bootprop_verify_error; +Lisp_Object Qgnutls_bootprop_verify_hostname_error; + +/* Callback keys for `gnutls-boot'. Unused currently. */ +Lisp_Object Qgnutls_bootprop_callbacks_verify; + +static void +gnutls_log_function (int level, const char* string) +{ + message ("gnutls.c: [%d] %s", level, string); +} + +static void +gnutls_log_function2 (int level, const char* string, const char* extra) +{ + message ("gnutls.c: [%d] %s %s", level, string, extra); +} + +static int emacs_gnutls_handshake (struct Lisp_Process *proc) { gnutls_session_t state = proc->gnutls_state; @@ -50,24 +78,55 @@ if (proc->gnutls_initstage < GNUTLS_STAGE_TRANSPORT_POINTERS_SET) { +#ifdef WINDOWSNT + /* On W32 we cannot transfer socket handles between different runtime + libraries, so we tell GnuTLS to use our special push/pull + functions. */ + gnutls_transport_set_ptr2 (state, + (gnutls_transport_ptr_t) proc, + (gnutls_transport_ptr_t) proc); + gnutls_transport_set_push_function (state, &emacs_gnutls_push); + gnutls_transport_set_pull_function (state, &emacs_gnutls_pull); + + /* For non blocking sockets or other custom made pull/push + functions the gnutls_transport_set_lowat must be called, with + a zero low water mark value. (GnuTLS 2.10.4 documentation) + + (Note: this is probably not strictly necessary as the lowat + value is only used when no custom pull/push functions are + set.) */ + gnutls_transport_set_lowat (state, 0); +#else /* This is how GnuTLS takes sockets: as file descriptors passed in. For an Emacs process socket, infd and outfd are the same but we use this two-argument version for clarity. */ gnutls_transport_set_ptr2 (state, - (gnutls_transport_ptr_t) (long) proc->infd, - (gnutls_transport_ptr_t) (long) proc->outfd); + (gnutls_transport_ptr_t) proc->infd, + (gnutls_transport_ptr_t) proc->outfd); +#endif proc->gnutls_initstage = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; } - ret = gnutls_handshake (state); + do + { + ret = gnutls_handshake (state); + emacs_gnutls_handle_error (state, ret); + } + while (ret < 0 && gnutls_error_is_fatal (ret) == 0); + proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED; if (ret == GNUTLS_E_SUCCESS) { - /* here we're finally done. */ + /* Here we're finally done. */ proc->gnutls_initstage = GNUTLS_STAGE_READY; } + else + { + gnutls_alert_send_appropriate (state, ret); + } + return ret; } EMACS_INT @@ -107,6 +166,7 @@ bytes_written += rtnval; } + emacs_gnutls_handle_error (state, rtnval); return (bytes_written); } @@ -122,19 +182,68 @@ emacs_gnutls_handshake (proc); return -1; } - rtnval = gnutls_read (state, buf, nbyte); if (rtnval >= 0) return rtnval; + else if (emacs_gnutls_handle_error (state, rtnval) == 0) + /* non-fatal error */ + return -1; else { - if (rtnval == GNUTLS_E_AGAIN || - rtnval == GNUTLS_E_INTERRUPTED) - return -1; - else - return 0; + /* a fatal error occured */ + return 0; } } +/* report a GnuTLS error to the user. + Returns zero if the error code was successfully handled. */ +static int +emacs_gnutls_handle_error (gnutls_session_t session, int err) +{ + Lisp_Object gnutls_log_level = Fsymbol_value (Qgnutls_log_level); + int max_log_level = 0; + + int alert, ret; + const char *str; + + /* TODO: use a Lisp_Object generated by gnutls_make_error? */ + if (err >= 0) + return 0; + + if (NUMBERP (gnutls_log_level)) + max_log_level = XINT (gnutls_log_level); + + /* TODO: use gnutls-error-fatalp and gnutls-error-string. */ + + str = gnutls_strerror (err); + if (!str) + str = "unknown"; + + if (gnutls_error_is_fatal (err)) + { + ret = err; + GNUTLS_LOG2 (0, max_log_level, "fatal error:", str); + } + else + { + ret = 0; + GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str); + /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2. */ + } + + if (err == GNUTLS_E_WARNING_ALERT_RECEIVED + || err == GNUTLS_E_FATAL_ALERT_RECEIVED) + { + int alert = gnutls_alert_get (session); + int level = (err == GNUTLS_E_FATAL_ALERT_RECEIVED) ? 0 : 1; + str = gnutls_alert_get_name (alert); + if (!str) + str = "unknown"; + + GNUTLS_LOG2 (level, max_log_level, "Received alert: ", str); + } + return ret; +} + /* convert an integer error to a Lisp_Object; it will be either a known symbol like `gnutls_e_interrupted' and `gnutls_e_again' or simply the integer value of the error. GNUTLS_E_SUCCESS is mapped @@ -262,14 +371,14 @@ Call `gnutls-global-deinit' when GnuTLS usage is no longer needed. Returns zero on success. */ static Lisp_Object -gnutls_emacs_global_init (void) +emacs_gnutls_global_init (void) { int ret = GNUTLS_E_SUCCESS; - if (!global_initialized) + if (!gnutls_global_initialized) ret = gnutls_global_init (); - global_initialized = 1; + gnutls_global_initialized = 1; return gnutls_make_error (ret); } @@ -277,28 +386,16 @@ /* Deinitializes global GnuTLS state. See also `gnutls-global-init'. */ static Lisp_Object -gnutls_emacs_global_deinit (void) +emacs_gnutls_global_deinit (void) { - if (global_initialized) + if (gnutls_global_initialized) gnutls_global_deinit (); - global_initialized = 0; + gnutls_global_initialized = 0; return gnutls_make_error (GNUTLS_E_SUCCESS); } -static void -gnutls_log_function (int level, const char* string) -{ - message ("gnutls.c: [%d] %s", level, string); -} - -static void -gnutls_log_function2 (int level, const char* string, const char* extra) -{ - message ("gnutls.c: [%d] %s %s", level, string, extra); -} - DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST. Currently only client mode is supported. Returns a success/failure @@ -307,12 +404,27 @@ TYPE is a symbol, either `gnutls-anon' or `gnutls-x509pki'. PROPLIST is a property list with the following keys: +:hostname is a string naming the remote host. + :priority is a GnuTLS priority string, defaults to "NORMAL". + :trustfiles is a list of PEM-encoded trust files for `gnutls-x509pki'. + :keyfiles is a list of PEM-encoded key files for `gnutls-x509pki'. -:callbacks is an alist of callback functions (TODO). + +:callbacks is an alist of callback functions, see below. + :loglevel is the debug level requested from GnuTLS, try 4. +:verify-flags is a bitset as per GnuTLS' +gnutls_certificate_set_verify_flags. + +:verify-error, if non-nil, makes failure of the certificate validation +an error. Otherwise it will be just a series of warnings. + +:verify-hostname-error, if non-nil, makes a hostname mismatch an +error. Otherwise it will be just a warning. + The debug level will be set for this process AND globally for GnuTLS. So if you set it higher or lower at any point, it affects global debugging. @@ -325,6 +437,9 @@ functions are used. This function allocates resources which can only be deallocated by calling `gnutls-deinit' or by calling it again. +The callbacks alist can have a `verify' key, associated with a +verification function (UNUSED). + Each authentication type may need additional information in order to work. For X.509 PKI (`gnutls-x509pki'), you probably need at least one trustfile (usually a CA bundle). */) @@ -337,12 +452,19 @@ /* TODO: GNUTLS_X509_FMT_DER is also an option. */ int file_format = GNUTLS_X509_FMT_PEM; + unsigned int gnutls_verify_flags = GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; + gnutls_x509_crt_t gnutls_verify_cert; + unsigned int gnutls_verify_cert_list_size; + const gnutls_datum_t *gnutls_verify_cert_list; + gnutls_session_t state; gnutls_certificate_credentials_t x509_cred; gnutls_anon_client_credentials_t anon_cred; Lisp_Object global_init; char* priority_string_ptr = "NORMAL"; /* default priority string. */ Lisp_Object tail; + int peer_verification; + char* c_hostname; /* Placeholders for the property list elements. */ Lisp_Object priority_string; @@ -350,16 +472,29 @@ Lisp_Object keyfiles; Lisp_Object callbacks; Lisp_Object loglevel; + Lisp_Object hostname; + Lisp_Object verify_flags; + Lisp_Object verify_error; + Lisp_Object verify_hostname_error; CHECK_PROCESS (proc); CHECK_SYMBOL (type); CHECK_LIST (proplist); - priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); - trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); - keyfiles = Fplist_get (proplist, Qgnutls_bootprop_keyfiles); - callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); - loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); + hostname = Fplist_get (proplist, Qgnutls_bootprop_hostname); + priority_string = Fplist_get (proplist, Qgnutls_bootprop_priority); + trustfiles = Fplist_get (proplist, Qgnutls_bootprop_trustfiles); + keyfiles = Fplist_get (proplist, Qgnutls_bootprop_keyfiles); + callbacks = Fplist_get (proplist, Qgnutls_bootprop_callbacks); + loglevel = Fplist_get (proplist, Qgnutls_bootprop_loglevel); + verify_flags = Fplist_get (proplist, Qgnutls_bootprop_verify_flags); + verify_error = Fplist_get (proplist, Qgnutls_bootprop_verify_error); + verify_hostname_error = Fplist_get (proplist, Qgnutls_bootprop_verify_hostname_error); + + if (!STRINGP (hostname)) + error ("gnutls-boot: invalid :hostname parameter"); + + c_hostname = SSDATA (hostname); state = XPROCESS (proc)->gnutls_state; XPROCESS (proc)->gnutls_p = 1; @@ -373,7 +508,7 @@ } /* always initialize globals. */ - global_init = gnutls_emacs_global_init (); + global_init = emacs_gnutls_global_init (); if (! NILP (Fgnutls_errorp (global_init))) return global_init; @@ -417,6 +552,23 @@ x509_cred = XPROCESS (proc)->gnutls_x509_cred; if (gnutls_certificate_allocate_credentials (&x509_cred) < 0) memory_full (); + + if (NUMBERP (verify_flags)) + { + gnutls_verify_flags = XINT (verify_flags); + GNUTLS_LOG (2, max_log_level, "setting verification flags"); + } + else if (NILP (verify_flags)) + { + /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ + GNUTLS_LOG (2, max_log_level, "using default verification flags"); + } + else + { + /* The default is already GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT. */ + GNUTLS_LOG (2, max_log_level, "ignoring invalid verify-flags"); + } + gnutls_certificate_set_verify_flags (x509_cred, gnutls_verify_flags); } else if (EQ (type, Qgnutls_anon)) { @@ -485,6 +637,14 @@ GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; + GNUTLS_LOG (1, max_log_level, "gnutls callbacks"); + + GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CALLBACKS; + +#ifdef HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY +#else +#endif + GNUTLS_LOG (1, max_log_level, "gnutls_init"); ret = gnutls_init (&state, GNUTLS_CLIENT); @@ -542,9 +702,113 @@ GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_SET; - emacs_gnutls_handshake (XPROCESS (proc)); - - return gnutls_make_error (GNUTLS_E_SUCCESS); + ret = emacs_gnutls_handshake (XPROCESS (proc)); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + /* Now verify the peer, following + http://www.gnu.org/software/gnutls/manual/html_node/Verifying-peer_0027s-certificate.html. + The peer should present at least one certificate in the chain; do a + check of the certificate's hostname with + gnutls_x509_crt_check_hostname() against :hostname. */ + + ret = gnutls_certificate_verify_peers2 (state, &peer_verification); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + if (XINT (loglevel) > 0 && peer_verification & GNUTLS_CERT_INVALID) + message ("%s certificate could not be verified.", + c_hostname); + + if (peer_verification & GNUTLS_CERT_REVOKED) + GNUTLS_LOG2 (1, max_log_level, "certificate was revoked (CRL):", + c_hostname); + + if (peer_verification & GNUTLS_CERT_SIGNER_NOT_FOUND) + GNUTLS_LOG2 (1, max_log_level, "certificate signer was not found:", + c_hostname); + + if (peer_verification & GNUTLS_CERT_SIGNER_NOT_CA) + GNUTLS_LOG2 (1, max_log_level, "certificate signer is not a CA:", + c_hostname); + + if (peer_verification & GNUTLS_CERT_INSECURE_ALGORITHM) + GNUTLS_LOG2 (1, max_log_level, + "certificate was signed with an insecure algorithm:", + c_hostname); + + if (peer_verification & GNUTLS_CERT_NOT_ACTIVATED) + GNUTLS_LOG2 (1, max_log_level, "certificate is not yet activated:", + c_hostname); + + if (peer_verification & GNUTLS_CERT_EXPIRED) + GNUTLS_LOG2 (1, max_log_level, "certificate has expired:", + c_hostname); + + if (peer_verification != 0) + { + if (NILP (verify_hostname_error)) + { + GNUTLS_LOG2 (1, max_log_level, "certificate validation failed:", + c_hostname); + } + else + { + error ("Certificate validation failed %s, verification code %d", + c_hostname, peer_verification); + } + } + + /* Up to here the process is the same for X.509 certificates and + OpenPGP keys. From now on X.509 certificates are assumed. This + can be easily extended to work with openpgp keys as well. */ + if (gnutls_certificate_type_get (state) == GNUTLS_CRT_X509) + { + ret = gnutls_x509_crt_init (&gnutls_verify_cert); + + if (ret < GNUTLS_E_SUCCESS) + return gnutls_make_error (ret); + + gnutls_verify_cert_list = + gnutls_certificate_get_peers (state, &gnutls_verify_cert_list_size); + + if (NULL == gnutls_verify_cert_list) + { + error ("No x509 certificate was found!\n"); + } + + /* We only check the first certificate in the given chain. */ + ret = gnutls_x509_crt_import (gnutls_verify_cert, + &gnutls_verify_cert_list[0], + GNUTLS_X509_FMT_DER); + + if (ret < GNUTLS_E_SUCCESS) + { + gnutls_x509_crt_deinit (gnutls_verify_cert); + return gnutls_make_error (ret); + } + + if (!gnutls_x509_crt_check_hostname (gnutls_verify_cert, c_hostname)) + { + if (NILP (verify_hostname_error)) + { + GNUTLS_LOG2 (1, max_log_level, "x509 certificate does not match:", + c_hostname); + } + else + { + gnutls_x509_crt_deinit (gnutls_verify_cert); + error ("The x509 certificate does not match \"%s\"", + c_hostname); + } + } + + gnutls_x509_crt_deinit (gnutls_verify_cert); + } + + return gnutls_make_error (ret); } DEFUN ("gnutls-bye", Fgnutls_bye, @@ -579,7 +843,10 @@ void syms_of_gnutls (void) { - global_initialized = 0; + gnutls_global_initialized = 0; + + Qgnutls_log_level = intern_c_string ("gnutls-log-level"); + staticpro (&Qgnutls_log_level); Qgnutls_code = intern_c_string ("gnutls-code"); staticpro (&Qgnutls_code); @@ -590,6 +857,9 @@ Qgnutls_x509pki = intern_c_string ("gnutls-x509pki"); staticpro (&Qgnutls_x509pki); + Qgnutls_bootprop_hostname = intern_c_string (":hostname"); + staticpro (&Qgnutls_bootprop_hostname); + Qgnutls_bootprop_priority = intern_c_string (":priority"); staticpro (&Qgnutls_bootprop_priority); @@ -602,9 +872,21 @@ Qgnutls_bootprop_callbacks = intern_c_string (":callbacks"); staticpro (&Qgnutls_bootprop_callbacks); + Qgnutls_bootprop_callbacks_verify = intern_c_string ("verify"); + staticpro (&Qgnutls_bootprop_callbacks_verify); + Qgnutls_bootprop_loglevel = intern_c_string (":loglevel"); staticpro (&Qgnutls_bootprop_loglevel); + Qgnutls_bootprop_verify_flags = intern_c_string (":verify-flags"); + staticpro (&Qgnutls_bootprop_verify_flags); + + Qgnutls_bootprop_verify_hostname_error = intern_c_string (":verify-error"); + staticpro (&Qgnutls_bootprop_verify_error); + + Qgnutls_bootprop_verify_hostname_error = intern_c_string (":verify-hostname-error"); + staticpro (&Qgnutls_bootprop_verify_hostname_error); + Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted"); staticpro (&Qgnutls_e_interrupted); Fput (Qgnutls_e_interrupted, Qgnutls_code, === modified file 'src/gnutls.h' --- src/gnutls.h 2011-04-15 08:22:34 +0000 +++ src/gnutls.h 2011-04-25 01:30:51 +0000 @@ -21,6 +21,7 @@ #ifdef HAVE_GNUTLS #include +#include typedef enum { @@ -28,6 +29,7 @@ GNUTLS_STAGE_EMPTY = 0, GNUTLS_STAGE_CRED_ALLOC, GNUTLS_STAGE_FILES, + GNUTLS_STAGE_CALLBACKS, GNUTLS_STAGE_INIT, GNUTLS_STAGE_PRIORITY, GNUTLS_STAGE_CRED_SET, === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2011-04-24 09:00:03 +0000 +++ src/makefile.w32-in 2011-04-25 01:30:51 +0000 @@ -105,6 +105,7 @@ $(BLD)/floatfns.$(O) \ $(BLD)/frame.$(O) \ $(BLD)/gmalloc.$(O) \ + $(BLD)/gnutls.$(O) \ $(BLD)/intervals.$(O) \ $(BLD)/composite.$(O) \ $(BLD)/ralloc.$(O) \ @@ -150,6 +151,7 @@ $(OLE32) \ $(COMCTL32) \ $(UNISCRIBE) \ + $(USER_LIBS) \ $(libc) # @@ -950,6 +952,14 @@ $(EMACS_ROOT)/nt/inc/unistd.h \ $(SRC)/getpagesize.h +$(BLD)/gnutls.$(O) : \ + $(SRC)/gnutls.h \ + $(SRC)/gnutls.c \ + $(CONFIG_H) \ + $(EMACS_ROOT)/nt/inc/sys/socket.h \ + $(SRC)/lisp.h \ + $(SRC)/process.h + $(BLD)/image.$(O) : \ $(SRC)/image.c \ $(CONFIG_H) \ === modified file 'src/process.c' --- src/process.c 2011-04-16 22:04:41 +0000 +++ src/process.c 2011-04-25 01:30:51 +0000 @@ -4532,6 +4532,22 @@ &Available, (check_write ? &Writeok : (SELECT_TYPE *)0), (SELECT_TYPE *)0, &timeout); + +#ifdef HAVE_GNUTLS + /* GnuTLS buffers data internally. In lowat mode it leaves + some data in the TCP buffers so that select works, but + with custom pull/push functions we need to check if some + data is available in the buffers manually. */ + if (nfds == 0 && + wait_proc && wait_proc->gnutls_p /* Check for valid process. */ + /* Do we have pending data? */ + && gnutls_record_check_pending (wait_proc->gnutls_state) > 0) + { + nfds = 1; + /* Set to Available. */ + FD_SET (wait_proc->infd, &Available); + } +#endif } xerrno = errno; === modified file 'src/w32.c' --- src/w32.c 2011-04-23 03:07:16 +0000 +++ src/w32.c 2011-04-25 01:30:51 +0000 @@ -6124,5 +6124,72 @@ p->childp = childp2; } +#ifdef HAVE_GNUTLS + +ssize_t +emacs_gnutls_pull (gnutls_transport_ptr_t p, void* buf, size_t sz) +{ + int n, sc, err; + SELECT_TYPE fdset; + EMACS_TIME timeout; + struct Lisp_Process *process = (struct Lisp_Process *)p; + int fd = process->infd; + + for (;;) + { + n = sys_read(fd, (char*)buf, sz); + + if (n >= 0) + return n; + + err = errno; + + if (err == EWOULDBLOCK) + { + /* Set a small timeout. */ + EMACS_SET_SECS_USECS(timeout, 1, 0); + FD_ZERO (&fdset); + FD_SET ((int)fd, &fdset); + + /* Use select with the timeout to poll the selector. */ + sc = select (fd + 1, &fdset, (SELECT_TYPE *)0, (SELECT_TYPE *)0, + &timeout); + + if (sc > 0) + continue; /* Try again. */ + + /* Translate the WSAEWOULDBLOCK alias EWOULDBLOCK to EAGAIN. + Also accept select return 0 as an indicator to EAGAIN. */ + if (sc == 0 || errno == EWOULDBLOCK) + err = EAGAIN; + else + err = errno; /* Other errors are just passed on. */ + } + + gnutls_transport_set_errno (process->gnutls_state, err); + + return -1; + } +} + +ssize_t +emacs_gnutls_push (gnutls_transport_ptr_t p, const void* buf, size_t sz) +{ + struct Lisp_Process *process = (struct Lisp_Process *)p; + int fd = proc->outfd; + ssize_t n = sys_write(fd, buf, sz); + + /* 0 or more bytes written means everything went fine. */ + if (n >= 0) + return n; + + /* Negative bytes written means we got an error in errno. + Translate the WSAEWOULDBLOCK alias EWOULDBLOCK to EAGAIN. */ + gnutls_transport_set_errno (process->gnutls_state, + errno == EWOULDBLOCK ? EAGAIN : errno); + + return -1; +} +#endif /* HAVE_GNUTLS */ + /* end of w32.c */ - === modified file 'src/w32.h' --- src/w32.h 2011-01-25 04:08:28 +0000 +++ src/w32.h 2011-04-25 01:30:51 +0000 @@ -143,5 +143,17 @@ extern int _sys_read_ahead (int fd); extern int _sys_wait_accept (int fd); +#ifdef HAVE_GNUTLS +#include + +/* GnuTLS pull (read from remote) interface. */ +extern ssize_t emacs_gnutls_pull (gnutls_transport_ptr_t p, + void* buf, size_t sz); + +/* GnuTLS push (write to remote) interface. */ +extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, + const void* buf, size_t sz); +#endif /* HAVE_GNUTLS */ + #endif /* EMACS_W32_H */ ------------------------------------------------------------ revno: 103997 committer: Ted Zlatanov branch nick: quickfixes timestamp: Sun 2011-04-24 20:30:05 -0500 message: Add certificate verify callback check for GnuTLS. * configure.in: Check for GnuTLS certificate verify callbacks. diff: === modified file 'ChangeLog' --- ChangeLog 2011-04-23 03:07:16 +0000 +++ ChangeLog 2011-04-25 01:30:05 +0000 @@ -1,3 +1,7 @@ +2011-04-24 Teodor Zlatanov + + * configure.in: Check for GnuTLS certificate verify callbacks. + 2011-04-20 Stefan Monnier * Makefile.in (config.status): Don't erase in case of error. === modified file 'configure.in' --- configure.in 2011-04-20 02:18:13 +0000 +++ configure.in 2011-04-25 01:30:05 +0000 @@ -1972,12 +1972,22 @@ AC_SUBST(LIBSELINUX_LIBS) HAVE_GNUTLS=no +HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=no if test "${with_gnutls}" = "yes" ; then PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.2.4], HAVE_GNUTLS=yes, HAVE_GNUTLS=no) if test "${HAVE_GNUTLS}" = "yes"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.]) fi + + CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS" + LIBS="$LIBGNUTLS_LIBS $LIBS" + AC_CHECK_FUNCS(gnutls_certificate_set_verify_function, HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=yes) + + if test "${HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY}" = "yes"; then + AC_DEFINE(HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY, 1, [Define if using GnuTLS certificate verification callbacks.]) + fi fi + AC_SUBST(LIBGNUTLS_LIBS) AC_SUBST(LIBGNUTLS_CFLAGS) ------------------------------------------------------------ revno: 103996 committer: Ted Zlatanov branch nick: quickfixes timestamp: Sun 2011-04-24 20:29:31 -0500 message: Add GnuTLS support for W32. * nt/configure.bat: New options --without-gnutls and --lib, new build variable USER_LIBS, automatically detect GnuTLS. Copies the PNG library setup with trivial modifications. * nt/INSTALL: Add instructions for GnuTLS support. * nt/gmake.defs: Prefix USER_LIBS with -l. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-04-15 22:48:00 +0000 +++ nt/ChangeLog 2011-04-25 01:29:31 +0000 @@ -1,3 +1,11 @@ +2011-04-24 Teodor Zlatanov + + * configure.bat: New options --without-gnutls and --lib, new build + variable USER_LIBS, automatically detect GnuTLS. Copies the PNG + library setup with trivial modifications. + * INSTALL: Add instructions for GnuTLS support. + * gmake.defs: Prefix USER_LIBS with -l. + 2011-04-15 Ben Key * configure.bat: Modified the code that parses the --cflags and === modified file 'nt/INSTALL' --- nt/INSTALL 2011-04-15 22:48:00 +0000 +++ nt/INSTALL 2011-04-25 01:29:31 +0000 @@ -316,6 +316,15 @@ `dynamic-library-alist' and the value of `libpng-version', and download compatible DLLs if needed. +* Optional GnuTLS support + + You can build Emacs with GnuTLS support. Put the gnutls/gnutls.h header in + the include path and link to the appropriate libraries (gnutls.dll and + gcrypt.dll) with the --lib option. + + You can get pre-built binaries and an installer at + http://josefsson.org/gnutls4win/. + * Experimental SVG support SVG support is currently experimental, and not built by default. === modified file 'nt/configure.bat' --- nt/configure.bat 2011-04-15 22:48:00 +0000 +++ nt/configure.bat 2011-04-25 01:29:31 +0000 @@ -99,10 +99,13 @@ set usercflags= set docflags= set userldflags= +set extrauserlibs= set doldflags= +set doextralibs= set sep1= set sep2= set sep3= +set sep4= set distfiles= rem ---------------------------------------------------------------------- @@ -120,10 +123,12 @@ if "%1" == "--no-cygwin" goto nocygwin if "%1" == "--cflags" goto usercflags if "%1" == "--ldflags" goto userldflags +if "%1" == "--lib" goto extrauserlibs if "%1" == "--without-png" goto withoutpng if "%1" == "--without-jpeg" goto withoutjpeg if "%1" == "--without-gif" goto withoutgif if "%1" == "--without-tiff" goto withouttiff +if "%1" == "--without-gnutls" goto withoutgnutls if "%1" == "--without-xpm" goto withoutxpm if "%1" == "--with-svg" goto withsvg if "%1" == "--distfiles" goto distfiles @@ -142,11 +147,13 @@ echo. --no-cygwin use -mno-cygwin option with GCC echo. --cflags FLAG pass FLAG to compiler echo. --ldflags FLAG pass FLAG to compiler when linking +echo. --lib LIB link to extra library LIB echo. --without-png do not use PNG library even if it is installed echo. --without-jpeg do not use JPEG library even if it is installed echo. --without-gif do not use GIF library even if it is installed echo. --without-tiff do not use TIFF library even if it is installed echo. --without-xpm do not use XPM library even if it is installed +echo. --without-gnutls do not use GNUTLS library even if it is installed echo. --with-svg use the RSVG library (experimental) echo. --distfiles path to files for make dist, e.g. libXpm.dll if "%use_extensions%" == "0" goto end @@ -242,6 +249,14 @@ shift goto again +:extrauserlibs +shift +echo. extrauserlibs: %extrauserlibs% +set extrauserlibs=%extrauserlibs%%sep4%%1 +set sep4= %nothing% +shift +goto again + rem ---------------------------------------------------------------------- :userldflags @@ -288,6 +303,14 @@ rem ---------------------------------------------------------------------- +:withoutgnutls +set tlssupport=N +set HAVE_GNUTLS= +shift +goto again + +rem ---------------------------------------------------------------------- + :withouttiff set tiffsupport=N set HAVE_TIFF= @@ -516,6 +539,30 @@ :pngDone rm -f junk.c junk.obj +if (%tlssupport%) == (N) goto tlsDone + +rem this is a copy of the PNG detection +echo Checking for libgnutls... +echo #include "gnutls/gnutls.h" >junk.c +echo main (){} >>junk.c +rem -o option is ignored with cl, but allows result to be consistent. +echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log +%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log +if exist junk.obj goto haveTls + +echo ...gnutls.h not found, building without TLS support. +echo The failed program was: >>config.log +type junk.c >>config.log +set HAVE_GNUTLS= +goto :tlsDone + +:haveTls +echo ...GNUTLS header available, building with GNUTLS support. +set HAVE_GNUTLS=1 + +:tlsDone +rm -f junk.c junk.obj + if (%jpegsupport%) == (N) goto jpegDone echo Checking for jpeg-6b... @@ -688,6 +735,8 @@ if (%docflags%)==(Y) echo USER_CFLAGS=%usercflags%>>config.settings for %%v in (%userldflags%) do if not (%%v)==() set doldflags=Y if (%doldflags%)==(Y) echo USER_LDFLAGS=%userldflags%>>config.settings +for %%v in (%extrauserlibs%) do if not (%%v)==() set doextralibs=Y +if (%doextralibs%)==(Y) echo USER_LIBS=%extrauserlibs%>>config.settings echo # End of settings from configure.bat>>config.settings echo. >>config.settings @@ -700,6 +749,7 @@ if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %userldflags%">>config.tmp if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp +if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp @@ -838,6 +888,7 @@ set HAVE_DISTFILES= set distFilesOk= set pngsupport= +set tlssupport= set jpegsupport= set gifsupport= set tiffsupport= === modified file 'nt/gmake.defs' --- nt/gmake.defs 2011-01-25 04:08:28 +0000 +++ nt/gmake.defs 2011-04-25 01:29:31 +0000 @@ -279,6 +279,10 @@ NOCYGWIN = -mno-cygwin endif +ifdef USER_LIBS +USER_LIBS := $(patsubst %,-l%,$(USER_LIBS)) +endif + ifeq "$(ARCH)" "i386" ifdef NOOPT ARCH_CFLAGS = -c $(DEBUG_FLAG) $(NOCYGWIN) ------------------------------------------------------------ revno: 103995 committer: Ted Zlatanov branch nick: quickfixes timestamp: Sun 2011-04-24 20:28:55 -0500 message: Add GnuTLS support for W32. * lib-src/makefile.w32-in (obj): Added gnutls.o. diff: === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2011-04-16 23:11:35 +0000 +++ lib-src/ChangeLog 2011-04-25 01:28:55 +0000 @@ -1,3 +1,7 @@ +2011-04-24 Teodor Zlatanov + + * makefile.w32-in (obj): Added gnutls.o. + 2011-04-16 Paul Eggert Static checks with GCC 4.6.0 and non-default toolkits. === modified file 'lib-src/makefile.w32-in' --- lib-src/makefile.w32-in 2011-03-12 19:19:47 +0000 +++ lib-src/makefile.w32-in 2011-04-25 01:28:55 +0000 @@ -142,7 +142,8 @@ syntax.o bytecode.o \ process.o callproc.o unexw32.o \ region-cache.o sound.o atimer.o \ - doprnt.o intervals.o textprop.o composite.o + doprnt.o intervals.o textprop.o composite.o \ + gnutls.o # # These are the lisp files that are loaded up in loadup.el ------------------------------------------------------------ revno: 103994 committer: Daniel Colascione branch nick: trunk timestamp: Sun 2011-04-24 17:31:41 -0700 message: * progmodes/cc-engine.el (c-forward-decl-or-cast-1): Use correct match group (bug#8438). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-24 20:32:23 +0000 +++ lisp/ChangeLog 2011-04-25 00:31:41 +0000 @@ -1,3 +1,8 @@ +2011-04-24 Daniel Colascione + + * progmodes/cc-engine.el (c-forward-decl-or-cast-1): Use + correct match group (bug#8438). + 2011-04-24 Chong Yidong * emacs-lisp/package.el (package-built-in-p): Fix typo. === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2011-03-06 17:03:45 +0000 +++ lisp/progmodes/cc-engine.el 2011-04-25 00:31:41 +0000 @@ -6475,7 +6475,7 @@ ;; `c-font-lock-declarators'.) (while (and (looking-at c-type-decl-prefix-key) (if (and (c-major-mode-is 'c++-mode) - (match-beginning 2)) + (match-beginning 3)) ;; If the second submatch matches in C++ then ;; we're looking at an identifier that's a ;; prefix only if it specifies a member pointer. ------------------------------------------------------------ revno: 103993 author: Lars Magne Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Sun 2011-04-24 22:12:21 +0000 message: shr.el (shr-tag-sup, shr-tag-sub): New functions. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-04-23 02:18:10 +0000 +++ lisp/gnus/ChangeLog 2011-04-24 22:12:21 +0000 @@ -2,6 +2,11 @@ * gnus-sum.el (gnus-extra-headers): Bump :version. +2011-04-24 Lars Magne Ingebrigtsen + + * shr.el (shr-tag-sup): New function. + (shr-tag-sub): Ditto. + 2011-04-22 Teodor Zlatanov * gnus-registry.el (gnus-registry-ignore-group-p): Test specifically === modified file 'lisp/gnus/shr.el' --- lisp/gnus/shr.el 2011-04-21 02:48:04 +0000 +++ lisp/gnus/shr.el 2011-04-24 22:12:21 +0000 @@ -734,6 +734,16 @@ (defun shr-tag-script (cont) ) +(defun shr-tag-sup (cont) + (let ((start (point))) + (shr-generic cont) + (put-text-property start (point) 'display '(raise 0.5)))) + +(defun shr-tag-sub (cont) + (let ((start (point))) + (shr-generic cont) + (put-text-property start (point) 'display '(raise -0.5)))) + (defun shr-tag-label (cont) (shr-generic cont) (shr-ensure-paragraph)) ------------------------------------------------------------ revno: 103992 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-04-24 16:32:23 -0400 message: Restore ability to show a restricted list of packages in Package Menu. * emacs-lisp/package.el (package-built-in-p): Fix typo. (package-menu--generate): New arg specifying packages to show. (package-menu-refresh, package-menu-execute, list-packages): Callers changed. (package-show-package-list): New function. * finder.el (finder-list-matches): Use package-show-package-list instead of deleted package--list-packages. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-24 19:37:47 +0000 +++ lisp/ChangeLog 2011-04-24 20:32:23 +0000 @@ -1,5 +1,15 @@ 2011-04-24 Chong Yidong + * emacs-lisp/package.el (package-built-in-p): Fix typo. + (package-menu--generate): New arg specifying packages to show. + (package-menu-refresh, package-menu-execute, list-packages): + Callers changed. + (package-show-package-list): New function, replacing deleted + package--list-packages (renamed because it is non-internal). + + * finder.el (finder-list-matches): Use package-show-package-list + instead of deleted package--list-packages. + * vc/vc-annotate.el (vc-annotate-goto-line): New command. Based on a previous implementation by Juanma Barranquero (Bug#8366). (vc-annotate-mode-map): Bind it to RET. === modified file 'lisp/emacs-lisp/package.el' --- lisp/emacs-lisp/package.el 2011-04-22 02:35:48 +0000 +++ lisp/emacs-lisp/package.el 2011-04-24 20:32:23 +0000 @@ -84,10 +84,6 @@ ;; can see what packages are available. This will automatically ;; fetch the latest list of packages from ELPA. ;; -;; M-x package-list-packages-no-fetch -;; Like package-list-packages, but does not automatically fetch the -;; new list of packages. -;; ;; M-x package-install-from-buffer ;; Install a package consisting of a single .el file that appears ;; in the current buffer. This only works for packages which @@ -462,7 +458,7 @@ specifying the minimum acceptable version." (require 'finder-inf nil t) ; For `package--builtins'. (let ((elt (assq package package--builtins))) - (and elt (min-version-<= min-version (package-desc-vers (cdr elt)))))) + (and elt (version-list-<= min-version (package-desc-vers (cdr elt)))))) ;; This function goes ahead and activates a newer version of a package ;; if an older one was already activated. This is not ideal; we'd at @@ -1344,38 +1340,45 @@ (unless (assoc key ,listname) (push (list key ,status (package-desc-doc ,desc)) ,listname)))) -(defun package-menu--generate (&optional remember-pos) +(defun package-menu--generate (remember-pos packages) "Populate the Package Menu. -Optional argument REMEMBER-POS, if non-nil, means to move point -to the entry as before." +If REMEMBER-POS is non-nil, keep point on the same entry. +PACKAGES should be t, which means to display all known packages, +or a list of package names (symbols) to display." ;; Construct list of ((PACKAGE . VERSION) STATUS DESCRIPTION). (let (info-list name builtin) ;; Installed packages: (dolist (elt package-alist) (setq name (car elt)) - (package--push name (cdr elt) - (if (stringp (cadr (assq name package-load-list))) - "held" "installed") - info-list)) + (when (or (eq packages t) (memq name packages)) + (package--push name (cdr elt) + (if (stringp (cadr (assq name package-load-list))) + "held" "installed") + info-list))) ;; Built-in packages: (dolist (elt package--builtins) (setq name (car elt)) - (unless (eq name 'emacs) ; Hide the `emacs' package. + (when (and (not (eq name 'emacs)) ; Hide the `emacs' package. + (or (eq packages t) (memq name packages))) (package--push name (cdr elt) "built-in" info-list))) ;; Available and disabled packages: (dolist (elt package-archive-contents) (setq name (car elt)) - (let ((hold (assq name package-load-list))) - (package--push name (cdr elt) - (if (and hold (null (cadr hold))) "disabled" "available") - info-list))) + (when (or (eq packages t) (memq name packages)) + (let ((hold (assq name package-load-list))) + (package--push name (cdr elt) + (if (and hold (null (cadr hold))) + "disabled" + "available") + info-list)))) ;; Obsolete packages: (dolist (elt package-obsolete-alist) (dolist (inner-elt (cdr elt)) - (package--push (car elt) (cdr inner-elt) "obsolete" info-list))) + (when (or (eq packages t) (memq (car elt) packages)) + (package--push (car elt) (cdr inner-elt) "obsolete" info-list)))) ;; Print the result. (setq tabulated-list-entries (mapcar 'package-menu--print-info info-list)) @@ -1416,7 +1419,7 @@ (unless (eq major-mode 'package-menu-mode) (error "The current buffer is not a Package Menu")) (package-refresh-contents) - (package-menu--generate t)) + (package-menu--generate t t)) (defun package-menu-describe-package (&optional button) "Describe the current package. @@ -1531,7 +1534,7 @@ (and delete-list (null install-list) (package-initialize)) (if (or delete-list install-list) - (package-menu--generate t) + (package-menu--generate t t) (message "No operations specified.")))) (defun package-menu--version-predicate (A B) @@ -1585,7 +1588,7 @@ (let ((buf (get-buffer-create "*Packages*"))) (with-current-buffer buf (package-menu-mode) - (package-menu--generate)) + (package-menu--generate nil t)) ;; The package menu buffer has keybindings. If the user types ;; `M-x list-packages', that suggests it should become current. (switch-to-buffer buf))) @@ -1593,6 +1596,19 @@ ;;;###autoload (defalias 'package-list-packages 'list-packages) +;; Used in finder.el +(defun package-show-package-list (packages) + "Display PACKAGES in a *Packages* buffer. +This is similar to `list-packages', but it does not fetch the +updated list of packages, and it only displays packages with +names in PACKAGES (which should be a list of symbols)." + (require 'finder-inf nil t) + (let ((buf (get-buffer-create "*Packages*"))) + (with-current-buffer buf + (package-menu-mode) + (package-menu--generate nil packages)) + (switch-to-buffer buf))) + (defun package-list-packages-no-fetch () "Display a list of packages. Does not fetch the updated list of packages before displaying. === modified file 'lisp/finder.el' --- lisp/finder.el 2011-01-25 04:08:28 +0000 +++ lisp/finder.el 2011-04-24 20:32:23 +0000 @@ -316,7 +316,7 @@ (packages (gethash id finder-keywords-hash))) (unless packages (error "No packages matching key `%s'" key)) - (package--list-packages packages))) + (package-show-package-list packages))) (define-button-type 'finder-xref 'action #'finder-goto-xref) ------------------------------------------------------------ revno: 103991 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-04-24 15:37:47 -0400 message: Add vc-annotate-goto-line. * vc/vc-annotate.el (vc-annotate-goto-line): New command. Based on a previous implementation by Juanma Barranquero (Bug#8366). (vc-annotate-mode-map): Bind it to RET. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-24 18:47:17 +0000 +++ lisp/ChangeLog 2011-04-24 19:37:47 +0000 @@ -1,3 +1,9 @@ +2011-04-24 Chong Yidong + + * vc/vc-annotate.el (vc-annotate-goto-line): New command. Based + on a previous implementation by Juanma Barranquero (Bug#8366). + (vc-annotate-mode-map): Bind it to RET. + 2011-04-24 Uday S Reddy (tiny change) * progmodes/etags.el (next-file): Don't use set-buffer to change === modified file 'lisp/vc/vc-annotate.el' --- lisp/vc/vc-annotate.el 2011-04-08 18:53:26 +0000 +++ lisp/vc/vc-annotate.el 2011-04-24 19:37:47 +0000 @@ -128,6 +128,8 @@ (define-key m "p" 'vc-annotate-prev-revision) (define-key m "w" 'vc-annotate-working-revision) (define-key m "v" 'vc-annotate-toggle-annotation-visibility) + (define-key m "v" 'vc-annotate-toggle-annotation-visibility) + (define-key m "\C-m" 'vc-annotate-goto-line) m) "Local keymap used for VC-Annotate mode.") @@ -673,6 +675,36 @@ ;; Pretend to font-lock there were no matches. nil) +(defun vc-annotate-goto-line () + "Go to the line corresponding to the current VC Annotate line." + (interactive) + (unless (eq major-mode 'vc-annotate-mode) + (error "Not in a VC-Annotate buffer")) + (let ((line (save-restriction + (widen) + (line-number-at-pos))) + (rev vc-annotate-parent-rev)) + (pop-to-buffer + (or (and (buffer-live-p vc-parent-buffer) + vc-parent-buffer) + (and (file-exists-p vc-annotate-parent-file) + (find-file-noselect vc-annotate-parent-file)) + (error "File not found: %s" vc-annotate-parent-file))) + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line (1- line)) + (recenter)) + ;; Issue a warning if the lines might be incorrect. + (cond + ((buffer-modified-p) + (message "Buffer modified; annotated line numbers may be incorrect")) + ((not (eq (vc-state buffer-file-name) 'up-to-date)) + (message "File is not up-to-date; annotated line numbers may be incorrect")) + ((not (equal rev (vc-working-revision buffer-file-name))) + (message "Annotations were for revision %s; line numbers may be incorrect" + rev))))) + (provide 'vc-annotate) ;;; vc-annotate.el ends here ------------------------------------------------------------ revno: 103990 author: Uday S Reddy committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-04-24 14:47:17 -0400 message: Fix next-file command in etags.el. * lisp/progmodes/etags.el (next-file): Don't use set-buffer to change buffers (Bug#8478). * doc/lisp/maintaining.texi (List Tags): Document next-file. diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2011-04-23 03:07:16 +0000 +++ doc/emacs/ChangeLog 2011-04-24 18:47:17 +0000 @@ -1,3 +1,8 @@ +2011-04-24 Chong Yidong + + * maintaining.texi (List Tags): Document next-file. Suggested by + Uday S Reddy. + 2011-04-23 Juanma Barranquero * mini.texi (Minibuffer Edit): === modified file 'doc/emacs/maintaining.texi' --- doc/emacs/maintaining.texi 2011-04-20 17:39:39 +0000 +++ doc/emacs/maintaining.texi 2011-04-24 18:47:17 +0000 @@ -2326,6 +2326,12 @@ You can also use the collection of tag names to complete a symbol name in the buffer. @xref{Symbol Completion}. + You can use @kbd{M-x next-file} to visit the files in the selected +tags table. The first time this command is called, it visits the +first file in the tags table. Each subsequent call visits the next +file in the table, unless a prefix argument is supplied, in which case +it returns to the first file. + @node EDE @section Emacs Development Environment @cindex EDE (Emacs Development Environment) === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-24 00:24:30 +0000 +++ lisp/ChangeLog 2011-04-24 18:47:17 +0000 @@ -1,3 +1,8 @@ +2011-04-24 Uday S Reddy (tiny change) + + * progmodes/etags.el (next-file): Don't use set-buffer to change + buffers (Bug#8478). + 2011-04-24 Chong Yidong * files.el (auto-mode-alist): Use js-mode for .json (Bug#8529). === modified file 'lisp/progmodes/etags.el' --- lisp/progmodes/etags.el 2011-04-22 18:44:26 +0000 +++ lisp/progmodes/etags.el 2011-04-24 18:47:17 +0000 @@ -1756,9 +1756,9 @@ (with-current-buffer buffer (revert-buffer t t))) (if (not (and new novisit)) - (set-buffer (find-file-noselect next novisit)) + (find-file next novisit) ;; Like find-file, but avoids random warning messages. - (set-buffer (get-buffer-create " *next-file*")) + (switch-to-buffer (get-buffer-create " *next-file*")) (kill-all-local-variables) (erase-buffer) (setq new next) ------------------------------------------------------------ revno: 103989 committer: Chong Yidong branch nick: trunk timestamp: Sun 2011-04-24 14:34:57 -0400 message: Revert undocumented change to .dir-locals.el in revision 103798. This bumped fill-column from 70 to 79, but was not documented in the commit log, and appears to be a mistake. diff: === modified file '.dir-locals.el' --- .dir-locals.el 2011-02-25 03:27:45 +0000 +++ .dir-locals.el 2011-04-24 18:34:57 +0000 @@ -1,6 +1,6 @@ ((nil . ((tab-width . 8) (sentence-end-double-space . t) - (fill-column . 79))) + (fill-column . 70))) (c-mode . ((c-file-style . "GNU"))) ;; You must set bugtracker_debbugs_url in your bazaar.conf for this to work. ;; See admin/notes/bugtracker. ------------------------------------------------------------ revno: 103988 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 19:59:37 +0300 message: Minor cleanup in src/xdisp.c. src/xdisp.c (handle_single_display_spec): Rename the display_replaced_before_p argument into display_replaced_p, to make it consistent with the commentary. Fix typos in the commentary. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 16:28:57 +0000 +++ src/ChangeLog 2011-04-24 16:59:37 +0000 @@ -1,5 +1,10 @@ 2011-04-24 Eli Zaretskii + * xdisp.c (handle_single_display_spec): Rename the + display_replaced_before_p argument into display_replaced_p, to + make it consistent with the commentary. Fix typos in the + commentary. + * textprop.c (syms_of_textprop): Remove dead code. (copy_text_properties): Delete obsolete commentary about an interface that was deleted long ago. Fix typos in the description === modified file 'src/xdisp.c' --- src/xdisp.c 2011-04-23 10:33:28 +0000 +++ src/xdisp.c 2011-04-24 16:59:37 +0000 @@ -3855,7 +3855,7 @@ } -/* Set up IT from a single `display' specification PROP. OBJECT +/* Set up IT from a single `display' property specification SPEC. OBJECT is the object in which the `display' property was found. *POSITION is the position at which it was found. DISPLAY_REPLACED_P non-zero means that we previously saw a display specification which already @@ -3865,7 +3865,7 @@ OVERLAY is the overlay this `display' property came from, or nil if it was a text property. - If PROP is a `space' or `image' specification, and in some other + If SPEC is a `space' or `image' specification, and in some other cases too, set *POSITION to the position where the `display' property ends. @@ -3875,7 +3875,7 @@ static int handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, Lisp_Object overlay, struct text_pos *position, - int display_replaced_before_p) + int display_replaced_p) { Lisp_Object form; Lisp_Object location, value; @@ -4171,7 +4171,7 @@ #endif /* not HAVE_WINDOW_SYSTEM */ || (CONSP (value) && EQ (XCAR (value), Qspace))); - if (valid_p && !display_replaced_before_p) + if (valid_p && !display_replaced_p) { /* Save current settings of IT so that we can restore them when we are finished with the glyph property value. */ ------------------------------------------------------------ revno: 103987 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 19:28:57 +0300 message: Minor cleanup in src/textprop.c. src/textprop.c (syms_of_textprop): Remove dead code. (copy_text_properties): Delete obsolete commentary about an interface that was deleted long ago. Fix typos in the description of arguments. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 12:48:30 +0000 +++ src/ChangeLog 2011-04-24 16:28:57 +0000 @@ -1,5 +1,10 @@ 2011-04-24 Eli Zaretskii + * textprop.c (syms_of_textprop): Remove dead code. + (copy_text_properties): Delete obsolete commentary about an + interface that was deleted long ago. Fix typos in the description + of arguments. + * msdos.c (XMenuActivate, XMenuAddSelection): Adjust argument list to changes in oldXMenu/XMenu.h from 2011-04-16. : Constify. === modified file 'src/textprop.c' --- src/textprop.c 2011-04-23 17:19:56 +0000 +++ src/textprop.c 2011-04-24 16:28:57 +0000 @@ -1756,15 +1756,9 @@ } -/* I don't think this is the right interface to export; how often do you - want to do something like this, other than when you're copying objects - around? - - I think it would be better to have a pair of functions, one which - returns the text properties of a region as a list of ranges and - plists, and another which applies such a list to another object. */ - -/* Add properties from SRC to SRC of SRC, starting at POS in DEST. +/* Copying properties between objects. */ + +/* Add properties from START to END of SRC, starting at POS in DEST. SRC and DEST may each refer to strings or buffers. Optional sixth argument PROP causes only that property to be copied. Properties are copied to DEST as if by `add-text-properties'. @@ -2304,6 +2298,4 @@ defsubr (&Sremove_list_of_text_properties); defsubr (&Stext_property_any); defsubr (&Stext_property_not_all); -/* defsubr (&Serase_text_properties); */ -/* defsubr (&Scopy_text_properties); */ } ------------------------------------------------------------ revno: 103986 [merge] committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 15:53:10 +0300 message: Repair the MSDOS build following latest changes. msdos/sedlibmk.inp (am_libgnu_a_OBJECTS): Edit out allocator.$(OBJEXT). Add editing for the new GNULIB_* and REPLACE_* variables. src/msdos.c (XMenuActivate, XMenuAddSelection): Adjust argument list to changes in oldXMenu/XMenu.h from 2011-04-16. : Constify. (IT_menu_make_room): menu->help_text is now `const char **'; adjust. src/msdos.h (XMenuActivate, XMenuAddSelection): Adjust prototypes to changes in oldXMenu/XMenu.h from 2011-04-16. (struct XMenu): Declare `help_text' `const char **'. src/xfaces.c : Make extern again. src/syntax.c: Include sys/types.h before including regex.h, as required by Posix. diff: === modified file 'msdos/ChangeLog' --- msdos/ChangeLog 2011-04-06 17:49:21 +0000 +++ msdos/ChangeLog 2011-04-24 12:48:30 +0000 @@ -1,3 +1,9 @@ +2011-04-24 Eli Zaretskii + + * sedlibmk.inp (am_libgnu_a_OBJECTS): Edit out + allocator.$(OBJEXT). Add editing for the new GNULIB_* and + REPLACE_* variables. + 2011-04-06 Eli Zaretskii * sedlibmk.inp: Update checklist. === modified file 'msdos/sedlibmk.inp' --- msdos/sedlibmk.inp 2011-04-06 17:49:21 +0000 +++ msdos/sedlibmk.inp 2011-04-24 12:48:30 +0000 @@ -36,7 +36,7 @@ # /^STDDEF_H *=/s/@[^@\n]*@// -- stddef.h is not needed # # . Some of the headers are generated conditionally, and the -# corresponding recipes are guarder by @GL_GENERATE_xxxx_H_TRUE@ +# corresponding recipes are guarded by @GL_GENERATE_xxxx_H_TRUE@ # and @GL_GENERATE_xxxx_H_FALSE@. Depending on whether DJGPP uses # the corresponding header, these should be edited either to # nothing (thus exposing the recipe) or to #, which comments the @@ -160,13 +160,17 @@ /^GNULIB_FCHMODAT *=/s/@GNULIB_FCHMODAT@/0/ /^GNULIB_FCLOSE *=/s/@GNULIB_FCLOSE@/0/ /^GNULIB_FFLUSH *=/s/@GNULIB_FFLUSH@/0/ +/^GNULIB_FGETC *=/s/@GNULIB_FGETC@/0/ +/^GNULIB_FGETS *=/s/@GNULIB_FGETS@/0/ /^GNULIB_FOPEN *=/s/@GNULIB_FOPEN@/0/ /^GNULIB_FPRINTF *=/s/@GNULIB_FPRINTF@/0/ /^GNULIB_FPRINTF_POSIX *=/s/@GNULIB_FPRINTF_POSIX@/0/ /^GNULIB_FPURGE *=/s/@GNULIB_FPURGE@/0/ /^GNULIB_FPUTC *=/s/@GNULIB_FPUTC@/0/ /^GNULIB_FPUTS *=/s/@GNULIB_FPUTS@/0/ +/^GNULIB_FREAD *=/s/@GNULIB_FREAD@/0/ /^GNULIB_FREOPEN *=/s/@GNULIB_FREOPEN@/0/ +/^GNULIB_FSCANF *=/s/@GNULIB_FSCANF@/0/ /^GNULIB_FSEEK *=/s/@GNULIB_FSEEK@/0/ /^GNULIB_FSEEKO *=/s/@GNULIB_FSEEKO@/0/ /^GNULIB_FSTATAT *=/s/@GNULIB_FSTATAT@/0/ @@ -176,6 +180,8 @@ /^GNULIB_FTRUNCATE *=/s/@GNULIB_FTRUNCATE@/0/ /^GNULIB_FUTIMENS *=/s/@GNULIB_FUTIMENS@/0/ /^GNULIB_FWRITE *=/s/@GNULIB_FWRITE@/0/ +/^GNULIB_GETC *=/s/@GNULIB_GETC@/0/ +/^GNULIB_GETCHAR *=/s/@GNULIB_GETCHAR@/0/ /^GNULIB_GETCWD *=/s/@GNULIB_GETCWD@/0/ /^GNULIB_GETDELIM *=/s/@GNULIB_GETDELIM@/0/ /^GNULIB_GETDOMAINNAME *=/s/@GNULIB_GETDOMAINNAME@/0/ @@ -187,6 +193,7 @@ /^GNULIB_GETLOGIN *=/s/@GNULIB_GETLOGIN@/0/ /^GNULIB_GETLOGIN_R *=/s/@GNULIB_GETLOGIN_R@/0/ /^GNULIB_GETPAGESIZE *=/s/@GNULIB_GETPAGESIZE@/0/ +/^GNULIB_GETS *=/s/@GNULIB_GETS@/0/ /^GNULIB_GETSUBOPT *=/s/@GNULIB_GETSUBOPT@/0/ /^GNULIB_GETUSERSHELL *=/s/@GNULIB_GETUSERSHELL@/0/ /^GNULIB_GRANTPT *=/s/@GNULIB_GRANTPT@/0/ @@ -226,6 +233,7 @@ /^GNULIB_PUTS *=/s/@GNULIB_PUTS@/0/ /^GNULIB_PWRITE *=/s/@GNULIB_PWRITE@/0/ /^GNULIB_RANDOM_R *=/s/@GNULIB_RANDOM_R@/0/ +/^GNULIB_READ *=/s/@GNULIB_READ@/0/ /^GNULIB_READLINK *=/s/@GNULIB_READLINK@/0/ /^GNULIB_READLINKAT *=/s/@GNULIB_READLINKAT@/0/ /^GNULIB_REALLOC_POSIX *=/s/@GNULIB_REALLOC_POSIX@/0/ @@ -235,11 +243,13 @@ /^GNULIB_RENAMEAT *=/s/@GNULIB_RENAMEAT@/0/ /^GNULIB_RMDIR *=/s/@GNULIB_RMDIR@/0/ /^GNULIB_RPMATCH *=/s/@GNULIB_RPMATCH@/0/ +/^GNULIB_SCANF *=/s/@GNULIB_SCANF@/0/ /^GNULIB_SETENV *=/s/@GNULIB_SETENV@/0/ /^GNULIB_SLEEP *=/s/@GNULIB_SLEEP@/0/ /^GNULIB_SNPRINTF *=/s/@GNULIB_SNPRINTF@/0/ /^GNULIB_SPRINTF_POSIX *=/s/@GNULIB_SPRINTF_POSIX@/0/ /^GNULIB_STAT *=/s/@GNULIB_STAT@/0/ +/^GNULIB_STDIO_H_NONBLOCKING *=/s/@GNULIB_STDIO_H_NONBLOCKING@/0/ /^GNULIB_STDIO_H_SIGPIPE *=/s/@GNULIB_STDIO_H_SIGPIPE@/0/ /^GNULIB_STRPTIME *=/s/@GNULIB_STRPTIME@/0/ /^GNULIB_STRTOD *=/s/@GNULIB_STRTOD@/0/ @@ -253,6 +263,7 @@ /^GNULIB_TMPFILE *=/s/@GNULIB_TMPFILE@/0/ /^GNULIB_TTYNAME_R *=/s/@GNULIB_TTYNAME_R@/0/ /^GNULIB_UNISTD_H_GETOPT *=/s/@GNULIB_UNISTD_H_GETOPT@/1/ +/^GNULIB_UNISTD_H_NONBLOCKING *=/s/@GNULIB_UNISTD_H_NONBLOCKING@/0/ /^GNULIB_UNISTD_H_SIGPIPE *=/s/@GNULIB_UNISTD_H_SIGPIPE@/0/ /^GNULIB_UNLINK *=/s/@GNULIB_UNLINK@/0/ /^GNULIB_UNLINKAT *=/s/@GNULIB_UNLINKAT@/0/ @@ -264,8 +275,10 @@ /^GNULIB_VDPRINTF *=/s/@GNULIB_VDPRINTF@/0/ /^GNULIB_VFPRINTF *=/s/@GNULIB_VFPRINTF@/0/ /^GNULIB_VFPRINTF_POSIX *=/s/@GNULIB_VFPRINTF_POSIX@/0/ +/^GNULIB_VFSCANF *=/s/@GNULIB_VFSCANF@/0/ /^GNULIB_VPRINTF *=/s/@GNULIB_VPRINTF@/0/ /^GNULIB_VPRINTF_POSIX *=/s/@GNULIB_VPRINTF_POSIX@/0/ +/^GNULIB_VSCANF *=/s/@GNULIB_VSCANF@/0/ /^GNULIB_VSNPRINTF *=/s/@GNULIB_VSNPRINTF@/0/ /^GNULIB_VSPRINTF_POSIX *=/s/@GNULIB_VSPRINTF_POSIX@/0/ /^GNULIB_WCTOMB *=/s/@GNULIB_WCTOMB@/0/ @@ -457,6 +470,7 @@ /^REPLACE_PRINTF *=/s/@REPLACE_PRINTF@/0/ /^REPLACE_PUTENV *=/s/@REPLACE_PUTENV@/0/ /^REPLACE_PWRITE *=/s/@REPLACE_PWRITE@/0/ +/^REPLACE_READ *=/s/@REPLACE_READ@/0/ /^REPLACE_READLINK *=/s/@REPLACE_READLINK@/0/ /^REPLACE_REALLOC *=/s/@REPLACE_REALLOC@/0/ /^REPLACE_REALPATH *=/s/@REPLACE_REALPATH@/0/ @@ -469,6 +483,7 @@ /^REPLACE_SNPRINTF *=/s/@REPLACE_SNPRINTF@/0/ /^REPLACE_SPRINTF *=/s/@REPLACE_SPRINTF@/0/ /^REPLACE_STAT *=/s/@REPLACE_STAT@/0/ +/^REPLACE_STDIO_READ_FUNCS *=/s/@REPLACE_STDIO_READ_FUNCS@/0/ /^REPLACE_STDIO_WRITE_FUNCS *=/s/@REPLACE_STDIO_WRITE_FUNCS@/0/ /^REPLACE_STRTOD *=/s/@REPLACE_STRTOD@/0/ /^REPLACE_SYMLINK *=/s/@REPLACE_SYMLINK@/0/ @@ -501,6 +516,7 @@ /^WINT_T_SUFFIX *=/s/@WINT_T_SUFFIX@// /^gl_LIBOBJS *=/s/@[^@\n]*@/getopt.o getopt1.o strftime.o time_r.o getloadavg.o md5.o filemode.o/ /^am_libgnu_a_OBJECTS *=/s/careadlinkat.\$(OBJEXT)// +/^am_libgnu_a_OBJECTS *=/s/allocator.\$(OBJEXT)// /^srcdir *=/s/@[^@\n]*@/./ /^top_srcdir *=/s/@[^@\n]*@/../ /^top_builddir *=/s/@[^@\n]*@/../ === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 09:00:03 +0000 +++ src/ChangeLog 2011-04-24 12:48:30 +0000 @@ -1,5 +1,20 @@ 2011-04-24 Eli Zaretskii + * msdos.c (XMenuActivate, XMenuAddSelection): Adjust argument list + to changes in oldXMenu/XMenu.h from 2011-04-16. + : Constify. + (IT_menu_make_room): menu->help_text is now `const char **'; + adjust. + + * msdos.h (XMenuActivate, XMenuAddSelection): Adjust prototypes + to changes in oldXMenu/XMenu.h from 2011-04-16. + (struct XMenu): Declare `help_text' `const char **'. + + * xfaces.c : Make extern again. + + * syntax.c: Include sys/types.h before including regex.h, as + required by Posix. + * doc.c (get_doc_string): Improve the format passed to `error'. * doprnt.c (doprnt): Improve commentary. === modified file 'src/msdos.c' --- src/msdos.c 2011-04-23 03:07:16 +0000 +++ src/msdos.c 2011-04-24 12:48:30 +0000 @@ -2812,7 +2812,7 @@ left), but I don't think it's worth the effort. */ /* These hold text of the current and the previous menu help messages. */ -static char *menu_help_message, *prev_menu_help_message; +static const char *menu_help_message, *prev_menu_help_message; /* Pane number and item number of the menu item which generated the last menu help message. */ static int menu_help_paneno, menu_help_itemno; @@ -2839,7 +2839,7 @@ menu->text = (char **) xmalloc (count * sizeof (char *)); menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); menu->panenumber = (int *) xmalloc (count * sizeof (int)); - menu->help_text = (char **) xmalloc (count * sizeof (char *)); + menu->help_text = (const char **) xmalloc (count * sizeof (char *)); } else if (menu->allocated == menu->count) { @@ -2851,7 +2851,7 @@ menu->panenumber = (int *) xrealloc (menu->panenumber, count * sizeof (int)); menu->help_text - = (char **) xrealloc (menu->help_text, count * sizeof (char *)); + = (const char **) xrealloc (menu->help_text, count * sizeof (char *)); } } @@ -3033,7 +3033,7 @@ int XMenuAddSelection (Display *bar, XMenu *menu, int pane, - int foo, char *txt, int enable, char *help_text) + int foo, char *txt, int enable, char const *help_text) { int len; char *p; @@ -3086,7 +3086,7 @@ int XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, int x0, int y0, unsigned ButtonMask, char **txt, - void (*help_callback)(char *, int, int)) + void (*help_callback)(char const *, int, int)) { struct IT_menu_state *state; int statecount, x, y, i, b, screensize, leave, result, onepane; === modified file 'src/msdos.h' --- src/msdos.h 2011-03-12 10:51:31 +0000 +++ src/msdos.h 2011-04-24 12:48:30 +0000 @@ -101,16 +101,16 @@ int allocated; int panecount; int width; - char **help_text; + const char **help_text; } XMenu; XMenu *XMenuCreate (Display *, Window, char *); -int XMenuAddPane (Display *, XMenu *, const char *, int); -int XMenuAddSelection (Display *, XMenu *, int, int, char *, int, char *); +int XMenuAddPane (Display *, XMenu *, char const *, int); +int XMenuAddSelection (Display *, XMenu *, int, int, char *, int, char const *); void XMenuLocate (Display *, XMenu *, int, int, int, int, int *, int *, int *, int *); int XMenuActivate (Display *, XMenu *, int *, int *, int, int, unsigned, - char **, void (*callback)(char *, int, int)); + char **, void (*callback)(char const *, int, int)); void XMenuDestroy (Display *, XMenu *); #endif /* not HAVE_X_WINDOWS */ === modified file 'src/syntax.c' --- src/syntax.c 2011-04-16 18:26:30 +0000 +++ src/syntax.c 2011-04-24 12:48:30 +0000 @@ -19,7 +19,9 @@ #include + #include +#include #include #include "lisp.h" #include "commands.h" === modified file 'src/xfaces.c' --- src/xfaces.c 2011-04-16 21:28:14 +0000 +++ src/xfaces.c 2011-04-24 12:48:30 +0000 @@ -331,7 +331,7 @@ static Lisp_Object Qultra_expanded; static Lisp_Object Qreleased_button, Qpressed_button; static Lisp_Object QCstyle, QCcolor, QCline_width; -static Lisp_Object Qunspecified; +Lisp_Object Qunspecified; /* used in dosfns.c */ static Lisp_Object Qignore_defface; char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; ------------------------------------------------------------ revno: 103985 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 12:00:03 +0300 message: Fallout from resurrecting doprnt. src/doc.c (get_doc_string): Improve the format passed to `error'. src/doprnt.c (doprnt): Improve commentary. src/term.c (init_tty) [MSDOS]: Fix 1st argument to maybe_fatal. src/Makefile.in (TAGS): Depend on $(M_FILE) and $(S_FILE), and scan them with etags. src/makefile.w32-in (TAGS): Depend on $(CURDIR)/m/intel386.h and $(CURDIR)/s/ms-w32.h. (TAGS-gmake): Scan $(CURDIR)/m/intel386.h and $(CURDIR)/s/ms-w32.h. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 07:15:17 +0000 +++ src/ChangeLog 2011-04-24 09:00:03 +0000 @@ -1,7 +1,19 @@ 2011-04-24 Eli Zaretskii + * doc.c (get_doc_string): Improve the format passed to `error'. + + * doprnt.c (doprnt): Improve commentary. + + * term.c (init_tty) [MSDOS]: Fix 1st argument to maybe_fatal. + + * Makefile.in (TAGS): Depend on $(M_FILE) and $(S_FILE), and scan + them with etags. + * makefile.w32-in (globals.h): Add a dummy recipe, to make any changes in globals.h immediately force recompilation. + (TAGS): Depend on $(CURDIR)/m/intel386.h and + $(CURDIR)/s/ms-w32.h. + (TAGS-gmake): Scan $(CURDIR)/m/intel386.h and $(CURDIR)/s/ms-w32.h. * character.c (Fchar_direction): Function deleted. (syms_of_character): Don't defsubr it. === modified file 'src/Makefile.in' --- src/Makefile.in 2011-04-23 10:33:28 +0000 +++ src/Makefile.in 2011-04-24 09:00:03 +0000 @@ -748,10 +748,10 @@ ctagsfiles1 = [xyzXYZ]*.[hcm] ctagsfiles2 = [a-wA-W]*.[hcm] -TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) +TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(M_FILE) $(S_FILE) ../lib-src/etags --include=TAGS-LISP --include=$(lwlibdir)/TAGS \ --regex='/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/' \ - $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) + $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(M_FILE) $(S_FILE) frc: TAGS-LISP: frc $(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags === modified file 'src/doc.c' --- src/doc.c 2011-04-14 19:34:42 +0000 +++ src/doc.c 2011-04-24 09:00:03 +0000 @@ -253,7 +253,9 @@ else if (c == '_') *to++ = 037; else - error ("Invalid data in documentation file -- ^A followed by code 0%o", c); + error ("\ +Invalid data in documentation file -- %c followed by code %03o", + 1, (unsigned)c); } else *to++ = *from++; === modified file 'src/doprnt.c' --- src/doprnt.c 2011-04-23 10:33:28 +0000 +++ src/doprnt.c 2011-04-24 09:00:03 +0000 @@ -1,6 +1,6 @@ /* Output like sprintf to a buffer of specified size. - Also takes args differently: pass one pointer to an array of strings - in addition to the format string which is separate. + Also takes args differently: pass one pointer to the end + of the format string in addition to the format string itself. Copyright (C) 1985, 2001-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -18,6 +18,35 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ +/* If you think about replacing this with some similar standard C function of + the printf family (such as vsnprintf), please note that this function + supports the following Emacs-specific features: + + . For %c conversions, it produces a string with the multibyte representation + of the (`int') argument, suitable for display in an Emacs buffer. + + . For %s and %c, when field width is specified (e.g., %25s), it accounts for + the diplay width of each character, according to char-width-table. That + is, it does not assume that each character takes one column on display. + + . If the size of the buffer is not enough to produce the formatted string in + its entirety, it makes sure that truncation does not chop the last + character in the middle of its multibyte sequence, producing an invalid + sequence. + + . It accepts a pointer to the end of the format string, so the format string + could include embedded null characters. + + . It signals an error if the length of the formatted string is about to + overflow MOST_POSITIVE_FIXNUM, to avoid producing strings longer than what + Emacs can handle. + + OTOH, this function supports only a small subset of the standard C formatted + output facilities. E.g., %u and %ll are not supported, and precision is + largely ignored except for converting floating-point values. However, this + is okay, as this function is supposed to be called from `error' and similar + functions, and thus does not need to support features beyond those in + `Fformat', which is used by `error' on the Lisp level. */ #include #include === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2011-04-24 07:15:17 +0000 +++ src/makefile.w32-in 2011-04-24 09:00:03 +0000 @@ -330,7 +330,7 @@ ## ## This works only with GNU Make. -TAGS: $(OBJ0) $(OBJ1) $(OBJ2) +TAGS: $(OBJ0) $(OBJ1) $(OBJ2) $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h $(MAKE) $(MFLAGS) TAGS-$(MAKETYPE) TAGS-LISP: $(OBJ0) $(OBJ1) $(OBJ2) @@ -344,7 +344,7 @@ $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ1)) ../lib-src/$(BLD)/etags.exe -a --regex=@../nt/emacs-src.tags \ $(patsubst $(BLD)%.$(O),$(CURDIR)%.c,$(OBJ2)) \ - $(CURDIR)/*.h + $(CURDIR)/*.h $(CURDIR)/m/intel386.h $(CURDIR)/s/ms-w32.h TAGS-nmake: echo This target is not supported with NMake === modified file 'src/term.c' --- src/term.c 2011-04-18 23:21:31 +0000 +++ src/term.c 2011-04-24 09:00:03 +0000 @@ -3121,7 +3121,7 @@ terminal = create_terminal (); #ifdef MSDOS if (been_here > 0) - maybe_fatal (1, 0, "Attempt to create another terminal %s", "", + maybe_fatal (0, 0, "Attempt to create another terminal %s", "", name, ""); been_here = 1; tty = &the_only_display_info; @@ -3627,7 +3627,7 @@ /* Auxiliary error-handling function for init_tty. Delete TERMINAL, then call error or fatal with str1 or str2, - respectively, according to MUST_SUCCEED. */ + respectively, according to whether MUST_SUCCEED is zero or not. */ static void maybe_fatal (int must_succeed, struct terminal *terminal, ------------------------------------------------------------ revno: 103984 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 10:15:17 +0300 message: Fix a minor bug in src/makefile.w32-in. src/makefile.w32-in (globals.h): Add a dummy recipe, to make any changes in globals.h immediately force recompilation. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-24 07:11:56 +0000 +++ src/ChangeLog 2011-04-24 07:15:17 +0000 @@ -1,5 +1,8 @@ 2011-04-24 Eli Zaretskii + * makefile.w32-in (globals.h): Add a dummy recipe, to make any + changes in globals.h immediately force recompilation. + * character.c (Fchar_direction): Function deleted. (syms_of_character): Don't defsubr it. : Deleted. === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2011-04-23 10:33:28 +0000 +++ src/makefile.w32-in 2011-04-24 07:15:17 +0000 @@ -225,6 +225,7 @@ obj = $(GLOBAL_SOURCES:.c=.o) globals.h: gl-stamp + @cmd /c rem true gl-stamp: ../lib-src/$(BLD)/make-docfile.exe $(GLOBAL_SOURCES) - $(DEL) gl-tmp ------------------------------------------------------------ revno: 103983 committer: Eli Zaretskii branch nick: trunk timestamp: Sun 2011-04-24 10:11:56 +0300 message: Delete char-direction-table and char-direction. See http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00675.html for the reasons. src/character.c (Fchar_direction): Function deleted. (syms_of_character): Don't defsubr it. : Deleted. etc/NEWS: Document the removal. diff: === modified file 'etc/NEWS' --- etc/NEWS 2011-04-20 22:31:06 +0000 +++ etc/NEWS 2011-04-24 07:11:56 +0000 @@ -134,7 +134,7 @@ libraries if they are present at build time. This needs ImageMagick 6.2.8 or newer (versions newer than 6.0.7 _may_ work but have not been tested). To disable ImageMagick support, use the configure option -`--without-imagemagick'. +`--without-imagemagick'. The new function `imagemagick-types' returns a list of image file extensions that your installation of ImageMagick supports. The @@ -720,6 +720,13 @@ * Incompatible Lisp Changes in Emacs 24.1 +--- +** `char-direction-table' and the associated function `char-direction' +were deleted. They were buggy and inferior to the new support of +bidirectional editing introduced in Emacs 24. If you need the +bidirectional properties of a character, use `get-char-code-property' +with the last argument `bidi-class'. + ** `copy-directory' now copies the source directory as a subdirectory of the target directory, if the latter is an existing directory. The new optional arg COPY-CONTENTS, if non-nil, makes the function copy === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-23 10:33:28 +0000 +++ src/ChangeLog 2011-04-24 07:11:56 +0000 @@ -1,3 +1,9 @@ +2011-04-24 Eli Zaretskii + + * character.c (Fchar_direction): Function deleted. + (syms_of_character): Don't defsubr it. + : Deleted. + 2011-04-23 Eli Zaretskii Fix doprnt so it could be used again safely in `verror'. (Bug#8435) === modified file 'src/character.c' --- src/character.c 2011-04-23 17:19:56 +0000 +++ src/character.c 2011-04-24 07:11:56 +0000 @@ -493,19 +493,6 @@ return val; } -DEFUN ("char-direction", Fchar_direction, Schar_direction, 1, 1, 0, - doc: /* Return the direction of CHAR. -The returned value is 0 for left-to-right and 1 for right-to-left. -usage: (char-direction CHAR) */) - (Lisp_Object ch) -{ - int c; - - CHECK_CHARACTER (ch); - c = XINT (ch); - return CHAR_TABLE_REF (Vchar_direction_table, c); -} - /* Return the number of characters in the NBYTES bytes at PTR. This works by looking at the contents and checking for multibyte sequences while assuming that there's no invalid sequence. @@ -1037,7 +1024,6 @@ defsubr (&Smultibyte_char_to_unibyte); defsubr (&Schar_width); defsubr (&Sstring_width); - defsubr (&Schar_direction); defsubr (&Sstring); defsubr (&Sunibyte_string); defsubr (&Schar_resolve_modifiers); @@ -1066,10 +1052,6 @@ char_table_set_range (Vchar_width_table, MAX_5_BYTE_CHAR + 1, MAX_CHAR, make_number (4)); - DEFVAR_LISP ("char-direction-table", Vchar_direction_table, - doc: /* A char-table for direction of each character. */); - Vchar_direction_table = Fmake_char_table (Qnil, make_number (1)); - DEFVAR_LISP ("printable-chars", Vprintable_chars, doc: /* A char-table for each printable character. */); Vprintable_chars = Fmake_char_table (Qnil, Qnil); ------------------------------------------------------------ revno: 103982 committer: Chong Yidong branch nick: trunk timestamp: Sat 2011-04-23 20:24:30 -0400 message: * files.el (auto-mode-alist): Use js-mode for .json (Bug#8529). diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-24 00:15:26 +0000 +++ lisp/ChangeLog 2011-04-24 00:24:30 +0000 @@ -1,5 +1,7 @@ 2011-04-24 Chong Yidong + * files.el (auto-mode-alist): Use js-mode for .json (Bug#8529). + * apropos.el (apropos-label-face): Avoid variable-pitch face. (apropos-accumulator): Doc fix. (apropos-function, apropos-macro, apropos-command) === modified file 'lisp/files.el' --- lisp/files.el 2011-04-19 13:44:55 +0000 +++ lisp/files.el 2011-04-24 00:24:30 +0000 @@ -2386,6 +2386,7 @@ ("\\.dtd\\'" . sgml-mode) ("\\.ds\\(ss\\)?l\\'" . dsssl-mode) ("\\.js\\'" . js-mode) ; javascript-mode would be better + ("\\.json\\'" . js-mode) ("\\.[ds]?vh?\\'" . verilog-mode) ;; .emacs or .gnus or .viper following a directory delimiter in ;; Unix, MSDOG or VMS syntax. ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.