[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/18] str: Rename ss_chomp() to ss_chomp_byte(), ds_chomp() to d
From: |
Ben Pfaff |
Subject: |
[PATCH 06/18] str: Rename ss_chomp() to ss_chomp_byte(), ds_chomp() to ds_chomp_byte(). |
Date: |
Sat, 19 Mar 2011 17:09:52 -0700 |
This paves the way for new functions that chomp an entire substring.
---
src/language/control/repeat.c | 2 +-
src/language/data-io/data-reader.c | 2 +-
src/language/lexer/lexer.c | 2 +-
src/language/stats/aggregate.c | 2 +-
src/language/syntax-file.c | 2 +-
src/libpspp/str.c | 10 +++++-----
src/libpspp/str.h | 6 +++---
src/ui/gui/text-data-import-dialog.c | 4 ++--
8 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c
index 24e3272..ecff057 100644
--- a/src/language/control/repeat.c
+++ b/src/language/control/repeat.c
@@ -527,7 +527,7 @@ do_repeat_filter (struct getl_interface *interface, struct
string *line)
/* 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)
diff --git a/src/language/data-io/data-reader.c
b/src/language/data-io/data-reader.c
index 7c9e4e6..87fa8c9 100644
--- a/src/language/data-io/data-reader.c
+++ b/src/language/data-io/data-reader.c
@@ -343,7 +343,7 @@ read_file_record (struct dfm_reader *r)
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
diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c
index eee15d6..938d266 100644
--- a/src/language/lexer/lexer.c
+++ b/src/language/lexer/lexer.c
@@ -908,7 +908,7 @@ lex_preprocess_line (struct string *line,
{
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)
{
diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c
index 319e19a..241ad7c 100644
--- a/src/language/stats/aggregate.c
+++ b/src/language/stats/aggregate.c
@@ -453,7 +453,7 @@ parse_aggregate_functions (struct lexer *lexer, const
struct dictionary *dict,
}
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)))
diff --git a/src/language/syntax-file.c b/src/language/syntax-file.c
index c563608..286ce1e 100644
--- a/src/language/syntax-file.c
+++ b/src/language/syntax-file.c
@@ -95,7 +95,7 @@ read_syntax_file (struct getl_interface *s,
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));
diff --git a/src/libpspp/str.c b/src/libpspp/str.c
index 25e2cfd..e34c150 100644
--- a/src/libpspp/str.c
+++ b/src/libpspp/str.c
@@ -1,5 +1,5 @@
/* 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
@@ -416,7 +416,7 @@ ss_trim (struct substring *ss, struct substring trim_set)
/* 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)
{
@@ -1036,9 +1036,9 @@ ds_trim (struct string *st, struct substring trim_set)
/* 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.
@@ -1358,7 +1358,7 @@ ds_read_config_line (struct string *st, int *line_number,
FILE *stream)
(*line_number)++;
ds_rtrim (st, ss_cstr (CC_SPACES));
}
- while (ds_chomp (st, '\\'));
+ while (ds_chomp_byte (st, '\\'));
remove_comment (st);
return true;
diff --git a/src/libpspp/str.h b/src/libpspp/str.h
index c691f9f..d2b39ef 100644
--- a/src/libpspp/str.h
+++ b/src/libpspp/str.h
@@ -1,5 +1,5 @@
/* 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
@@ -98,7 +98,7 @@ void ss_truncate (struct substring *, size_t);
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,
@@ -177,7 +177,7 @@ void ds_truncate (struct string *, size_t);
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,
diff --git a/src/ui/gui/text-data-import-dialog.c
b/src/ui/gui/text-data-import-dialog.c
index e5c48fd..534cec9 100644
--- a/src/ui/gui/text-data-import-dialog.c
+++ b/src/ui/gui/text-data-import-dialog.c
@@ -476,8 +476,8 @@ init_file (struct import_assistant *ia, GtkWindow
*parent_window)
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)
--
1.7.2.3
- [PATCH 00/18] rewrite PSPP lexer, Ben Pfaff, 2011/03/19
- [PATCH 01/18] data-reader: Remove unreachable "return" statements., Ben Pfaff, 2011/03/19
- [PATCH 07/18] str: New functions for checking for and removing string suffixes., Ben Pfaff, 2011/03/19
- [PATCH 10/18] i18n: New function recode_string_len()., Ben Pfaff, 2011/03/19
- [PATCH 09/18] i18n: New function uc_name()., Ben Pfaff, 2011/03/19
- [PATCH 14/18] encoding-guesser: New library to guess the encoding of a text file., Ben Pfaff, 2011/03/19
- [PATCH 04/18] output: New function text_item_create_nocopy()., Ben Pfaff, 2011/03/19
- [PATCH 05/18] str: New function ss_realloc()., Ben Pfaff, 2011/03/19
- [PATCH 13/18] i18n: New functions and data structure for obtaining encoding info., Ben Pfaff, 2011/03/19
- [PATCH 06/18] str: Rename ss_chomp() to ss_chomp_byte(), ds_chomp() to ds_chomp_byte().,
Ben Pfaff <=
- [PATCH 02/18] file-name: Do not make output files line-buffered in fn_open()., Ben Pfaff, 2011/03/19
- [PATCH 12/18] identifier: Rename token_type_to_string() and make a new version., Ben Pfaff, 2011/03/19
- [PATCH 08/18] hash-functions: New function hash_case_bytes()., Ben Pfaff, 2011/03/19
- [PATCH 11/18] i18n: New functions for truncating strings in an arbitrary encoding., Ben Pfaff, 2011/03/19
- [PATCH 17/18] scan: New library for high-level PSPP syntax lexical analysis., Ben Pfaff, 2011/03/19
- [PATCH 15/18] u8-istream: New library for reading a text file and recoding to UTF-8., Ben Pfaff, 2011/03/19
- [PATCH 16/18] segment: New library for low-level phase of lexical syntax analysis., Ben Pfaff, 2011/03/19
- [PATCH 03/18] sys-file-reader: Refactor to clean up character encoding support., Ben Pfaff, 2011/03/19
- Re: [PATCH 00/18] rewrite PSPP lexer, John Darrington, 2011/03/20