diff --git a/ChangeLog b/ChangeLog index 0b269716aa..6a7d292aa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Mon Sep 27 17:13:48 1999 ape@gandalf.spacetec.no (Asbjorn Pettersen) + + * app/unittest/gimpparse.c (global_parse_init): + Use parse_add_directory_tokens(). + + * app/unittest/parse_gimprc.c: comment out + parse_add_directory_tokens(). Test parse_gimprc() with argc != 1. + + * app/gimprc.c (parse_add_directory_tokens): Add this init function + to add directoy tokens. Code taken from parse_gimprc (). + No logic changed, but parse_gimprc () is cleaner. + Changes tested by unittest program parse_gimprc. + 1999-09-26 Kelly Lynn Martin * plug-ins/common/mblur.c (mblur): fixed a stupid typo diff --git a/app/gimprc.c b/app/gimprc.c index cb4e8b816e..5577d2817d 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -352,11 +352,8 @@ parse_buffers_init () parse_info.tokenbuf_size = 2048; } -void -parse_gimprc () +static GList *parse_add_directory_tokens (void) { - char libfilename[MAXPATHLEN]; - char filename[MAXPATHLEN]; char *gimp_dir; gimp_dir = gimp_directory (); @@ -364,6 +361,17 @@ parse_gimprc () #ifdef __EMX__ add_x11root_token(getenv("X11ROOT")); #endif + /* the real output is unknown_tokens list ! */ + return (unknown_tokens); +} + +void +parse_gimprc () +{ + char libfilename[MAXPATHLEN]; + char filename[MAXPATHLEN]; + + parse_add_directory_tokens (); strcpy (libfilename, gimp_system_rc_file ()); if (alternate_system_gimprc != NULL) diff --git a/app/unittest/gimpparse.c b/app/unittest/gimpparse.c index 189764be63..7a9cb3c44a 100644 --- a/app/unittest/gimpparse.c +++ b/app/unittest/gimpparse.c @@ -305,12 +305,19 @@ printf("token=%d\n",token); return parse_unknown (token_sym); } +static void global_parse_init() +{ + parse_add_directory_tokens(); + + parse_buffers_init(); +/* next_token = -1;*/ +} void parse_gimprc_file2 (char *filename) { int status; char rfilename[MAXPATHLEN]; -#if 1 +#if 0 char *gimp_dir; gimp_dir = gimp_directory (); @@ -322,6 +329,7 @@ parse_gimprc_file2 (char *filename) parse_buffers_init(); /* next_token = -1;*/ #endif + global_parse_init(); printf("parse_gimprc_file2 %s\n",filename); if (!g_path_is_absolute (filename)) { diff --git a/app/unittest/parse_gimprc.c b/app/unittest/parse_gimprc.c index 4d95583633..52494df75c 100644 --- a/app/unittest/parse_gimprc.c +++ b/app/unittest/parse_gimprc.c @@ -33,7 +33,7 @@ parse_show_tokens (GList *list) list = list->next; } } - +#if 0 static GList *parse_add_directory_tokens (void) { char *gimp_dir; @@ -45,14 +45,18 @@ static GList *parse_add_directory_tokens (void) #endif return (unknown_tokens); } +#endif -static void global_parse_init() +static void global_parse_init(int showit) { GList *list; list = parse_add_directory_tokens(); - printf("----- Directory Tokens:\n"); - parse_show_tokens (list); + if (showit) + { + printf("----- Directory Tokens:\n"); + parse_show_tokens (list); + } parse_buffers_init(); /* next_token = -1;*/ } @@ -92,7 +96,7 @@ static void parse_get_alt_personal_gimprc(char *alternate, char *filename) gboolean -parse_gimprc_absolute_file (char *filename) +parse_absolute_gimprc_file (char *filename) { int status; @@ -136,27 +140,35 @@ main (int argc, char **argv) char libfilename[MAXPATHLEN]; char filename[MAXPATHLEN]; gboolean status; + int showit = 1; - global_parse_init(); + if (argc > 1) + showit = 0; - parse_get_system_file (alternate_system_gimprc, libfilename); - parse_get_alt_personal_gimprc(alternate_gimprc, filename); - printf("\n----- Parse files: \n"); - printf("libfilename= %s\n", libfilename); - printf("filename= %s\n\n", filename); -#if 1 - status = parse_gimprc_absolute_file (libfilename); - printf("----- Parse Result:%d,filename=%s\n", status,libfilename); - if (status) - parse_show_tokens (unknown_tokens); + global_parse_init(showit); - status = parse_gimprc_absolute_file (filename); - printf("----- Parse Result:%d,filename=%s\n", status,filename); - if (status) + if (argc == 1) + { + parse_get_system_file (alternate_system_gimprc, libfilename); + parse_get_alt_personal_gimprc(alternate_gimprc, filename); + printf("\n----- Parse files: \n"); + printf("libfilename= %s\n", libfilename); + printf("filename= %s\n\n", filename); + + status = parse_absolute_gimprc_file (libfilename); + printf("----- Parse Result:%d,filename=%s\n", status,libfilename); + if (status) + parse_show_tokens (unknown_tokens); + + status = parse_absolute_gimprc_file (filename); + printf("----- Parse Result:%d,filename=%s\n", status,filename); + if (status) + parse_show_tokens (unknown_tokens); + } + else + { + parse_gimprc (); parse_show_tokens (unknown_tokens); -#else - parse_gimprc (); -#endif - parse_show_tokens (unknown_tokens); + } }