Skip to content

Commit

Permalink
Separate path building code from options loading code.
Browse files Browse the repository at this point in the history
Most code of load_options() is moved to new load_options_from().
ExifUIList initialization is moved to setup_default_options().
  • Loading branch information
Laurent Monin committed May 22, 2008
1 parent b5d0f1f commit 2d0d34e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "main.h"

#include "bar_exif.h"
#include "cache.h"
#include "collect.h"
#include "collect-io.h"
Expand Down Expand Up @@ -583,6 +584,9 @@ static void setup_default_options(void)

options->shell.path = g_strdup(GQ_DEFAULT_SHELL_PATH);
options->shell.options = g_strdup(GQ_DEFAULT_SHELL_OPTIONS);

for (i = 0; ExifUIList[i].key; i++)
ExifUIList[i].current = ExifUIList[i].default_value;
}

static void exit_program_final(void)
Expand Down
27 changes: 14 additions & 13 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,30 +618,22 @@ static gboolean is_numbered_option(const gchar *option, const gchar *prefix, gin
return TRUE;
}

void load_options(void)


static gboolean load_options_from(const gchar *utf8_path)
{
FILE *f;
gchar *rc_path;
gchar *rc_pathl;
gchar s_buf[1024];
gchar option[1024];
gchar value[1024];
gchar value_all[1024];
gint i;

for (i = 0; ExifUIList[i].key; i++)
ExifUIList[i].current = ExifUIList[i].default_value;

rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);

rc_pathl = path_from_utf8(rc_path);
rc_pathl = path_from_utf8(utf8_path);
f = fopen(rc_pathl,"r");
g_free(rc_pathl);
if (!f)
{
g_free(rc_path);
return;
}
if (!f) return FALSE;

while (fgets(s_buf, sizeof(s_buf), f))
{
Expand Down Expand Up @@ -917,5 +909,14 @@ void load_options(void)
}

fclose(f);
return TRUE;
}

void load_options(void)
{
gchar *rc_path;

rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL);
load_options_from(rc_path);
g_free(rc_path);
}

0 comments on commit 2d0d34e

Please sign in to comment.