Hello community, here is the log from the commit of package gcalctool checked in at Sun Apr 20 21:26:57 CEST 2008. -------- --- GNOME/gcalctool/gcalctool.changes 2008-04-10 18:39:22.000000000 +0200 +++ gcalctool/gcalctool.changes 2008-04-18 15:13:20.000000000 +0200 @@ -1,0 +2,5 @@ +Fri Apr 18 15:13:09 CEST 2008 - sbrabec@suse.cz + +- Fix grouping and brokenness in some locales (bgo#527669). + +------------------------------------------------------------------- New: ---- gcalctool-grouping.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gcalctool.spec ++++++ --- /var/tmp/diff_new_pack.NU1893/_old 2008-04-20 21:26:19.000000000 +0200 +++ /var/tmp/diff_new_pack.NU1893/_new 2008-04-20 21:26:19.000000000 +0200 @@ -16,7 +16,7 @@ License: GPL v2 or later Group: Productivity/Scientific/Math Version: 5.22.1 -Release: 1 +Release: 5 Summary: A GNOME Calculator Application Source: ftp://ftp.gnome.org/pub/gnome/sources/gcalctool/5.22/%{name}-%{version}.tar.bz2 # PATCH-FIX-OPENSUSE gcalctool-59753_59377_59378.patch @@ -25,6 +25,8 @@ Patch3: gcalctool-5.19.92-correct-help-uri.patch # PATCH-FIX-UPSTREAM Fix crash in Gnome Calculator: pressed "4" bgo527318 Patch4: gcalctool-c-style.patch +# PATCH-FIX-UPSTREAM Fix grouping and brokenness in some locales bgo527669 +Patch5: gcalctool-grouping.patch Url: http://www.gnome.org BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: gnome-icon-theme @@ -69,6 +71,7 @@ %patch1 -p1 %patch3 -p1 %patch4 +%patch5 %build autoreconf -f -i @@ -115,6 +118,8 @@ %files lang -f %{name}.lang %changelog +* Fri Apr 18 2008 sbrabec@suse.cz +- Fix grouping and brokenness in some locales (bgo#527669). * Thu Apr 10 2008 sbrabec@suse.cz - Updated to version 5.22.1: * Fix for bug where the initial zero in the display was not ++++++ gcalctool-grouping.patch ++++++ * Fix a number of thousands separator issues (Bug #527669). Index: gcalctool/calctool.c =================================================================== --- gcalctool/calctool.c (revision 2071) +++ gcalctool/calctool.c (revision 2072) @@ -750,7 +750,8 @@ resources_init(); /* Initialise configuration */ v->radix = get_radix(); /* Locale specific radix string. */ - v->tsep = get_tsep(); /* Locale specific thousands seperator. */ + v->tsep = get_tsep(); /* Locale specific thousands separator. */ + v->tsep_count = get_tsep_count(); init_text(); /* Setup text strings depending upon language. */ read_resources(); /* Read resources from merged database. */ Index: gcalctool/display.c =================================================================== --- gcalctool/display.c (revision 2071) +++ gcalctool/display.c (revision 2072) @@ -46,60 +46,68 @@ */ void -localize_number(char *dest, const char *src, int dest_length) +localize_expression(char *dest, const char *src, int dest_length) { - char tnum[MAX_LOCALIZED], *dstp; + GString *output = g_string_sized_new(dest_length); + const char *c, *d; + int digit_count = -1; + gboolean after_radix = FALSE; - if (!v->error && v->show_tsep && v->base == DEC) { - const char *radixp, *srcp; - int n, i; - size_t tsep_len; - - /* Process the fractional part (if any). */ - srcp = src + strlen(src) - 1; - dstp = tnum; - if ((radixp = strchr(src, '.')) != NULL) { - while (srcp != radixp) { - *dstp++ = *srcp--; + /* Only modify if valid */ + if (v->error || v->base != DEC) { + STRNCPY(dest, src, dest_length - 1); + return; + } + + /* Remove separators if not supported */ + if(!v->show_tsep) { + for (c = src; *c; c++) { + if (strncmp(c, v->tsep, strlen(v->radix)) == 0) { + c += strlen(v->radix) - 1; } - *dstp++ = *srcp--; + else { + g_string_append_c(output, *c); + } } - - /* Process the integer part, add in thousand separators. */ - tsep_len = strlen(v->tsep); - n = 0; - while (srcp >= src) { - *dstp++ = *srcp--; - n++; - if (n == 3 && srcp >= src && *srcp != '-') { - for (i = tsep_len - 1; i >= 0; i--) { - *dstp++ = v->tsep[i]; - } - n = 0; + STRNCPY(dest, output->str, dest_length - 1); + return; + } + + /* Scan expression looking for numbers and inserting separators */ + for (c = src; *c; c++) { + /* Insert separators between digits */ + if (*c >= '0' && *c <= '9') { + /* Read ahead to find the number of digits */ + if (digit_count < 0) { + digit_count = 1; + for (d = c + 1; *d >= '0' && *d <= '9'; d++) + digit_count++; } + + g_string_append_c(output, *c); + + /* Insert separator after nth digit */ + if (!after_radix && digit_count > 1 && digit_count % v->tsep_count == 1) { + g_string_append(output, v->tsep); + } + digit_count--; } - *dstp++ = '\0'; - - /* Move from scratch pad to fnum, reversing the character order. */ - srcp = tnum + strlen(tnum) - 1; - dstp = dest; - while (srcp >= tnum) { - *dstp++ = *srcp--; + /* Ignore digits after the radix */ + else if (strncmp(c, v->radix, strlen(v->radix)) == 0) { + digit_count = -1; + after_radix = TRUE; + c += strlen(v->radix) - 1; + g_string_append(output, v->radix); } - *dstp++ = '\0'; - } else { - STRNCPY(dest, src, dest_length - 1); - } - dstp = strchr(dest, '.'); - if (dstp != NULL) { - size_t radix_len; - - radix_len = strlen(v->radix); - if (radix_len != 1) { - memmove(dstp + radix_len, dstp + 1, strlen (dstp + 1) + 1); + /* Reset when encountering other characters (e.g. '+') */ + else { + digit_count = -1; + after_radix = FALSE; + g_string_append_c(output, *c); } - MEMCPY(dstp, v->radix, radix_len); } + + STRNCPY(dest, output->str, dest_length - 1); } @@ -588,7 +596,7 @@ } ans = make_number(e->ans, v->base, TRUE); - localize_number(localized, ans, MAX_LOCALIZED); + localize_expression(localized, ans, MAX_LOCALIZED); t = str_replace(str, "Ans", localized); free(str); str = t; Index: gcalctool/calctool.h =================================================================== --- gcalctool/calctool.h (revision 2071) +++ gcalctool/calctool.h (revision 2072) @@ -210,7 +210,8 @@ const char *radix; /* Locale specific radix string. */ char *shelf; /* PUT selection shelf contents. */ char snum[MAX_LOCALIZED]; /* Scratchpad for scientific numbers. */ - const char *tsep; /* Locale specific thousands seperator. */ + const char *tsep; /* Locale specific thousands separator. */ + int tsep_count; /* Number of digits between separator. */ char fun_names[MAX_FUNCTIONS][MAXLINE]; /* Function names from .gcalctoolcf. */ char fun_vals[MAX_FUNCTIONS][MAXLINE]; /* Function defs from .gcalctoolcf. */ @@ -245,7 +246,7 @@ int old_cal_value; /* Previous calculation operator. */ int pointed; /* Whether a decimal point has been given. */ 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_tsep; /* Set if the thousands separator should be shown. */ int show_zeroes; /* Set if trailing zeroes should be shown. */ int toclear; /* Indicates if display should be cleared. */ }; Index: gcalctool/display.h =================================================================== --- gcalctool/display.h (revision 2071) +++ gcalctool/display.h (revision 2072) @@ -25,7 +25,7 @@ #include "calctool.h" void initialise(); -void localize_number(char *, const char *, int); +void localize_expression(char *, const char *, int); char *make_fixed(int *, char *, int, int, int); char *make_number(int *, int, int); void clear_display(int); Index: gcalctool/get.c =================================================================== --- gcalctool/get.c (revision 2071) +++ gcalctool/get.c (revision 2072) @@ -225,6 +225,13 @@ } +int +get_tsep_count() +{ + return 3; +} + + void read_resources() /* Read all possible resources from the database. */ { Index: gcalctool/ui.h =================================================================== --- gcalctool/ui.h (revision 2071) +++ gcalctool/ui.h (revision 2072) @@ -43,7 +43,7 @@ void ui_set_hyperbolic_state(gboolean); void ui_set_trigonometric_mode(enum trig_type); void ui_set_numeric_mode(enum base_type); -void ui_set_show_thousands_seperator(gboolean); +void ui_set_show_thousands_separator(gboolean); void ui_set_show_bitcalculating(gboolean); void ui_set_show_trailing_zeroes(gboolean); Index: gcalctool/get.h =================================================================== --- gcalctool/get.h (revision 2071) +++ gcalctool/get.h (revision 2072) @@ -58,5 +58,6 @@ const char *get_radix(); const char *get_tsep(); +int get_tsep_count(); #endif /* GET_H */ Index: gcalctool/gtk.c =================================================================== --- gcalctool/gtk.c (revision 2071) +++ gcalctool/gtk.c (revision 2072) @@ -650,7 +650,7 @@ void -ui_set_show_thousands_seperator(gboolean visible) +ui_set_show_thousands_separator(gboolean visible) { GtkWidget *menu; @@ -771,7 +771,7 @@ ui_set_base(DEC); ui_set_numeric_mode(FIX); ui_set_accuracy(DEFAULT_ACCURACY); - ui_set_show_thousands_seperator(FALSE); + ui_set_show_thousands_separator(FALSE); ui_set_show_trailing_zeroes(FALSE); ui_make_registers(); @@ -970,7 +970,7 @@ str = " "; } else { if (v->noparens == 0) { - localize_number(localized, str, MAX_LOCALIZED); + localize_expression(localized, str, MAX_LOCALIZED); str = localized; } } @@ -2466,7 +2466,7 @@ gboolean visible; visible = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); - ui_set_show_thousands_seperator(visible); + ui_set_show_thousands_separator(visible); } @@ -2894,7 +2894,7 @@ resource = get_resource(R_BITCALC); show_bit = resource != NULL && strcmp(resource, Rcstr[0]) != 0; - ui_set_show_thousands_seperator(v->show_tsep); + ui_set_show_thousands_separator(v->show_tsep); ui_set_show_trailing_zeroes(v->show_zeroes); ui_set_show_bitcalculating(show_bit); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org