The aim of this patch is to localize the string literals in order to carry out translations based on the char-mode. This is a continuation to add ASCII/EBCDIC support for z/OS. This could also be the ground work for enabling internationalization of the runtime messages.
LGTM with minor suggestions.
I might be wrong but I think the use defined headers should be included after the system ones. Can you keep it the original order?
This will make consistent by including this header as user define one and move it down after `cxxabi.h as being done in other locations.
same as above
same as above
The "abort_message.h" header should be included before the others in this case because we refer to bimodal functions (eg __fprintf_a). In particular, abort_message.h includes error_message.h which includes the Bimodal header. This should be included before the other headers (such as stdio.h) to avoid an undeclared identifier error.
I suggest making a macro to wrap the function fprintf. That would simplify the this code. For example:
#ifdef __MVS__ #define fprintf(...) \ if (__isASCII()) __fprintf_a(__VA_ARGS__); \ else __fprintf_e(__VA_ARGS__) #endif
Do the same for vfprintf() and we can remove the duplication in this code. Same for the snprintf system_error.cpp. Just confirm fprintf, etc aren't macros already on MVS.
The CI is failing with the following warning (shown as an error):
/home/libcxx-builder/.buildkite-agent/builds/63ef6a49a323-1/llvm-project/libcxx-ci/libcxx/src/system_error.cpp:134:44: error: format string is not a string literal [-Werror,-Wformat-nonliteral] snprintf(buffer, strerror_buff_size, getRuntimeErrorString(RM_UNKNOWN_ERROR), ev);
Any suggestions on getting passed this warning? It should be noted that getRuntimeErrorString(RM_UNKNOWN_ERROR) returns "Unknown error %d", which includes a format specifier so we can't make the call with "%s" as a string literal.