From: Ben Pfaff Date: Thu, 18 Nov 2010 04:03:26 +0000 (-0800) Subject: str: Change "char" to "byte" in function names. X-Git-Tag: v0.7.7~129 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8493b3b0617cc447446a70b031a69079bc19002;p=pspp-builds.git str: Change "char" to "byte" in function names. As PSPP moves toward using UTF-8 pervasively for command syntax, a character is no longer always a byte, so this naming is clearer. --- diff --git a/src/data/data-in.c b/src/data/data-in.c index d36aefb5..45ff6099 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -301,44 +301,44 @@ parse_number (struct data_in *i) /* Prefix character may precede sign. */ if (!ss_is_empty (style->prefix)) { - ss_match_char (&i->input, ss_first (style->prefix)); + ss_match_byte (&i->input, ss_first (style->prefix)); ss_ltrim (&i->input, ss_cstr (CC_SPACES)); } /* Sign. */ - if (ss_match_char (&i->input, '-')) + if (ss_match_byte (&i->input, '-')) { - ds_put_char (&tmp, '-'); + ds_put_byte (&tmp, '-'); ss_ltrim (&i->input, ss_cstr (CC_SPACES)); } else { - ss_match_char (&i->input, '+'); + ss_match_byte (&i->input, '+'); ss_ltrim (&i->input, ss_cstr (CC_SPACES)); } /* Prefix character may follow sign. */ if (!ss_is_empty (style->prefix)) { - ss_match_char (&i->input, ss_first (style->prefix)); + ss_match_byte (&i->input, ss_first (style->prefix)); ss_ltrim (&i->input, ss_cstr (CC_SPACES)); } /* Digits before decimal point. */ while (c_isdigit (ss_first (i->input))) { - ds_put_char (&tmp, ss_get_char (&i->input)); + ds_put_byte (&tmp, ss_get_byte (&i->input)); if (style->grouping != 0) - ss_match_char (&i->input, style->grouping); + ss_match_byte (&i->input, style->grouping); } /* Decimal point and following digits. */ - if (ss_match_char (&i->input, style->decimal)) + if (ss_match_byte (&i->input, style->decimal)) { explicit_decimals = true; - ds_put_char (&tmp, '.'); + ds_put_byte (&tmp, '.'); while (c_isdigit (ss_first (i->input))) - ds_put_char (&tmp, ss_get_char (&i->input)); + ds_put_byte (&tmp, ss_get_byte (&i->input)); } /* Exponent. */ @@ -347,28 +347,28 @@ parse_number (struct data_in *i) && strchr ("eEdD-+", ss_first (i->input))) { explicit_decimals = true; - ds_put_char (&tmp, 'e'); + ds_put_byte (&tmp, 'e'); if (strchr ("eEdD", ss_first (i->input))) { ss_advance (&i->input, 1); - ss_match_char (&i->input, ' '); + ss_match_byte (&i->input, ' '); } if (ss_first (i->input) == '-' || ss_first (i->input) == '+') { - if (ss_get_char (&i->input) == '-') - ds_put_char (&tmp, '-'); - ss_match_char (&i->input, ' '); + if (ss_get_byte (&i->input) == '-') + ds_put_byte (&tmp, '-'); + ss_match_byte (&i->input, ' '); } while (c_isdigit (ss_first (i->input))) - ds_put_char (&tmp, ss_get_char (&i->input)); + ds_put_byte (&tmp, ss_get_byte (&i->input)); } /* Suffix character. */ if (!ss_is_empty (style->suffix)) - ss_match_char (&i->input, ss_first (style->suffix)); + ss_match_byte (&i->input, ss_first (style->suffix)); if (!ss_is_empty (i->input)) { @@ -420,7 +420,7 @@ parse_N (struct data_in *i) int c; i->output->f = 0; - while ((c = ss_get_char (&i->input)) != EOF) + while ((c = ss_get_byte (&i->input)) != EOF) { if (!c_isdigit (c)) return xstrdup (_("All characters in field must be digits.")); @@ -439,7 +439,7 @@ parse_PIBHEX (struct data_in *i) n = 0.0; - while ((c = ss_get_char (&i->input)) != EOF) + while ((c = ss_get_byte (&i->input)) != EOF) { if (!c_isxdigit (c)) return xstrdup (_("Unrecognized character in field.")); @@ -460,8 +460,8 @@ parse_RBHEX (struct data_in *i) memset (&d, 0, sizeof d); for (j = 0; !ss_is_empty (i->input) && j < sizeof d; j++) { - int hi = ss_get_char (&i->input); - int lo = ss_get_char (&i->input); + int hi = ss_get_byte (&i->input); + int lo = ss_get_byte (&i->input); if (lo == EOF) return xstrdup (_("Field must have even length.")); else if (!c_isxdigit (hi) || !c_isxdigit (lo)) @@ -520,22 +520,22 @@ parse_Z (struct data_in *i) ds_init_empty (&tmp); ds_extend (&tmp, 64); - ds_put_char (&tmp, '+'); + ds_put_byte (&tmp, '+'); while (!ss_is_empty (i->input)) { - int c = ss_get_char (&i->input); + int c = ss_get_byte (&i->input); if (c_isdigit (c) && !got_final_digit) - ds_put_char (&tmp, c); + ds_put_byte (&tmp, c); else if (is_z_digit (c) && !got_final_digit) { - ds_put_char (&tmp, z_digit_value (c) + '0'); + ds_put_byte (&tmp, z_digit_value (c) + '0'); if (is_negative_z_digit (c)) ds_data (&tmp)[0] = '-'; got_final_digit = true; } else if (c == '.' && !got_dot) { - ds_put_char (&tmp, '.'); + ds_put_byte (&tmp, '.'); got_dot = true; } else @@ -623,7 +623,7 @@ parse_PIB (struct data_in *i) static void get_nibbles (struct substring *s, int *high_nibble, int *low_nibble) { - int c = ss_get_char (s); + int c = ss_get_byte (s); assert (c != EOF); *high_nibble = (c >> 4) & 15; *low_nibble = c & 15; @@ -721,8 +721,8 @@ parse_AHEX (struct data_in *i) for (j = 0; ; j++) { - int hi = ss_get_char (&i->input); - int lo = ss_get_char (&i->input); + int hi = ss_get_byte (&i->input); + int lo = ss_get_byte (&i->input); if (hi == EOF) break; else if (lo == EOF) @@ -799,11 +799,11 @@ parse_time_units (struct data_in *i, double seconds_per_unit, if (*time_sign == SIGN_NO_TIME) { - if (ss_match_char (&i->input, '-')) + if (ss_match_byte (&i->input, '-')) *time_sign = SIGN_NEGATIVE; else { - ss_match_char (&i->input, '+'); + ss_match_byte (&i->input, '+'); *time_sign = SIGN_POSITIVE; } } @@ -839,7 +839,7 @@ static struct substring parse_name_token (struct data_in *i) { struct substring token; - ss_get_chars (&i->input, ss_span (i->input, ss_cstr (CC_LETTERS)), &token); + ss_get_bytes (&i->input, ss_span (i->input, ss_cstr (CC_LETTERS)), &token); return token; } @@ -949,7 +949,7 @@ parse_yday (struct data_in *i, long *yday) struct substring num_s; long num; - ss_get_chars (&i->input, 3, &num_s); + ss_get_bytes (&i->input, 3, &num_s); if (ss_span (num_s, ss_cstr (CC_DIGITS)) != 3) return xstrdup (_("Julian day must have exactly three digits.")); else if (!ss_get_long (&num_s, &num) || num < 1 || num > 366) @@ -1041,11 +1041,11 @@ parse_minute_second (struct data_in *i, double *time) /* Parse seconds. */ cp = buf; while (c_isdigit (ss_first (i->input))) - *cp++ = ss_get_char (&i->input); - if (ss_match_char (&i->input, settings_get_decimal_char (FMT_F))) + *cp++ = ss_get_byte (&i->input); + if (ss_match_byte (&i->input, settings_get_decimal_char (FMT_F))) *cp++ = '.'; while (c_isdigit (ss_first (i->input))) - *cp++ = ss_get_char (&i->input); + *cp++ = ss_get_byte (&i->input); *cp = '\0'; *time += strtod (buf, NULL); @@ -1192,8 +1192,8 @@ parse_date (struct data_in *i) break; default: assert (count == 1); - if (!ss_match_char (&i->input, c_toupper (ch)) - && !ss_match_char (&i->input, c_tolower (ch))) + if (!ss_match_byte (&i->input, c_toupper (ch)) + && !ss_match_byte (&i->input, c_tolower (ch))) error = xasprintf (_("`%c' expected in date field."), ch); else error = NULL; diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 9222f7ec..0ca9f9e4 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -1262,7 +1262,7 @@ dict_set_documents (struct dictionary *d, const char *documents) final line with spaces. */ remainder = ds_length (&d->documents) % DOC_LINE_LENGTH; if (remainder != 0) - ds_put_char_multiple (&d->documents, ' ', DOC_LINE_LENGTH - remainder); + ds_put_byte_multiple (&d->documents, ' ', DOC_LINE_LENGTH - remainder); } /* Drops the documents from dictionary D. */ diff --git a/src/data/format-guesser.c b/src/data/format-guesser.c index 26c917b8..bdf46a06 100644 --- a/src/data/format-guesser.c +++ b/src/data/format-guesser.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -304,12 +304,12 @@ add_numeric (struct fmt_guesser *g, struct substring s) int c; /* Skip leading "$" and optional following white space. */ - has_dollar = ss_match_char (&s, '$'); + has_dollar = ss_match_byte (&s, '$'); if (has_dollar) ss_ltrim (&s, ss_cstr (CC_SPACES)); /* Skip optional sign. */ - ss_match_char_in (&s, ss_cstr ("+-")); + ss_match_byte_in (&s, ss_cstr ("+-")); /* Skip digits punctuated by commas and dots. We don't know whether the decimal point is a comma or a dot, so for now we @@ -348,10 +348,10 @@ add_numeric (struct fmt_guesser *g, struct substring s) } /* Skip the optional exponent. */ - has_exp = ss_match_char_in (&s, ss_cstr ("eEdD")) != EOF; - has_exp_sign = ss_match_char_in (&s, ss_cstr ("-+")) != EOF; + has_exp = ss_match_byte_in (&s, ss_cstr ("eEdD")) != EOF; + has_exp_sign = ss_match_byte_in (&s, ss_cstr ("-+")) != EOF; if (has_exp_sign) - ss_match_char (&s, ' '); + ss_match_byte (&s, ' '); exp_digits = ss_ltrim (&s, ss_cstr (CC_DIGITS)); if ((has_exp || has_exp_sign) && !exp_digits) { @@ -361,7 +361,7 @@ add_numeric (struct fmt_guesser *g, struct substring s) } /* Skip optional '%'. */ - has_percent = ss_match_char (&s, '%'); + has_percent = ss_match_byte (&s, '%'); if (has_dollar && has_percent) { /* A valid number cannot have both '$' and '%'. */ @@ -635,7 +635,7 @@ parse_date_token (struct substring *s, enum date_token tokens_seen, ss_advance (s, 1); token = recognize_identifier_token (s); if (token) - ss_match_char_in (s, ss_cstr (CC_SPACES)); + ss_match_byte_in (s, ss_cstr (CC_SPACES)); else token = DT_DELIM | DT_SPACE; return token; @@ -666,7 +666,7 @@ parse_date_number (struct substring *s, enum date_token tokens_seen, size_t digit_cnt = ss_get_long (s, &value); enum date_token token = 0; - if (ss_match_char (s, settings_get_decimal_char (FMT_F)) + if (ss_match_byte (s, settings_get_decimal_char (FMT_F)) && tokens_seen & DT_COLON && value <= 59) { diff --git a/src/data/settings.c b/src/data/settings.c index 13512cc0..092187a6 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -688,20 +688,20 @@ settings_dollar_template (const struct fmt_spec *fmt) fns = fmt_settings_get_style (the_settings.styles, fmt->type); - ds_put_char (&str, '$'); + ds_put_byte (&str, '$'); for (c = MAX (fmt->w - fmt->d - 1, 0); c > 0; ) { - ds_put_char (&str, '#'); + ds_put_byte (&str, '#'); if (--c % 4 == 0 && c > 0) { - ds_put_char (&str, fns->grouping); + ds_put_byte (&str, fns->grouping); --c; } } if (fmt->d > 0) { - ds_put_char (&str, fns->decimal); - ds_put_char_multiple (&str, '#', fmt->d); + ds_put_byte (&str, fns->decimal); + ds_put_byte_multiple (&str, '#', fmt->d); } return ds_cstr (&str); diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index f31bd99a..efefa8fb 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -572,10 +572,10 @@ put_attrset (struct string *string, const struct attrset *attrs) size_t j; ds_put_cstr (string, attribute_get_name (attr)); - ds_put_char (string, '('); + ds_put_byte (string, '('); for (j = 0; j < n_values; j++) ds_put_format (string, "'%s'\n", attribute_get_value (attr, j)); - ds_put_char (string, ')'); + ds_put_byte (string, ')'); } } @@ -615,7 +615,7 @@ write_variable_attributes (struct sfm_writer *w, const struct dictionary *d) if (attrset_count (attrs)) { if (n_attrsets++) - ds_put_char (&s, '/'); + ds_put_byte (&s, '/'); ds_put_format (&s, "%s:", var_get_short_name (v, 0)); put_attrset (&s, attrs); } @@ -658,7 +658,7 @@ write_mrsets (struct sfm_writer *w, const struct dictionary *dict, if (mrset->cat_source == MRSET_COUNTEDVALUES) ds_put_format (&s, "E %d ", mrset->label_from_var_label ? 11 : 1); else - ds_put_char (&s, 'D'); + ds_put_byte (&s, 'D'); if (mrset->width == 0) counted = xasprintf ("%.0f", mrset->counted.f); @@ -669,15 +669,15 @@ write_mrsets (struct sfm_writer *w, const struct dictionary *dict, free (counted); } else - ds_put_char (&s, 'C'); - ds_put_char (&s, ' '); + ds_put_byte (&s, 'C'); + ds_put_byte (&s, ' '); label = mrset->label && !mrset->label_from_var_label ? mrset->label : ""; ds_put_format (&s, "%zu %s", strlen (label), label); for (j = 0; j < mrset->n_vars; j++) ds_put_format (&s, " %s", var_get_short_name (mrset->vars[j], 0)); - ds_put_char (&s, '\n'); + ds_put_byte (&s, '\n'); } write_attribute_record (w, &s, 7); ds_destroy (&s); @@ -843,7 +843,7 @@ write_longvar_table (struct sfm_writer *w, const struct dictionary *dict) char *longname = recode_string (dict_get_encoding (dict), UTF8, var_get_name (v), -1); if (i) - ds_put_char (&map, '\t'); + ds_put_byte (&map, '\t'); ds_put_format (&map, "%s=%s", var_get_short_name (v, 0), longname); free (longname); diff --git a/src/language/command.c b/src/language/command.c index 9f90db93..a6805898 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -483,7 +483,7 @@ unknown_command_error (struct lexer *lexer, char *const words[], size_t word_cnt for (i = 0; i < word_cnt; i++) { if (i != 0) - ds_put_char (&s, ' '); + ds_put_byte (&s, ' '); ds_put_cstr (&s, words[i]); } diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index 69c92ac1..bae0e4af 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -259,7 +259,7 @@ recognize_keyword (struct substring *line, const char *keyword) { struct substring id; ss_ltrim (line, ss_cstr (CC_SPACES)); - ss_get_chars (line, lex_id_get_length (*line), &id); + ss_get_bytes (line, lex_id_get_length (*line), &id); return lex_id_match (ss_cstr (keyword), id); } @@ -541,18 +541,18 @@ do_repeat_filter (struct getl_interface *interface, struct string *line) if (in_quote || in_apos || !lex_is_id1 (c)) { - ds_put_char (&output, c); + ds_put_byte (&output, c); ss_advance (&input, 1); } else { struct substring id; - ss_get_chars (&input, lex_id_get_length (input), &id); + ss_get_bytes (&input, lex_id_get_length (input), &id); ds_put_substring (&output, find_substitution (block, id)); } } if (dot) - ds_put_char (&output, settings_get_endcmd ()); + ds_put_byte (&output, settings_get_endcmd ()); ds_swap (line, &output); ds_destroy (&output); diff --git a/src/language/data-io/data-list.c b/src/language/data-io/data-list.c index 80c9849b..95596c15 100644 --- a/src/language/data-io/data-list.c +++ b/src/language/data-io/data-list.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -208,7 +208,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) ds_destroy (&delims); goto error; } - ds_put_char (&delims, delim); + ds_put_byte (&delims, delim); lex_match (lexer, ','); } diff --git a/src/language/data-io/data-parser.c b/src/language/data-io/data-parser.c index 714b2a95..1e67c713 100644 --- a/src/language/data-io/data-parser.c +++ b/src/language/data-io/data-parser.c @@ -450,19 +450,19 @@ cut_field (const struct data_parser *parser, struct dfm_reader *reader, } *first_column = dfm_column_start (reader); - if (ss_find_char (parser->quotes, ss_first (p)) != SIZE_MAX) + if (ss_find_byte (parser->quotes, ss_first (p)) != SIZE_MAX) { /* Quoted field. */ - int quote = ss_get_char (&p); + int quote = ss_get_byte (&p); if (!ss_get_until (&p, quote, field)) msg (SW, _("Quoted string extends beyond end of line.")); if (parser->quote_escape && ss_first (p) == quote) { ds_assign_substring (tmp, *field); - while (ss_match_char (&p, quote)) + while (ss_match_byte (&p, quote)) { struct substring ss; - ds_put_char (tmp, quote); + ds_put_byte (tmp, quote); if (!ss_get_until (&p, quote, &ss)) msg (SW, _("Quoted string extends beyond end of line.")); ds_put_substring (tmp, ss); @@ -475,17 +475,17 @@ cut_field (const struct data_parser *parser, struct dfm_reader *reader, if present. */ ss_ltrim (&p, parser->soft_seps); if (!ss_is_empty (p) - && ss_find_char (parser->hard_seps, ss_first (p)) != SIZE_MAX) + && ss_find_byte (parser->hard_seps, ss_first (p)) != SIZE_MAX) ss_advance (&p, 1); } else { /* Regular field. */ - ss_get_chars (&p, ss_cspan (p, ds_ss (&parser->any_sep)), field); + ss_get_bytes (&p, ss_cspan (p, ds_ss (&parser->any_sep)), field); *last_column = *first_column + ss_length (*field); if (!ss_ltrim (&p, parser->soft_seps) || ss_is_empty (p) - || ss_find_char (parser->hard_seps, p.string[0]) != SIZE_MAX) + || ss_find_byte (parser->hard_seps, p.string[0]) != SIZE_MAX) { /* Advance past a trailing hard separator, regardless of whether one actually existed. If diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index e52433ac..142e1d4a 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -556,7 +556,7 @@ dfm_expand_tabs (struct dfm_reader *r) if (r->fh != fh_inline_file () && (fh_get_mode (r->fh) != FH_MODE_TEXT || fh_get_tab_width (r->fh) == 0 - || ds_find_char (&r->line, '\t') == SIZE_MAX)) + || ds_find_byte (&r->line, '\t') == SIZE_MAX)) return; /* Expand tabs from r->line into r->scratch, and figure out @@ -573,11 +573,11 @@ dfm_expand_tabs (struct dfm_reader *r) c = ds_data (&r->line)[ofs]; if (c != '\t') - ds_put_char (&r->scratch, c); + ds_put_byte (&r->scratch, c); else { do - ds_put_char (&r->scratch, ' '); + ds_put_byte (&r->scratch, ' '); while (ds_length (&r->scratch) % tab_width != 0); } } diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 94fadd60..9be7a2d6 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -420,11 +420,11 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) ds_put_cstr (&hard_seps, "\t"); if (ss_match_string (&s, ss_cstr ("\\\\"))) ds_put_cstr (&hard_seps, "\\"); - while ((c = ss_get_char (&s)) != EOF) + while ((c = ss_get_byte (&s)) != EOF) if (c == ' ') soft_seps = " "; else - ds_put_char (&hard_seps, c); + ds_put_byte (&hard_seps, c); data_parser_set_soft_delimiters (parser, ss_cstr (soft_seps)); data_parser_set_hard_delimiters (parser, ds_ss (&hard_seps)); ds_destroy (&hard_seps); diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 164d9927..3308629e 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -459,7 +459,7 @@ print_trns_proc (void *trns_, struct ccase **c, casenumber case_num UNUSED) struct prt_out_spec *spec; ds_clear (&trns->line); - ds_put_char (&trns->line, ' '); + ds_put_byte (&trns->line, ' '); ll_for_each (spec, struct prt_out_spec, ll, &trns->specs) { flush_records (trns, spec->record, &eject, &record); @@ -474,7 +474,7 @@ print_trns_proc (void *trns_, struct ccase **c, casenumber case_num UNUSED) else memset (output, encoded_space, spec->format.w); if (spec->add_space) - ds_put_char (&trns->line, encoded_space); + ds_put_byte (&trns->line, encoded_space); } else { diff --git a/src/language/expressions/parse.c b/src/language/expressions/parse.c index f2b4f1c7..e4af2db8 100644 --- a/src/language/expressions/parse.c +++ b/src/language/expressions/parse.c @@ -1149,7 +1149,7 @@ put_invocation (struct string *s, ds_put_cstr (s, ", "); ds_put_cstr (s, operations[expr_node_returns (args[i])].prototype); } - ds_put_char (s, ')'); + ds_put_byte (s, ')'); } static void @@ -1176,7 +1176,7 @@ no_match (const char *func_name, for (f = first; f < last; f++) ds_put_format (&s, "\n%s", f->prototype); } - ds_put_char (&s, '.'); + ds_put_byte (&s, '.'); msg (SE, "%s", ds_cstr (&s)); diff --git a/src/language/lexer/format-parser.c b/src/language/lexer/format-parser.c index 9adbeb15..1730b493 100644 --- a/src/language/lexer/format-parser.c +++ b/src/language/lexer/format-parser.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,12 +47,12 @@ parse_abstract_format_specifier__ (struct lexer *lexer, /* Extract pieces. */ s = ds_ss (lex_tokstr (lexer)); - ss_get_chars (&s, ss_span (s, ss_cstr (CC_LETTERS)), &type_ss); - ss_get_chars (&s, ss_span (s, ss_cstr (CC_DIGITS)), &width_ss); - if (ss_match_char (&s, '.')) + ss_get_bytes (&s, ss_span (s, ss_cstr (CC_LETTERS)), &type_ss); + ss_get_bytes (&s, ss_span (s, ss_cstr (CC_DIGITS)), &width_ss); + if (ss_match_byte (&s, '.')) { has_decimals = true; - ss_get_chars (&s, ss_span (s, ss_cstr (CC_DIGITS)), &decimals_ss); + ss_get_bytes (&s, ss_span (s, ss_cstr (CC_DIGITS)), &decimals_ss); } else has_decimals = false; diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index 8d0352ae..3ef8dc1d 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -224,7 +224,7 @@ lex_get (struct lexer *lexer) negative numbers into two tokens. */ if (*lexer->prog == '-') { - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); while (c_isspace ((unsigned char) *lexer->prog)) lexer->prog++; @@ -240,20 +240,20 @@ lex_get (struct lexer *lexer) /* Parse the number, copying it into tokstr. */ while (c_isdigit ((unsigned char) *lexer->prog)) - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); if (*lexer->prog == '.') { - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); while (c_isdigit ((unsigned char) *lexer->prog)) - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); } if (*lexer->prog == 'e' || *lexer->prog == 'E') { - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); if (*lexer->prog == '+' || *lexer->prog == '-') - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); while (c_isdigit ((unsigned char) *lexer->prog)) - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); } /* Parse as floating point. */ @@ -265,7 +265,7 @@ lex_get (struct lexer *lexer) lexer->tokval = 0.0; ds_clear (&lexer->tokstr); - ds_put_char (&lexer->tokstr, '0'); + ds_put_byte (&lexer->tokstr, '0'); } break; @@ -1135,7 +1135,7 @@ parse_string (struct lexer *lexer, enum string_type type) break; } - ds_put_char (&lexer->tokstr, *lexer->prog++); + ds_put_byte (&lexer->tokstr, *lexer->prog++); } lexer->prog++; diff --git a/src/language/syntax-string-source.c b/src/language/syntax-string-source.c index 4f3c1c14..c40a221c 100644 --- a/src/language/syntax-string-source.c +++ b/src/language/syntax-string-source.c @@ -83,7 +83,7 @@ read_single_line (struct getl_interface *i, if ( sss->posn == -1) return false; - next = ss_find_char (ds_substr (&sss->buffer, + next = ss_find_byte (ds_substr (&sss->buffer, sss->posn, -1), '\n'); ds_assign_substring (line, diff --git a/src/language/utilities/host.c b/src/language/utilities/host.c index ac091454..dc9d4898 100644 --- a/src/language/utilities/host.c +++ b/src/language/utilities/host.c @@ -144,7 +144,7 @@ cmd_host (struct lexer *lexer, struct dataset *ds UNUSED) while (lex_is_string (lexer)) { if (!ds_is_empty (&command)) - ds_put_char (&command, '\n'); + ds_put_byte (&command, '\n'); ds_put_substring (&command, ds_ss (lex_tokstr (lexer))); lex_get (lexer); } diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index 9a2e981a..0528939b 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -558,12 +558,12 @@ format_cc (struct string *out, struct substring in, char grouping) { while (!ss_is_empty (in)) { - char c = ss_get_char (&in); + char c = ss_get_byte (&in); if (c == grouping || c == '\'') - ds_put_char (out, '\''); + ds_put_byte (out, '\''); else if (c == '"') - ds_put_char (out, '"'); - ds_put_char (out, c); + ds_put_byte (out, '"'); + ds_put_byte (out, c); } } @@ -575,11 +575,11 @@ show_cc (enum fmt_type type) ds_init_empty (&out); format_cc (&out, cc->neg_prefix, cc->grouping); - ds_put_char (&out, cc->grouping); + ds_put_byte (&out, cc->grouping); format_cc (&out, cc->prefix, cc->grouping); - ds_put_char (&out, cc->grouping); + ds_put_byte (&out, cc->grouping); format_cc (&out, cc->suffix, cc->grouping); - ds_put_char (&out, cc->grouping); + ds_put_byte (&out, cc->grouping); format_cc (&out, cc->neg_suffix, cc->grouping); return ds_cstr (&out); diff --git a/src/language/utilities/title.c b/src/language/utilities/title.c index fe826db1..8b8ac77c 100644 --- a/src/language/utilities/title.c +++ b/src/language/utilities/title.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2007, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -117,7 +117,7 @@ cmd_document (struct lexer *lexer, struct dataset *ds) end_dot = lex_end_dot (lexer); ds_assign_string (&line, lex_entire_line_ds (lexer)); if (end_dot) - ds_put_char (&line, '.'); + ds_put_byte (&line, '.'); dict_add_document_line (dict, ds_cstr (&line)); lex_discard_line (lexer); diff --git a/src/libpspp/argv-parser.c b/src/libpspp/argv-parser.c index ecf1ab23..dfa86fad 100644 --- a/src/libpspp/argv-parser.c +++ b/src/libpspp/argv-parser.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,11 +128,11 @@ argv_parser_run (struct argv_parser *ap, int argc, char **argv) if (shortopt_ptrs[c] == NULL) { shortopt_ptrs[c] = aop; - ds_put_char (&shortopts, aop->base.short_name); + ds_put_byte (&shortopts, aop->base.short_name); if (aop->base.has_arg != no_argument) - ds_put_char (&shortopts, ':'); + ds_put_byte (&shortopts, ':'); if (aop->base.has_arg == optional_argument) - ds_put_char (&shortopts, ':'); + ds_put_byte (&shortopts, ':'); } else { diff --git a/src/libpspp/message.c b/src/libpspp/message.c index ed6d6e7a..40949930 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -127,7 +127,7 @@ msg_to_string (const struct msg *m, const char *command_name) if (m->where.line_number > 0) { if (!ds_is_empty (&s)) - ds_put_char (&s, ':'); + ds_put_byte (&s, ':'); ds_put_format (&s, "%d", m->where.line_number); } if (m->where.first_column > 0) diff --git a/src/libpspp/model-checker.c b/src/libpspp/model-checker.c index 940f89aa..0e73fec6 100644 --- a/src/libpspp/model-checker.c +++ b/src/libpspp/model-checker.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -120,7 +120,7 @@ mc_path_to_string (const struct mc_path *path, struct string *string) for (i = 0; i < mc_path_get_length (path); i++) { if (i > 0) - ds_put_char (string, ' '); + ds_put_byte (string, ' '); ds_put_format (string, "%d", mc_path_get_operation (path, i)); } } diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 6c2e3991..cd2363a0 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -23,15 +23,15 @@ #include #include -#include -#include -#include - -#include -#include "minmax.h" -#include "xalloc.h" -#include "xmemdup0.h" -#include "xsize.h" +#include "libpspp/cast.h" +#include "libpspp/message.h" +#include "libpspp/pool.h" + +#include "gl/relocatable.h" +#include "gl/minmax.h" +#include "gl/xalloc.h" +#include "gl/xmemdup0.h" +#include "gl/xsize.h" /* Reverses the order of NBYTES bytes at address P, thus converting between little- and big-endian byte orders. */ @@ -181,8 +181,8 @@ buf_copy_rpad (char *dst, size_t dst_size, /* Copies string SRC to string DST, which is in a buffer DST_SIZE bytes long. - Truncates DST to DST_SIZE - 1 characters or right-pads with - spaces to DST_SIZE - 1 characters if necessary. */ + Truncates DST to DST_SIZE - 1 bytes or right-pads with + spaces to DST_SIZE - 1 bytes if necessary. */ void str_copy_rpad (char *dst, size_t dst_size, const char *src) { @@ -201,7 +201,7 @@ str_copy_rpad (char *dst, size_t dst_size, const char *src) } /* Copies SRC to DST, which is in a buffer DST_SIZE bytes long. - Truncates DST to DST_SIZE - 1 characters, if necessary. */ + Truncates DST to DST_SIZE - 1 bytes, if necessary. */ void str_copy_trunc (char *dst, size_t dst_size, const char *src) { @@ -218,7 +218,7 @@ str_copy_trunc (char *dst, size_t dst_size, const char *src) /* Copies buffer SRC, of SRC_LEN bytes, to DST, which is in a buffer DST_SIZE bytes long. - Truncates DST to DST_SIZE - 1 characters, if necessary. */ + Truncates DST to DST_SIZE - 1 bytes, if necessary. */ void str_copy_buf_trunc (char *dst, size_t dst_size, const char *src, size_t src_size) @@ -231,7 +231,7 @@ str_copy_buf_trunc (char *dst, size_t dst_size, dst[dst_len] = '\0'; } -/* Converts each character in S to uppercase. */ +/* Converts each byte in S to uppercase. */ void str_uppercase (char *s) { @@ -239,7 +239,7 @@ str_uppercase (char *s) *s = toupper ((unsigned char) *s); } -/* Converts each character in S to lowercase. */ +/* Converts each byte in S to lowercase. */ void str_lowercase (char *s) { @@ -293,7 +293,7 @@ mempset (void *block, int c, size_t size) /* Substrings. */ -/* Returns a substring whose contents are the CNT characters +/* Returns a substring whose contents are the CNT bytes starting at the (0-based) position START in SS. */ struct substring ss_substr (struct substring ss, size_t start, size_t cnt) @@ -305,14 +305,14 @@ ss_substr (struct substring ss, size_t start, size_t cnt) } /* Returns a substring whose contents are the first CNT - characters in SS. */ + bytes in SS. */ struct substring ss_head (struct substring ss, size_t cnt) { return ss_buffer (ss.string, MIN (cnt, ss.length)); } -/* Returns a substring whose contents are the last CNT characters +/* Returns a substring whose contents are the last CNT bytes in SS. */ struct substring ss_tail (struct substring ss, size_t cnt) @@ -332,7 +332,7 @@ ss_alloc_substring (struct substring *new, struct substring old) new->length = old.length; } -/* Allocates room for a CNT-character string in NEW. */ +/* Allocates room for a CNT-byte string in NEW. */ void ss_alloc_uninit (struct substring *new, size_t cnt) { @@ -351,7 +351,7 @@ ss_alloc_substring_pool (struct substring *new, struct substring old, memcpy (new->string, old.string, old.length); } -/* Allocates room for a CNT-character string in NEW in POOL. */ +/* Allocates room for a CNT-byte string in NEW in POOL. */ void ss_alloc_uninit_pool (struct substring *new, size_t cnt, struct pool *pool) { @@ -366,7 +366,7 @@ ss_dealloc (struct substring *ss) free (ss->string); } -/* Truncates SS to at most CNT characters in length. */ +/* Truncates SS to at most CNT bytes in length. */ void ss_truncate (struct substring *ss, size_t cnt) { @@ -374,22 +374,22 @@ ss_truncate (struct substring *ss, size_t cnt) ss->length = cnt; } -/* Removes trailing characters in TRIM_SET from SS. - Returns number of characters removed. */ +/* Removes trailing bytes in TRIM_SET from SS. + Returns number of bytes removed. */ size_t ss_rtrim (struct substring *ss, struct substring trim_set) { size_t cnt = 0; while (cnt < ss->length - && ss_find_char (trim_set, + && ss_find_byte (trim_set, ss->string[ss->length - cnt - 1]) != SIZE_MAX) cnt++; ss->length -= cnt; return cnt; } -/* Removes leading characters in TRIM_SET from SS. - Returns number of characters removed. */ +/* Removes leading bytes in TRIM_SET from SS. + Returns number of bytes removed. */ size_t ss_ltrim (struct substring *ss, struct substring trim_set) { @@ -398,7 +398,7 @@ ss_ltrim (struct substring *ss, struct substring trim_set) return cnt; } -/* Trims leading and trailing characters in TRIM_SET from SS. */ +/* Trims leading and trailing bytes in TRIM_SET from SS. */ void ss_trim (struct substring *ss, struct substring trim_set) { @@ -406,7 +406,7 @@ ss_trim (struct substring *ss, struct substring trim_set) ss_rtrim (ss, trim_set); } -/* If the last character in SS is C, removes it and returns true. +/* If the last byte in SS is C, removes it and returns true. Otherwise, returns false without changing the string. */ bool ss_chomp (struct substring *ss, char c) @@ -466,12 +466,12 @@ ss_tokenize (struct substring ss, struct substring delimiters, { ss_advance (&ss, *save_idx); *save_idx += ss_ltrim (&ss, delimiters); - ss_get_chars (&ss, ss_cspan (ss, delimiters), token); + ss_get_bytes (&ss, ss_cspan (ss, delimiters), token); *save_idx += ss_length (*token) + 1; return ss_length (*token) > 0; } -/* Removes the first CNT characters from SS. */ +/* Removes the first CNT bytes from SS. */ void ss_advance (struct substring *ss, size_t cnt) { @@ -481,10 +481,10 @@ ss_advance (struct substring *ss, size_t cnt) ss->length -= cnt; } -/* If the first character in SS is C, removes it and returns true. +/* If the first byte in SS is C, removes it and returns true. Otherwise, returns false without changing the string. */ bool -ss_match_char (struct substring *ss, char c) +ss_match_byte (struct substring *ss, char c) { if (ss_first (*ss) == c) { @@ -496,11 +496,11 @@ ss_match_char (struct substring *ss, char c) return false; } -/* If the first character in SS is in MATCH, removes it and - returns the character that was removed. +/* If the first byte in SS is in MATCH, removes it and + returns the byte that was removed. Otherwise, returns EOF without changing the string. */ int -ss_match_char_in (struct substring *ss, struct substring match) +ss_match_byte_in (struct substring *ss, struct substring match) { int c = EOF; if (ss->length > 0 @@ -528,10 +528,10 @@ ss_match_string (struct substring *ss, const struct substring target) return false; } -/* Removes the first character from SS and returns it. +/* Removes the first byte from SS and returns it. If SS is empty, returns EOF without modifying SS. */ int -ss_get_char (struct substring *ss) +ss_get_byte (struct substring *ss) { int c = ss_first (*ss); if (c != EOF) @@ -543,21 +543,21 @@ ss_get_char (struct substring *ss) } /* Stores the prefix of SS up to the first DELIMITER in OUT (if - any). Trims those same characters from SS. DELIMITER is + any). Trims those same bytes from SS. DELIMITER is removed from SS but not made part of OUT. Returns true if DELIMITER was found (and removed), false otherwise. */ bool ss_get_until (struct substring *ss, char delimiter, struct substring *out) { - ss_get_chars (ss, ss_cspan (*ss, ss_buffer (&delimiter, 1)), out); - return ss_match_char (ss, delimiter); + ss_get_bytes (ss, ss_cspan (*ss, ss_buffer (&delimiter, 1)), out); + return ss_match_byte (ss, delimiter); } -/* Stores the first CNT characters in SS in OUT (or fewer, if SS - is shorter than CNT characters). Trims the same characters +/* Stores the first CNT bytes in SS in OUT (or fewer, if SS + is shorter than CNT bytes). Trims the same bytes from the beginning of SS. Returns CNT. */ size_t -ss_get_chars (struct substring *ss, size_t cnt, struct substring *out) +ss_get_bytes (struct substring *ss, size_t cnt, struct substring *out) { *out = ss_head (*ss, cnt); ss_advance (ss, cnt); @@ -566,7 +566,7 @@ ss_get_chars (struct substring *ss, size_t cnt, struct substring *out) /* Parses and removes an optionally signed decimal integer from the beginning of SS. Returns 0 if an error occurred, - otherwise the number of characters removed from SS. Stores + otherwise the number of bytes removed from SS. Stores the integer's value into *VALUE. */ size_t ss_get_long (struct substring *ss, long *value) @@ -594,7 +594,7 @@ ss_get_long (struct substring *ss, long *value) return 0; } -/* Returns true if SS is empty (contains no characters), +/* Returns true if SS is empty (has length 0 bytes), false otherwise. */ bool ss_is_empty (struct substring ss) @@ -602,28 +602,28 @@ ss_is_empty (struct substring ss) return ss.length == 0; } -/* Returns the number of characters in SS. */ +/* Returns the number of bytes in SS. */ size_t ss_length (struct substring ss) { return ss.length; } -/* Returns a pointer to the characters in SS. */ +/* Returns a pointer to the bytes in SS. */ char * ss_data (struct substring ss) { return ss.string; } -/* Returns a pointer just past the last character in SS. */ +/* Returns a pointer just past the last byte in SS. */ char * ss_end (struct substring ss) { return ss.string + ss.length; } -/* Returns the character in position IDX in SS, as a value in the +/* Returns the byte in position IDX in SS, as a value in the range of unsigned char. Returns EOF if IDX is out of the range of indexes for SS. */ int @@ -632,7 +632,7 @@ ss_at (struct substring ss, size_t idx) return idx < ss.length ? (unsigned char) ss.string[idx] : EOF; } -/* Returns the first character in SS as a value in the range of +/* Returns the first byte in SS as a value in the range of unsigned char. Returns EOF if SS is the empty string. */ int ss_first (struct substring ss) @@ -640,7 +640,7 @@ ss_first (struct substring ss) return ss_at (ss, 0); } -/* Returns the last character in SS as a value in the range of +/* Returns the last byte in SS as a value in the range of unsigned char. Returns EOF if SS is the empty string. */ int ss_last (struct substring ss) @@ -648,26 +648,26 @@ ss_last (struct substring ss) return ss.length > 0 ? (unsigned char) ss.string[ss.length - 1] : EOF; } -/* Returns the number of contiguous characters at the beginning +/* Returns the number of contiguous bytes at the beginning of SS that are in SKIP_SET. */ size_t ss_span (struct substring ss, struct substring skip_set) { size_t i; for (i = 0; i < ss.length; i++) - if (ss_find_char (skip_set, ss.string[i]) == SIZE_MAX) + if (ss_find_byte (skip_set, ss.string[i]) == SIZE_MAX) break; return i; } -/* Returns the number of contiguous characters at the beginning +/* Returns the number of contiguous bytes at the beginning of SS that are not in SKIP_SET. */ size_t ss_cspan (struct substring ss, struct substring stop_set) { size_t i; for (i = 0; i < ss.length; i++) - if (ss_find_char (stop_set, ss.string[i]) != SIZE_MAX) + if (ss_find_byte (stop_set, ss.string[i]) != SIZE_MAX) break; return i; } @@ -675,7 +675,7 @@ ss_cspan (struct substring ss, struct substring stop_set) /* Returns the offset in SS of the first instance of C, or SIZE_MAX if C does not occur in SS. */ size_t -ss_find_char (struct substring ss, char c) +ss_find_byte (struct substring ss, char c) { const char *p = memchr (ss.string, c, ss.length); return p != NULL ? p - ss.string : SIZE_MAX; @@ -720,7 +720,7 @@ ss_equals_case (struct substring a, struct substring b) return a.length == b.length && !memcasecmp (a.string, b.string, a.length); } -/* Returns the position in SS that the character at P occupies. +/* Returns the position in SS that the byte at P occupies. P must point within SS or one past its end. */ size_t ss_pointer_to_position (struct substring ss, const char *p) @@ -859,20 +859,20 @@ ds_ss (const struct string *st) return st->ss; } -/* Returns a substring that contains CNT characters from ST +/* Returns a substring that contains CNT bytes from ST starting at position START. If START is greater than or equal to the length of ST, then the substring will be the empty string. If START + CNT exceeds the length of ST, then the substring will only be - ds_length(ST) - START characters long. */ + ds_length(ST) - START bytes long. */ struct substring ds_substr (const struct string *st, size_t start, size_t cnt) { return ss_substr (ds_ss (st), start, cnt); } -/* Returns a substring that contains the first CNT characters in +/* Returns a substring that contains the first CNT bytes in ST. If CNT exceeds the length of ST, then the substring will contain all of ST. */ struct substring @@ -881,7 +881,7 @@ ds_head (const struct string *st, size_t cnt) return ss_head (ds_ss (st), cnt); } -/* Returns a substring that contains the last CNT characters in +/* Returns a substring that contains the last CNT bytes in ST. If CNT exceeds the length of ST, then the substring will contain all of ST. */ struct substring @@ -890,7 +890,7 @@ ds_tail (const struct string *st, size_t cnt) return ss_tail (ds_ss (st), cnt); } -/* Ensures that ST can hold at least MIN_CAPACITY characters plus a null +/* Ensures that ST can hold at least MIN_CAPACITY bytes plus a null terminator. */ void ds_extend (struct string *st, size_t min_capacity) @@ -916,23 +916,23 @@ ds_shrink (struct string *st) } } -/* Truncates ST to at most LENGTH characters long. */ +/* Truncates ST to at most LENGTH bytes long. */ void ds_truncate (struct string *st, size_t length) { ss_truncate (&st->ss, length); } -/* Removes trailing characters in TRIM_SET from ST. - Returns number of characters removed. */ +/* Removes trailing bytes in TRIM_SET from ST. + Returns number of bytes removed. */ size_t ds_rtrim (struct string *st, struct substring trim_set) { return ss_rtrim (&st->ss, trim_set); } -/* Removes leading characters in TRIM_SET from ST. - Returns number of characters removed. */ +/* Removes leading bytes in TRIM_SET from ST. + Returns number of bytes removed. */ size_t ds_ltrim (struct string *st, struct substring trim_set) { @@ -942,8 +942,8 @@ ds_ltrim (struct string *st, struct substring trim_set) return cnt; } -/* Trims leading and trailing characters in TRIM_SET from ST. - Returns number of charactesr removed. */ +/* Trims leading and trailing bytes in TRIM_SET from ST. + Returns number of bytes removed. */ size_t ds_trim (struct string *st, struct substring trim_set) { @@ -951,7 +951,7 @@ ds_trim (struct string *st, struct substring trim_set) return cnt + ds_ltrim (st, trim_set); } -/* If the last character in ST is C, removes it and returns true. +/* If the last byte in ST is C, removes it and returns true. Otherwise, returns false without modifying ST. */ bool ds_chomp (struct string *st, char c) @@ -994,17 +994,17 @@ ds_tokenize (const struct string *st, struct substring delimiters, } /* Pad ST on the right with copies of PAD until ST is at least - LENGTH characters in size. If ST is initially LENGTH - characters or longer, this is a no-op. */ + LENGTH bytes in size. If ST is initially LENGTH + bytes or longer, this is a no-op. */ void ds_rpad (struct string *st, size_t length, char pad) { if (length > st->ss.length) - ds_put_char_multiple (st, pad, length - st->ss.length); + ds_put_byte_multiple (st, pad, length - st->ss.length); } /* Sets the length of ST to exactly NEW_LENGTH, - either by truncating characters from the end, + either by truncating bytes from the end, or by padding on the right with PAD. */ void ds_set_length (struct string *st, size_t new_length, char pad) @@ -1015,7 +1015,7 @@ ds_set_length (struct string *st, size_t new_length, char pad) st->ss.length = new_length; } -/* Removes N characters from ST starting at offset START. */ +/* Removes N bytes from ST starting at offset START. */ void ds_remove (struct string *st, size_t start, size_t n) { @@ -1023,12 +1023,12 @@ ds_remove (struct string *st, size_t start, size_t n) { if (st->ss.length - start <= n) { - /* All characters at or beyond START are deleted. */ + /* All bytes at or beyond START are deleted. */ st->ss.length = start; } else { - /* Some characters remain and must be shifted into + /* Some bytes remain and must be shifted into position. */ memmove (st->ss.string + st->ss.length, st->ss.string + st->ss.length + n, @@ -1038,7 +1038,7 @@ ds_remove (struct string *st, size_t start, size_t n) } else { - /* There are no characters to delete or no characters at or + /* There are no bytes to delete or no bytes at or beyond START, hence deletion is a no-op. */ } } @@ -1065,7 +1065,7 @@ ds_data (const struct string *st) } /* Returns a pointer to the null terminator ST. - This might not be an actual null character unless ds_c_str() has + This might not be an actual null byte unless ds_c_str() has been called since the last modification to ST. */ char * ds_end (const struct string *st) @@ -1073,7 +1073,7 @@ ds_end (const struct string *st) return ss_end (ds_ss (st)); } -/* Returns the character in position IDX in ST, as a value in the +/* Returns the byte in position IDX in ST, as a value in the range of unsigned char. Returns EOF if IDX is out of the range of indexes for ST. */ int @@ -1082,7 +1082,7 @@ ds_at (const struct string *st, size_t idx) return ss_at (ds_ss (st), idx); } -/* Returns the first character in ST as a value in the range of +/* Returns the first byte in ST as a value in the range of unsigned char. Returns EOF if ST is the empty string. */ int ds_first (const struct string *st) @@ -1090,7 +1090,7 @@ ds_first (const struct string *st) return ss_first (ds_ss (st)); } -/* Returns the last character in ST as a value in the range of +/* Returns the last byte in ST as a value in the range of unsigned char. Returns EOF if ST is the empty string. */ int ds_last (const struct string *st) @@ -1098,7 +1098,7 @@ ds_last (const struct string *st) return ss_last (ds_ss (st)); } -/* Returns the number of consecutive characters at the beginning +/* Returns the number of consecutive bytes at the beginning of ST that are in SKIP_SET. */ size_t ds_span (const struct string *st, struct substring skip_set) @@ -1106,7 +1106,7 @@ ds_span (const struct string *st, struct substring skip_set) return ss_span (ds_ss (st), skip_set); } -/* Returns the number of consecutive characters at the beginning +/* Returns the number of consecutive bytes at the beginning of ST that are not in STOP_SET. */ size_t ds_cspan (const struct string *st, struct substring stop_set) @@ -1114,13 +1114,13 @@ ds_cspan (const struct string *st, struct substring stop_set) return ss_cspan (ds_ss (st), stop_set); } -/* Returns the position of the first occurrence of character C in +/* Returns the position of the first occurrence of byte C in ST at or after position OFS, or SIZE_MAX if there is no such occurrence. */ size_t -ds_find_char (const struct string *st, char c) +ds_find_byte (const struct string *st, char c) { - return ss_find_char (ds_ss (st), c); + return ss_find_byte (ds_ss (st), c); } /* Compares A and B and returns a strcmp()-type comparison @@ -1131,7 +1131,7 @@ ds_compare (const struct string *a, const struct string *b) return ss_compare (ds_ss (a), ds_ss (b)); } -/* Returns the position in ST that the character at P occupies. +/* Returns the position in ST that the byte at P occupies. P must point within ST or one past its end. */ size_t ds_pointer_to_position (const struct string *st, const char *p) @@ -1176,16 +1176,15 @@ ds_steal_cstr (struct string *st) return s; } -/* Reads characters from STREAM and appends them to ST, stopping - after MAX_LENGTH characters, after appending a newline, or +/* Reads bytes from STREAM and appends them to ST, stopping + after MAX_LENGTH bytes, after appending a newline, or after an I/O error or end of file was encountered, whichever - comes first. Returns true if at least one character was added - to ST, false if no characters were read before an I/O error or + comes first. Returns true if at least one byte was added + to ST, false if no bytes were read before an I/O error or end of file (or if MAX_LENGTH was 0). This function treats LF and CR LF sequences as new-line, - translating each of them to a single '\n' new-line character - in ST. */ + translating each of them to a single '\n' in ST. */ bool ds_read_line (struct string *st, FILE *stream, size_t max_length) { @@ -1200,7 +1199,7 @@ ds_read_line (struct string *st, FILE *stream, size_t max_length) return length > 0; case '\n': - ds_put_char (st, c); + ds_put_byte (st, c); return true; case '\r': @@ -1208,13 +1207,13 @@ ds_read_line (struct string *st, FILE *stream, size_t max_length) if (c == '\n') { /* CR followed by LF is special: translate to \n. */ - ds_put_char (st, '\n'); + ds_put_byte (st, '\n'); return true; } else { /* CR followed by anything else is just CR. */ - ds_put_char (st, '\r'); + ds_put_byte (st, '\r'); if (c == EOF) return true; ungetc (c, stream); @@ -1222,7 +1221,7 @@ ds_read_line (struct string *st, FILE *stream, size_t max_length) break; default: - ds_put_char (st, c); + ds_put_byte (st, c); } } @@ -1381,16 +1380,16 @@ ds_put_vformat (struct string *st, const char *format, va_list args_) } } -/* Appends character CH to ST. */ +/* Appends byte CH to ST. */ void -ds_put_char (struct string *st, int ch) +ds_put_byte (struct string *st, int ch) { ds_put_uninit (st, 1)[0] = ch; } -/* Appends CNT copies of character CH to ST. */ +/* Appends CNT copies of byte CH to ST. */ void -ds_put_char_multiple (struct string *st, int ch, size_t cnt) +ds_put_byte_multiple (struct string *st, int ch, size_t cnt) { memset (ds_put_uninit (st, cnt), ch, cnt); } diff --git a/src/libpspp/str.h b/src/libpspp/str.h index 4a219d7a..ecf9e6eb 100644 --- a/src/libpspp/str.h +++ b/src/libpspp/str.h @@ -102,11 +102,11 @@ bool ss_separate (struct substring src, struct substring delimiters, bool ss_tokenize (struct substring src, struct substring delimiters, size_t *save_idx, struct substring *token); void ss_advance (struct substring *, size_t); -bool ss_match_char (struct substring *, char); -int ss_match_char_in (struct substring *, struct substring); +bool ss_match_byte (struct substring *, char); +int ss_match_byte_in (struct substring *, struct substring); bool ss_match_string (struct substring *, const struct substring); -int ss_get_char (struct substring *); -size_t ss_get_chars (struct substring *, size_t cnt, struct substring *); +int ss_get_byte (struct substring *); +size_t ss_get_bytes (struct substring *, size_t cnt, struct substring *); bool ss_get_until (struct substring *, char delimiter, struct substring *); size_t ss_get_long (struct substring *, long *); @@ -120,7 +120,7 @@ int ss_first (struct substring); int ss_last (struct substring); size_t ss_span (struct substring, struct substring skip_set); size_t ss_cspan (struct substring, struct substring stop_set); -size_t ss_find_char (struct substring, char); +size_t ss_find_byte (struct substring, char); int ss_compare (struct substring, struct substring); int ss_compare_case (struct substring, struct substring); int ss_equals (struct substring, struct substring); @@ -193,7 +193,7 @@ int ds_first (const struct string *); int ds_last (const struct string *); size_t ds_span (const struct string *, struct substring skip_set); size_t ds_cspan (const struct string *, struct substring stop_set); -size_t ds_find_char (const struct string *, char); +size_t ds_find_byte (const struct string *, char); int ds_compare (const struct string *, const struct string *); size_t ds_pointer_to_position (const struct string *, const char *); char *ds_xstrdup (const struct string *); @@ -208,8 +208,8 @@ bool ds_read_config_line (struct string *, int *line_number, FILE *); bool ds_read_stream (struct string *, size_t size, size_t cnt, FILE *stream); /* Append. */ -void ds_put_char (struct string *, int ch); -void ds_put_char_multiple (struct string *, int ch, size_t); +void ds_put_byte (struct string *, int ch); +void ds_put_byte_multiple (struct string *, int ch, size_t); void ds_put_cstr (struct string *, const char *); void ds_put_substring (struct string *, struct substring); void ds_put_vformat (struct string *st, const char *, va_list) diff --git a/src/output/ascii.c b/src/output/ascii.c index 00e3f33c..06bd1906 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -901,7 +901,7 @@ static void output_title_line (FILE *out, int width, const char *left, const char *right) { struct string s = DS_EMPTY_INITIALIZER; - ds_put_char_multiple (&s, ' ', width); + ds_put_byte_multiple (&s, ' ', width); if (left != NULL) { size_t length = MIN (strlen (left), width); @@ -912,7 +912,7 @@ output_title_line (FILE *out, int width, const char *left, const char *right) size_t length = MIN (strlen (right), width); memcpy (ds_end (&s) - length, right, length); } - ds_put_char (&s, '\n'); + ds_put_byte (&s, '\n'); fputs (ds_cstr (&s), out); ds_destroy (&s); } diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 13c6d968..4db2d8ca 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -338,7 +338,7 @@ apply_dict (const struct dictionary *dict, struct string *s) const struct val_lab *vl = labels[i]; ds_put_cstr (s, "\n "); syntax_gen_value (s, &vl->value, width, format); - ds_put_char (s, ' '); + ds_put_byte (s, ' '); syntax_gen_string (s, ss_cstr (val_lab_get_label (vl))); } free (labels); @@ -398,9 +398,9 @@ generate_syntax (const struct import_assistant *ia) if (ia->first_line.skip_lines > 0) ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line.skip_lines + 1); ds_put_cstr (&s, " /DELIMITERS=\""); - if (ds_find_char (&ia->separators.separators, '\t') != SIZE_MAX) + if (ds_find_byte (&ia->separators.separators, '\t') != SIZE_MAX) ds_put_cstr (&s, "\\t"); - if (ds_find_char (&ia->separators.separators, '\\') != SIZE_MAX) + if (ds_find_byte (&ia->separators.separators, '\\') != SIZE_MAX) ds_put_cstr (&s, "\\\\"); for (i = 0; i < ds_length (&ia->separators.separators); i++) { @@ -408,7 +408,7 @@ generate_syntax (const struct import_assistant *ia) if (c == '"') ds_put_cstr (&s, "\"\""); else if (c != '\t' && c != '\\') - ds_put_char (&s, c); + ds_put_byte (&s, c); } ds_put_cstr (&s, "\"\n"); if (!ds_is_empty (&ia->separators.quotes)) @@ -1169,7 +1169,7 @@ split_fields (struct import_assistant *ia) clear_fields (ia); /* Is space in the set of separators? */ - space_sep = ss_find_char (ds_ss (&s->separators), ' ') != SIZE_MAX; + space_sep = ss_find_byte (ds_ss (&s->separators), ' ') != SIZE_MAX; /* Split all the lines, not just those from ia->first_line.skip_lines on, so that we split the line that @@ -1196,9 +1196,9 @@ split_fields (struct import_assistant *ia) field = text; } else if (!ds_is_empty (&s->quotes) - && ds_find_char (&s->quotes, text.string[0]) != SIZE_MAX) + && ds_find_byte (&s->quotes, text.string[0]) != SIZE_MAX) { - int quote = ss_get_char (&text); + int quote = ss_get_byte (&text); if (!s->escape) ss_get_until (&text, quote, &field); else @@ -1207,18 +1207,18 @@ split_fields (struct import_assistant *ia) int c; ds_init_empty (&s); - while ((c = ss_get_char (&text)) != EOF) + while ((c = ss_get_byte (&text)) != EOF) if (c != quote) - ds_put_char (&s, c); - else if (ss_match_char (&text, quote)) - ds_put_char (&s, quote); + ds_put_byte (&s, c); + else if (ss_match_byte (&text, quote)) + ds_put_byte (&s, quote); else break; field = ds_ss (&s); } } else - ss_get_chars (&text, ss_cspan (text, ds_ss (&s->separators)), + ss_get_bytes (&text, ss_cspan (text, ds_ss (&s->separators)), &field); if (column_idx >= s->column_cnt) @@ -1243,7 +1243,7 @@ split_fields (struct import_assistant *ia) ss_ltrim (&text, ss_cstr (" ")); if (ss_is_empty (text)) break; - if (ss_find_char (ds_ss (&s->separators), ss_first (text)) + if (ss_find_byte (ds_ss (&s->separators), ss_first (text)) != SIZE_MAX) ss_advance (&text, 1); } @@ -1331,7 +1331,7 @@ find_commonest_chars (unsigned long int histogram[UCHAR_MAX + 1], if (max_count > 0) { ds_clear (result); - ds_put_char (result, max); + ds_put_byte (result, max); } else ds_assign_cstr (result, def); @@ -1387,7 +1387,7 @@ set_separators (struct import_assistant *ia) } } - ds_put_char (&custom, c); + ds_put_byte (&custom, c); next:; } @@ -1430,7 +1430,7 @@ get_separators (struct import_assistant *ia) const struct separator *sep = &separators[i]; GtkWidget *button = get_widget_assert (ia->asst.builder, sep->name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - ds_put_char (&s->separators, sep->c); + ds_put_byte (&s->separators, sep->c); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (s->custom_cb))) @@ -1952,8 +1952,8 @@ get_monospace_width (GtkTreeView *treeview, GtkCellRenderer *renderer, gint width; ds_init_empty (&s); - ds_put_char_multiple (&s, '0', char_cnt); - ds_put_char (&s, ' '); + ds_put_byte_multiple (&s, '0', char_cnt); + ds_put_byte (&s, ' '); width = get_string_width (treeview, renderer, ds_cstr (&s)); ds_destroy (&s); diff --git a/src/ui/syntax-gen.c b/src/ui/syntax-gen.c index b49911f5..35de44da 100644 --- a/src/ui/syntax-gen.c +++ b/src/ui/syntax-gen.c @@ -38,8 +38,8 @@ syntax_gen_hex_digits (struct string *output, struct substring in) for (i = 0; i < in.length; i++) { unsigned char c = in.string[i]; - ds_put_char (output, "0123456789ABCDEF"[c >> 4]); - ds_put_char (output, "0123456789ABCDEF"[c & 0xf]); + ds_put_byte (output, "0123456789ABCDEF"[c >> 4]); + ds_put_byte (output, "0123456789ABCDEF"[c & 0xf]); } } @@ -59,13 +59,13 @@ has_control_chars (struct substring in) static bool has_single_quote (struct substring str) { - return (SIZE_MAX != ss_find_char (str, '\'')); + return (SIZE_MAX != ss_find_byte (str, '\'')); } static bool has_double_quote (struct substring str) { - return (SIZE_MAX != ss_find_char (str, '"')); + return (SIZE_MAX != ss_find_byte (str, '"')); } /* Appends to OUTPUT valid PSPP syntax for a quoted string that @@ -84,7 +84,7 @@ syntax_gen_string (struct string *output, struct substring in) { ds_put_cstr (output, "X'"); syntax_gen_hex_digits (output, in); - ds_put_char (output, '\''); + ds_put_byte (output, '\''); } else { @@ -99,15 +99,15 @@ syntax_gen_string (struct string *output, struct substring in) assert (is_basic ('\'')); quote = has_double_quote (in) && !has_single_quote (in) ? '\'' : '"'; - ds_put_char (output, quote); + ds_put_byte (output, quote); for (i = 0; i < in.length; i++) { char c = in.string[i]; if (c == quote) - ds_put_char (output, quote); - ds_put_char (output, c); + ds_put_byte (output, quote); + ds_put_byte (output, c); } - ds_put_char (output, quote); + ds_put_byte (output, quote); } } @@ -286,7 +286,7 @@ syntax_gen_pspp_valist (struct string *output, const char *format, } case '%': - ds_put_char (output, '%'); + ds_put_byte (output, '%'); break; default: