? buildit.ksh
? env.sh
? gcalctool-4.3.22.tar.gz
Index: gcalctool/calctool.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.c,v
retrieving revision 1.59
diff -u -r1.59 calctool.c
--- gcalctool/calctool.c	24 Nov 2003 21:00:20 -0000	1.59
+++ gcalctool/calctool.c	26 Nov 2003 20:21:58 -0000
@@ -60,7 +60,7 @@
 
 char *calc_res[] = {
     "accuracy", "base", "display", "mode", "showregisters", "trigtype",
-    "removezeroes"
+    "showzeroes", "showthousands"
 };
 
 char *dtype_str[] = {          /* Strings for each display mode value. */
@@ -1018,6 +1018,7 @@
     }
 
     v->radix_char = get_radix_char();   /* Locale specific radix character. */
+    v->tsep_char  = get_tsep_char();  /* Locale specific thousands seperator. */
 
     init_text();               /* Setup text strings depending upon language. */
     init_vars();               /* Setup default values for variables. */
Index: gcalctool/calctool.h
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/calctool.h,v
retrieving revision 1.42
diff -u -r1.42 calctool.h
--- gcalctool/calctool.h	13 Oct 2003 15:37:37 -0000	1.42
+++ gcalctool/calctool.h	26 Nov 2003 20:21:58 -0000
@@ -47,7 +47,7 @@
 
 /* Menu bar menu types. */
 enum mb_type { M_ABOUT, M_ASCII, M_BASIC, M_CONTENTS, M_COPY,  M_FIN,
-               M_PASTE, M_QUIT,  M_REGS,  M_SCI,      M_ZEROES };
+               M_PASTE, M_QUIT,  M_REGS,  M_SCI,      M_TSEP,  M_ZEROES };
 
 enum base_type { BIN, OCT, DEC, HEX };      /* Base definitions. */
 
@@ -69,7 +69,7 @@
 
 /* Resources. */
 enum res_type { R_ACCURACY, R_BASE, R_DISPLAY, R_MODE, R_REGS, R_TRIG,
-                R_ZEROES
+                R_ZEROES,   R_TSEP
 };
 
 enum trig_type { DEG, GRAD, RAD };          /* Trigonometric types. */
@@ -247,6 +247,8 @@
     char radix_char;                   /* Locale specific radix character. */
     char *shelf;                       /* PUT selection shelf contents. */
     char snum[MAX_DIGITS+1];           /* Scratchpad for scientific numbers. */
+    char tnum[MAX_DIGITS+1];           /* Scratchpad for tsep numbers. */
+    char tsep_char;                 /* Locale specific thousands seperator. */
     char *titleline;                   /* Value of titleline (if present). */
     char *tool_label;                  /* Title line for calculator window. */
 
@@ -290,6 +292,7 @@
     int pointed;       /* Whether a decimal point has been given. */
     int rstate;        /* Indicates if memory register frame is displayed. */
     int show_paren;    /* Set if we wish to show DISPLAYITEM during parens. */
+    int show_tsep;     /* Set if the thousands seperator should be shown. */
     int show_zeroes;   /* Set if trailing zeroes should be shown. */
     int started;       /* Set just before window is displayed. */
     int toclear;       /* Indicates if display should be cleared. */
@@ -314,6 +317,7 @@
 char *convert(char *);
 char get_radix_char();
 char *get_resource(enum res_type);
+char get_tsep_char();
 char *make_number(int *, int, BOOLEAN, BOOLEAN);
 char *set_bool(int);
 
Index: gcalctool/display.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/display.c,v
retrieving revision 1.32
diff -u -r1.32 display.c
--- gcalctool/display.c	26 Nov 2003 16:14:10 -0000	1.32
+++ gcalctool/display.c	26 Nov 2003 20:21:58 -0000
@@ -174,6 +174,45 @@
         *optr = '\0';
     }
 
+/* Add in the thousand separators characters if required and if we are
+ * currently in the decimal numeric base.
+ */
+
+    if (v->show_tsep && v->base == DEC) {
+        char *dstp, *radixp, *srcp;
+        int n;
+
+        /* Process the fractional part (if any). */
+        srcp = v->fnum + strlen(v->fnum) - 1;
+        dstp = v->tnum;
+        if ((radixp = strchr(v->fnum, v->radix_char)) != NULL) {
+            while (*srcp != v->radix_char) {
+                *dstp++ = *srcp--;
+            }
+            *dstp++ = *srcp--;     /* Copy over the radix char. */
+        }
+
+        /* Process the integer part, add in thousand separators. */
+        n = 0;
+        while (srcp >= v->fnum) {
+            *dstp++ = *srcp--;
+            n++;
+            if (n == 3 && srcp >= v->fnum) {
+                *dstp++ = ',';
+                n = 0;
+            }
+        }
+        *dstp++ = '\0';
+
+        /* Move from scratch pad to fnum, reversing the character order. */
+        srcp = v->tnum + strlen(v->tnum) - 1;
+	dstp = v->fnum;
+        while (srcp >= v->tnum) {
+            *dstp++ = *srcp--;
+        }
+        *dstp++ = '\0';
+    }
+
     return(v->fnum);
 }
 
Index: gcalctool/gcalctool.1
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gcalctool.1,v
retrieving revision 1.20
diff -u -r1.20 gcalctool.1
--- gcalctool/gcalctool.1	3 Oct 2003 15:45:53 -0000	1.20
+++ gcalctool/gcalctool.1	26 Nov 2003 20:21:58 -0000
@@ -1,5 +1,5 @@
 .\" Copyright (c) 1987-2003 - Sun Microsystems, Inc.
-.TH gcalctool 1 "3 October 2003"
+.TH gcalctool 1 "26 November 2003"
 .SH NAME
 gcalctool \- a desktop calculator
 .SH SYNOPSIS
@@ -149,6 +149,17 @@
 .B Description
 Whether trailing zeroes, after the numeric point, are shown in the
 display value.
+.sp
+.TP
+.B Resource:
+/schemes/apps/gcalctool/showthousands
+.TP
+.B Values:
+true, false (false)
+.TP
+.B Description
+Whether fixed numbers in the decimal base are displayed with thousands
+sparated.
 .sp
 .TP
 .B Resource:
Index: gcalctool/get.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/get.c,v
retrieving revision 1.23
diff -u -r1.23 get.c
--- gcalctool/get.c	20 Oct 2003 15:20:44 -0000	1.23
+++ gcalctool/get.c	26 Nov 2003 20:21:58 -0000
@@ -211,6 +211,22 @@
 }
 
 
+/* Return the thousands separator character. For most locales, this is a 
+ * comma.
+ */
+
+char
+get_tsep_char()
+{
+    char *tsep_char;
+
+    setlocale(LC_NUMERIC, "");
+    tsep_char = nl_langinfo(THOUSEP);
+
+    return(tsep_char[0]);
+}
+
+
 void
 init_vars()    /* Setup default values for various variables. */
 {
@@ -348,6 +364,10 @@
 
     if (get_bool_resource(R_ZEROES, &boolval)) {
         v->show_zeroes = boolval;
+    }
+
+    if (get_bool_resource(R_TSEP, &boolval)) {
+        v->show_tsep = boolval;
     }
 }
 
Index: gcalctool/gtk.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gtk.c,v
retrieving revision 1.105
diff -u -r1.105 gtk.c
--- gcalctool/gtk.c	26 Nov 2003 15:12:33 -0000	1.105
+++ gcalctool/gtk.c	26 Nov 2003 20:21:59 -0000
@@ -153,8 +153,10 @@
 static void set_button_state(GtkWidget *, int);
 static void set_gcalctool_icon(void);
 static void set_memory_toggle(int);
+static void set_show_tsep_toggle(int);
 static void set_show_zeroes_toggle(int);
 static void trig_cb(GtkToggleButton *, gpointer);
+static void ts_proc(gpointer, int, GtkWidget *);
 
 static XVars X;
 
@@ -176,6 +178,7 @@
     { N_("/View/_Scientific Mode"),"<control>S", mb_proc, M_SCI, "/View/Basic Mode" },
     { N_("/View/sep1"),            NULL, NULL,    0,       "<Separator>" },
     { N_("/View/Show _Trailing Zeroes"),"<control>T", mstz_proc, M_ZEROES, "<ToggleItem>" },
+   { N_("/View/Show T_housands Separator"),"<control>K", ts_proc, M_TSEP, "<ToggleItem>" },
     { N_("/View/sep2"),	           NULL, NULL,	  0,       "<Separator>" },
     { N_("/View/_Memory Registers"),"<control>M", mb_proc, M_REGS, "<ToggleItem>" },
 
@@ -1398,6 +1401,7 @@
     n = (struct button *) g_object_get_data(G_OBJECT(BUT_ACC), "button");
     menu = create_menu(n->mtype, n);
     set_accuracy_toggle(v->accuracy);
+    set_show_tsep_toggle(v->show_tsep);
     set_show_zeroes_toggle(v->show_zeroes);
 }
 
@@ -1723,7 +1727,6 @@
 {
     GtkWidget *mi;
 
-
     if (!v->doing_mi) {
 	v->show_zeroes = !v->show_zeroes;
         v->doing_mi = 1;
@@ -1808,6 +1811,10 @@
     v->accuracy = 9;
     set_accuracy_toggle(v->accuracy);
 
+    v->show_tsep = FALSE;
+    set_show_tsep_toggle(v->show_tsep);
+    put_resource(R_TSEP, set_bool(v->show_tsep == TRUE));
+
     v->show_zeroes = FALSE;
     set_show_zeroes_toggle(v->show_zeroes);
     put_resource(R_ZEROES, set_bool(v->show_zeroes == TRUE));
@@ -2048,6 +2055,16 @@
 
 
 static void
+set_show_tsep_toggle(int state)
+{
+    GtkWidget *mi;
+
+    mi = gtk_item_factory_get_widget_by_action(X->mb_fact, M_TSEP);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi), state);
+}
+
+
+static void
 set_show_zeroes_toggle(int state)
 {
     GtkWidget *mi;
@@ -2094,6 +2111,21 @@
     set_item(NUMITEM, v->dtype);
     gtk_widget_show(X->kframe);
     gtk_main();
+}
+
+
+static void
+ts_proc(gpointer data, int choice, GtkWidget *item)
+{
+    if (!v->started) {
+	return;
+    }
+
+    v->show_tsep = !v->show_tsep;
+
+    show_display(v->MPdisp_val);
+    put_resource(R_TSEP, set_bool(v->show_tsep == TRUE));
+    make_registers();
 }
 
 
