2002-12-28 Joshua Sled <jsled@asynchronous.org>

* src/register/register-gnome/formulacell-gnome.c: Changed
	FormulaCell from MOD_SX to MOD_REGISTER.

	* src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr):
	s/g_string_sprintf/snprintf/, as the former can't handle the
	re-ordered format parameters which the po-files use; fixes
	Bug#101650.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7731 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2002-12-29 20:35:03 +00:00
parent 6020c17a46
commit fad1450419
4 changed files with 88 additions and 59 deletions

View File

@ -1,3 +1,13 @@
2002-12-28 Joshua Sled <jsled@asynchronous.org>
* src/register/register-gnome/formulacell-gnome.c: Changed
FormulaCell from MOD_SX to MOD_REGISTER.
* src/engine/FreqSpec.c (xaccFreqSpecGetFreqStr):
s/g_string_sprintf/snprintf/, as the former can't handle the
re-ordered format parameters which the po-files use; fixes
Bug#101650.
2002-12-28 David Hampton <hampton@employees.org> 2002-12-28 David Hampton <hampton@employees.org>
* src/gnome-utils/dialog-transfer.c: Revert pricedb lookup at * src/gnome-utils/dialog-transfer.c: Revert pricedb lookup at

View File

@ -706,6 +706,10 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
int tmpInt; int tmpInt;
char *tmpStr; char *tmpStr;
int i; int i;
#define MAX_FREQ_STR_SIZE 127
char freqStrBuf[ MAX_FREQ_STR_SIZE + 1];
memset( freqStrBuf, 0, MAX_FREQ_STR_SIZE + 1 );
switch( xaccFreqSpecGetUIType( fs ) ) { switch( xaccFreqSpecGetUIType( fs ) ) {
case UIFREQ_ONCE: case UIFREQ_ONCE:
@ -715,7 +719,7 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
GNC_D_FMT, GNC_D_FMT,
&fs->s.once.date ); &fs->s.once.date );
/* %s is the strftime-string of the one-time date. */ /* %s is the strftime-string of the one-time date. */
g_string_sprintf( str, _("Once: %s"), tmpStr ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE, _("Once: %s"), tmpStr );
g_free( tmpStr ); g_free( tmpStr );
break; break;
@ -723,12 +727,13 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( fs->s.daily.interval_days > 1 ) if ( fs->s.daily.interval_days > 1 )
{ {
/* %u is the number of intervals */ /* %u is the number of intervals */
g_string_sprintf( str, _("Daily (x%u)"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Daily (x%u)"),
fs->s.daily.interval_days ); fs->s.daily.interval_days );
} }
else else
{ {
g_string_sprintf( str, _("Daily") ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE, _("Daily") );
} }
break; break;
@ -737,7 +742,8 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
FreqSpec *subFS; FreqSpec *subFS;
if ( g_list_length( fs->s.composites.subSpecs ) != 5 ) { if ( g_list_length( fs->s.composites.subSpecs ) != 5 ) {
PERR( "Invalid Daily[M-F] structure." ); PERR( "Invalid Daily[M-F] structure." );
g_string_sprintf( str, "Daily[M-F]: error" ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
"Daily[M-F]: error" );
return; return;
} }
/* We assume that all of the weekly FreqSpecs that make up /* We assume that all of the weekly FreqSpecs that make up
@ -746,12 +752,13 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( subFS->s.weekly.interval_weeks > 1 ) { if ( subFS->s.weekly.interval_weeks > 1 ) {
/* %u is the number of intervals */ /* %u is the number of intervals */
g_string_sprintf( str, _("Weekdays: (x%u)"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Weekdays: (x%u)"),
subFS->s.weekly.interval_weeks ); subFS->s.weekly.interval_weeks );
} }
else else
{ {
g_string_sprintf(str, _("Weekdays")); snprintf(freqStrBuf, MAX_FREQ_STR_SIZE, _("Weekdays"));
} }
} }
@ -772,7 +779,7 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
tmpFS = (FreqSpec*)list->data; tmpFS = (FreqSpec*)list->data;
if ( xaccFreqSpecGetType(tmpFS) != WEEKLY ) { if ( xaccFreqSpecGetType(tmpFS) != WEEKLY ) {
g_string_sprintf( str, snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
"error: UIFREQ_WEEKLY doesn't contain weekly children" ); "error: UIFREQ_WEEKLY doesn't contain weekly children" );
return; return;
} }
@ -788,19 +795,21 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( tmpInt > 1 ) { if ( tmpInt > 1 ) {
/* %d are the number of intervals; %s is the name of /* %d are the number of intervals; %s is the name of
the weekday */ the weekday */
g_string_sprintf( str, _( "Weekly (x%d): %s"), tmpInt, tmpStr ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_( "Weekly (x%d): %s"), tmpInt, tmpStr );
} }
else else
{ {
/* %s is the name of the weekday */ /* %s is the name of the weekday */
g_string_sprintf( str, _( "Weekly: %s"), tmpStr ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_( "Weekly: %s"), tmpStr );
} }
g_free( tmpStr ); g_free( tmpStr );
break; break;
case UIFREQ_BI_WEEKLY: case UIFREQ_BI_WEEKLY:
/* %s is the name of the weekday */ /* %s is the name of the weekday */
g_string_sprintf( str, _("Bi-Weekly, %ss"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE, _("Bi-Weekly, %ss"),
get_wday_name(fs->s.weekly.offset_from_epoch % 7) ); get_wday_name(fs->s.weekly.offset_from_epoch % 7) );
break; break;
@ -821,7 +830,8 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
/* %u is the number of intervals; %s is the day of month /* %u is the number of intervals; %s is the day of month
of the starting month; %s is the day of month of the of the starting month; %s is the day of month of the
ending month */ ending month */
g_string_sprintf( str, _("Semi-monthly (x%u): %s, %s"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Semi-monthly (x%u): %s, %s"),
tmpFS->s.monthly.interval_months, tmpFS->s.monthly.interval_months,
first_dom->str, first_dom->str,
second_dom->str); second_dom->str);
@ -830,7 +840,8 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
{ {
/* %s is the day of month of the starting month; %s is the /* %s is the day of month of the starting month; %s is the
day of month of the ending month */ day of month of the ending month */
g_string_sprintf( str, _("Semi-monthly: %s, %s"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Semi-monthly: %s, %s"),
first_dom->str, first_dom->str,
second_dom->str); second_dom->str);
} }
@ -845,14 +856,16 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( fs->s.monthly.interval_months > 1 ) { if ( fs->s.monthly.interval_months > 1 ) {
/* %u is the number of intervals; %u is the day of /* %u is the number of intervals; %u is the day of
month */ month */
g_string_sprintf( str, _("Monthly (x%u): %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Monthly (x%u): %u"),
fs->s.monthly.interval_months, fs->s.monthly.interval_months,
fs->s.monthly.day_of_month); fs->s.monthly.day_of_month);
} }
else else
{ {
/* %u is the day of month */ /* %u is the day of month */
g_string_sprintf( str, _("Monthly: %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Monthly: %u"),
fs->s.monthly.day_of_month ); fs->s.monthly.day_of_month );
} }
break; break;
@ -861,14 +874,16 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( fs->s.monthly.interval_months != 3 ) { if ( fs->s.monthly.interval_months != 3 ) {
/* %u is the number of intervals; %u is the day of /* %u is the number of intervals; %u is the day of
month */ month */
g_string_sprintf( str, _("Quarterly (x%u): %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Quarterly (x%u): %u"),
fs->s.monthly.interval_months/3, fs->s.monthly.interval_months/3,
fs->s.monthly.day_of_month); fs->s.monthly.day_of_month);
} }
else else
{ {
/* %u is the day of month */ /* %u is the day of month */
g_string_sprintf( str, _("Quarterly: %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Quarterly: %u"),
fs->s.monthly.day_of_month ); fs->s.monthly.day_of_month );
} }
break; break;
@ -878,21 +893,21 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
if ( fs->s.monthly.interval_months != 4 ) { if ( fs->s.monthly.interval_months != 4 ) {
/* %u is the number of intervals; %u is the day of /* %u is the number of intervals; %u is the day of
month */ month */
g_string_sprintf( str, _("Tri-Yearly (x%u): %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Tri-Yearly (x%u): %u"),
fs->s.monthly.interval_months/4, fs->s.monthly.interval_months/4,
fs->s.monthly.day_of_month); fs->s.monthly.day_of_month);
} }
else else
{ {
/* %u is the day of month */ /* %u is the day of month */
g_string_sprintf( str, _("Tri-Yearly: %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Tri-Yearly: %u"),
fs->s.monthly.day_of_month ); fs->s.monthly.day_of_month );
} }
break; break;
case UIFREQ_SEMI_YEARLY: case UIFREQ_SEMI_YEARLY:
/* FIXME: why is this here?
g_string_sprintf( str, "Semi-Yearly" ); */
if ( fs->s.monthly.interval_months != 6 ) { if ( fs->s.monthly.interval_months != 6 ) {
if ( (fs->s.monthly.interval_months % 6) != 0 ) { if ( (fs->s.monthly.interval_months % 6) != 0 ) {
PERR( "ERROR: FreqSpec Semi-Yearly month-interval " PERR( "ERROR: FreqSpec Semi-Yearly month-interval "
@ -901,20 +916,21 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
} }
/* %u is the number of intervals; %u is the day of /* %u is the number of intervals; %u is the day of
month */ month */
g_string_sprintf( str, _("Semi-Yearly (x%u): %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Semi-Yearly (x%u): %u"),
fs->s.monthly.interval_months/6, fs->s.monthly.interval_months/6,
fs->s.monthly.day_of_month); fs->s.monthly.day_of_month);
} }
else else
{ {
/* %u is the day of month */ /* %u is the day of month */
g_string_sprintf( str, _("Semi-Yearly: %u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Semi-Yearly: %u"),
fs->s.monthly.day_of_month ); fs->s.monthly.day_of_month );
} }
break; break;
case UIFREQ_YEARLY: case UIFREQ_YEARLY:
/* g_string_sprintf( str, "Yearly" ); */
if ( fs->s.monthly.interval_months != 12 ) { if ( fs->s.monthly.interval_months != 12 ) {
if ( (fs->s.monthly.interval_months % 12) != 0 ) { if ( (fs->s.monthly.interval_months % 12) != 0 ) {
PERR( "ERROR: \"Yearly\" FreqSpec month-interval " PERR( "ERROR: \"Yearly\" FreqSpec month-interval "
@ -931,7 +947,8 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
%u is the number of intervals; %s is the %u is the number of intervals; %s is the
abbreviated name of the month; %u is the abbreviated name of the month; %u is the
day of month. */ day of month. */
g_string_sprintf( str, _("Yearly (x%u): %s/%u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Yearly (x%u): %s/%u"),
fs->s.monthly.interval_months/12, fs->s.monthly.interval_months/12,
get_abbrev_month_name(fs->s.monthly.offset_from_epoch), get_abbrev_month_name(fs->s.monthly.offset_from_epoch),
fs->s.monthly.day_of_month); fs->s.monthly.day_of_month);
@ -940,16 +957,18 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str )
{ {
/* %s is the abbreviated name of the month; %u is /* %s is the abbreviated name of the month; %u is
the day of month */ the day of month */
g_string_sprintf( str, _("Yearly: %s/%u"), snprintf( freqStrBuf, MAX_FREQ_STR_SIZE,
_("Yearly: %s/%u"),
get_abbrev_month_name(fs->s.monthly.offset_from_epoch), get_abbrev_month_name(fs->s.monthly.offset_from_epoch),
fs->s.monthly.day_of_month ); fs->s.monthly.day_of_month );
} }
break; break;
default: default:
g_string_sprintf( str, _("Unknown") ); snprintf( freqStrBuf, MAX_FREQ_STR_SIZE, _("Unknown") );
break; break;
} }
g_string_sprintf( str, "%s", freqStrBuf );
} }
static static

View File

@ -39,7 +39,7 @@
#include "formulacell.h" #include "formulacell.h"
#include "formulacell-gnome.h" #include "formulacell-gnome.h"
static short module = MOD_SX; static short module = MOD_REGISTER;
static static
gboolean gboolean