X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/8a392978b2d6e7db62cdf6d576e071d70fef9b94..b23692f3038296c94d25c84c55ed4c1bb49619cf:/Library.cpp diff --git a/Library.cpp b/Library.cpp index e8e70d6..7203225 100644 --- a/Library.cpp +++ b/Library.cpp @@ -19,14 +19,8 @@ **/ /* }}} */ -#include - #include "cycript.hpp" -#include "Pooling.hpp" - -#include - #include #include #include @@ -34,13 +28,17 @@ #include #include +#include + +#include + +#include "ConvertUTF.h" #include "Driver.hpp" #include "Error.hpp" #include "Execute.hpp" -#include "Parser.hpp" +#include "Pooling.hpp" #include "String.hpp" - -#include "ConvertUTF.h" +#include "Syntax.hpp" template <> ::pthread_key_t CYLocal::key_ = Key_(); @@ -174,6 +172,13 @@ void CYStringify(std::ostringstream &str, const char *data, size_t size) { } void CYNumerify(std::ostringstream &str, double value) { + if (std::isinf(value)) { + if (value < 0) + str << '-'; + str << "Infinity"; + return; + } + char string[32]; // XXX: I want this to print 1e3 rather than 1000 sprintf(string, "%.17g", value); @@ -215,6 +220,10 @@ double CYCastDouble(const char *value) { return CYCastDouble(value, strlen(value)); } +_visible bool CYStartsWith(const CYUTF8String &haystack, const CYUTF8String &needle) { + return haystack.size >= needle.size && strncmp(haystack.data, needle.data, needle.size) == 0; +} + CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream) { CYLocalPool local; CYDriver driver(local, stream);