add new function for debug in Lama: LprintfPerrror --- synonym for fprintf(perror,...)

This commit is contained in:
danyaberezun 2024-02-29 15:30:23 +02:00
parent 7541ea64c2
commit 539e9712e5
2 changed files with 16 additions and 2 deletions

View file

@ -23,6 +23,7 @@ F,regexpMatch;
F,sprintf; F,sprintf;
F,makeString; F,makeString;
F,printf; F,printf;
F,printfPerror;
F,fprintf; F,fprintf;
F,fopen; F,fopen;
F,fclose; F,fclose;

View file

@ -987,6 +987,19 @@ extern void Lfailure (char *s, ...) {
vfailure(s, args); vfailure(s, args);
} }
extern void LprintfPerror (char *s, ...) {
va_list args = (va_list)BOX(NULL);
ASSERT_STRING("printfPerror:1", s);
va_start(args, s);
fix_unboxed(s, args);
if (vfprintf(stderr, s, args) < 0) { failure("printfPerror (...): %s\n", strerror(errno)); }
fflush(stderr);
}
extern void Bmatch_failure (void *v, char *fname, int line, int col) { extern void Bmatch_failure (void *v, char *fname, int line, int col) {
createStringBuf(); createStringBuf();
printValue(v); printValue(v);
@ -1251,8 +1264,8 @@ extern void set_args (int argc, char *argv[]) {
POST_GC(); POST_GC();
global_sysargs = p; global_sysargs = p;
global_stdout = stdout; global_stdout = stdout;
global_stderr = stderr; global_stderr = stderr;
push_extra_root((void **)&global_sysargs); push_extra_root((void **)&global_sysargs);
} }