[tex-k] header special extension proposal
Akira Kakuto
kakuto at fsci.fuk.kindai.ac.jp
Wed Aug 17 05:07:43 CEST 2005
Hi Karl, Hendri
> Wow, thanks. I checked in a (slightly modified form of) the patch, so
> Hendri could test it.
Many thanks for the simplification.
In the previous example, Hendri cannot use braces
in pre code and post code. In the next example, he can use "balanced"
braces:
--- dospecial.c.orig Wed Aug 17 07:45:56 2005
+++ dospecial.c Wed Aug 17 10:13:04 2005
@@ -403,15 +403,21 @@
while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0)
p++ ;
if(strncmp(p, "pre", 3) == 0) {
+ int bracecount = 1, numbytes = 0, j ;
while(*p != '{')
p++ ;
p++;
r = p;
- while(*r != '}')
+ for( ; ; ) {
+ if (*r == '{') bracecount++ ;
+ else if (*r == '}') bracecount-- ;
+ if (bracecount == 0) break ;
r++ ;
- pre = (char *)malloc(r-p+1);
+ numbytes++ ;
+ }
+ pre = (char *)malloc(numbytes+1);
r = pre ;
- while(*p != '}')
+ for (j=0; j < numbytes; j++)
*r++ = *p++;
*r = 0;
p++;
@@ -419,15 +425,21 @@
while ((*p <= ' ' || *p == '=' || *p == '(') && *p != 0)
p++ ;
if(strncmp(p, "post", 4) == 0) {
+ int bracecount = 1, numbytes = 0, j ;
while(*p != '{')
p++ ;
p++;
r = p;
- while(*r != '}')
+ for( ; ; ) {
+ if (*r == '{') bracecount++ ;
+ else if (*r == '}') bracecount-- ;
+ if (bracecount == 0) break ;
r++ ;
- post = (char *)malloc(r-p+1);
+ numbytes++ ;
+ }
+ post = (char *)malloc(numbytes+1);
r = post ;
- while(*p != '}')
+ for (j=0; j < numbytes; j++)
*r++ = *p++;
*r = 0;
}
More information about the tex-k
mailing list