~bouncepaw/agidel

ddf1b38cbd0ba4e20d3cf22f3832a4e44fea2532 — Timur Ismagilov 5 years ago 9ed954d
Make enquote not quote car
1 files changed, 9 insertions(+), 2 deletions(-)

M enquote.c
M enquote.c => enquote.c +9 -2
@@ 4,7 4,9 @@
#include <ctype.h>

enum State { LIST, STRING, ESCAPING, SYMBOL} state = LIST;
int nestlvl = 0;
bool in_car = false;
int nestlvl = 0,
  spacecnt = 0;
char ch;

int main() {


@@ 33,16 35,19 @@ int main() {
    case SYMBOL:
      if (isspace(ch)) state = LIST;
      putchar(ch);
      spacecnt++;
      break;

    case LIST:
      switch (ch) {
      case '(':
        nestlvl++;
        spacecnt = 0;
        putchar(ch);
        break;
      case ')':
        nestlvl--;
        spacecnt = 1;
        putchar(ch);
        break;
      case '\"':


@@ 52,9 57,11 @@ int main() {
      default:
        if (isspace(ch)) {
          putchar(ch);
          spacecnt++;
        } else {
          state = SYMBOL;
          printf("'%c", ch);
          if (spacecnt > 0) printf("'%c", ch);
          else putchar(ch);
        }
      }
    }