From 02e5761ed637c414c4415247df447c6a6a5a0999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 4 Oct 2024 09:31:01 +0200 Subject: [PATCH] Mark onig_snprintf_with_pattern() as printf()-like. This allows Oniguruma to build cleanly using gcc and clang with the format-nonliteral warning enabled. --- src/regint.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/regint.h b/src/regint.h index 9244879b..def361a3 100644 --- a/src/regint.h +++ b/src/regint.h @@ -61,6 +61,14 @@ #endif #endif +#ifndef ONIG_PRINTFLIKE +#if defined(__clang__) || defined(__GNUC__) +#define ONIG_PRINTFLIKE(x, y) __attribute__((format(printf, x, y))) +#else +#define ONIG_PRINTFLIKE(x, y) +#endif +#endif + /* config */ /* spec. config */ #define USE_REGSET @@ -945,7 +953,7 @@ struct re_pattern_buffer { extern void onig_add_end_call(void (*func)(void)); extern void onig_warning(const char* s); extern UChar* onig_error_code_to_format P_((int code)); -extern void ONIG_VARIADIC_FUNC_ATTR onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...)); +extern void ONIG_VARIADIC_FUNC_ATTR ONIG_PRINTFLIKE(6, 7) onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...)); extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo)); extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, void* /* CClassNode* */ cc)); extern RegexExt* onig_get_regex_ext(regex_t* reg);