[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] helper: Move escape_underscores() here.
From: |
Ben Pfaff |
Subject: |
[PATCH 4/4] helper: Move escape_underscores() here. |
Date: |
Fri, 20 Apr 2012 22:11:55 -0700 |
An upcoming commit will introduce a new user in a different file.
---
src/ui/gui/helper.c | 20 ++++++++++++++++++++
src/ui/gui/helper.h | 1 +
src/ui/gui/text-data-import-dialog.c | 19 -------------------
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c
index 04c9bfe..c5f7883 100644
--- a/src/ui/gui/helper.c
+++ b/src/ui/gui/helper.c
@@ -47,6 +47,26 @@
#include <gettext.h>
+/* Returns a copy of IN with each underscore doubled. The caller should free
+ the returned string (with free()) when it is no longer needed. */
+char *
+escape_underscores (const char *in)
+{
+ char *out = xmalloc (2 * strlen (in) + 1);
+ char *p;
+
+ p = out;
+ for (; *in != '\0'; in++)
+ {
+ if (*in == '_')
+ *p++ = '_';
+ *p++ = *in;
+ }
+ *p = '\0';
+
+ return out;
+}
+
/* Formats a value according to VAR's print format and strips white space
appropriately for VAR's type. That is, if VAR is numeric, strips leading
white space (because numbers are right-justified within their fields), and
diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h
index d9fb3d6..be0b1ad 100644
--- a/src/ui/gui/helper.h
+++ b/src/ui/gui/helper.h
@@ -44,6 +44,7 @@ null_if_empty_param (const gchar *name, const gchar *nick,
return param;
}
+char *escape_underscores (const char *);
gchar * value_to_text (union value v, const struct variable *);
gchar * value_to_text__ (union value v, const struct fmt_spec *,
diff --git a/src/ui/gui/text-data-import-dialog.c
b/src/ui/gui/text-data-import-dialog.c
index 10dc626..c4abeaa 100644
--- a/src/ui/gui/text-data-import-dialog.c
+++ b/src/ui/gui/text-data-import-dialog.c
@@ -213,7 +213,6 @@ static GtkTreeViewColumn *make_data_column (struct
import_assistant *,
gint column_idx);
static GtkTreeView *create_data_tree_view (bool input, GtkContainer *parent,
struct import_assistant *);
-static char *escape_underscores (const char *in);
static void push_watch_cursor (struct import_assistant *);
static void pop_watch_cursor (struct import_assistant *);
@@ -2088,24 +2087,6 @@ create_data_tree_view (bool input, GtkContainer *parent,
return tree_view;
}
-static char *
-escape_underscores (const char *in)
-{
- char *out = xmalloc (2 * strlen (in) + 1);
- char *p;
-
- p = out;
- for (; *in != '\0'; in++)
- {
- if (*in == '_')
- *p++ = '_';
- *p++ = *in;
- }
- *p = '\0';
-
- return out;
-}
-
/* Increments the "watch cursor" level, setting the cursor for
the assistant window to a watch face to indicate to the user
that the ongoing operation may take some time. */
--
1.7.2.5