Mercurial > geeqie
changeset 350:00696edf1dd3
Partly rewrite option parser to accept whitespaces at start
of lines.
author | zas_ |
---|---|
date | Sat, 12 Apr 2008 23:59:31 +0000 |
parents | 452a4c25da22 |
children | 55ee774d5bc3 |
files | src/rcfile.c |
diffstat | 1 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/rcfile.c Sat Apr 12 23:41:35 2008 +0000 +++ b/src/rcfile.c Sat Apr 12 23:59:31 2008 +0000 @@ -506,11 +506,10 @@ gchar *rc_path; gchar *rc_pathl; gchar s_buf[1024]; - gchar *s_buf_ptr; gchar option[1024]; gchar value[1024]; gchar value_all[1024]; - gint c,l,i; + gint i; for (i = 0; ExifUIList[i].key; i++) ExifUIList[i].current = ExifUIList[i].default_value; @@ -526,24 +525,25 @@ return; } - while (fgets(s_buf,1024,f)) + while (fgets(s_buf, sizeof(s_buf), f)) { - if (s_buf[0]=='#') continue; - if (s_buf[0]=='\n') continue; - c = 0; - l = strlen(s_buf); - while (s_buf[c] != ':' && c < l) c++; - if (c >= l) continue; - s_buf[c] = '\0'; - c++; - while ((s_buf[c] == ' ' || s_buf[c] == 8) && c < l) c++; - s_buf_ptr = s_buf + c; - strncpy(value_all, s_buf_ptr, sizeof(value_all)); - while (s_buf[c] != 8 && s_buf[c] != ' ' && s_buf[c] != '\n' && c < l) c++; - s_buf[c] = '\0'; - strncpy(option, s_buf, sizeof(option)); - strncpy(value, s_buf_ptr, sizeof(value)); + gchar *option_start, *value_start; + gchar *p = s_buf; + while(g_ascii_isspace(*p)) p++; + if (!*p || *p == '\n' || *p == '#') continue; + option_start = p; + while(*p && *p != ':') p++; + if (!*p) continue; + *p = '\0'; + p++; + strncpy(option, option_start, sizeof(option)); + while(g_ascii_isspace(*p)) p++; + value_start = p; + strncpy(value_all, value_start, sizeof(value_all)); + while(*p && !g_ascii_isspace(*p) && *p != '\n') p++; + *p = '\0'; + strncpy(value, value_start, sizeof(value)); /* general options */ options->show_icon_names = read_bool_option(f, option,