emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 bb0cd31 2/2: Merge branch 'emacs-25' of git.sv.gn


From: Phillip Lord
Subject: [Emacs-diffs] emacs-25 bb0cd31 2/2: Merge branch 'emacs-25' of git.sv.gnu.org:/srv/git/emacs into emacs-25
Date: Fri, 15 Jan 2016 22:22:34 +0000

branch: emacs-25
commit bb0cd3193912032ae11a27016271d4587f876f98
Merge: 549a765 9e5452f
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    Merge branch 'emacs-25' of git.sv.gnu.org:/srv/git/emacs into emacs-25
---
 configure.ac                |   16 ++++++++++++++++
 doc/lispref/numbers.texi    |    4 +++-
 doc/man/etags.1             |   12 +++++++++---
 etc/NEWS                    |   10 ++++++++--
 lib-src/etags.c             |    3 +--
 lisp/gnus/gnus-start.el     |   10 +++++-----
 lisp/newcomment.el          |   12 ++++++++++--
 lisp/progmodes/cc-engine.el |    6 ++++++
 lisp/progmodes/cc-langs.el  |    8 ++++++++
 lisp/textmodes/picture.el   |    6 +++++-
 src/dispnew.c               |    4 +++-
 src/fns.c                   |    3 ++-
 src/sysdep.c                |   31 +++++++++++++++++++++++++++++--
 src/w32.c                   |   32 ++++++++++++++++++++++++++++++++
 src/w32.h                   |    3 +++
 src/window.c                |   10 ++++++----
 16 files changed, 146 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8c01aba..6c9b621 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4153,6 +4153,22 @@ fi
 
 AC_TYPE_MBSTATE_T
 
+AC_MSG_CHECKING([whether "/dev/urandom" is available])
+dev_urandom=no
+dnl MSYS, being a Cygwin fork, thinks "/dev/urandom" does exist, so
+dnl don't check this for the MinGW builds.
+if test "${opsys}" != "mingw32"; then
+   if test -r "/dev/urandom"; then
+      AC_DEFINE(HAVE_DEV_URANDOM, 1, [Define if the system supports the 
"/dev/urandom" device.])
+      dev_urandom=yes
+   fi
+fi
+if test $dev_urandom = yes; then
+   AC_MSG_RESULT(yes)
+else
+   AC_MSG_RESULT(no)
+fi
+
 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
 dnl how the tty code is related to POSIX and/or other versions of termios.
 dnl The following looks like a useful start.
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index 20d3c42..3a9483a 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -1252,7 +1252,9 @@ any integer representable in Lisp, i.e., an integer 
between
 (@pxref{Integer Basics}).
 
 If @var{limit} is @code{t}, it means to choose a new seed as if Emacs
-were restarting.
+were restarting.  The new seed will be set from the system entropy, if
+that is available, or from the current time and Emacs process's PID
+(@pxref{System Environment, emacs-pid}) if not.
 
 If @var{limit} is a string, it means to choose a new seed based on the
 string's contents.
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index 7d5d374..d34063f 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -17,7 +17,7 @@ etags, ctags \- generate tag file for Emacs, vi
 [\|\-\-parse\-stdin=\fIfile\fP\|]
 .br
 [\|\-\-append\|] [\|\-\-no\-defines\|] [\|\-\-globals\|]
-[\|\-\-no\-globals\|] [\|\-\-include=\fIfile\fP\|]
+[\|\-\-no\-globals\|] [\|\-\-no\-line\-directive\|] 
[\|\-\-include=\fIfile\fP\|]
 [\|\-\-ignore\-indentation\|] [\|\-\-language=\fIlanguage\fP\|]
 [\|\-\-members\|] [\|\-\-no\-members\|] [\|\-\-output=\fItagfile\fP\|]
 [\|\-\-class\-qualify\|]
@@ -31,8 +31,8 @@ etags, ctags \- generate tag file for Emacs, vi
 [\|\-\-parse\-stdin=\fIfile\fP\|]
 .br
 [\|\-\-append\|] [\|\-\-backward\-search\|]
-[\|\-\-cxref\|] [\|\-\-no\-defines\|]
-[\|\-\-globals\|] [\|\-\-no\-globals\|] [\|\-\-ignore\-indentation\|]
+[\|\-\-cxref\|] [\|\-\-no\-defines\|] [\|\-\-globals\|]
+[\|\-\-no\-globals\|] [\|\-\-no\-line\-directive\|] 
[\|\-\-ignore\-indentation\|]
 [\|\-\-language=\fIlanguage\fP\|] [\|\-\-members\|] [\|\-\-no\-members\|]
 [\|\-\-class\-qualify\|]
 [\|\-\-output=\fItagfile\fP\|] [\|\-\-regex=\fIregexp\fP\|]
@@ -105,6 +105,12 @@ the default in C and derived languages.
 Do not tag global variables in C and derived languages.  Typically this
 reduces the file size by one fourth.
 .TP
+.B \-\-no\-line\-directive
+Ignore \fB#line\fP preprocessor directives in C and derived languages.  The
+default is to honor those directives, and record the tags as if the
+file scanned was the one named in the \fB#line\fP directive.  This switch is
+useful when the original file named by \fB#line\fP is no longer available.
+.TP
 \fB\-i\fP \fIfile\fP, \fB\-\-include=\fIfile\fP
 Include a note in the tag file indicating that, when searching for a
 tag, one should also consult the tags file \fIfile\fP after checking the
diff --git a/etc/NEWS b/etc/NEWS
index ef72d45..9e63579 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -214,6 +214,14 @@ for use in Emacs bug reports.
 hiding character but the default `.' can be used by let-binding the
 variable `read-hide-char'.
 
++++
+** The Emacs pseudo-random number generator can be securely seeded.
+On system where Emacs can access the system entropy or some other
+cryptographically secure random stream, it now uses that when `random'
+is called with its argument `t'.  This allows cryptographically strong
+random values; in particular, the Emacs server now uses this facility
+to produce its authentication key.
+
 ---
 ** New input methods: `tamil-dvorak' and `programmer-dvorak'.
 
@@ -726,8 +734,6 @@ to produce a neat summary.
 
 ---
 ** New js.el option `js-indent-first-init'.
-It was renamed from `js-indent-first-initialiser', to avoid issues
-with American vs British spelling.
 
 ** Info
 
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 2192627..54ed1b4 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -951,8 +951,7 @@ Relative ones are stored relative to the output file's 
directory.\n");
        Do not create tag entries for global variables in some\n\
        languages.  This makes the tags file smaller.");
 
-  if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
-    puts ("--no-line-directive\n\
+  puts ("--no-line-directive\n\
         Ignore #line preprocessor directives in C and derived languages.");
 
   if (CTAGS)
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index 4efec86..10f93d8 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -122,7 +122,6 @@ This variable can be a list of select methods which Gnus 
will query with
 the `ask-server' method in addition to the primary, secondary, and archive
 servers.
 
-
 E.g.:
   (setq gnus-check-new-newsgroups
        \\='((nntp \"some.server\") (nntp \"other.server\")))
@@ -1673,10 +1672,11 @@ backend check whether the group actually exists."
        (push (setq method-group-list (list method method-type nil nil))
              type-cache))
       ;; Only add groups that need updating.
-      (if (funcall (if one-level #'= #'<=) (gnus-info-level info)
-             (if (eq (cadr method-group-list) 'foreign)
-                 foreign-level
-               alevel))
+      (if (or (and foreign-level (null (numberp foreign-level)))
+             (funcall (if one-level #'= #'<=) (gnus-info-level info)
+                      (if (eq (cadr method-group-list) 'foreign)
+                          foreign-level
+                        alevel)))
          (setcar (nthcdr 2 method-group-list)
                  (cons info (nth 2 method-group-list)))
        ;; The group is inactive, so we nix out the number of unread articles.
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 88ed08d..80b52ed 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -990,6 +990,14 @@ comment markers."
          (goto-char (point-max))))))
   (set-marker end nil))
 
+(defun comment-make-bol-ws (len)
+  "Make a white-space string of width LEN for use at BOL.
+When `indent-tabs-mode' is non-nil, tab characters will be used."
+  (if (and indent-tabs-mode (> tab-width 0))
+      (concat (make-string (/ len tab-width) ?\t)
+             (make-string (% len tab-width) ? ))
+    (make-string len ? )))
+
 (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional 
block)
   "Make the leading and trailing extra lines.
 This is used for `extra-line' style (or `box' style if BLOCK is specified)."
@@ -1025,8 +1033,8 @@ This is used for `extra-line' style (or `box' style if 
BLOCK is specified)."
          (setq cs (replace-match fill t t s)))
        (string-match re e)
        (setq ce (replace-match fill t t e))))
-    (cons (concat cs "\n" (make-string min-indent ? ) ccs)
-         (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce))))
+    (cons (concat cs "\n" (comment-make-bol-ws min-indent) ccs)
+         (concat cce "\n" (comment-make-bol-ws (+ min-indent eindent)) ce))))
 
 (defmacro comment-with-narrowing (beg end &rest body)
   "Execute BODY with BEG..END narrowing.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index b08c555..63f0182 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6739,6 +6739,9 @@ comment at the start of cc-engine.el for more info."
                      (c-backward-syntactic-ws))
                    (c-back-over-list-of-member-inits)
                    (and (eq (char-before) ?:)
+                        (save-excursion
+                          (c-backward-token-2)
+                          (not (looking-at c-:$-multichar-token-regexp)))
                         (c-just-after-func-arglist-p))))
 
            (while (and (not (and level-plausible
@@ -6753,6 +6756,9 @@ comment at the start of cc-engine.el for more info."
                      (c-backward-syntactic-ws)
                      (c-back-over-list-of-member-inits)
                      (and (eq (char-before) ?:)
+                          (save-excursion
+                            (c-backward-token-2)
+                            (not (looking-at c-:$-multichar-token-regexp)))
                           (c-just-after-func-arglist-p)))))
 
            (and at-top-level level-plausible)))
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index b52da3f..48dd996 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1219,6 +1219,14 @@ operators."
 (c-lang-defvar c-assignment-op-regexp
   (c-lang-const c-assignment-op-regexp))
 
+(c-lang-defconst c-:$-multichar-token-regexp
+  ;; Regexp matching all tokens ending in ":" which are longer than one char.
+  ;; Currently (2016-01-07) only used in C++ Mode.
+  t (c-make-keywords-re nil
+      (c-filter-ops (c-lang-const c-operators) t ".+:$")))
+(c-lang-defvar c-:$-multichar-token-regexp
+  (c-lang-const c-:$-multichar-token-regexp))
+
 (c-lang-defconst c-<>-multichar-token-regexp
   ;; Regexp matching all tokens containing "<" or ">" which are longer
   ;; than one char.
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index 4aee273..b77f8e9 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -272,7 +272,11 @@ Use \"\\[command-apropos] picture-movement\" to see 
commands which control motio
        (or (eolp)
            (let ((pos (point)))
              (move-to-column col t)
-             (delete-region pos (point)))))
+             (let ((old-width (string-width (buffer-substring pos (point)))))
+               (delete-region pos (point))
+               (when (> old-width width)
+                 (insert-char ?  (- old-width width))
+                 (goto-char pos))))))
       (insert ch)
       (forward-char -1)
       (picture-move))))
diff --git a/src/dispnew.c b/src/dispnew.c
index 8d671f8..3e1557f 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -320,7 +320,9 @@ margin_glyphs_to_reserve (struct window *w, int 
total_glyphs, int margin)
       int width = w->total_cols;
       double d = max (0, margin);
       d = min (width / 2 - 1, d);
-      return (int) ((double) total_glyphs / width * d);
+      /* Since MARGIN is positive, we cannot possibly have less than
+        one glyph for the marginal area.  */
+      return max (1, (int) ((double) total_glyphs / width * d));
     }
   return 0;
 }
diff --git a/src/fns.c b/src/fns.c
index 977229b..19fa440 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -50,7 +50,8 @@ All integers representable in Lisp, i.e. between 
`most-negative-fixnum'
 and `most-positive-fixnum', inclusive, are equally likely.
 
 With positive integer LIMIT, return random number in interval [0,LIMIT).
-With argument t, set the random number seed from the current time and pid.
+With argument t, set the random number seed from the system's entropy
+pool, or from the current time and pid if entropy is unavailable.
 With a string argument, set the seed based on the string's contents.
 Other values of LIMIT are ignored.
 
diff --git a/src/sysdep.c b/src/sysdep.c
index a78c4c6..1fa4229 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2095,8 +2095,35 @@ seed_random (void *seed, ptrdiff_t seed_size)
 void
 init_random (void)
 {
-  struct timespec t = current_timespec ();
-  uintmax_t v = getpid () ^ t.tv_sec ^ t.tv_nsec;
+  uintmax_t v;
+  struct timespec t;
+  bool success = false;
+
+#if HAVE_DEV_URANDOM
+  FILE *fp = fopen ("/dev/urandom", "rb");
+
+  if (fp)
+    {
+      int i;
+
+      for (i = 0, v = 0; i < sizeof (uintmax_t); i++)
+       {
+         v <<= 8;
+         v |= fgetc (fp);
+       }
+      fclose (fp);
+      success = true;
+    }
+#elif defined WINDOWSNT
+  if (w32_init_random (&v, sizeof v) == 0)
+    success = true;
+#endif /* HAVE_DEV_URANDOM || WINDOWSNT */
+  if (!success)
+    {
+      /* Fall back to current time value + PID.  */
+      t = current_timespec ();
+      v = getpid () ^ t.tv_sec ^ t.tv_nsec;
+    }
   seed_random (&v, sizeof v);
 }
 
diff --git a/src/w32.c b/src/w32.c
index ea3a9da..7884bad 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -224,6 +224,8 @@ typedef struct _REPARSE_DATA_BUFFER {
 
 #include <iphlpapi.h>  /* should be after winsock2.h */
 
+#include <wincrypt.h>
+
 #include <c-strcase.h>
 
 #include "w32.h"
@@ -2093,6 +2095,34 @@ init_user_info (void)
     CloseHandle (token);
 }
 
+static HCRYPTPROV w32_crypto_hprov;
+static int
+w32_init_crypt_random (void)
+{
+  if (!CryptAcquireContext (&w32_crypto_hprov, NULL, NULL, PROV_RSA_FULL,
+                           CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+    {
+      DebPrint (("CryptAcquireContext failed with error %x\n",
+                GetLastError ()));
+      w32_crypto_hprov = 0;
+      return -1;
+    }
+  return 0;
+}
+
+int
+w32_init_random (void *buf, ptrdiff_t buflen)
+{
+  if (!w32_crypto_hprov)
+    w32_init_crypt_random ();
+  if (w32_crypto_hprov)
+    {
+      if (CryptGenRandom (w32_crypto_hprov, buflen, (BYTE *)buf))
+       return 0;
+    }
+  return -1;
+}
+
 int
 random (void)
 {
@@ -9410,6 +9440,8 @@ globals_of_w32 (void)
   extern void dynlib_reset_last_error (void);
   dynlib_reset_last_error ();
 #endif
+
+  w32_crypto_hprov = (HCRYPTPROV)0;
 }
 
 /* For make-serial-process  */
diff --git a/src/w32.h b/src/w32.h
index 501056d..ba3fec8 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -222,6 +222,9 @@ extern int w32_memory_info (unsigned long long *, unsigned 
long long *,
 /* Compare 2 UTF-8 strings in locale-dependent fashion.  */
 extern int w32_compare_strings (const char *, const char *, char *, int);
 
+/* Return a cryptographically secure seed for PRNG.  */
+extern int w32_init_random (void *, ptrdiff_t);
+
 #ifdef HAVE_GNUTLS
 #include <gnutls/gnutls.h>
 
diff --git a/src/window.c b/src/window.c
index bb414e7..bbe47c7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3970,9 +3970,11 @@ values.  */)
 }
 
 
-/* Resize frame F's windows when number of lines of F is set to SIZE.
-   HORFLAG means resize windows when number of columns of F is set to
-   SIZE.  PIXELWISE means to interpret SIZE as pixels.  */
+/* Resize frame F's windows when F's width or height is set to SIZE.
+   If HORFLAG is zero, F's width was set to SIZE, otherwise its height
+   was set.  SIZE is interpreted in F's canonical character units
+   (a.k.a. "columns" or "lines"), unless PIXELWISE is non-zero, which
+   means to interpret SIZE in pixel units.  */
 void
 resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise)
 {
@@ -4073,7 +4075,7 @@ resize_frame_windows (struct frame *f, int size, bool 
horflag, bool pixelwise)
       m = XWINDOW (mini);
       if (horflag)
        {
-         m->total_cols = size;
+         m->total_cols = new_size;
          m->pixel_width = new_pixel_size;
        }
       else



reply via email to

[Prev in Thread] Current Thread [Next in Thread]