[brlcad-commits] SF.net SVN: brlcad:[47665] brlcad/trunk/src/other/perplex
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <n_...@us...> - 2011-11-28 20:23:35
|
Revision: 47665 http://brlcad.svn.sourceforge.net/brlcad/?rev=47665&view=rev Author: n_reed Date: 2011-11-28 20:23:29 +0000 (Mon, 28 Nov 2011) Log Message: ----------- fix scanning from string Modified Paths: -------------- brlcad/trunk/src/other/perplex/perplex.h brlcad/trunk/src/other/perplex/scanner.re brlcad/trunk/src/other/perplex/template.c Modified: brlcad/trunk/src/other/perplex/perplex.h =================================================================== --- brlcad/trunk/src/other/perplex/perplex.h 2011-11-28 19:26:50 UTC (rev 47664) +++ brlcad/trunk/src/other/perplex/perplex.h 2011-11-28 20:23:29 UTC (rev 47665) @@ -73,7 +73,7 @@ /* scanner data */ typedef struct perplex_t { - union { + struct { FILE *file; char *string; } in; Modified: brlcad/trunk/src/other/perplex/scanner.re =================================================================== --- brlcad/trunk/src/other/perplex/scanner.re 2011-11-28 19:26:50 UTC (rev 47664) +++ brlcad/trunk/src/other/perplex/scanner.re 2011-11-28 20:23:29 UTC (rev 47665) @@ -320,8 +320,6 @@ /* --- */ /* input buffering support */ -/*!max:re2c*/ - static void buf_append_null(struct Buf *buf) { @@ -368,6 +366,12 @@ struct Buf *buf; size_t shiftSize, marker, start, used; + if (scanner->in.string != NULL) { + /* Can't get any more input for a string. */ + scanner->atEOI = 1; + return; + } + buf = scanner->buffer; start = (size_t)buf->elts; @@ -414,9 +418,19 @@ perplex_t scanner; scanner = (perplex_t)calloc(1, sizeof(struct perplex_t)); + scanner->in.file = NULL; + scanner->in.string = NULL; + + scanner->atEOI = 0; + + scanner->cursor = scanner->marker = scanner->null = NULL; + + scanner->tokenStart = NULL; scanner->buffer = NULL; + scanner->tokenText = NULL; + scanner->appData = NULL; + scanner->condition = 0; - scanner->atEOI = 0; return scanner; } @@ -429,7 +443,16 @@ perplex_t scanner = newScanner(); scanner->in.string = input; + scanner->in.file = NULL; + scanner->marker = scanner->cursor = input; + + /* scanner->null actually points one past + * '\0', so that '\0' is actually part of the + * input, used as EOI indicator + */ + scanner->null = input + strlen(input) + 1; + return scanner; } @@ -439,6 +462,7 @@ perplex_t scanner = newScanner(); scanner->in.file = input; + scanner->in.string = NULL; scanner->buffer = (struct Buf*)malloc(sizeof(struct Buf)); buf_init(scanner->buffer, sizeof(char)); Modified: brlcad/trunk/src/other/perplex/template.c =================================================================== --- brlcad/trunk/src/other/perplex/template.c 2011-11-28 19:26:50 UTC (rev 47664) +++ brlcad/trunk/src/other/perplex/template.c 2011-11-28 20:23:29 UTC (rev 47665) @@ -61,7 +61,7 @@ /* scanner data */ typedef struct perplex_t { - union { + struct { FILE *file; char *string; } in; @@ -322,8 +322,6 @@ /* --- */ /* input buffering support */ -/*!max:re2c*/ - static void buf_append_null(struct Buf *buf) { @@ -370,6 +368,12 @@ struct Buf *buf; size_t shiftSize, marker, start, used; + if (scanner->in.string != NULL) { + /* Can't get any more input for a string. */ + scanner->atEOI = 1; + return; + } + buf = scanner->buffer; start = (size_t)buf->elts; @@ -416,9 +420,19 @@ perplex_t scanner; scanner = (perplex_t)calloc(1, sizeof(struct perplex_t)); + scanner->in.file = NULL; + scanner->in.string = NULL; + + scanner->atEOI = 0; + + scanner->cursor = scanner->marker = scanner->null = NULL; + + scanner->tokenStart = NULL; scanner->buffer = NULL; + scanner->tokenText = NULL; + scanner->appData = NULL; + scanner->condition = 0; - scanner->atEOI = 0; return scanner; } @@ -431,7 +445,16 @@ perplex_t scanner = newScanner(); scanner->in.string = input; + scanner->in.file = NULL; + scanner->marker = scanner->cursor = input; + + /* scanner->null actually points one past + * '\0', so that '\0' is actually part of the + * input, used as EOI indicator + */ + scanner->null = input + strlen(input) + 1; + return scanner; } @@ -441,6 +464,7 @@ perplex_t scanner = newScanner(); scanner->in.file = input; + scanner->in.string = NULL; scanner->buffer = (struct Buf*)malloc(sizeof(struct Buf)); buf_init(scanner->buffer, sizeof(char)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |