bigzaphod / ifunicodeurl Goto Github PK
View Code? Open in Web Editor NEWCategory to add internationalized domain name support to NSURL
License: Other
Category to add internationalized domain name support to NSURL
License: Other
If Apple adds their own -initWithUnicodeString:
etc. methods one day, they'll conflict with those supplied by IFUnicodeURL.
Currently strings like this:
http://example.com/path#fragment#test
result in nil
. Apple's developer docs have a nasty tendency to produce URLs like it.
Maybe this is outside of IFUnicodeURL's remit, but it would be nice to handle.
Gentlefolk,
Xcode 4/clang, as well as Xcode 3.*/gcc, issues 3 warnings when compiling nameprep.c, toxxx.c and util.c.
Here is one of the warnings:
/Users/awd/Projects/Chatter/ChatterX4/../../Libraries/IFUnicodeURL/IFUnicodeURL/IDNSDK/nameprep.c:76:14:{76:7-76:13}{76:16-76:17}: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare,2]
if (offset < 0 || offset > *length) {return;}
~~~~~~ ^ ~
/Users/awd/Projects/Chatter/ChatterX4/../../Libraries/IFUnicodeURL/IFUnicodeURL/IDNSDK/toxxx.c:192:31:{192:10-192:30}{192:33-192:34}: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare,2]
if ( *(dwzOutputString+i) < 0 || *(dwzOutputString+i) > 0x7F )
~~~~~~~~~~~~~~~~~~~~ ^ ~
There is, of course, a simple fix:
if (offset > *length) {return;}
Or we could mask out the sign bit:
For nameprep.c:
#define SIZE_T_SIGN_BIT (SIZE_MAX - (SIZE_MAX / 2))
if ((offset & SIZE_T_SIGN_BIT) || offset > *length) {return;}
For toxxx.c:
#define SIZE_SIGN_BIT (SIZE_MAX - (SIZE_MAX / 2))
if ( (*(dwzOutputString+i) & SIZE_SIGN_BIT) || *(dwzOutputString+i) > 0x7F )
util.c is a bit harder:
Before:
if (( c >= 0x0000 && c <= 0x002C ) ||
( c == 0x002E || c == 0x002F ) ||
( c >= 0x003A && c <= 0x0040 ) ||
( c >= 0x005B && c <= 0x0060 ) ||
( c >= 0x007B && c <= 0x007F ) )
After:
if (((!c || c >= 0x0001) && c <= 0x002C ) ||
( c == 0x002E || c == 0x002F ) ||
( c >= 0x003A && c <= 0x0040 ) ||
( c >= 0x005B && c <= 0x0060 ) ||
( c >= 0x007B && c <= 0x007F ) )
Or, even simpler is to turn off tautological warnings ... but I would rather not.
What would be the "right" answer for this project? I've been using the simplest answers, which is to elide the checks on zero, without effect for a long while.
Andrew
Does this code have any thread-safety limitations?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.