X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fpor-file-reader.c;h=4f087734f615c993165089d1f16a649a957096da;hb=f43378497b8400e9c22a3485c534693dc1bc9554;hp=0824bb311147993a0ad6795abfd654bea54f2ee9;hpb=3f2ed1c5fe6dc692ca00bb18a15e41617fa2d37d;p=pspp-builds.git diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index 0824bb31..4f087734 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -85,23 +85,25 @@ error (struct pfm_reader *r, const char *msg,...) static void error (struct pfm_reader *r, const char *msg, ...) { - struct error e; - const char *file_name; - char *title; + struct msg m; + struct string text; va_list args; - e.class = ME; - e.where.file_name = NULL; - e.where.line_number = 0; - file_name = fh_get_file_name (r->fh); - e.title = title = pool_alloc (r->pool, strlen (file_name) + 80); - sprintf (title, _("portable file %s corrupt at offset %ld: "), - file_name, ftell (r->file)); - + ds_init_empty (&text); + ds_put_format (&text, _("portable file %s corrupt at offset %ld: "), + fh_get_file_name (r->fh), ftell (r->file)); va_start (args, msg); - err_vmsg (&e, msg, args); + ds_put_vformat (&text, msg, args); va_end (args); + m.category = MSG_GENERAL; + m.severity = MSG_ERROR; + m.where.file_name = NULL; + m.where.line_number = 0; + m.text = ds_cstr (&text); + + msg_emit (&m); + r->ok = false; longjmp (r->bail_out, 1); @@ -466,18 +468,25 @@ static void convert_format (struct pfm_reader *r, const int portable_format[3], struct fmt_spec *format, struct variable *v) { - format->type = translate_fmt (portable_format[0]); - if (format->type == -1) + bool ok; + + if (!fmt_from_io (portable_format[0], &format->type)) error (r, _("%s: Bad format specifier byte (%d)."), v->name, portable_format[0]); format->w = portable_format[1]; format->d = portable_format[2]; - if (!check_output_specifier (format, false) - || !check_specifier_width (format, v->width, false)) - error (r, _("%s variable %s has invalid format specifier %s."), - v->type == NUMERIC ? _("Numeric") : _("String"), - v->name, fmt_to_string (format)); + msg_disable (); + ok = fmt_check_output (format) && fmt_check_width_compat (format, v->width); + msg_enable (); + + if (!ok) + { + char fmt_string[FMT_STRING_LEN_MAX + 1]; + error (r, _("%s variable %s has invalid format specifier %s."), + v->type == NUMERIC ? _("Numeric") : _("String"), + v->name, fmt_to_string (format, fmt_string)); + } } static union value parse_value (struct pfm_reader *, struct variable *);