Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jan 1, 2023
2 parents 5645d87 + dcb45d6 commit f4f246a
Show file tree
Hide file tree
Showing 56 changed files with 4,889 additions and 19,941 deletions.
2 changes: 2 additions & 0 deletions .dscanner.ini
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,5 @@ trust_too_much="-std.regex,-std.stdio,-std.uni,-std.internal.cstring"
; Checks for if statements whose 'then' block is the same as the 'else' block
; Temporarily disable until https://github.com/dlang-community/D-Scanner/issues/593 is fixed
if_else_same_check="-std.typecons"
; Disable checks for generated unicode tables
long_line_check="-std.internal.unicode_decomp,-std.internal.unicode_comp,-std.internal.unicode_grapheme,-std.internal.unicode_norm,-std.internal.unicode_tables"
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
circleci.sh @CyberShadow @MartinNowak @wilzbach
etc/c/* @CyberShadow
posix.mak @CyberShadow @MartinNowak @wilzbach
# tools/unicode_table_generator.d
std/* @andralex
std/algorithm/* @andralex @JackStouffer @wilzbach @PetarKirov
std/array.d @JackStouffer @wilzbach @PetarKirov
Expand Down
15 changes: 15 additions & 0 deletions changelog/log_float_double_implementations.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Single- and double-precision implementations for log function families

New `float` and `double` overloads of $(REF log, std, math, exponential),
$(REF log10, std, math, exponential), $(REF log1p, std, math, exponential),
$(REF log2, std, math, exponential), and $(REF logb, std, math, exponential)
have been added to Phobos with proper 'software' implementations in the
corresponding precision. Furthermore, $(REF logb, std, math, exponential) is
now `pure`.

While this may result in a slowdown in some cases for DMD, the overall speed-up
factor for GDC and LDC is over 3x, for both `double` and `float`.

This also implies less precise results, especially in single-precision,
so if your code depended on more accurate results via 80-bit intermediate
precision, you'll have to cast the argument(s) explicitly now.
24 changes: 24 additions & 0 deletions changelog/unicode_properties_c.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The Unicode property "C" aka "Other" has had the wrong properties associated with it.

If you use `unicode.c` or `unicode.Other` (case insensitive) from `std.uni`, you should mitigate or fix your codebase.

This change makes it match the [Unicode Techical Report #44](https://www.unicode.org/reports/tr44/). Unfortunately if you are already using it with its previous wrong values, this will break your code, below is a function which reflects the original values that you can use to mitigate against any breakage.

---
@property auto loadPropertyOriginal(string name)() pure
{
import std.uni : unicode;

static if (name == "C" || name == "c" || name == "other" || name == "Other")
{
auto target = unicode.Co;
target |= unicode.Lo;
target |= unicode.No;
target |= unicode.So;
target |= unicode.Po;
return target;
}
else
return unicode.opDispatch!name;
}
---
5 changes: 5 additions & 0 deletions changelog/unicode_table_generator.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Unicode table generator is now in Phobos, tables are updated to version 15.

It is likely that this change will result in breakage in code and program usage.
This is due to a number of factors, the tables being updated so significantly and the table generator not having all its changes commited throughout the years.

28 changes: 28 additions & 0 deletions changelog/unique-struct-dtor.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
`std.typecons.Unique` now calls `destroy` on struct types

When Unique goes out of scope, any destructor will now be called.
Previously the destructor was not called then.

$(RUNNABLE_EXAMPLE
---
static int i;

struct S
{
~this()
{
i++;
}
}
{
Unique!S u = new S;
// S.~this now called here
}
assert(i == 1);
---
)

$(B Note:) Above, the struct destructor will also be called by the GC just
before the memory for `new S` is reclaimed. Take care that any struct
destructor used will handle being called again on the struct `.init`
value.
4 changes: 4 additions & 0 deletions etc/c/zlib/osx.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
CC=gcc
LD=link
CFLAGS=-I. -O -g -DHAVE_UNISTD_H -DHAVE_STDARG_H
ifeq (64,$(MODEL))
CFLAGS+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd
endif

LDFLAGS=
O=.o

Expand Down
6 changes: 6 additions & 0 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ else
endif
endif
endif
ifeq (osx,$(OS))
ifeq (64,$(MODEL))
CFLAGS+=--target=x86_64-darwin-apple # ARM cpu is not supported by dmd
endif
endif


# Set DFLAGS
DFLAGS=
Expand Down
5 changes: 3 additions & 2 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -7737,8 +7737,9 @@ if (isInputRange!R &&

// uniq
/**
Lazily iterates unique consecutive elements of the given range (functionality
akin to the $(HTTP wikipedia.org/wiki/_Uniq, _uniq) system
Lazily iterates unique consecutive elements of the given range, which is
assumed to be sorted (functionality akin to the
$(HTTP wikipedia.org/wiki/_Uniq, _uniq) system
utility). Equivalence of elements is assessed by using the predicate
`pred`, by default `"a == b"`. The predicate is passed to
$(REF binaryFun, std,functional), and can either accept a string, or any callable
Expand Down
3 changes: 2 additions & 1 deletion std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ $(LINK2 http://en.cppreference.com/w/cpp/algorithm/copy_backward, STL's `copy_ba
Assigns `value` to each element of input range `range`.
Alternatively, instead of using a single `value` to fill the `range`,
a `filter` $(REF_ALTTEXT forward range, isForwardRange, std,range,primitives)
a `filler` $(REF_ALTTEXT forward range, isForwardRange, std,range,primitives)
can be provided. The length of `filler` and `range` do not need to match, but
`filler` must not be empty.
Expand Down Expand Up @@ -1943,6 +1943,7 @@ if (Offset.length >= 1 && allSatisfy!(isValidIntegralTuple, Offset))
return removeImpl!s(range, offset);
}

/// ditto
deprecated("Use of non-integral tuples is deprecated. Use remove(tuple(start, end).")
Range remove
(SwapStrategy s = SwapStrategy.stable, Range, Offset ...)
Expand Down
2 changes: 1 addition & 1 deletion std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -3946,7 +3946,7 @@ if (isRandomAccessRange!(Range1) && hasLength!Range1 &&
{
foreach (T2; ReferenceRanges)
{
import std.array;
import std.array : array;

T1 A;
T2 B;
Expand Down
12 changes: 7 additions & 5 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ if (isIterable!Range && !isAutodecodableString!Range && !isInfinite!Range)
}

/// ditto
ForeachType!(PointerTarget!Range)[] array(Range)(Range r)
if (isPointer!Range && isIterable!(PointerTarget!Range) && !isAutodecodableString!Range && !isInfinite!Range)
ForeachType!(typeof((*Range).init))[] array(Range)(Range r)
if (is(Range : U*, U) && isIterable!U && !isAutodecodableString!Range && !isInfinite!Range)
{
return array(*r);
}
Expand Down Expand Up @@ -586,7 +586,7 @@ if (isInputRange!Range)
static assert(isMutable!ValueType, "assocArray: value type must be mutable");

ValueType[KeyType] aa;
foreach (t; r)
foreach (ref t; r)
aa[t[0]] = t[1];
return aa;
}
Expand Down Expand Up @@ -3416,7 +3416,8 @@ do
Implements an output range that appends data to an array. This is
recommended over $(D array ~= data) when appending many elements because it is more
efficient. `Appender` maintains its own array metadata locally, so it can avoid
global locking for each append where $(LREF capacity) is non-zero.
the $(DDSUBLINK spec/arrays, capacity-reserve, performance hit of looking up slice `capacity`)
for each append.
Params:
A = the array type to simulate.
Expand Down Expand Up @@ -3587,7 +3588,7 @@ if (isDynamicArray!A)
private template canPutItem(U)
{
enum bool canPutItem =
isImplicitlyConvertible!(Unqual!U, Unqual!T) ||
is(Unqual!U : Unqual!T) ||
isSomeChar!T && isSomeChar!U;
}
private template canPutConstRange(Range)
Expand Down Expand Up @@ -4676,6 +4677,7 @@ nothrow pure @safe @nogc unittest
assert(a == [0, 1]);
}

/// ditto
pragma(inline, true) U[n] staticArray(U, T, size_t n)(auto ref T[n] a)
if (!is(T == U) && is(T : U))
{
Expand Down
6 changes: 4 additions & 2 deletions std/ascii.d
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ else
+/
bool isAlphaNum(dchar c) @safe pure nothrow @nogc
{
return c <= 'z' && c >= '0' && (c <= '9' || c >= 'a' || (c >= 'A' && c <= 'Z'));
const hc = c | 0x20;
return ('0' <= c && c <= '9') || ('a' <= hc && hc <= 'z');
}

///
Expand Down Expand Up @@ -377,7 +378,8 @@ bool isOctalDigit(dchar c) @safe pure nothrow @nogc
+/
bool isHexDigit(dchar c) @safe pure nothrow @nogc
{
return c <= 'f' && c >= '0' && (c <= '9' || c >= 'a' || (c >= 'A' && c <= 'F'));
const hc = c | 0x20;
return ('0' <= c && c <= '9') || ('a' <= hc && hc <= 'f');
}

///
Expand Down
6 changes: 3 additions & 3 deletions std/base64.d
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Encoder with no data remaining"));
assert(!empty, "Cannot call popFront on Encoder with no data remaining");

range_.popFront();

Expand Down Expand Up @@ -757,7 +757,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Encoder with no data remaining"));
assert(!empty, "Cannot call popFront on Encoder with no data remaining");

static if (Padding != NoPadding)
if (padding)
Expand Down Expand Up @@ -1414,7 +1414,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
void popFront()
{
enforce(!empty, new Base64Exception("Cannot call popFront on Decoder with no data remaining."));
assert(!empty, "Cannot call popFront on Decoder with no data remaining.");

range_.popFront();

Expand Down
Loading

0 comments on commit f4f246a

Please sign in to comment.