The following patch reverses the search order in witch it script paths are searched to allow users to override default configurations.
The currrent openocd indeed searches the paths in the "wrong" order. The patch attached fixes this problem but in a ugly way. The current configuration driver keeps 2 static variables: script_search_dirs and num_script_dirs. upon adding a new directory to the path a reallocation is performed (to grow to be 1 element larger). The new path is added at index-1 and the array is ended by a NULL value. When needed later in the code script_search_dirs it used as iterator and the NULL value is used as condition to stop. Because the patch reverses that order the NULL value can no longer be used as terminator and the num_script_dirs value it used to initialize the iterator. A proper fix need to do one of the following -stop using the NULL as terminator and use a combo of script_search_dirs and num_script_dirs or -put the added paths to the start of the array. Greetings On Sat, Dec 13, 2008 at 12:41 PM, Øyvind Harboe <oyvind.har...@zylin.com> wrote: > On Sat, Dec 13, 2008 at 11:31 AM, Kees Jongenburger > <kees.jongenbur...@gmail.com> wrote: >> Hello >> >> OpenOCD offers the -s option to specify additional search paths for >> configuration files. Currently the search order appears >> to be first the global configuration and then only the local. For my >> purposes it would be handy if the order would be reversed >> so it is possible to overide some configuration files. what do you think? > > Sounds like you've found a bug. It should be possible to override > the default files, that's the whole point. > > -- > Øyvind Harboe > http://www.zylin.com/zy1000.html > ARM7 ARM9 XScale Cortex > JTAG debugger and flash programmer >
Index: src/helper/configuration.c =================================================================== --- src/helper/configuration.c (revision 1340) +++ src/helper/configuration.c (working copy) @@ -61,7 +61,7 @@ char *find_file(const char *file) { FILE *fp = NULL; - char **search_dirs = script_search_dirs; + char **search_dirs = &script_search_dirs[num_script_dirs -1]; char *dir; char const *mode="r"; char full_path[1024]; @@ -73,13 +73,11 @@ while (!fp) { - dir = *search_dirs++; - - if (!dir) - break; - + dir = *search_dirs--; snprintf(full_path, 1024, "%s/%s", dir, file); fp = fopen(full_path, mode); + if (dir == script_search_dirs) + break; } if (fp)
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development