diff --git a/src/modal.c b/src/modal.c index 6d34bdc..8bd4db2 100644 --- a/src/modal.c +++ b/src/modal.c @@ -55,32 +55,31 @@ put_reg(char r) } ss = walk(s); if(r == '*') { - if(*s == '(') { /* special implode */ - while(s < ss && (c = *s++)) - if(!spacer(c)) *dst_++ = c; - } else { /* special explode */ - int i, depth = 0; + int i, depth = 0; + if(*s == '(') { /* special explode tuple */ + s++; + while(s < ss) { + while((c = *s) && !spacer(c)) + *dst_++ = c, s++; + *dst_++ = ' '; + *dst_++ = '(', s++, depth++; + } + } else { /* special explode token */ while((c = *s++) && !spacer(c)) *dst_++ = c, *dst_++ = ' ', *dst_++ = '(', depth++; - for(i = 0; i < depth; i++) - *dst_++ = ')'; - } - } else if(r == '.') { /* special unpack */ - if(*s == '(') - s++, --ss; - while(s < ss) *dst_++ = *s++; - } else if(r == '^') { /* special align */ - int i, depth = 0; - s++; - while(s < ss) { - *dst_++ = '('; - while((c = *s) && !spacer(c)) - *dst_++ = c, s++; - if(s < ss - 1) *dst_++ = ' '; - s++, depth++; } for(i = 0; i < depth; i++) *dst_++ = ')'; + } else if(r == '.') { /* special unpack */ + if(*s == '(') s++, --ss; + while(s < ss) *dst_++ = *s++; + } else if(r == '^') { /* special join */ + if(*s == '(') s++, --ss; + while(s < ss && (c = *s++)) + if(!spacer(c)) *dst_++ = c; + } else if(r == '~') { /* special stdin */ + while(fread(&c, 1, 1, stdin) && c >= ' ') + *dst_++ = c; } else if(r == ':') { /* special stdout */ if(*s == '(') s++, --ss; while(s < ss) { @@ -94,9 +93,6 @@ put_reg(char r) } else putc(c, stdout); } - } else if(r == '~') { /* special stdin */ - while(fread(&c, 1, 1, stdin) && c >= ' ') - *dst_++ = c; } else while(s < ss) *dst_++ = *s++; }