pspp-dev
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]