[needs review] Fix compilation on MacOS X 10.9

* Various type mismatches between signed/unsigned.
* Do not include tr1 on LLVM

Fixes #1, but I'm not at all sure that my fixes don't break the library in the cases of long string lengths.  The existing code mixes up the types badly enough that the original author should look at this again rather than accept this particular patch I think.