aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/doprnt.c2
-rw-r--r--src/emacs-module.c32
2 files changed, 14 insertions, 20 deletions
diff --git a/src/doprnt.c b/src/doprnt.c
index 51f8fd72ba0..55f249f5d72 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -500,7 +500,7 @@ esprintf (char *buf, char const *format, ...)
500 return nbytes; 500 return nbytes;
501} 501}
502 502
503#if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT 503#if HAVE_MODULES || (defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT)
504 504
505/* Format to buffer *BUF of positive size *BUFSIZE, reallocating *BUF 505/* Format to buffer *BUF of positive size *BUFSIZE, reallocating *BUF
506 and updating *BUFSIZE if the buffer is too small, and otherwise 506 and updating *BUFSIZE if the buffer is too small, and otherwise
diff --git a/src/emacs-module.c b/src/emacs-module.c
index a24d85537bd..1a5e253c969 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -1039,25 +1039,19 @@ module_format_fun_env (const struct module_fun_env *env)
1039{ 1039{
1040 /* Try to print a function name if possible. */ 1040 /* Try to print a function name if possible. */
1041 const char *path, *sym; 1041 const char *path, *sym;
1042 if (dynlib_addr (env->subr, &path, &sym)) 1042 char buffer[256];
1043 { 1043 char *buf = buffer;
1044 static char const format[] = "#<module function %s from %s>"; 1044 ptrdiff_t bufsize = sizeof buffer;
1045 int size = snprintf (NULL, 0, format, sym, path); 1045 ptrdiff_t size
1046 eassert (size > 0); 1046 = (dynlib_addr (env->subr, &path, &sym)
1047 char buffer[size + 1]; 1047 ? exprintf (&buf, &bufsize, buffer, -1,
1048 snprintf (buffer, sizeof buffer, format, sym, path); 1048 "#<module function %s from %s>", sym, path)
1049 return make_unibyte_string (buffer, size); 1049 : exprintf (&buf, &bufsize, buffer, -1,
1050 } 1050 "#<module function at %p>", env->subr));
1051 else 1051 Lisp_Object unibyte_result = make_unibyte_string (buffer, size);
1052 { 1052 if (buf != buffer)
1053 static char const format[] = "#<module function at %p>"; 1053 xfree (buf);
1054 void *subr = env->subr; 1054 return code_convert_string_norecord (unibyte_result, Qutf_8, false);
1055 int size = snprintf (NULL, 0, format, subr);
1056 eassert (size > 0);
1057 char buffer[size + 1];
1058 snprintf (buffer, sizeof buffer, format, subr);
1059 return make_unibyte_string (buffer, size);
1060 }
1061} 1055}
1062 1056
1063 1057