From 496d36978ac92234b8a2db9899b0b31026ee4ec2 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Fri, 21 Jul 2023 17:15:45 -0700 Subject: [PATCH] Even more stubby Signed-off-by: Larry Gritz --- src/liboslexec/opstring.cpp | 73 ++++++++++++------------------------- 1 file changed, 23 insertions(+), 50 deletions(-) diff --git a/src/liboslexec/opstring.cpp b/src/liboslexec/opstring.cpp index 1d6f6f9c67..50c7fa206a 100644 --- a/src/liboslexec/opstring.cpp +++ b/src/liboslexec/opstring.cpp @@ -164,77 +164,50 @@ osl_format(const char* format_str, ...) +OSL_SHADEOP int +osl_split(const char* str, ustring* results, const char* sep, int maxsplit, + int resultslen) +{ + maxsplit = OIIO::clamp(maxsplit, 0, resultslen); + std::vector splits; + Strutil::split(USTR(str).string(), splits, USTR(sep).string(), maxsplit); + int n = std::min(maxsplit, (int)splits.size()); + for (int i = 0; i < n; ++i) + results[i] = ustring(splits[i]); + return n; +} + + + +//////// +// The osl_printf, osl_error, osl_warning, and osl_fprintf are deprecated but +// the stubs are needed for now to prevent breaking OptiX-based renderers who +// aren't quite ready to refactor around the journaling print family of +// functions. They eventually can be removed when we're happy that all the +// compliant renderers have adapted. + OSL_SHADEOP void osl_printf(ShaderGlobals* sg, const char* format_str, ...) { - va_list args; - va_start(args, format_str); -#if 0 - // Make super sure we know we are executing LLVM-generated code! - std::string newfmt = std::string("llvm: ") + format_str; - format_str = newfmt.c_str(); -#endif - std::string s = Strutil::vsprintf(format_str, args); - va_end(args); - sg->context->messagefmt("{}", s); } - OSL_SHADEOP void osl_error(ShaderGlobals* sg, const char* format_str, ...) { - va_list args; - va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); - va_end(args); - sg->context->errorfmt("{}", s); } - OSL_SHADEOP void osl_warning(ShaderGlobals* sg, const char* format_str, ...) { - if (sg->context->allow_warnings()) { - va_list args; - va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); - va_end(args); - sg->context->warningfmt("{}", s); - } } - - OSL_SHADEOP void osl_fprintf(ShaderGlobals* /*sg*/, const char* filename, const char* format_str, ...) { - va_list args; - va_start(args, format_str); - std::string s = Strutil::vsprintf(format_str, args); - va_end(args); - - static OIIO::mutex fprintf_mutex; - OIIO::lock_guard lock(fprintf_mutex); - FILE* file = OIIO::Filesystem::fopen(filename, "a"); - fputs(s.c_str(), file); - fclose(file); } - - -OSL_SHADEOP int -osl_split(const char* str, ustring* results, const char* sep, int maxsplit, - int resultslen) -{ - maxsplit = OIIO::clamp(maxsplit, 0, resultslen); - std::vector splits; - Strutil::split(USTR(str).string(), splits, USTR(sep).string(), maxsplit); - int n = std::min(maxsplit, (int)splits.size()); - for (int i = 0; i < n; ++i) - results[i] = ustring(splits[i]); - return n; -} +//////// } // end namespace pvt