Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-01-19 13:08:11 -0500
committerEugene Tarassov2012-01-19 13:08:11 -0500
commit1ce4a51e4552419007d95548ef4498d5f6df3f86 (patch)
treef9eb9b5842541332d4d31ccfc567380533c64d1c
parentb3f4d6f13d845d6c840c7e5d8d08c892c3c2575c (diff)
downloadorg.eclipse.tcf.agent-1ce4a51e4552419007d95548ef4498d5f6df3f86.tar.gz
org.eclipse.tcf.agent-1ce4a51e4552419007d95548ef4498d5f6df3f86.tar.xz
org.eclipse.tcf.agent-1ce4a51e4552419007d95548ef4498d5f6df3f86.zip
Bug 369105 - Command line could use support for comments.
-rw-r--r--agent/tcf/main/cmdline.c22
-rw-r--r--tests/client-test.tcf21
2 files changed, 29 insertions, 14 deletions
diff --git a/agent/tcf/main/cmdline.c b/agent/tcf/main/cmdline.c
index 55632b27..4c9c0307 100644
--- a/agent/tcf/main/cmdline.c
+++ b/agent/tcf/main/cmdline.c
@@ -124,12 +124,6 @@ static void display_tcf_reply(Channel * c, void * client_data, int error) {
cmd_done(error);
}
-static int is_space(unsigned ch) {
- if (ch == ' ') return 1;
- if (ch == '\t') return 1;
- return 0;
-}
-
static int cmd_tcf(char * args) {
char * service = NULL;
char * command = NULL;
@@ -141,19 +135,19 @@ static int cmd_tcf(char * args) {
fprintf(stderr, "Error: Channel not connected, use 'connect' command\n");
return -1;
}
- while (is_space(*s)) s++;
+ while (isspace(*s)) s++;
if (*s) {
service = (char *)s;
- while (*s && !is_space(*s)) s++;
+ while (*s && !isspace(*s)) s++;
if (*s) {
*s++ = 0;
- while (is_space(*s)) s++;
+ while (isspace(*s)) s++;
if (*s) {
command = (char *)s;
- while (*s && !is_space(*s)) s++;
+ while (*s && !isspace(*s)) s++;
if (*s) {
*s++ = 0;
- while (is_space(*s)) s++;
+ while (isspace(*s)) s++;
if (*s) json = s;
}
}
@@ -184,8 +178,8 @@ static int cmd_tcf(char * args) {
else if (ch == '{') in_struct++;
else if (ch == '}') in_struct--;
else if (ch == '"') in_string++;
- else if (is_space(ch)) {
- while (is_space(*json)) json++;
+ else if (isspace(ch)) {
+ while (isspace(*json)) json++;
if (in_array || in_struct) continue;
if (*json == 0) break;
ch = 0;
@@ -309,7 +303,7 @@ static void event_cmd_line(void * arg) {
}
while (*s && isspace((int)*s)) s++;
- if (*s) {
+ if (*s && *s != '#') {
for (cp = 0; cp < cmd_count; ++cp) {
len = strlen(cmds[cp].cmd);
if (strncmp(s, cmds[cp].cmd, len) == 0 && (s[len] == 0 || isspace((int)s[len]))) {
diff --git a/tests/client-test.tcf b/tests/client-test.tcf
new file mode 100644
index 00000000..fb1753b8
--- /dev/null
+++ b/tests/client-test.tcf
@@ -0,0 +1,21 @@
+connect TCP:127.0.0.1:1534
+
+# A comment
+ # Another comment
+
+# Spaces in a string
+tcf Diagnostics echo "a ga ag ag a"
+
+# Empty string
+tcf Diagnostics echo ""
+
+# Space betweem arguments
+tcf Diagnostics echoERR null
+
+# Space inside a struct
+tcf Diagnostics echoERR { }
+
+# Space inside an array
+tcf Diagnostics echoERR { } null { "Code" : 1, "Time" : 334, "Array" : [ 1, 2, 3 ] }
+
+tcf Diagnostics getTestList \ No newline at end of file

Back to the top