This paves the way for new functions that chomp an entire substring.
/* Strip trailing whitespace, check for & remove terminal dot. */
ds_rtrim (line, ss_cstr (CC_SPACES));
- dot = ds_chomp (line, '.');
+ dot = ds_chomp_byte (line, '.');
input = ds_ss (line);
in_apos = in_quote = false;
while ((c = ss_first (input)) != EOF)
case FH_MODE_TEXT:
if (ds_read_line (&r->line, r->file, SIZE_MAX))
{
- ds_chomp (&r->line, '\n');
+ ds_chomp_byte (&r->line, '\n');
return true;
}
else
{
strip_comments (line);
ds_rtrim (line, ss_cstr (CC_SPACES));
- *line_ends_command = ds_chomp (line, '.') || ds_is_empty (line);
+ *line_ends_command = ds_chomp_byte (line, '.') || ds_is_empty (line);
*line_starts_command = false;
if (syntax == GETL_BATCH)
{
}
ds_assign_substring (&function_name, lex_tokss (lexer));
- exclude = ds_chomp (&function_name, '.') ? MV_SYSTEM : MV_ANY;
+ exclude = ds_chomp_byte (&function_name, '.') ? MV_SYSTEM : MV_ANY;
for (function = agr_func_tab; function->name; function++)
if (!strcasecmp (function->name, ds_cstr (&function_name)))
msg (ME, _("Reading `%s': %s."), sfs->fn, strerror (errno));
return false;
}
- ds_chomp (line, '\n');
+ ds_chomp_byte (line, '\n');
}
while (sfs->ln == 1 && !memcmp (ds_cstr (line), "#!", 2));
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 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 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_chomp_byte (struct substring *ss, char c)
{
if (ss_last (*ss) == c)
{
/* 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)
+ds_chomp_byte (struct string *st, char c)
{
- return ss_chomp (&st->ss, c);
+ return ss_chomp_byte (&st->ss, c);
}
/* Divides ST into tokens separated by any of the DELIMITERS.
(*line_number)++;
ds_rtrim (st, ss_cstr (CC_SPACES));
}
- while (ds_chomp (st, '\\'));
+ while (ds_chomp_byte (st, '\\'));
remove_comment (st);
return true;
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010, 2011 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
size_t ss_rtrim (struct substring *, struct substring trim_set);
size_t ss_ltrim (struct substring *, struct substring trim_set);
void ss_trim (struct substring *, struct substring trim_set);
-bool ss_chomp (struct substring *, char);
+bool ss_chomp_byte (struct substring *, char);
bool ss_separate (struct substring src, struct substring delimiters,
size_t *save_idx, struct substring *token);
bool ss_tokenize (struct substring src, struct substring delimiters,
size_t ds_rtrim (struct string *, struct substring trim_set);
size_t ds_ltrim (struct string *, struct substring trim_set);
size_t ds_trim (struct string *, struct substring trim_set);
-bool ds_chomp (struct string *, char);
+bool ds_chomp_byte (struct string *, char);
bool ds_separate (const struct string *src, struct substring delimiters,
size_t *save_idx, struct substring *token);
bool ds_tokenize (const struct string *src, struct substring delimiters,
destroy_file (ia);
return false;
}
- ds_chomp (line, '\n');
- ds_chomp (line, '\r');
+ ds_chomp_byte (line, '\n');
+ ds_chomp_byte (line, '\r');
}
if (file->line_cnt == 0)