+void
+cl_cmdline::split_out_string(char **_start, char **_end)
+{
+ char *start= *_start, *end;
+ start++;
+ end= start;
+ while (*end &&
+ *end != '"')
+ {
+ if (*end == '\\')
+ {
+ end++;
+ if (*end)
+ end++;
+ }
+ else
+ end++;
+ }
+ if (*end == '"')
+ end--;
+ else
+ con->dd_printf("Unterminated string\n");
+ char *param_str= (char *)malloc(end-start+2);
+ strncpy(param_str, start, 1+end-start);
+ param_str[1+end-start]= '\0';
+ tokens->add(strdup(param_str));
+ class cl_cmd_arg *arg;
+ params->add(arg= new cl_cmd_str_arg(param_str));
+ arg->init();
+ free(param_str);
+ if (*end)
+ end++;
+ if (*end == '"')
+ end++;
+ *_start= start;
+ *_end= end;
+}
+
+void
+cl_cmdline::split_out_output_redirection(char **_start, char **_end)
+{
+ char *start= *_start, *end/*= *_end*/;
+ int i;
+ char mode[2];
+
+ mode[0]= 'w';
+ mode[1]= '\0';
+ start++;
+ i= strcspn(start, " \t\v\r,");
+ end= start+i;
+ char *param_str= (char *)malloc(i+1);
+ char *n= param_str;
+ strncpy(param_str, start, i);
+ param_str[i]= '\0';
+ if (param_str &&
+ param_str[0] == '>')
+ {
+ n++;
+ mode[0]= 'a';
+ }
+ tokens->add(strdup(n));
+ con->redirect(n, mode);
+ free(param_str);
+ *_start= start;
+ *_end= end;
+}
+
+void
+cl_cmdline::split_out_bit(char *dot, char *param_str)
+{
+ class cl_cmd_arg *sfr, *bit;
+
+ *dot= '\0';
+ dot++;
+ if (strchr("0123456789", *param_str) != NULL)
+ {
+ sfr= new cl_cmd_int_arg((long)strtol(param_str, 0, 0));
+ sfr->init();
+ }
+ else
+ {
+ sfr= new cl_cmd_sym_arg(param_str);
+ sfr->init();
+ }
+ if (*dot == '\0')
+ {
+ bit= 0;
+ con->dd_printf("Uncomplete bit address\n");
+ delete sfr;
+ }
+ else
+ {
+ if (strchr("0123456789", *dot) != NULL)
+ {
+ bit= new cl_cmd_int_arg((long)strtol(dot, 0, 0));
+ bit->init();
+ }
+ else
+ {
+ bit= new cl_cmd_sym_arg(dot);
+ bit->init();
+ }
+ class cl_cmd_arg *arg;
+ params->add(arg= new cl_cmd_bit_arg(sfr, bit));
+ arg->init();
+ }
+}
+
+void
+cl_cmdline::split_out_array(char *dot, char *param_str)
+{
+ class cl_cmd_arg *aname, *aindex;
+
+ *dot= '\0';
+ dot++;
+ if (strchr("0123456789", *param_str) != NULL)
+ {
+ aname= new cl_cmd_int_arg((long)strtol(param_str, 0, 0));
+ aname->init();
+ }
+ else
+ {
+ aname= new cl_cmd_sym_arg(param_str);
+ aname->init();
+ }
+ if (*dot == '\0')
+ {
+ aname= 0;
+ con->dd_printf("Uncomplete array\n");
+ }
+ else
+ {
+ char *p;
+ p= dot + strlen(dot) - 1;
+ while (p > dot &&
+ *p != ']')
+ {
+ *p= '\0';
+ p--;
+ }
+ if (*p == ']')
+ *p= '\0';
+ if (strlen(dot) == 0)
+ {
+ con->dd_printf("Uncomplete array index\n");
+ delete aname;
+ }
+ else
+ {
+ if (strchr("0123456789", *dot) != NULL)
+ {
+ aindex= new cl_cmd_int_arg((long)strtol(dot, 0, 0));
+ aindex->init();
+ }
+ else
+ {
+ aindex= new cl_cmd_sym_arg(dot);
+ aindex->init();
+ }
+ class cl_cmd_arg *arg;
+ params->add(arg= new cl_cmd_array_arg(aname, aindex));
+ arg->init();
+ }
+ }
+}
+