X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Foptions.c;h=5351e825077e42d2e70740881c955bd5e9d8ee94;hb=1fa24ebe399bb064f5d68311e712432b64327472;hp=00f1dbed600dc2e0c55b4841503eae2eae0c0100;hpb=619b8383e9cf31159c16825206a5da7154451494;p=openocd.git diff --git a/src/helper/options.c b/src/helper/options.c index 00f1dbed60..5351e82507 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -113,6 +113,17 @@ static void add_default_dirs(void) free(path); } } +#ifdef _WIN32 + const char *appdata = getenv("APPDATA"); + + if (appdata) { + path = alloc_printf("%s/OpenOCD", appdata); + if (path) { + add_script_search_dir(path); + free(path); + } + } +#endif path = alloc_printf("%s%s%s", run_prefix, PKGDATADIR, "/site"); if (path) { @@ -130,7 +141,6 @@ static void add_default_dirs(void) int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) { int c; - char command_buffer[128]; while (1) { /* getopt_long stores the option index here. */ @@ -153,24 +163,26 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) break; case 'f': /* --file | -f */ { - snprintf(command_buffer, 128, "script {%s}", optarg); - add_config_command(command_buffer); + char *command = alloc_printf("script {%s}", optarg); + add_config_command(command); + free(command); break; } case 's': /* --search | -s */ add_script_search_dir(optarg); break; case 'd': /* --debug | -d */ - if (optarg) - snprintf(command_buffer, 128, "debug_level %s", optarg); - else - snprintf(command_buffer, 128, "debug_level 3"); - command_run_line(cmd_ctx, command_buffer); + { + char *command = alloc_printf("debug_level %s", optarg ? optarg : "3"); + command_run_line(cmd_ctx, command); + free(command); break; + } case 'l': /* --log_output | -l */ if (optarg) { - snprintf(command_buffer, 128, "log_output %s", optarg); - command_run_line(cmd_ctx, command_buffer); + char *command = alloc_printf("log_output %s", optarg); + command_run_line(cmd_ctx, command); + free(command); } break; case 'c': /* --command | -c */