From: Ben Pfaff Date: Sat, 13 Oct 2007 04:35:25 +0000 (+0000) Subject: posix-xprintf-functions.patch from patch #6230. X-Git-Tag: v0.6.0~220 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=9f4661992f4b481c6dafa6fd53c94ecfe7b3af8c posix-xprintf-functions.patch from patch #6230. Add fprintf-posix, printf-posix, printf-safe, snprintf-posix, sprintf-posix, vasprintf-posxi, vfprintf-posix, vprintf-posix, vsnprintf-posix, and vsprintf-posix modules, which allow us to use C99 format specifiers (e.g. 'z') in *printf. Also, changed many formerly casted arguments in *printf calls to use one of these format specifiers and drop the cast. --- diff --git a/ChangeLog b/ChangeLog index e18976e8..7e1e8ea9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-10-12 Ben Pfaff + + * Smake: Add fprintf-posix, printf-posix, printf-safe, + snprintf-posix, sprintf-posix, vasprintf-posxi, vfprintf-posix, + vprintf-posix, vsnprintf-posix, and vsprintf-posix modules, which + allow us to use C99 format specifiers (e.g. 'z') in *printf. + Also, changed many formerly casted arguments in *printf calls to + use one of these format specifiers and drop the cast. + 2007-10-11 Ben Pfaff * Smake: Drop alloca, alloca-opt modules as we don't use them diff --git a/Smake b/Smake index edb247e8..21e6a224 100644 --- a/Smake +++ b/Smake @@ -13,6 +13,7 @@ GNULIB_MODULES = \ dirname \ exit \ fpieee \ + fprintf-posix \ full-read \ full-write \ fseeko \ @@ -37,9 +38,13 @@ GNULIB_MODULES = \ memset \ minmax \ mkstemp \ + printf-posix \ + printf-safe \ progname \ relocatable-prog \ snprintf \ + snprintf-posix \ + sprintf-posix \ stdarg \ stdbool \ stdint \ @@ -57,7 +62,12 @@ GNULIB_MODULES = \ tmpfile \ unistd \ unlocked-io \ + vasprintf-posix \ + vfprintf-posix \ + vprintf-posix \ vsnprintf \ + vsnprintf-posix \ + vsprintf-posix \ xalloc \ xalloc-die \ xmalloca \ diff --git a/src/data/datasheet.c b/src/data/datasheet.c index 4115cf02..842e9c3a 100644 --- a/src/data/datasheet.c +++ b/src/data/datasheet.c @@ -1374,8 +1374,8 @@ check_datasheet (struct mc *mc, struct datasheet *ds, mc_error (mc, "row count (%lu) does not match expected (%zu)", (unsigned long int) datasheet_get_row_cnt (ds), row_cnt); else if (column_cnt != datasheet_get_column_cnt (ds)) - mc_error (mc, "column count (%lu) does not match expected (%zu)", - (unsigned long int) datasheet_get_column_cnt (ds), column_cnt); + mc_error (mc, "column count (%zu) does not match expected (%zu)", + datasheet_get_column_cnt (ds), column_cnt); else { size_t row, col; diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index 4636d5fb..37ae2335 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -515,9 +515,9 @@ read_version_data (struct pfm_reader *r, struct pfm_read_info *info) /* Validate file. */ if (strlen (date) != 8) - error (r, _("Bad date string length %d."), (int) strlen (date)); + error (r, _("Bad date string length %zu."), strlen (date)); if (strlen (time) != 6) - error (r, _("Bad time string length %d."), (int) strlen (time)); + error (r, _("Bad time string length %zu."), strlen (time)); /* Save file info. */ if (info != NULL) diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index baa0c0e6..de9ae0d6 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -509,8 +509,8 @@ read_variable_record (struct sfm_reader *r, struct dictionary *dict, len = read_int (r); if (len >= sizeof label) - sys_error (r, _("Variable %s has label of invalid length %u."), - name, (unsigned int) len); + sys_error (r, _("Variable %s has label of invalid length %zu."), + name, len); read_string (r, label, len + 1); var_set_label (var, label); @@ -608,7 +608,7 @@ parse_format_spec (struct sfm_reader *r, unsigned int s, bool ok; if (!fmt_from_io (raw_type, &f.type)) - sys_error (r, _("Unknown variable format %d."), (int) raw_type); + sys_error (r, _("Unknown variable format %"PRIu8"."), raw_type); f.w = w; f.d = d; @@ -769,9 +769,9 @@ read_machine_integer_info (struct sfm_reader *r, size_t size, size_t count, int expected_integer_format; if (size != 4 || count != 8) - sys_error (r, _("Bad size (%u) or count (%u) field on record type 7, " + sys_error (r, _("Bad size (%zu) or count (%zu) field on record type 7, " "subtype 3."), - (unsigned int) size, (unsigned int) count); + size, count); /* Save version info. */ info->version_major = version_major; @@ -819,8 +819,8 @@ read_machine_float_info (struct sfm_reader *r, size_t size, size_t count) double lowest = read_float (r); if (size != 8 || count != 3) - sys_error (r, _("Bad size (%u) or count (%u) on extension 4."), - (unsigned int) size, (unsigned int) count); + sys_error (r, _("Bad size (%zu) or count (%zu) on extension 4."), + size, count); if (sysmis != SYSMIS) sys_warn (r, _("File specifies unexpected value %g as SYSMIS."), sysmis); @@ -841,8 +841,8 @@ read_display_parameters (struct sfm_reader *r, size_t size, size_t count, int i; if (count % 3 || n_vars != dict_get_var_cnt (dict)) - sys_error (r, _("Bad size (%u) or count (%u) on extension 11."), - (unsigned int) size, (unsigned int) count); + sys_error (r, _("Bad size (%zu) or count (%zu) on extension 11."), + size, count); for (i = 0; i < n_vars; ++i) { @@ -1082,8 +1082,8 @@ read_value_labels (struct sfm_reader *r, var_cnt = read_int (r); if (var_cnt < 1 || var_cnt > dict_get_var_cnt (dict)) sys_error (r, _("Number of variables associated with a value label (%d) " - "is not between 1 and the number of variables (%u)."), - var_cnt, (unsigned int) dict_get_var_cnt (dict)); + "is not between 1 and the number of variables (%zu)."), + var_cnt, dict_get_var_cnt (dict)); /* Read the list of variables. */ var = pool_nalloc (subpool, var_cnt, sizeof *var); diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 7845ca33..71cc961f 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -96,12 +96,12 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) if (cmd.n_lrecl[0] == LONG_MIN) msg (SE, _("Fixed-length records were specified on /RECFORM, but " "record length was not specified on /LRECL. " - "Assuming %u-character records."), - (unsigned int) properties.record_width); + "Assuming %zu-character records."), + properties.record_width); else if (cmd.n_lrecl[0] < 1) msg (SE, _("Record length (%ld) must be at least one byte. " - "Assuming %u-character records."), - cmd.n_lrecl[0], (unsigned int) properties.record_width); + "Assuming %zu-character records."), + cmd.n_lrecl[0], properties.record_width); else properties.record_width = cmd.n_lrecl[0]; break; diff --git a/src/language/data-io/get.c b/src/language/data-io/get.c index e34ea799..574656b9 100644 --- a/src/language/data-io/get.c +++ b/src/language/data-io/get.c @@ -564,10 +564,10 @@ rename_variables (struct lexer *lexer, struct dictionary *dict) goto done; if (nn != nv) { - msg (SE, _("Number of variables on left side of `=' (%d) does not " - "match number of variables on right side (%d), in " + msg (SE, _("Number of variables on left side of `=' (%zu) does not " + "match number of variables on right side (%zu), in " "parenthesized group %d of RENAME subcommand."), - (unsigned) (nv - old_nv), (unsigned) (nn - old_nv), group); + nv - old_nv, nn - old_nv, group); goto done; } if (!lex_force_match (lexer, ')')) diff --git a/src/language/data-io/placement-parser.c b/src/language/data-io/placement-parser.c index bdd204da..679049d7 100644 --- a/src/language/data-io/placement-parser.c +++ b/src/language/data-io/placement-parser.c @@ -82,9 +82,9 @@ parse_var_placements (struct lexer *lexer, struct pool *pool, size_t var_cnt, bo if (assignment_cnt != var_cnt) { - msg (SE, _("Number of variables specified (%d) " - "differs from number of variable formats (%d)."), - (int) var_cnt, (int) assignment_cnt); + msg (SE, _("Number of variables specified (%zu) " + "differs from number of variable formats (%zu)."), + var_cnt, assignment_cnt); return false; } @@ -115,8 +115,8 @@ fixed_parse_columns (struct lexer *lexer, struct pool *pool, size_t var_cnt, boo if ((lc - fc + 1) % var_cnt) { msg (SE, _("The %d columns %d-%d " - "can't be evenly divided into %u fields."), - lc - fc + 1, fc, lc, (unsigned int) var_cnt); + "can't be evenly divided into %zu fields."), + lc - fc + 1, fc, lc, var_cnt); return false; } diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 67dfa129..8ec63c4d 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -256,9 +256,9 @@ parse_specs (struct lexer *lexer, struct pool *tmp_pool, struct print_trns *trns } if (trns->record_cnt != 0 && trns->record_cnt != record) - msg (SW, _("Output calls for %d records but %u specified on RECORDS " + msg (SW, _("Output calls for %d records but %zu specified on RECORDS " "subcommand."), - record, (unsigned int) trns->record_cnt); + record, trns->record_cnt); trns->record_cnt = record; return true; diff --git a/src/language/dictionary/modify-variables.c b/src/language/dictionary/modify-variables.c index d9a72f35..9fc6fa55 100644 --- a/src/language/dictionary/modify-variables.c +++ b/src/language/dictionary/modify-variables.c @@ -206,9 +206,8 @@ cmd_modify_vars (struct lexer *lexer, struct dataset *ds) if (prev_nv_1 != vm.rename_cnt) { msg (SE, _("Differing number of variables in old name list " - "(%d) and in new name list (%d)."), - (int) (vm.rename_cnt - prev_nv_2), - (int) (prev_nv_1 - prev_nv_2)); + "(%zu) and in new name list (%zu)."), + vm.rename_cnt - prev_nv_2, prev_nv_1 - prev_nv_2); for (i = 0; i < prev_nv_1; i++) free (vm.new_names[i]); free (vm.new_names); diff --git a/src/language/dictionary/rename-variables.c b/src/language/dictionary/rename-variables.c index 3179efda..90117ff6 100644 --- a/src/language/dictionary/rename-variables.c +++ b/src/language/dictionary/rename-variables.c @@ -74,9 +74,8 @@ cmd_rename_variables (struct lexer *lexer, struct dataset *ds) size_t i; msg (SE, _("Differing number of variables in old name list " - "(%d) and in new name list (%d)."), - (int) (rename_cnt - prev_nv_2), - (int) (prev_nv_1 - prev_nv_2)); + "(%zu) and in new name list (%zu)."), + rename_cnt - prev_nv_2, prev_nv_1 - prev_nv_2); for (i = 0; i < prev_nv_1; i++) free (rename_new_names[i]); free (rename_new_names); diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 48703b4a..2369b99e 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -130,8 +130,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) : info.float_format == FLOAT_Z_LONG ? _("IBM 390 Hex Long.") : _("Unknown.")); tab_text (t, 0, 5, TAB_LEFT, _("Variables:")); - tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF, "%u", - (unsigned int) dict_get_var_cnt (d)); + tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF, "%zu", dict_get_var_cnt (d)); tab_text (t, 0, 6, TAB_LEFT, _("Cases:")); tab_text (t, 1, 6, TAB_LEFT | TAT_PRINTF, info.case_cnt == -1 ? _("Unknown") : "%ld", @@ -424,8 +423,8 @@ display_variables (const struct variable **vl, size_t n, int as) } if (as != AS_NAMES) { - tab_text (t, pc, r, TAT_PRINTF, "%d", - (int) var_get_dict_index (v) + 1); + tab_text (t, pc, r, TAT_PRINTF, "%zu", + var_get_dict_index (v) + 1); tab_hline (t, TAL_1, 0, nc - 1, r); } r++; @@ -459,7 +458,7 @@ describe_variable (const struct variable *v, struct tab_table *t, int r, int as) /* Put the name, var label, and position into the first row. */ tab_text (t, 0, r, TAB_LEFT, var_get_name (v)); - tab_text (t, 3, r, TAT_PRINTF, "%d", (int) var_get_dict_index (v) + 1); + tab_text (t, 3, r, TAT_PRINTF, "%zu", var_get_dict_index (v) + 1); if (as == AS_DICTIONARY && var_has_label (v)) { @@ -647,7 +646,7 @@ display_vectors (const struct dictionary *dict, int sorted) char fmt_string[FMT_STRING_LEN_MAX + 1]; fmt_to_string (var_get_print_format (var), fmt_string); - tab_text (t, 1, row, TAB_RIGHT | TAT_PRINTF, "%d", (int) j + 1); + tab_text (t, 1, row, TAB_RIGHT | TAT_PRINTF, "%zu", j + 1); tab_text (t, 2, row, TAB_LEFT, var_get_name (var)); tab_text (t, 3, row, TAB_LEFT, fmt_string); row++; diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index 2af520ac..79657df7 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -1069,9 +1069,9 @@ convert_numeric_string_to_char_string (struct lexer *lexer, byte_cnt = ds_length (&lexer->tokstr) / chars_per_byte; if (ds_length (&lexer->tokstr) % chars_per_byte) - msg (SE, _("String of %s digits has %d characters, which is not a " + msg (SE, _("String of %s digits has %zu characters, which is not a " "multiple of %d."), - base_name, (int) ds_length (&lexer->tokstr), chars_per_byte); + base_name, ds_length (&lexer->tokstr), chars_per_byte); p = ds_cstr (&lexer->tokstr); for (i = 0; i < byte_cnt; i++) @@ -1207,8 +1207,8 @@ finish: if (ds_length (&lexer->tokstr) > 255) { - msg (SE, _("String exceeds 255 characters in length (%d characters)."), - (int) ds_length (&lexer->tokstr)); + msg (SE, _("String exceeds 255 characters in length (%zu characters)."), + ds_length (&lexer->tokstr)); ds_truncate (&lexer->tokstr, 255); } diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index b464a289..c9d68d35 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -485,8 +485,8 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, s } else { - msg (SE, _("Missing argument %d to %s."), - (int) i + 1, function->name); + msg (SE, _("Missing argument %zu to %s."), + i + 1, function->name); goto error; } @@ -516,9 +516,9 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, s like `unknown variable t'. */ if (n_src != n_dest) { - msg (SE, _("Number of source variables (%u) does not match " - "number of target variables (%u)."), - (unsigned) n_src, (unsigned) n_dest); + msg (SE, _("Number of source variables (%zu) does not match " + "number of target variables (%zu)."), + n_src, n_dest); goto error; } diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index 8b64ff3d..af9280b5 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -133,9 +133,9 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) { size_t i; - msg (SE, _("Source variable count (%u) does not match " - "target variable count (%u)."), - (unsigned) arc.var_cnt, (unsigned) dst_cnt); + msg (SE, _("Source variable count (%zu) does not match " + "target variable count (%zu)."), + arc.var_cnt, dst_cnt); for (i = 0; i < dst_cnt; i++) free (arc.dst_names[i]); diff --git a/src/language/stats/npar.q b/src/language/stats/npar.q index a49dec0b..688ce237 100644 --- a/src/language/stats/npar.q +++ b/src/language/stats/npar.q @@ -423,8 +423,8 @@ parse_two_sample_related_test (struct lexer *lexer, { if ( n_vlist1 != n_vlist2) msg (SE, _("PAIRED was specified but the number of variables " - "preceding WITH (%d) did not match the number " - "following (%d)."), (int) n_vlist1, (int) n_vlist2); + "preceding WITH (%zu) did not match the number " + "following (%zu)."), n_vlist1, n_vlist2); test_parameters->n_pairs = n_vlist1 ; } diff --git a/src/language/stats/oneway.q b/src/language/stats/oneway.q index d10dbb5b..8215d6b8 100644 --- a/src/language/stats/oneway.q +++ b/src/language/stats/oneway.q @@ -175,8 +175,7 @@ output_oneway(void) sum += subc_list_double_at(&cmd.dl_contrast[i],j); if ( sum != 0.0 ) - msg(SW,_("Coefficients for contrast %d do not total zero"), - (int) i + 1); + msg(SW,_("Coefficients for contrast %zu do not total zero"), i + 1); } if ( stat_tables & STAT_DESC ) diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index 79e5bf61..23237072 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -484,9 +484,9 @@ tts_custom_pairs (struct lexer *lexer, struct dataset *ds, struct cmd_t_test *cm { free (vars); msg (SE, _("PAIRED was specified but the number of variables " - "preceding WITH (%d) did not match the number " - "following (%d)."), - (int) n_before_WITH, (int) n_after_WITH ); + "preceding WITH (%zu) did not match the number " + "following (%zu)."), + n_before_WITH, n_after_WITH); return 0; } n_pairs_local = n_before_WITH; diff --git a/src/language/tests/float-format.c b/src/language/tests/float-format.c index 9e6f777c..fed19479 100644 --- a/src/language/tests/float-format.c +++ b/src/language/tests/float-format.c @@ -121,8 +121,9 @@ parse_fp (struct lexer *lexer, struct fp *fp) { if (length != float_get_size (fp->format)) { - msg (SE, _("%d-byte string needed but %d-byte string supplied."), - (int) float_get_size (fp->format), (int) length); + msg (SE, _("%zu-byte string needed but %zu-byte string " + "supplied."), + float_get_size (fp->format), length); return false; } assert (length <= sizeof fp->data); diff --git a/src/language/tests/moments-test.c b/src/language/tests/moments-test.c index 0e10b7fd..91a67939 100644 --- a/src/language/tests/moments-test.c +++ b/src/language/tests/moments-test.c @@ -123,7 +123,7 @@ cmd_debug_moments (struct lexer *lexer, struct dataset *ds UNUSED) fprintf (stderr, "W=%.3f", weight); for (i = 0; i < 4; i++) { - fprintf (stderr, " M%d=", (int) i + 1); + fprintf (stderr, " M%zu=", i + 1); if (M[i] == SYSMIS) fprintf (stderr, "sysmis"); else if (fabs (M[i]) <= 0.0005) diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 08bece5d..f4ae92f4 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -436,10 +436,10 @@ parse_dst_vars (struct lexer *lexer, struct recode_trns *trns, if (name_cnt != trns->var_cnt) { - msg (SE, _("%u variable(s) cannot be recoded into " - "%u variable(s). Specify the same number " + msg (SE, _("%zu variable(s) cannot be recoded into " + "%zu variable(s). Specify the same number " "of variables as source and target variables."), - (unsigned) trns->var_cnt, (unsigned) name_cnt); + trns->var_cnt, name_cnt); return false; } diff --git a/tests/automake.mk b/tests/automake.mk index 5e6e2369..58400ac0 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -161,6 +161,7 @@ tests_libpspp_ll_test_SOURCES = \ src/libpspp/ll.c \ src/libpspp/ll.h \ tests/libpspp/ll-test.c +tests_libpspp_ll_test_LDADD = gl/libgl.la @LIBINTL@ tests_libpspp_llx_test_SOURCES = \ src/libpspp/ll.c \ @@ -168,6 +169,7 @@ tests_libpspp_llx_test_SOURCES = \ src/libpspp/llx.c \ src/libpspp/llx.h \ tests/libpspp/llx-test.c +tests_libpspp_llx_test_LDADD = gl/libgl.la @LIBINTL@ tests_libpspp_heap_test_SOURCES = \ src/libpspp/heap.c \