[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug33254 4/6] gui: Refactor checking for .sav and .por suffixes.
From: |
Ben Pfaff |
Subject: |
[bug33254 4/6] gui: Refactor checking for .sav and .por suffixes. |
Date: |
Wed, 11 May 2011 22:42:05 -0700 |
It seems reasonable to allow, e.g., .Sav as well as .SAV and .sav, so
this does that. It also splits name_has_suffix() into smaller
pieces that will individually be used in an upcoming commit.
---
src/ui/gui/psppire-data-window.c | 36 +++++++++++++++++++++---------------
1 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c
index 00efcb6..0f14179 100644
--- a/src/ui/gui/psppire-data-window.c
+++ b/src/ui/gui/psppire-data-window.c
@@ -63,6 +63,7 @@
#include "ui/gui/weight-cases-dialog.h"
#include "ui/syntax-gen.h"
+#include "gl/c-strcase.h"
#include "gl/xvasprintf.h"
#include <gettext.h>
@@ -334,6 +335,26 @@ dump_rm (GtkRecentManager *rm)
}
#endif
+static gboolean
+name_has_por_suffix (const gchar *name)
+{
+ size_t length = strlen (name);
+ return length > 4 && !c_strcasecmp (&name[length - 4], ".por");
+}
+
+static gboolean
+name_has_sav_suffix (const gchar *name)
+{
+ size_t length = strlen (name);
+ return length > 4 && !c_strcasecmp (&name[length - 4], ".sav");
+}
+
+/* Returns true if NAME has a suffix which might denote a PSPP file */
+static gboolean
+name_has_suffix (const gchar *name)
+{
+ return name_has_por_suffix (name) || name_has_sav_suffix (name);
+}
static gboolean
load_file (PsppireWindow *de, const gchar *file_name)
@@ -360,21 +381,6 @@ load_file (PsppireWindow *de, const gchar *file_name)
return ok;
}
-/* Returns true if NAME has a suffix which might denote a PSPP file */
-static gboolean
-name_has_suffix (const gchar *name)
-{
- if ( g_str_has_suffix (name, ".sav"))
- return TRUE;
- if ( g_str_has_suffix (name, ".SAV"))
- return TRUE;
- if ( g_str_has_suffix (name, ".por"))
- return TRUE;
- if ( g_str_has_suffix (name, ".POR"))
- return TRUE;
-
- return FALSE;
-}
/* Save DE to file */
--
1.7.2.5
- [bug33254 1/6] encoding-guesser: New function encoding_guess_whole_file()., Ben Pfaff, 2011/05/12
- [bug33254 6/6] gui: Make File|Recent Files remember the correct encoding., Ben Pfaff, 2011/05/12
- [bug33254 2/6] i18n: New function is_encoding_supported()., Ben Pfaff, 2011/05/12
- [bug33254 3/6] gui: Move null_if_empty_param() from psppire-window to helper., Ben Pfaff, 2011/05/12
- [bug33254 5/6] gui: Recode syntax files on load and save., Ben Pfaff, 2011/05/12
- [bug33254 4/6] gui: Refactor checking for .sav and .por suffixes.,
Ben Pfaff <=
- Re: [bug33254 1/6] encoding-guesser: New function encoding_guess_whole_file()., John Darrington, 2011/05/12