- case ' ':
- case '\t':
- case '\n':
- case '\0':
- if (*end == '\0' && (in_simple_quote || in_double_quote)) {
- THROW2(arg_error,0,
- "End of string found while searching for %c in %s",
- (in_simple_quote?'\'':'"'),
- s);
- }
- if (in_simple_quote || in_double_quote) {
- end++;
- } else {
- if (ctn) {
- /* Found a separator. Push the string if contains something */
- char *topush=xbt_malloc(end-beg+1);
- memcpy(topush,beg,end-beg);
- topush[end - beg] = '\0';
- xbt_dynar_push(res,&topush);
- }
- ctn= 0;
-
- if (*end == '\0') {
- done = 1;
- break;
- }
-
- beg=++end;
- xbt_str_ltrim(beg," ");
- end=beg;
- }
- break;
-
- default:
- ctn = 1;
- end++;
- }
+ switch (*end) {
+ case '\\':
+ ctn = 1;
+ /* Protected char; move it closer */
+ memmove(end,end+1,strlen(end));
+ if (*end=='\0')
+ THROW0(arg_error,0,"String ends with \\");
+ end++; /* Pass the protected char */
+ break;
+
+ case '\'':
+ ctn = 1;
+ if (!in_double_quote) {
+ in_simple_quote = !in_simple_quote;
+ memmove(end,end+1,strlen(end));
+ } else {
+ /* simple quote protected by double ones */
+ end++;
+ }
+ break;
+ case '"':
+ ctn = 1;
+ if (!in_simple_quote) {
+ in_double_quote = !in_double_quote;
+ memmove(end,end+1,strlen(end));
+ } else {
+ /* double quote protected by simple ones */
+ end++;
+ }
+ break;
+
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\0':
+ if (*end == '\0' && (in_simple_quote || in_double_quote)) {
+ THROW2(arg_error,0,
+ "End of string found while searching for %c in %s",
+ (in_simple_quote?'\'':'"'),
+ s);
+ }
+ if (in_simple_quote || in_double_quote) {
+ end++;
+ } else {
+ if (ctn) {
+ /* Found a separator. Push the string if contains something */
+ char *topush=xbt_malloc(end-beg+1);
+ memcpy(topush,beg,end-beg);
+ topush[end - beg] = '\0';
+ xbt_dynar_push(res,&topush);
+ }
+ ctn= 0;
+
+ if (*end == '\0') {
+ done = 1;
+ break;
+ }
+
+ beg=++end;
+ xbt_str_ltrim(beg," ");
+ end=beg;
+ }
+ break;
+
+ default:
+ ctn = 1;
+ end++;
+ }