isl_stream: only quote newline using '\'
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 5 Mar 2011 09:38:18 +0000 (10:38 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 5 Mar 2011 09:56:06 +0000 (10:56 +0100)
This is all we need to support line continuation.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_stream.c

index bb0f817..6a7a912 100644 (file)
@@ -187,6 +187,13 @@ static int stream_getc(struct isl_stream *s)
        return c;
 }
 
+static void isl_stream_ungetc(struct isl_stream *s, int c)
+{
+       isl_assert(s->ctx, s->n_un < 5, return);
+       s->un[s->n_un++] = c;
+       s->c = -1;
+}
+
 static int isl_stream_getc(struct isl_stream *s)
 {
        int c;
@@ -194,18 +201,13 @@ static int isl_stream_getc(struct isl_stream *s)
        do {
                c = stream_getc(s);
                if (c != '\\')
-                       break;
+                       return c;
                c = stream_getc(s);
        } while (c == '\n');
 
-       return c;
-}
+       isl_stream_ungetc(s, c);
 
-static void isl_stream_ungetc(struct isl_stream *s, int c)
-{
-       isl_assert(s->ctx, s->n_un < 5, return);
-       s->un[s->n_un++] = c;
-       s->c = -1;
+       return '\\';
 }
 
 static int isl_stream_push_char(struct isl_stream *s, int c)