GithubHelp home page GithubHelp logo

bigzaphod / ifunicodeurl Goto Github PK

View Code? Open in Web Editor NEW
55.0 55.0 15.0 3.32 MB

Category to add internationalized domain name support to NSURL

License: Other

C++ 0.03% Shell 0.08% Objective-C 0.22% Java 14.58% C 85.10%

ifunicodeurl's People

Contributors

bigzaphod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ifunicodeurl's Issues

Prefix category methods

If Apple adds their own -initWithUnicodeString: etc. methods one day, they'll conflict with those supplied by IFUnicodeURL.

Warnings in Xcode 4

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

Thread-safety

Does this code have any thread-safety limitations?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.