[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src data/ChangeLog data/format.c data/form...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src data/ChangeLog data/format.c data/form... |
Date: |
Sun, 10 Dec 2006 04:03:34 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 06/12/10 04:03:34
Modified files:
src/data : ChangeLog format.c format.h
src/ui/gui : ChangeLog var-type-dialog.c
Log message:
New function fmt_dollar_template based on pspp-dev discussion.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.83&r2=1.84
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/format.c?cvsroot=pspp&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/format.h?cvsroot=pspp&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/ChangeLog?cvsroot=pspp&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/var-type-dialog.c?cvsroot=pspp&r1=1.7&r2=1.8
Patches:
Index: data/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- data/ChangeLog 10 Dec 2006 03:42:50 -0000 1.83
+++ data/ChangeLog 10 Dec 2006 04:03:34 -0000 1.84
@@ -1,3 +1,8 @@
+Sat Dec 9 20:02:25 2006 Ben Pfaff <address@hidden>
+
+ * format.c (fmt_dollar_template): New function, based on
+ dollar_format_template from var-type-dialog.c.
+
Sat Dec 9 18:05:59 2006 Ben Pfaff <address@hidden>
* data-out.c (output_scientific): Fix bad assumption that "buf" is
Index: data/format.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/format.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- data/format.c 10 Dec 2006 03:42:50 -0000 1.16
+++ data/format.c 10 Dec 2006 04:03:34 -0000 1.17
@@ -588,6 +588,34 @@
}
}
+/* Returns a string of the form "$#,###.##" according to FMT,
+ which must be of type FMT_DOLLAR. The caller must free the
+ string. */
+char *
+fmt_dollar_template (const struct fmt_spec *fmt)
+{
+ struct string s = DS_EMPTY_INITIALIZER;
+ int c;
+
+ ds_put_char (&s, '$');
+ for (c = MAX (fmt->w - fmt->d - 1, 0); c > 0; )
+ {
+ ds_put_char (&s, '#');
+ if (--c % 4 == 0 && c > 0)
+ {
+ ds_put_char (&s, fmt_grouping_char (fmt->type));
+ --c;
+ }
+ }
+ if (fmt->d > 0)
+ {
+ ds_put_char (&s, '.');
+ ds_put_char_multiple (&s, '#', fmt->d);
+ }
+
+ return ds_cstr (&s);
+}
+
/* Returns true if TYPE is a valid format type,
false otherwise. */
static bool
Index: data/format.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/format.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- data/format.h 10 Dec 2006 03:42:50 -0000 1.11
+++ data/format.h 10 Dec 2006 04:03:34 -0000 1.12
@@ -116,6 +116,7 @@
bool fmt_usable_for_input (enum fmt_type) PURE_FUNCTION;
const char *fmt_date_template (enum fmt_type) PURE_FUNCTION;
+char *fmt_dollar_template (const struct fmt_spec *);
/* Maximum length of prefix or suffix string in
struct fmt_number_style. */
Index: ui/gui/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- ui/gui/ChangeLog 8 Dec 2006 22:24:08 -0000 1.25
+++ ui/gui/ChangeLog 10 Dec 2006 04:03:34 -0000 1.26
@@ -1,3 +1,9 @@
+Sat Dec 9 20:03:04 2006 Ben Pfaff <address@hidden>
+
+ * var-type-dialog.c (var_type_dialog_create): Use
+ fmt_dollar_template from data/format.c.
+ (dollar_format_template) Removed.
+
Sat Dec 9 07:19:53 WST 2006 John Darrington <address@hidden>
* syntax-editor.c : New file.
Index: ui/gui/var-type-dialog.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/var-type-dialog.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ui/gui/var-type-dialog.c 10 Dec 2006 03:42:52 -0000 1.7
+++ ui/gui/var-type-dialog.c 10 Dec 2006 04:03:34 -0000 1.8
@@ -212,44 +212,6 @@
#define LEN 20
-/* return a string of the form "$#,###.##" according to FMT.
- FMT must be of type FMT_DOLLAR
- */
-static const gchar *
-dollar_format_template(const struct fmt_spec *fmt)
-{
- static gchar buf[LEN];
- g_assert( fmt->type == FMT_DOLLAR);
-
- {
- gint c ;
- gint int_part = fmt->w - fmt->d;
- if ( fmt->d > 0 ) --int_part;
- g_assert(int_part > 0);
-
- g_strlcpy(buf, "$", LEN);
-
- c = int_part - 1;
- while(c > 0)
- {
- g_strlcat(buf, "#", LEN);
- if(--c % 4 == 0 && c > 0 )
- {
- g_strlcat(buf, ",", LEN);
- --c;
- }
- }
- if ( fmt->d > 0 )
- {
- g_strlcat(buf, ".", LEN);
- for ( c = 0 ; c < fmt->d ; ++c )
- g_strlcat(buf, "#", LEN);
- }
- }
-
- return buf;
-}
-
static void
add_to_group(GtkWidget *w, gpointer data)
{
@@ -504,11 +466,13 @@
for ( i = 0 ; i < sizeof(dollar_format)/sizeof(dollar_format[0]) ; ++i )
{
+ char *template = fmt_dollar_template (&dollar_format[i]);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter,
- 0, dollar_format_template(&dollar_format[i]),
+ 0, template,
1, &dollar_format[i],
-1);
+ free (template);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(dialog->dollar_treeview),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src data/ChangeLog data/format.c data/form...,
Ben Pfaff <=