]> code.delx.au - gnu-emacs/commitdiff
Merge from origin/emacs-25
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 May 2016 01:14:22 +0000 (18:14 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 May 2016 01:14:22 +0000 (18:14 -0700)
d8affa3 Use ‘T *restrict’ proto, not ‘T[restrict]’
d38d2a8 Fix documentation of 'url-retrieve-synchronously'
586b213 * lisp/url/url.el (url-retrieve-synchronously): Doc fix.  (Bu...

# Conflicts:
# doc/misc/url.texi
# lisp/url/url.el

1  2 
doc/misc/url.texi
src/fns.c

diff --combined doc/misc/url.texi
index fe03234d111b9217d79d97f4b88244fa979491a6,a3c6b88ea05d3f43f8c1d02318f1c49947c6e4a9..097f626e71893aca4db457bb241bbd02362f58cd
@@@ -289,16 -289,15 +289,17 @@@ string or a parsed URL structure.  If i
  passed through @code{url-encode-url} before using it, to ensure that
  it is properly URI-encoded (@pxref{URI Encoding}).
  
 -@defun url-retrieve-synchronously url silent no-cookies
 +@defun url-retrieve-synchronously url &optional silent no-cookies timeout
  This function synchronously retrieves the data specified by @var{url},
  and returns a buffer containing the data.  The return value is
  @code{nil} if there is no data associated with the URL (as is the case
  for @code{dired}, @code{info}, and @code{mailto} URLs).
  
- If @var{silent} is non-@code{nil}, don't do any messaging while
- retrieving.  If @var{inhibit-cookies} is non-@code{nil}, refuse to
- store cookies.  If @var{timeout} is passed, it should be a number that
+ If the optional argument @var{silent} is non-@code{nil}, progress
+ messages are suppressed.  If the optional argument @var{no-cookies} is
 -non-@code{nil}, cookies are not stored or sent.
++non-@code{nil}, cookies are not stored or sent.  If the optional
++argument @var{timeout} is non-@code{nil}, it should be a number that
 +says (in seconds) how long to wait for a response before giving up.
  @end defun
  
  @defun url-retrieve url callback &optional cbargs silent no-cookies
@@@ -422,12 -421,6 +423,12 @@@ cookies, if there are any.  You can rem
  @kbd{C-k} (@code{url-cookie-delete}) command.
  @end defun
  
 +@defun url-cookie-delete-cookies &optional regexp
 +This function takes a regular expression as its parameters and deletes
 +all cookies from that domain.  If @var{regexp} is @code{nil}, delete
 +all cookies.
 +@end defun
 +
  @defopt url-cookie-file
  The file in which cookies are stored, defaulting to @file{cookies} in
  the directory specified by @code{url-configuration-directory}.
@@@ -1342,16 -1335,10 +1343,16 @@@ Connect directly
  @end defopt
  
  @defopt url-user-agent
 -The User Agent string used for sending HTTP/HTTPS requests.  The value
 -should be a string or a function of no arguments that returns a
 -string.  The default value is @w{@samp{User-Agent: @var{package-name}
 -URL/Emacs}}, where @var{package-name} is the value of
 +The User Agent string used for sending @acronym{HTTP}/@acronym{HTTPS}
 +requests.  The value should be @code{nil}, which means that no
 +@samp{User-Agent} header is generated, @code{default}, which means
 +that a string is generated based on the setting of
 +@code{url-privacy-leve}, a string or a function of no arguments that
 +returns a string.
 +
 +The default is @code{default}, which means that the
 +@w{@samp{User-Agent: @var{package-name} URL/Emacs}} string will be
 +generated, where @var{package-name} is the value of
  @code{url-package-name} and its version, if they are non-@code{nil}.
  @end defopt
  
diff --combined src/fns.c
index 5217b068882c1c169e97115b0b8f4c58bb4f5f41,9bbbb6d7b7177575c58f6a493e6771ae74322121..731f0a899a9415edfe8fe05f157c85246c63ed62
+++ b/src/fns.c
@@@ -21,10 -21,8 +21,10 @@@ along with GNU Emacs.  If not, see <htt
  #include <config.h>
  
  #include <unistd.h>
 +#include <filevercmp.h>
  #include <intprops.h>
  #include <vla.h>
 +#include <errno.h>
  
  #include "lisp.h"
  #include "character.h"
  #include "intervals.h"
  #include "window.h"
  
- #if __GNUC__ >= 4
  static void sort_vector_copy (Lisp_Object, ptrdiff_t,
-                             Lisp_Object [restrict], Lisp_Object [restrict]);
- #else
- static void sort_vector_copy (Lisp_Object, ptrdiff_t,
-                             Lisp_Object [], Lisp_Object []);
- #endif
+                             Lisp_Object *restrict, Lisp_Object *restrict);
  static bool internal_equal (Lisp_Object, Lisp_Object, int, bool, Lisp_Object);
  
  DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
@@@ -338,50 -331,6 +333,50 @@@ Symbols are also allowed; their print n
    return i1 < SCHARS (string2) ? Qt : Qnil;
  }
  
 +DEFUN ("string-version-lessp", Fstring_version_lessp,
 +       Sstring_version_lessp, 2, 2, 0,
 +       doc: /* Return non-nil if S1 is less than S2, as version strings.
 +
 +This function compares version strings S1 and S2:
 +   1) By prefix lexicographically.
 +   2) Then by version (similarly to version comparison of Debian's dpkg).
 +      Leading zeros in version numbers are ignored.
 +   3) If both prefix and version are equal, compare as ordinary strings.
 +
 +For example, \"foo2.png\" compares less than \"foo12.png\".
 +Case is significant.
 +Symbols are also allowed; their print names are used instead.  */)
 +  (Lisp_Object string1, Lisp_Object string2)
 +{
 +  if (SYMBOLP (string1))
 +    string1 = SYMBOL_NAME (string1);
 +  if (SYMBOLP (string2))
 +    string2 = SYMBOL_NAME (string2);
 +  CHECK_STRING (string1);
 +  CHECK_STRING (string2);
 +
 +  char *p1 = SSDATA (string1);
 +  char *p2 = SSDATA (string2);
 +  char *lim1 = p1 + SBYTES (string1);
 +  char *lim2 = p2 + SBYTES (string2);
 +  int cmp;
 +
 +  while ((cmp = filevercmp (p1, p2)) == 0)
 +    {
 +      /* If the strings are identical through their first null bytes,
 +       skip past identical prefixes and try again.  */
 +      ptrdiff_t size = strlen (p1) + 1;
 +      p1 += size;
 +      p2 += size;
 +      if (lim1 < p1)
 +      return lim2 < p2 ? Qnil : Qt;
 +      if (lim2 < p2)
 +      return Qnil;
 +    }
 +
 +  return cmp < 0 ? Qt : Qnil;
 +}
 +
  DEFUN ("string-collate-lessp", Fstring_collate_lessp, Sstring_collate_lessp, 2, 4, 0,
         doc: /* Return t if first arg string is less than second in collation order.
  Symbols are also allowed; their print names are used instead.
@@@ -1400,7 -1349,7 +1395,7 @@@ The value is actually the tail of LIST 
    (register Lisp_Object elt, Lisp_Object list)
  {
    register Lisp_Object tail;
 -  for (tail = list; CONSP (tail); tail = XCDR (tail))
 +  for (tail = list; !NILP (tail); tail = XCDR (tail))
      {
        register Lisp_Object tem;
        CHECK_LIST_CONS (tail, list);
@@@ -1448,7 -1397,7 +1443,7 @@@ The value is actually the tail of LIST 
    if (!FLOATP (elt))
      return Fmemq (elt, list);
  
 -  for (tail = list; CONSP (tail); tail = XCDR (tail))
 +  for (tail = list; !NILP (tail); tail = XCDR (tail))
      {
        register Lisp_Object tem;
        CHECK_LIST_CONS (tail, list);
@@@ -1761,7 -1710,7 +1756,7 @@@ changing the value of a sequence `foo'
      {
        Lisp_Object tail, prev;
  
 -      for (tail = seq, prev = Qnil; CONSP (tail); tail = XCDR (tail))
 +      for (tail = seq, prev = Qnil; !NILP (tail); tail = XCDR (tail))
        {
          CHECK_LIST_CONS (tail, seq);
  
@@@ -2813,24 -2762,17 +2808,24 @@@ require_unwind (Lisp_Object old_value
  
  DEFUN ("require", Frequire, Srequire, 1, 3, 0,
         doc: /* If feature FEATURE is not loaded, load it from FILENAME.
 -If FEATURE is not a member of the list `features', then the feature
 -is not loaded; so load the file FILENAME.
 -If FILENAME is omitted, the printname of FEATURE is used as the file name,
 -and `load' will try to load this name appended with the suffix `.elc',
 -`.el', or the system-dependent suffix for dynamic module files, in that
 -order.  The name without appended suffix will not be used.
 -See `get-load-suffixes' for the complete list of suffixes.
 -If the optional third argument NOERROR is non-nil,
 -then return nil if the file is not found instead of signaling an error.
 -Normally the return value is FEATURE.
 -The normal messages at start and end of loading FILENAME are suppressed.  */)
 +If FEATURE is not a member of the list `features', then the feature is
 +not loaded; so load the file FILENAME.
 +
 +If FILENAME is omitted, the printname of FEATURE is used as the file
 +name, and `load' will try to load this name appended with the suffix
 +`.elc', `.el', or the system-dependent suffix for dynamic module
 +files, in that order.  The name without appended suffix will not be
 +used.  See `get-load-suffixes' for the complete list of suffixes.
 +
 +The directories in `load-path' are searched when trying to find the
 +file name.
 +
 +If the optional third argument NOERROR is non-nil, then return nil if
 +the file is not found instead of signaling an error.  Normally the
 +return value is FEATURE.
 +
 +The normal messages at start and end of loading FILENAME are
 +suppressed.  */)
    (Lisp_Object feature, Lisp_Object filename, Lisp_Object noerror)
  {
    Lisp_Object tem;
@@@ -3011,6 -2953,7 +3006,6 @@@ The data read from the system are decod
  {
    char *str = NULL;
  #ifdef HAVE_LANGINFO_CODESET
 -  Lisp_Object val;
    if (EQ (item, Qcodeset))
      {
        str = nl_langinfo (CODESET);
        for (i = 0; i < 7; i++)
        {
          str = nl_langinfo (days[i]);
 -        val = build_unibyte_string (str);
 +        AUTO_STRING (val, str);
          /* Fixme: Is this coding system necessarily right, even if
             it is consistent with CODESET?  If not, what to do?  */
          ASET (v, i, code_convert_string_norecord (val, Vlocale_coding_system,
        for (i = 0; i < 12; i++)
        {
          str = nl_langinfo (months[i]);
 -        val = build_unibyte_string (str);
 +        AUTO_STRING (val, str);
          ASET (v, i, code_convert_string_norecord (val, Vlocale_coding_system,
                                                    0));
        }
@@@ -3679,6 -3622,8 +3674,6 @@@ larger_vector (Lisp_Object vec, ptrdiff
                         Low-level Functions
   ***********************************************************************/
  
 -struct hash_table_test hashtest_eq, hashtest_eql, hashtest_equal;
 -
  /* Compare KEY1 which has hash code HASH1 and KEY2 with hash code
     HASH2 in hash table H using `eql'.  Value is true if KEY1 and
     KEY2 are the same.  */
@@@ -3719,6 -3664,7 +3714,6 @@@ cmpfn_user_defined (struct hash_table_t
    return !NILP (call2 (ht->user_cmp_function, key1, key2));
  }
  
 -
  /* Value is a hash code for KEY for use in hash table H which uses
     `eq' to compare keys.  The hash code returned is guaranteed to fit
     in a Lisp integer.  */
  static EMACS_UINT
  hashfn_eq (struct hash_table_test *ht, Lisp_Object key)
  {
 -  EMACS_UINT hash = XHASH (key) ^ XTYPE (key);
 -  return hash;
 +  return XHASH (key) ^ XTYPE (key);
  }
  
  /* Value is a hash code for KEY for use in hash table H which uses
 -   `eql' to compare keys.  The hash code returned is guaranteed to fit
 +   `equal' to compare keys.  The hash code returned is guaranteed to fit
     in a Lisp integer.  */
  
  static EMACS_UINT
 -hashfn_eql (struct hash_table_test *ht, Lisp_Object key)
 +hashfn_equal (struct hash_table_test *ht, Lisp_Object key)
  {
 -  EMACS_UINT hash;
 -  if (FLOATP (key))
 -    hash = sxhash (key, 0);
 -  else
 -    hash = XHASH (key) ^ XTYPE (key);
 -  return hash;
 +  return sxhash (key, 0);
  }
  
  /* Value is a hash code for KEY for use in hash table H which uses
 -   `equal' to compare keys.  The hash code returned is guaranteed to fit
 +   `eql' to compare keys.  The hash code returned is guaranteed to fit
     in a Lisp integer.  */
  
  static EMACS_UINT
 -hashfn_equal (struct hash_table_test *ht, Lisp_Object key)
 +hashfn_eql (struct hash_table_test *ht, Lisp_Object key)
  {
 -  EMACS_UINT hash = sxhash (key, 0);
 -  return hash;
 +  return FLOATP (key) ? hashfn_equal (ht, key) : hashfn_eq (ht, key);
  }
  
  /* Value is a hash code for KEY for use in hash table H which uses as
@@@ -3760,14 -3713,6 +3755,14 @@@ hashfn_user_defined (struct hash_table_
    return hashfn_eq (ht, hash);
  }
  
 +struct hash_table_test const
 +  hashtest_eq = { LISPSYM_INITIALLY (Qeq), LISPSYM_INITIALLY (Qnil),
 +                LISPSYM_INITIALLY (Qnil), 0, hashfn_eq },
 +  hashtest_eql = { LISPSYM_INITIALLY (Qeql), LISPSYM_INITIALLY (Qnil),
 +                 LISPSYM_INITIALLY (Qnil), cmpfn_eql, hashfn_eql },
 +  hashtest_equal = { LISPSYM_INITIALLY (Qequal), LISPSYM_INITIALLY (Qnil),
 +                   LISPSYM_INITIALLY (Qnil), cmpfn_equal, hashfn_equal };
 +
  /* Allocate basically initialized hash table.  */
  
  static struct Lisp_Hash_Table *
@@@ -4457,29 -4402,15 +4452,29 @@@ sxhash (Lisp_Object obj, int depth
                            Lisp Interface
   ***********************************************************************/
  
 +DEFUN ("sxhash-eq", Fsxhash_eq, Ssxhash_eq, 1, 1, 0,
 +       doc: /* Return an integer hash code for OBJ suitable for `eq'.
 +If (eq A B), then (= (sxhash-eq A) (sxhash-eq B)).  */)
 +  (Lisp_Object obj)
 +{
 +  return make_number (hashfn_eq (NULL, obj));
 +}
  
 -DEFUN ("sxhash", Fsxhash, Ssxhash, 1, 1, 0,
 -       doc: /* Compute a hash code for OBJ and return it as integer.  */)
 +DEFUN ("sxhash-eql", Fsxhash_eql, Ssxhash_eql, 1, 1, 0,
 +       doc: /* Return an integer hash code for OBJ suitable for `eql'.
 +If (eql A B), then (= (sxhash-eql A) (sxhash-eql B)).  */)
    (Lisp_Object obj)
  {
 -  EMACS_UINT hash = sxhash (obj, 0);
 -  return make_number (hash);
 +  return make_number (hashfn_eql (NULL, obj));
  }
  
 +DEFUN ("sxhash-equal", Fsxhash_equal, Ssxhash_equal, 1, 1, 0,
 +       doc: /* Return an integer hash code for OBJ suitable for `equal'.
 +If (equal A B), then (= (sxhash-equal A) (sxhash-equal B)).  */)
 +  (Lisp_Object obj)
 +{
 +  return make_number (hashfn_equal (NULL, obj));
 +}
  
  DEFUN ("make-hash-table", Fmake_hash_table, Smake_hash_table, 0, MANY, 0,
         doc: /* Create and return a new hash table.
@@@ -4760,21 -4691,6 +4755,21 @@@ returns nil, then (funcall TEST x1 x2) 
  #include "sha256.h"
  #include "sha512.h"
  
 +static Lisp_Object
 +make_digest_string (Lisp_Object digest, int digest_size)
 +{
 +  unsigned char *p = SDATA (digest);
 +
 +  for (int i = digest_size - 1; i >= 0; i--)
 +    {
 +      static char const hexdigit[16] = "0123456789abcdef";
 +      int p_i = p[i];
 +      p[2 * i] = hexdigit[p_i >> 4];
 +      p[2 * i + 1] = hexdigit[p_i & 0xf];
 +    }
 +  return digest;
 +}
 +
  /* ALGORITHM is a symbol: md5, sha1, sha224 and so on. */
  
  static Lisp_Object
@@@ -4782,6 -4698,7 +4777,6 @@@ secure_hash (Lisp_Object algorithm, Lis
             Lisp_Object end, Lisp_Object coding_system, Lisp_Object noerror,
             Lisp_Object binary)
  {
 -  int i;
    ptrdiff_t size, start_char = 0, start_byte, end_char = 0, end_byte;
    register EMACS_INT b, e;
    register struct buffer *bp;
             SSDATA (digest));
  
    if (NILP (binary))
 -    {
 -      unsigned char *p = SDATA (digest);
 -      for (i = digest_size - 1; i >= 0; i--)
 -      {
 -        static char const hexdigit[16] = "0123456789abcdef";
 -        int p_i = p[i];
 -        p[2 * i] = hexdigit[p_i >> 4];
 -        p[2 * i + 1] = hexdigit[p_i & 0xf];
 -      }
 -      return digest;
 -    }
 +    return make_digest_string (digest, digest_size);
    else
      return make_unibyte_string (SSDATA (digest), digest_size);
  }
@@@ -5024,45 -4951,6 +5019,45 @@@ If BINARY is non-nil, returns a string 
  {
    return secure_hash (algorithm, object, start, end, Qnil, Qnil, binary);
  }
 +
 +DEFUN ("buffer-hash", Fbuffer_hash, Sbuffer_hash, 0, 1, 0,
 +       doc: /* Return a hash of the contents of BUFFER-OR-NAME.
 +This hash is performed on the raw internal format of the buffer,
 +disregarding any coding systems.
 +If nil, use the current buffer." */ )
 +  (Lisp_Object buffer_or_name)
 +{
 +  Lisp_Object buffer;
 +  struct buffer *b;
 +  struct sha1_ctx ctx;
 +
 +  if (NILP (buffer_or_name))
 +    buffer = Fcurrent_buffer ();
 +  else
 +    buffer = Fget_buffer (buffer_or_name);
 +  if (NILP (buffer))
 +    nsberror (buffer_or_name);
 +
 +  b = XBUFFER (buffer);
 +  sha1_init_ctx (&ctx);
 +
 +  /* Process the first part of the buffer. */
 +  sha1_process_bytes (BUF_BEG_ADDR (b),
 +                    BUF_GPT_BYTE (b) - BUF_BEG_BYTE (b),
 +                    &ctx);
 +
 +  /* If the gap is before the end of the buffer, process the last half
 +     of the buffer. */
 +  if (BUF_GPT_BYTE (b) < BUF_Z_BYTE (b))
 +    sha1_process_bytes (BUF_GAP_END_ADDR (b),
 +                      BUF_Z_ADDR (b) - BUF_GAP_END_ADDR (b),
 +                      &ctx);
 +
 +  Lisp_Object digest = make_uninit_string (SHA1_DIGEST_SIZE * 2);
 +  sha1_finish_ctx (&ctx, SSDATA (digest));
 +  return make_digest_string (digest, SHA1_DIGEST_SIZE);
 +}
 +
  \f
  void
  syms_of_fns (void)
    DEFSYM (Qkey_or_value, "key-or-value");
    DEFSYM (Qkey_and_value, "key-and-value");
  
 -  defsubr (&Ssxhash);
 +  defsubr (&Ssxhash_eq);
 +  defsubr (&Ssxhash_eql);
 +  defsubr (&Ssxhash_equal);
    defsubr (&Smake_hash_table);
    defsubr (&Scopy_hash_table);
    defsubr (&Shash_table_count);
@@@ -5163,7 -5049,6 +5158,7 @@@ this variable.  */)
    defsubr (&Sstring_equal);
    defsubr (&Scompare_strings);
    defsubr (&Sstring_lessp);
 +  defsubr (&Sstring_version_lessp);
    defsubr (&Sstring_collate_lessp);
    defsubr (&Sstring_collate_equalp);
    defsubr (&Sappend);
    defsubr (&Sbase64_decode_string);
    defsubr (&Smd5);
    defsubr (&Ssecure_hash);
 +  defsubr (&Sbuffer_hash);
    defsubr (&Slocale_info);
 -
 -  hashtest_eq.name = Qeq;
 -  hashtest_eq.user_hash_function = Qnil;
 -  hashtest_eq.user_cmp_function = Qnil;
 -  hashtest_eq.cmpfn = 0;
 -  hashtest_eq.hashfn = hashfn_eq;
 -
 -  hashtest_eql.name = Qeql;
 -  hashtest_eql.user_hash_function = Qnil;
 -  hashtest_eql.user_cmp_function = Qnil;
 -  hashtest_eql.cmpfn = cmpfn_eql;
 -  hashtest_eql.hashfn = hashfn_eql;
 -
 -  hashtest_equal.name = Qequal;
 -  hashtest_equal.user_hash_function = Qnil;
 -  hashtest_equal.user_cmp_function = Qnil;
 -  hashtest_equal.cmpfn = cmpfn_equal;
 -  hashtest_equal.hashfn = hashfn_equal;
  }