Make dln_warning a variadic macro

This commit is contained in:
Nobuyoshi Nakada 2023-08-08 08:06:08 +09:00
parent b5b54c19f6
commit ed4d03ea41
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

View File

@ -11,11 +11,9 @@
#ifdef RUBY_EXPORT #ifdef RUBY_EXPORT
#include "ruby/ruby.h" #include "ruby/ruby.h"
#define dln_warning rb_warning #define dln_warning(...) rb_warning(__VA_ARGS__)
#define dln_warning_arg
#else #else
#define dln_warning fprintf #define dln_warning(...) fprintf(stderr, __VA_ARGS__)
#define dln_warning_arg stderr,
#endif #endif
#include "dln.h" #include "dln.h"
@ -109,7 +107,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\ static const char pathname_too_long[] = "openpath: pathname too long (ignored)\n\
\tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n"; \tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n";
#define PATHNAME_TOO_LONG() dln_warning(dln_warning_arg pathname_too_long, \ #define PATHNAME_TOO_LONG() dln_warning(pathname_too_long, \
((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \ ((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \
((bp - fbuf) > 100 ? "..." : ""), \ ((bp - fbuf) > 100 ? "..." : ""), \
(fnlen > 100 ? 100 : (int)fnlen), fname, \ (fnlen > 100 ? 100 : (int)fnlen), fname, \
@ -120,8 +118,7 @@ dln_find_1(const char *fname, const char *path, char *fbuf, size_t size,
RETURN_IF(!fname); RETURN_IF(!fname);
fnlen = strlen(fname); fnlen = strlen(fname);
if (fnlen >= size) { if (fnlen >= size) {
dln_warning(dln_warning_arg dln_warning("openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
"openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
(fnlen > 100 ? 100 : (int)fnlen), fname, (fnlen > 100 ? 100 : (int)fnlen), fname,
(fnlen > 100 ? "..." : "")); (fnlen > 100 ? "..." : ""));
return NULL; return NULL;