Until now the difference between the current and global settings for
the algorithms in uses has been maintained as two values plus a pointer
to the setting actually in use. Using global data like that makes it
harder to save and restore settings, so this commit adopt an alternate
method that avoids using global data or pointers.
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "gettext.h"
#define _(msgid) gettext (msgid)
-static int global_algorithm = ENHANCED;
-
struct settings
{
/* Integer format used for IB and PIB input. */
struct settings
{
/* Integer format used for IB and PIB input. */
bool testing_mode;
int cmd_algorithm;
bool testing_mode;
int cmd_algorithm;
int syntax;
struct fmt_settings *styles;
int syntax;
struct fmt_settings *styles;
{FMT_F, 8, 2}, /* default_format */
false, /* testing_mode */
ENHANCED, /* cmd_algorithm */
{FMT_F, 8, 2}, /* default_format */
false, /* testing_mode */
ENHANCED, /* cmd_algorithm */
- &global_algorithm, /* algorithm */
+ ENHANCED, /* global_algorithm */
ENHANCED, /* syntax */
NULL, /* styles */
ENHANCED, /* syntax */
NULL, /* styles */
enum behavior_mode
settings_get_algorithm (void)
{
enum behavior_mode
settings_get_algorithm (void)
{
- return *the_settings.algorithm;
+ return the_settings.cmd_algorithm;
}
/* Set the algorithm option globally. */
void
settings_set_algorithm (enum behavior_mode mode)
{
}
/* Set the algorithm option globally. */
void
settings_set_algorithm (enum behavior_mode mode)
{
- global_algorithm = mode;
+ the_settings.global_algorithm = the_settings.cmd_algorithm = mode;
}
/* Set the algorithm option for this command only */
}
/* Set the algorithm option for this command only */
settings_set_cmd_algorithm ( enum behavior_mode mode)
{
the_settings.cmd_algorithm = mode;
settings_set_cmd_algorithm ( enum behavior_mode mode)
{
the_settings.cmd_algorithm = mode;
- the_settings.algorithm = &the_settings.cmd_algorithm;
}
/* Unset the algorithm option for this command */
void
unset_cmd_algorithm (void)
{
}
/* Unset the algorithm option for this command */
void
unset_cmd_algorithm (void)
{
- the_settings.algorithm = &global_algorithm;
+ the_settings.cmd_algorithm = the_settings.global_algorithm;
}
/* Get the current syntax setting */
}
/* Get the current syntax setting */