This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
[PATCH] updated scsh block comment fix + regular comment speedup
- To: guile at sourceware dot cygnus dot com
- Subject: [PATCH] updated scsh block comment fix + regular comment speedup
- From: Chris Cramer <crayc at kiwi dot pyro dot net>
- Date: Thu, 4 May 2000 19:31:41 -0500
Here it is.
--
C. Ray C. aka Christopher Cramer
crayc@pyro.net
http://www.pyro.net/~crayc/
diff -ru old/guile-1.3.4/libguile/ports.c guile-1.3.4/libguile/ports.c
--- old/guile-1.3.4/libguile/ports.c Mon Sep 20 16:34:57 1999
+++ guile-1.3.4/libguile/ports.c Thu May 4 17:20:26 2000
@@ -703,11 +703,7 @@
int c;
scm_port *pt = SCM_PTAB_ENTRY (port);
- if (pt->rw_active == SCM_PORT_WRITE)
- {
- /* may be marginally faster than calling scm_flush. */
- scm_ptobs[SCM_PTOBNUM (port)].flush (port);
- }
+ if (pt->rw_active == SCM_PORT_WRITE) scm_flush (port);
if (pt->rw_random)
pt->rw_active = SCM_PORT_READ;
diff -ru old/guile-1.3.4/libguile/ports.h guile-1.3.4/libguile/ports.h
--- old/guile-1.3.4/libguile/ports.h Thu Aug 19 19:44:14 1999
+++ guile-1.3.4/libguile/ports.h Thu May 4 17:13:12 2000
@@ -167,6 +167,8 @@
#define SCM_COL(x) SCM_PTAB_ENTRY(x)->column_number
#define SCM_REVEALED(x) SCM_PTAB_ENTRY(x)->revealed
#define SCM_SETREVEALED(x,s) (SCM_PTAB_ENTRY(x)->revealed = s)
+#define SCM_READ_POS(x) SCM_PTAB_ENTRY(x)->read_pos
+#define SCM_READ_END(x) SCM_PTAB_ENTRY(x)->read_end
#define SCM_INCLINE(port) {SCM_LINUM (port) += 1; SCM_COL (port) = 0;}
#define SCM_INCCOL(port) {SCM_COL (port) += 1;}
diff -ru old/guile-1.3.4/libguile/print.c guile-1.3.4/libguile/print.c
--- old/guile-1.3.4/libguile/print.c Wed Sep 15 10:33:58 1999
+++ guile-1.3.4/libguile/print.c Thu May 4 00:55:58 2000
@@ -505,7 +505,7 @@
case '"':
case ';':
case SCM_WHITE_SPACES:
- case SCM_LINE_INCREMENTORS:
+ case SCM_LINE_INCREMENTOR:
weird_handler:
if (maybe_weird)
{
diff -ru old/guile-1.3.4/libguile/read.c guile-1.3.4/libguile/read.c
--- old/guile-1.3.4/libguile/read.c Mon Sep 20 16:34:57 1999
+++ guile-1.3.4/libguile/read.c Thu May 4 01:00:08 2000
@@ -55,6 +55,7 @@
#include "read.h"
+static void skip_scsh_block_comment (SCM port);
SCM_SYMBOL (scm_keyword_prefix, "prefix");
@@ -112,8 +113,6 @@
return scm_lreadr (&tok_buf, port, ©);
}
-
-
char *
scm_grow_tok_buf (tok_buf)
SCM * tok_buf;
@@ -122,45 +121,66 @@
return SCM_CHARS (*tok_buf);
}
-
-
int
-scm_flush_ws (port, eoferr)
- SCM port;
- const char *eoferr;
+scm_flush_ws (SCM port, const char *eoferr)
{
- register int c;
+ int c;
+ const unsigned char *bp;
+ unsigned char *be;
+
while (1)
- switch (c = scm_getc (port))
- {
- case EOF:
- goteof:
- if (eoferr)
- scm_wta (SCM_UNDEFINED, "end of file in ", eoferr);
- return c;
- case ';':
- lp:
- switch (c = scm_getc (port))
- {
- case EOF:
- goto goteof;
- default:
- goto lp;
- case SCM_LINE_INCREMENTORS:
- break;
- }
- break;
- case SCM_LINE_INCREMENTORS:
- case SCM_SINGLE_SPACES:
- case '\t':
- break;
- default:
- return c;
- }
+ {
+ switch (c = scm_getc(port))
+ {
+ case ';':
+ bp = SCM_READ_POS (port);
+ be = SCM_READ_END (port);
+ while ((bp = memchr(bp, SCM_LINE_INCREMENTOR, be - bp)) == NULL)
+ {
+ if (scm_fill_input(port) == EOF)
+ {
+ if (eoferr)
+ scm_wta (SCM_UNDEFINED, "end of file in ", eoferr);
+ return EOF;
+ }
+ bp = SCM_READ_POS (port);
+ be = SCM_READ_END (port);
+ }
+ SCM_READ_POS (port) = bp + 1;
+ SCM_LINUM (port)++;
+ SCM_COL (port) = 0;
+ break;
+ case SCM_LINE_INCREMENTOR:
+ case SCM_SINGLE_SPACES:
+ case '\t':
+ break;
+ case '#':
+ if ((c = scm_getc(port)) == '!')
+ {
+ skip_scsh_block_comment(port);
+ }
+ else if (c == EOF)
+ {
+ if (eoferr)
+ scm_wta (SCM_UNDEFINED, "end of file in ", eoferr);
+ return EOF;
+ }
+ else
+ {
+ scm_ungetc(c, port);
+ return '#';
+ }
+ break;
+ case EOF:
+ if (eoferr)
+ scm_wta (SCM_UNDEFINED, "end of file in ", eoferr);
+ return EOF;
+ default:
+ return c;
+ }
+ }
}
-
-
int
scm_casei_streq (s1, s2)
char * s1;
@@ -242,8 +262,7 @@
newline/exclamation-point/sharp-sign/newline sequence. */
static void
-skip_scsh_block_comment (port)
- SCM port;
+skip_scsh_block_comment (SCM port)
{
/* Is this portable? Dear God, spare me from the non-eight-bit
characters. But is it tasteful? */
@@ -281,7 +300,6 @@
tryagain:
c = scm_flush_ws (port, s_read);
-tryagain_no_flush_ws:
switch (c)
{
case EOF:
@@ -358,14 +376,6 @@
c = '#';
goto num;
- case '!':
- /* start of a shell script. Parse as a block comment,
- terminated by !#, just like SCSH. */
- skip_scsh_block_comment (port);
- /* EOF is not an error here */
- c = scm_flush_ws (port, (char *)NULL);
- goto tryagain_no_flush_ws;
-
case '*':
j = scm_read_token (c, tok_buf, port, 0);
p = scm_istr2bve (SCM_CHARS (*tok_buf) + 1, (long) (j - 1));
@@ -559,7 +569,7 @@
case '"':
case ';':
case SCM_WHITE_SPACES:
- case SCM_LINE_INCREMENTORS:
+ case SCM_LINE_INCREMENTOR:
if (weird)
goto default_case;