You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_dtcl-cvs@tcl.apache.org by da...@apache.org on 2001/08/31 16:32:41 UTC
cvs commit: tcl-moddtcl mod_dtcl.h parser.c
davidw 01/08/31 07:32:41
Modified: . mod_dtcl.h parser.c
Log:
Converted parser to DString for small speed improvement.
Turned off old style <+ +> tags by default!
Revision Changes Path
1.11 +1 -1 tcl-moddtcl/mod_dtcl.h
Index: mod_dtcl.h
===================================================================
RCS file: /home/cvs/tcl-moddtcl/mod_dtcl.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- mod_dtcl.h 2001/07/06 12:48:14 1.10
+++ mod_dtcl.h 2001/08/31 14:32:41 1.11
@@ -32,7 +32,7 @@
/* Allow <+ +> tags for backwards compatibility. Use the
mod_dtcl/contrib/newtags.sh script to update your .ttml files to
use <? ?> tags. */
-#define USE_OLD_TAGS 1
+#define USE_OLD_TAGS 0
/* Turn off 'old-style' $VARS variable handling, and use only the
'var' command. */
1.2 +28 -14 tcl-moddtcl/parser.c
Index: parser.c
===================================================================
RCS file: /home/cvs/tcl-moddtcl/parser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- parser.c 2001/07/06 12:48:15 1.1
+++ parser.c 2001/08/31 14:32:41 1.2
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.1 2001/07/06 12:48:15 davidw Exp $
+/* $Id: parser.c,v 1.2 2001/08/31 14:32:41 davidw Exp $
Dtcl parser - doesn't really need any of the includes besides
tcl.h.
@@ -24,7 +24,11 @@
int ch;
int endseqlen = strlen(ENDING_SEQUENCE), startseqlen = strlen(STARTING_SEQUENCE), p = 0;
int inside = 0;
+ Tcl_DString dstr;
+/* Tcl_DString convdstr; */
+ Tcl_DStringInit(&dstr);
+
while ((ch = getc(openfile)) != EOF)
{
if (ch == -1)
@@ -40,7 +44,7 @@
int nextchar = getc(openfile);
if (nextchar == '+')
{
- Tcl_AppendToObj(outbuf, "\"\n", 2);
+ Tcl_DStringAppend(&dstr, "\"\n", 2);
inside = 1;
p = 0;
continue;
@@ -55,34 +59,34 @@
if ((++p) == endseqlen)
{
/* ok, we have matched the whole ending sequence - do something */
- Tcl_AppendToObj(outbuf, "\"\n", 2);
+ Tcl_DStringAppend(&dstr, "\"\n", 2);
inside = 1;
p = 0;
continue;
}
} else {
if (p > 0)
- Tcl_AppendToObj(outbuf, (char *)strstart, p);
+ Tcl_DStringAppend(&dstr, (char *)strstart, p);
/* or else just put the char in outbuf */
switch (c)
{
case '$':
- Tcl_AppendToObj(outbuf, "\\$", -1);
+ Tcl_DStringAppend(&dstr, "\\$", -1);
break;
case '[':
- Tcl_AppendToObj(outbuf, "\\[", -1);
+ Tcl_DStringAppend(&dstr, "\\[", -1);
break;
case ']':
- Tcl_AppendToObj(outbuf, "\\]", -1);
+ Tcl_DStringAppend(&dstr, "\\]", -1);
break;
case '"':
- Tcl_AppendToObj(outbuf, "\\\"", -1);
+ Tcl_DStringAppend(&dstr, "\\\"", -1);
break;
case '\\':
- Tcl_AppendToObj(outbuf, "\\\\", -1);
+ Tcl_DStringAppend(&dstr, "\\\\", -1);
break;
default:
- Tcl_AppendToObj(outbuf, &c, 1);
+ Tcl_DStringAppend(&dstr, &c, 1);
break;
}
p = 0;
@@ -97,7 +101,7 @@
int nextchar = getc(openfile);
if (nextchar == '>')
{
- Tcl_AppendToObj(outbuf, "\n hputs \"", -1);
+ Tcl_DStringAppend(&dstr, "\n hputs \"", -1);
inside = 0;
p = 0;
continue;
@@ -111,7 +115,7 @@
{
if ((++p) == startseqlen)
{
- Tcl_AppendToObj(outbuf, "\n hputs \"", -1);
+ Tcl_DStringAppend(&dstr, "\n hputs \"", -1);
inside = 0;
p = 0;
continue;
@@ -121,11 +125,21 @@
{
/* plop stuff into outbuf, which we will then eval */
if (p > 0)
- Tcl_AppendToObj(outbuf, (char *)strend, p);
- Tcl_AppendToObj(outbuf, &c, 1);
+ Tcl_DStringAppend(&dstr, (char *)strend, p);
+ Tcl_DStringAppend(&dstr, &c, 1);
p = 0;
}
}
}
+
+/* Tcl_ExternalToUtfDString(NULL,
+ Tcl_DStringValue(&dstr),
+ Tcl_DStringLength(&dstr),
+ &convdstr); */
+
+ Tcl_AppendToObj(outbuf, Tcl_DStringValue(&dstr),
+ Tcl_DStringLength(&dstr));
+ Tcl_DStringFree(&dstr);
+/* Tcl_DStringFree(&convdstr); */
return inside;
}