diff --git a/posix.mak b/posix.mak index 452f2e7b98b..f23aff0cb9a 100644 --- a/posix.mak +++ b/posix.mak @@ -88,8 +88,8 @@ WEBSITE_DIR = ../web DOC_OUTPUT_DIR = $(WEBSITE_DIR)/phobos-prerelease BIGDOC_OUTPUT_DIR = /tmp SRC_DOCUMENTABLES = index.d $(addsuffix .d,$(STD_MODULES) $(STD_NET_MODULES) $(STD_DIGEST_MODULES) $(STD_CONTAINER_MODULES) $(EXTRA_DOCUMENTABLES)) -STDDOC = $(DOCSRC)/std.ddoc -BIGSTDDOC = $(DOCSRC)/std_consolidated.ddoc +STDDOC = $(DOCSRC)/std.ddoc $(DOCSRC)/macros.ddoc +BIGSTDDOC = $(DOCSRC)/std_consolidated.ddoc $(DOCSRC)/macros.ddoc # Set DDOC, the documentation generator DDOC=$(DMD) -m$(MODEL) -w -c -o- -version=StdDdoc \ -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) diff --git a/std/utf.d b/std/utf.d index bfcaa0146f8..b9e47ab0d4f 100644 --- a/std/utf.d +++ b/std/utf.d @@ -138,7 +138,8 @@ unittest $(D index) defaults to $(D 0) if none is passed. Returns: - The number of bytes in the UTF-8 sequence. + The number of bytes in the UTF-8 sequence, a value between 1 and 4 + (as per $(WEB tools.ietf.org/html/rfc3629#section-3, RFC 3629$(COMMA) section 3)). Throws: May throw a $(D UTFException) if $(D str[index]) is not the start of a @@ -186,7 +187,7 @@ body { import core.bitop : bsr; immutable msbs = 7 - bsr(~c); - if (msbs < 2 || msbs > 6) + if (msbs < 2 || msbs > 4) throw new UTFException("Invalid UTF-8 sequence", index); return msbs; } @@ -258,6 +259,20 @@ unittest }); } +unittest // invalid start bytes +{ + import std.exception: assertThrown; + immutable char[] invalidStartBytes = [ + 0b1111_1000, // indicating a sequence length of 5 + 0b1111_1100, // 6 + 0b1111_1110, // 7 + 0b1111_1111, // 8 + 0b1000_0000, // continuation byte + ]; + foreach(c; invalidStartBytes) + assertThrown!UTFException(stride([c])); +} + /++ $(D strideBack) returns the length of the UTF-8 sequence ending one code diff --git a/win32.mak b/win32.mak index 921628b4822..3c3ee7a0aa8 100644 --- a/win32.mak +++ b/win32.mak @@ -61,7 +61,7 @@ DMD=dmd ## Location of where to write the html documentation files DOCSRC = ../dlang.org -STDDOC = $(DOCSRC)/std.ddoc +STDDOC = $(DOCSRC)/std.ddoc $(DOCSRC)/macros.ddoc DOC=..\..\html\d\phobos #DOC=..\doc\phobos diff --git a/win64.mak b/win64.mak index 79fdc3767bd..1e3bef6819d 100644 --- a/win64.mak +++ b/win64.mak @@ -61,7 +61,7 @@ DMD=dmd ## Location of where to write the html documentation files DOCSRC = ../dlang.org -STDDOC = $(DOCSRC)/std.ddoc +STDDOC = $(DOCSRC)/std.ddoc $(DOCSRC)/macros.ddoc DOC=..\..\html\d\phobos #DOC=..\doc\phobos