diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-07-23 16:04:45 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-07-23 16:04:45 +0000 |
commit | 2637bbccaf12edd22bc6d82759b1e3c187d303a1 (patch) | |
tree | 7ed358084a3226808a2734e2854dcd4efbe42d17 /src/helper | |
parent | be00c7d0c4e85fd44d8c2d71521a5181688feeb8 (diff) | |
download | openocd_libswd-2637bbccaf12edd22bc6d82759b1e3c187d303a1.tar.gz openocd_libswd-2637bbccaf12edd22bc6d82759b1e3c187d303a1.tar.bz2 openocd_libswd-2637bbccaf12edd22bc6d82759b1e3c187d303a1.tar.xz openocd_libswd-2637bbccaf12edd22bc6d82759b1e3c187d303a1.zip |
handle end of line comments to improve compatibility with event scripts
git-svn-id: svn://svn.berlios.de/openocd/trunk@860 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/command.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index 0876d877..81eadd3f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -71,19 +71,24 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) c = interp->cmdPrivData; LOG_DEBUG("script_command - %s", c->name); - nwords = argc; - words = malloc(sizeof(char *) * nwords); - for (i = 0; i < nwords; i++) + words = malloc(sizeof(char *) * argc); + for (i = 0; i < argc; i++) { int len; - - words[i] = strdup(Jim_GetString(argv[i], &len)); + char *w=Jim_GetString(argv[i], &len); + if (*w=='#') + { + /* hit an end of line comment */ + break; + } + words[i] = strdup(w); if (words[i] == NULL) { return JIM_ERR; } LOG_DEBUG("script_command - %s, argv[%u]=%s", c->name, i, words[i]); } + nwords = i; /* grab the command context from the associated data */ context = Jim_GetAssocData(interp, "context"); |