X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fdata-in.c;h=de19d670484fd8344de1351497684386ca0d3f16;hb=38993354cabb6fc37bb882be92f9a49e9aeb4c88;hp=b8226b37f926601dd1ed04f0ce368a242a5346ff;hpb=00129e248ab4ce96af72d380d8a0ccfad2f5d776;p=pspp diff --git a/src/data/data-in.c b/src/data/data-in.c index b8226b37f9..de19d67048 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -79,17 +79,16 @@ static bool trim_spaces_and_check_missing (struct data_in *); static int hexit_value (int c); /* Parses the characters in INPUT, which are encoded in the given - ENCODING, according to FORMAT. Stores the parsed - representation in OUTPUT, which the caller must have - initialized with the given WIDTH (0 for a numeric field, - otherwise the string width). - Iff FORMAT is a string format, then DICT must be a pointer - to the dictionary associated with OUTPUT. Otherwise, DICT - may be null. */ + INPUT_ENCODING, according to FORMAT. + + Stores the parsed representation in OUTPUT, which the caller must have + initialized with the given WIDTH (0 for a numeric field, otherwise the + string width). If FORMAT is FMT_A, then OUTPUT_ENCODING must specify the + correct encoding for OUTPUT (normally obtained via dict_get_encoding()). */ bool -data_in (struct substring input, const char *encoding, +data_in (struct substring input, const char *input_encoding, enum fmt_type format, int first_column, int last_column, - const struct dictionary *dict, union value *output, int width) + union value *output, int width, const char *output_encoding) { static data_in_parser_func *const handlers[FMT_NUMBER_OF_FORMATS] = { @@ -146,13 +145,14 @@ data_in (struct substring input, const char *encoding, else { /* Use the final output encoding. */ - dest_encoding = dict_get_encoding (dict); + dest_encoding = output_encoding; } } if (dest_encoding != NULL) { - i.input = recode_substring_pool (dest_encoding, encoding, input, NULL); + i.input = recode_substring_pool (dest_encoding, input_encoding, input, + NULL); s = i.input.string; } else @@ -209,7 +209,7 @@ number_has_implied_decimals (const char *s, enum fmt_type type) } static bool -has_implied_decimals (struct substring input, const char *encoding, +has_implied_decimals (struct substring input, const char *input_encoding, enum fmt_type format) { bool retval; @@ -237,7 +237,7 @@ has_implied_decimals (struct substring input, const char *encoding, return false; } - s = recode_string (LEGACY_NATIVE, encoding, + s = recode_string (LEGACY_NATIVE, input_encoding, ss_data (input), ss_length (input)); retval = (format == FMT_Z ? strchr (s, '.') == NULL @@ -255,11 +255,11 @@ has_implied_decimals (struct substring input, const char *encoding, If it is appropriate, this function modifies the numeric value in OUTPUT. */ void -data_in_imply_decimals (struct substring input, const char *encoding, +data_in_imply_decimals (struct substring input, const char *input_encoding, enum fmt_type format, int d, union value *output) { if (d > 0 && output->f != SYSMIS - && has_implied_decimals (input, encoding, format)) + && has_implied_decimals (input, input_encoding, format)) output->f /= pow (10., d); }