Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / bytecode.c
index 8f6769b..8157c82 100644 (file)
@@ -53,6 +53,7 @@ by Hallvard:
 #include "bytecode.h"
 #include "opaque.h"
 #include "syntax.h"
+#include "ent/ent.h"
 
 EXFUN(Ffetch_bytecode, 1);
 
@@ -1328,9 +1329,11 @@ static void invalid_byte_code_error(char *error_message, ...)
 {
        Lisp_Object obj;
        va_list args;
-       char *buf = alloca_array(char, strlen(error_message) + 128);
+       int maxsz = strlen(error_message) + 128;
+       char *buf = alloca_array(char, maxsz);
 
-       sprintf(buf, "%s", error_message);
+       int sz=snprintf(buf, maxsz, "%s", error_message);
+       assert(sz>=0 && sz<maxsz);
        va_start(args, error_message);
        obj = emacs_doprnt_string_va((const Bufbyte *)GETTEXT(buf), Qnil, -1,
                                     args);
@@ -1790,7 +1793,6 @@ print_compiled_function(Lisp_Object obj, Lisp_Object printcharfun,
        int docp = f->flags.documentationp;
        int intp = f->flags.interactivep;
        struct gcpro gcpro1, gcpro2;
-       char buf[100];
        GCPRO2(obj, printcharfun);
 
        write_c_string(print_readably ? "#[" : "#<compiled-function ",
@@ -1816,9 +1818,8 @@ print_compiled_function(Lisp_Object obj, Lisp_Object printcharfun,
                NGCPRO1(instructions);
                if (STRINGP(instructions) && !print_readably) {
                        /* We don't usually want to see that junk in the bytecode. */
-                       sprintf(buf, "\"...(%ld)\"",
-                               (long)XSTRING_CHAR_LENGTH(instructions));
-                       write_c_string(buf, printcharfun);
+                       write_fmt_str(printcharfun, "\"...(%ld)\"",
+                                     (long)XSTRING_CHAR_LENGTH(instructions));
                } else
                        print_internal(instructions, printcharfun, escapeflag);
                NUNGCPRO;
@@ -1830,8 +1831,7 @@ print_compiled_function(Lisp_Object obj, Lisp_Object printcharfun,
                       escapeflag);
 
        /* COMPILED_STACK_DEPTH = 3 */
-       sprintf(buf, " %d", compiled_function_stack_depth(f));
-       write_c_string(buf, printcharfun);
+       write_fmt_str(printcharfun, " %d", compiled_function_stack_depth(f));
 
        /* COMPILED_DOC_STRING = 4 */
        if (docp || intp) {