/* 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. */
&& 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))
{
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."));
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."));
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))
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
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;
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)
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;
}
}
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;
}
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)
/* 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);
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;
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. */
/* 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
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
}
/* 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)
{
}
/* 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 '%'. */
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;
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)
{
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);
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, ')');
}
}
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);
}
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);
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);
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);
for (i = 0; i < word_cnt; i++)
{
if (i != 0)
- ds_put_char (&s, ' ');
+ ds_put_byte (&s, ' ');
ds_put_cstr (&s, words[i]);
}
{
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);
}
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);
/* 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
ds_destroy (&delims);
goto error;
}
- ds_put_char (&delims, delim);
+ ds_put_byte (&delims, delim);
lex_match (lexer, ',');
}
}
*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);
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
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
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);
}
}
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);
/* 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
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);
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
{
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
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));
/* 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
/* 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;
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++;
/* 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. */
lexer->tokval = 0.0;
ds_clear (&lexer->tokstr);
- ds_put_char (&lexer->tokstr, '0');
+ ds_put_byte (&lexer->tokstr, '0');
}
break;
break;
}
- ds_put_char (&lexer->tokstr, *lexer->prog++);
+ ds_put_byte (&lexer->tokstr, *lexer->prog++);
}
lexer->prog++;
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,
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);
}
{
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);
}
}
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);
/* 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
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);
/* 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
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
{
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)
/* 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
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));
}
}
#include <stdint.h>
#include <stdlib.h>
-#include <libpspp/cast.h>
-#include <libpspp/message.h>
-#include <libpspp/pool.h>
-
-#include <relocatable.h>
-#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"
\f
/* Reverses the order of NBYTES bytes at address P, thus converting
between little- and big-endian byte orders. */
/* 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)
{
}
/* 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)
{
/* 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)
dst[dst_len] = '\0';
}
-/* Converts each character in S to uppercase. */
+/* Converts each byte in S to uppercase. */
void
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)
{
\f
/* 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)
}
/* 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)
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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
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)
}
/* 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);
/* 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)
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)
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
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)
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)
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;
}
/* 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;
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)
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
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
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)
}
}
-/* 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)
{
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)
{
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)
}
/* 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)
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)
{
{
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,
}
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. */
}
}
}
/* 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)
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
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)
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)
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)
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)
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
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)
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)
{
return length > 0;
case '\n':
- ds_put_char (st, c);
+ ds_put_byte (st, c);
return true;
case '\r':
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);
break;
default:
- ds_put_char (st, c);
+ ds_put_byte (st, c);
}
}
}
}
-/* 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);
}
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 *);
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);
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 *);
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)
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);
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);
}
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);
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++)
{
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))
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
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
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)
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);
}
if (max_count > 0)
{
ds_clear (result);
- ds_put_char (result, max);
+ ds_put_byte (result, max);
}
else
ds_assign_cstr (result, def);
}
}
- ds_put_char (&custom, c);
+ ds_put_byte (&custom, c);
next:;
}
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)))
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);
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]);
}
}
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
{
ds_put_cstr (output, "X'");
syntax_gen_hex_digits (output, in);
- ds_put_char (output, '\'');
+ ds_put_byte (output, '\'');
}
else
{
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);
}
}
}
case '%':
- ds_put_char (output, '%');
+ ds_put_byte (output, '%');
break;
default: