[phobos] [D-Programming-Language/phobos] cb5ee3: Fix Issue #12877: allow uniform() to handle dchar ...

GitHub via phobos phobos at puremagic.com
Tue Jun 10 05:14:37 PDT 2014


  Branch: refs/heads/master
  Home:   https://github.com/D-Programming-Language/phobos
  Commit: cb5ee35ad69024293d5d557151e5939065fa0a06
      https://github.com/D-Programming-Language/phobos/commit/cb5ee35ad69024293d5d557151e5939065fa0a06
  Author: Joseph Rushton Wakeling <joe at webdrake.net>
  Date:   2014-06-08 (Sun, 08 Jun 2014)

  Changed paths:
    M std/random.d

  Log Message:
  -----------
  Fix Issue #12877: allow uniform() to handle dchar variates

Since [dchar.min, dchar.max] does not cover the full bit range of dchar,
optimizations that work for other integral types will fail here, and
result in illegal unicode points being generated.

This fix avoids breaking any existing calls to uniform() via a twofold
approach:

   * uniform!"[]"(T.min, T.max) will only call uniform!ResultType if
     T is not a dchar;

   * uniform!dchar will not try and use the entire bit range but will
     instead call uniform!"[]"(dchar.min, dchar.max).

Unittests have been added that should prevent such issues from arising
again.


  Commit: 240a11ebe31ca9980d951553c2dac3fd62070b56
      https://github.com/D-Programming-Language/phobos/commit/240a11ebe31ca9980d951553c2dac3fd62070b56
  Author: monarch dodra <monarchdodra at gmail.com>
  Date:   2014-06-10 (Tue, 10 Jun 2014)

  Changed paths:
    M std/random.d

  Log Message:
  -----------
  Merge pull request #2235 from WebDrake/uniform-dchar

Fix Issue #12877: allow uniform() to handle dchar variates


Compare: https://github.com/D-Programming-Language/phobos/compare/4b47a2530ed7...240a11ebe31c


More information about the phobos mailing list