]> granicus.if.org Git - re2c/commitdiff
Fix WS and set the curser to make the uncommented pinrf's working
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 17 Apr 2004 15:46:28 +0000 (15:46 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 17 Apr 2004 15:46:28 +0000 (15:46 +0000)
examples/c.re

index 419964fb2f2198a30aa10f6c5f29849909b6b911..7e413e2d0d210a1bf83a614dd0125aa4010446d7 100644 (file)
@@ -86,34 +86,34 @@ typedef struct Scanner {
 } Scanner;
 
 uchar *fill(Scanner *s, uchar *cursor){
-    if(!s->eof){
-       uint cnt = s->tok - s->bot;
-       if(cnt){
-           memcpy(s->bot, s->tok, s->lim - s->tok);
-           s->tok = s->bot;
-           s->ptr -= cnt;
-           cursor -= cnt;
-           s->pos -= cnt;
-           s->lim -= cnt;
+       if(!s->eof) {
+               uint cnt = s->tok - s->bot;
+               if(cnt){
+                       memcpy(s->bot, s->tok, s->lim - s->tok);
+                       s->tok = s->bot;
+                       s->ptr -= cnt;
+                       cursor -= cnt;
+                       s->pos -= cnt;
+                       s->lim -= cnt;
+               }
+               if((s->top - s->lim) < BSIZE){
+                       uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar));
+                       memcpy(buf, s->tok, s->lim - s->tok);
+                       s->tok = buf;
+                       s->ptr = &buf[s->ptr - s->bot];
+                       cursor = &buf[cursor - s->bot];
+                       s->pos = &buf[s->pos - s->bot];
+                       s->lim = &buf[s->lim - s->bot];
+                       s->top = &s->lim[BSIZE];
+                       free(s->bot);
+                       s->bot = buf;
+               }
+               if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){
+                       s->eof = &s->lim[cnt]; *(s->eof)++ = '\n';
+               }
+               s->lim += cnt;
        }
-       if((s->top - s->lim) < BSIZE){
-           uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar));
-           memcpy(buf, s->tok, s->lim - s->tok);
-           s->tok = buf;
-           s->ptr = &buf[s->ptr - s->bot];
-           cursor = &buf[cursor - s->bot];
-           s->pos = &buf[s->pos - s->bot];
-           s->lim = &buf[s->lim - s->bot];
-           s->top = &s->lim[BSIZE];
-           free(s->bot);
-           s->bot = buf;
-       }
-       if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){
-           s->eof = &s->lim[cnt]; *(s->eof)++ = '\n';
-       }
-       s->lim += cnt;
-    }
-    return cursor;
+       return cursor;
 }
 
 int scan(Scanner *s){