Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation: std.utf.toUTF8 -> encode #5143

Merged
merged 1 commit into from
Feb 17, 2017

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented Feb 17, 2017

It seems like DMD doesn't like deprecating only one symbol. For selective imports it will always trigger a deprecation warning even if the symbol isn't used (issue 17193).

This PR fixes the deprecation warnings from toUTF8 on Posix. grep shows that there are more on Windows.

std/json.d Outdated
@@ -823,7 +823,8 @@ if (isInputRange!T)
val += (isDigit(hex) ? hex - '0' : hex - ('A' - 10)) << (4 * i);
}
char[4] buf;
str.put(toUTF8(buf, val));
encode(buf, val);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immutable len = encode(buf, val);
str.put(buf[0 .. len]);

std/uri.d Outdated
import std.utf : toUTF8;
// selective imports trigger wrong deprecation
// https://issues.dlang.org/show_bug.cgi?id=17193
import std.utf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to trigger a failure in circle

std/json.d Outdated
@@ -703,7 +703,7 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1, JSONOptions options = JSONOpti
if (isInputRange!T)
{
import std.ascii : isWhite, isDigit, isHexDigit, toUpper, toLower;
import std.utf : toUTF8;
import std.utf : encode, Yes;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes is from std.typecons

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW any module using template flags is supposed to export Yes as well, so this is really personal preference or personal purism ;-)

std/stdio.d Outdated
auto b = toUTF8(buf, c);
foreach (i ; 0 .. b.length)
trustedFPUTC(b[i], handle_);
auto len = encode(buf, c);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immutable

@JackStouffer
Copy link
Member

Auto-merge toggled on

@JackStouffer JackStouffer merged commit bf7e608 into dlang:master Feb 17, 2017
@wilzbach wilzbach deleted the fix-deprecations branch February 19, 2017 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants