remove xformat family
This commit is contained in:
parent
267cfb0a02
commit
0d8d7d5b91
|
@ -21,30 +21,29 @@ void
|
|||
pic_warnf(pic_state *pic, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
pic_value err_line;
|
||||
pic_str *err;
|
||||
|
||||
va_start(ap, fmt);
|
||||
err_line = pic_xvformat(pic, fmt, ap);
|
||||
err = pic_vformat(pic, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
xfprintf(pic, pic_stderr(pic)->file, "warn: %s\n", pic_str_cstr(pic, pic_str_ptr(pic_car(pic, err_line))));
|
||||
xfprintf(pic, pic_stderr(pic)->file, "warn: %s\n", pic_str_cstr(pic, err));
|
||||
}
|
||||
|
||||
void
|
||||
pic_errorf(pic_state *pic, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
pic_value err_line, irrs;
|
||||
const char *msg;
|
||||
pic_str *err;
|
||||
|
||||
va_start(ap, fmt);
|
||||
err_line = pic_xvformat(pic, fmt, ap);
|
||||
err = pic_vformat(pic, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
msg = pic_str_cstr(pic, pic_str_ptr(pic_car(pic, err_line)));
|
||||
irrs = pic_cdr(pic, err_line);
|
||||
msg = pic_str_cstr(pic, err);
|
||||
|
||||
pic_error(pic, msg, irrs);
|
||||
pic_error(pic, msg, pic_nil_value());
|
||||
}
|
||||
|
||||
pic_value
|
||||
|
|
|
@ -32,11 +32,6 @@ const char *pic_str_cstr(pic_state *, pic_str *);
|
|||
|
||||
pic_str *pic_format(pic_state *, const char *, ...);
|
||||
pic_str *pic_vformat(pic_state *, const char *, va_list);
|
||||
void pic_vfformat(pic_state *, xFILE *, const char *, va_list);
|
||||
|
||||
pic_value pic_xformat(pic_state *, const char *, ...);
|
||||
pic_value pic_xvformat(pic_state *, const char *, va_list);
|
||||
pic_value pic_xvfformat(pic_state *, xFILE *, const char *, va_list);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
|
|
@ -283,13 +283,12 @@ pic_str_cstr(pic_state *pic, pic_str *str)
|
|||
return rope_cstr(pic, str->rope);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_xvfformat(pic_state *pic, xFILE *file, const char *fmt, va_list ap)
|
||||
static void
|
||||
pic_vfformat(pic_state *pic, xFILE *file, const char *fmt, va_list ap)
|
||||
{
|
||||
char c;
|
||||
pic_value irrs = pic_nil_value();
|
||||
|
||||
while ((c = *fmt++)) {
|
||||
while ((c = *fmt++) != '\0') {
|
||||
switch (c) {
|
||||
default:
|
||||
xfputc(pic, c, file);
|
||||
|
@ -337,52 +336,17 @@ pic_xvfformat(pic_state *pic, xFILE *file, const char *fmt, va_list ap)
|
|||
xfputc(pic, '\n', file);
|
||||
break;
|
||||
case 'a':
|
||||
irrs = pic_cons(pic, pic_fdisplay(pic, va_arg(ap, pic_value), file), irrs);
|
||||
pic_fdisplay(pic, va_arg(ap, pic_value), file);
|
||||
break;
|
||||
case 's':
|
||||
irrs = pic_cons(pic, pic_fwrite(pic, va_arg(ap, pic_value), file), irrs);
|
||||
pic_fwrite(pic, va_arg(ap, pic_value), file);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit:
|
||||
|
||||
return pic_reverse(pic, irrs);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_xvformat(pic_state *pic, const char *fmt, va_list ap)
|
||||
{
|
||||
struct pic_port *port;
|
||||
pic_value irrs;
|
||||
|
||||
port = pic_open_output_string(pic);
|
||||
|
||||
irrs = pic_xvfformat(pic, port->file, fmt, ap);
|
||||
irrs = pic_cons(pic, pic_obj_value(pic_get_output_string(pic, port)), irrs);
|
||||
|
||||
pic_close_port(pic, port);
|
||||
return irrs;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_xformat(pic_state *pic, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
pic_value objs;
|
||||
|
||||
va_start(ap, fmt);
|
||||
objs = pic_xvformat(pic, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
void
|
||||
pic_vfformat(pic_state *pic, xFILE *file, const char *fmt, va_list ap)
|
||||
{
|
||||
pic_xvfformat(pic, file, fmt, ap);
|
||||
return;
|
||||
}
|
||||
|
||||
pic_str *
|
||||
|
|
|
@ -437,7 +437,7 @@ pic_printf(pic_state *pic, const char *fmt, ...)
|
|||
|
||||
va_start(ap, fmt);
|
||||
|
||||
str = pic_str_ptr(pic_car(pic, pic_xvformat(pic, fmt, ap)));
|
||||
str = pic_vformat(pic, fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
|
|
Loading…
Reference in New Issue