On Sat, 2009-11-21 at 16:53 +0100, Andreas Fritiofson wrote: > Add $HOME/.openocd as the first default script search directory, allowing > the user to override the standard scripts.
Comments are in-line and at the end. > Signed-off-by: Andreas Fritiofson <andreas.fritiof...@gmail.com> > --- > src/helper/options.c | 16 +++++++++++++++- > 1 files changed, 15 insertions(+), 1 deletions(-) > > diff --git a/src/helper/options.c b/src/helper/options.c > index 5792e11..2187ff7 100644 > --- a/src/helper/options.c > +++ b/src/helper/options.c > @@ -29,6 +29,7 @@ > #include "server.h" > > #include <getopt.h> > +#include <stdlib.h> > > static int help_flag, version_flag; > > @@ -54,6 +55,10 @@ int configuration_output_handler(struct command_context > *context, const char* li > > static void add_default_dirs(void) > { > +#ifndef MAX_PATH > +#define MAX_PATH 1024 > +#endif > + PATH_MAX should be defined and available (in <limits.h>). Use it. > #ifdef _WIN32 > /* Add the parent of the directory where openocd.exe resides to the > * config script search path. > @@ -101,7 +106,16 @@ static void add_default_dirs(void) > * listed last in the built-in search order, so the user can > * override these scripts with site-specific customizations. > */ > - /// @todo Implement @c add_script_search_dir("${HOME}/.openocd"). As the one who added that @todo item, thanks for doing this! :) > + > + char *home = getenv("HOME"); > + > + if (home) { > + char path[MAX_PATH]; > + > + if (snprintf(path, MAX_PATH, "%s/.openocd", home) < MAX_PATH) > + add_script_search_dir(path); > + } > + > add_script_search_dir(PKGDATADIR "/site"); > add_script_search_dir(PKGDATADIR "/scripts"); > #endif As others note, this deserves mention in doc/openocd.texi and NEWS. --Z _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development