version 1.2, 1999/11/16 11:48:12 |
version 1.3, 1999/12/13 07:55:23 |
|
|
\maketitle |
\maketitle |
\section{$BA0=q$-(B} |
\section{$BA0=q$-(B} |
*/ |
*/ |
/* $OpenXM: OpenXM/src/kxx/oxweave.c,v 1.1 1999/11/16 07:57:37 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/oxweave.c,v 1.2 1999/11/16 11:48:12 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
|
|
/* Modify here to change the begin tag and EndComment. Less than 9 characters. |
|
*/ |
|
char *BeginTag0="/*\x026"; /* 0x26 = & */ |
|
char *BeginTag1="//\x026"; /* 0x26 = & */ |
|
char *EndComment0="*/"; |
|
char *EndComment1="\n"; |
|
|
#define BSIZE 256 |
#define BSIZE 256 |
#define VSIZE 256 |
#define VSIZE 256 |
static int Debug = 0; |
static int Debug = 0; |
Line 30 int OutputNoTaggedSegment = 0; |
|
Line 38 int OutputNoTaggedSegment = 0; |
|
int OutputtingTaggedSegment = 0; |
int OutputtingTaggedSegment = 0; |
int BeginVerbatim = 0; |
int BeginVerbatim = 0; |
|
|
|
|
/*&jp \section{$B%W%m%0%i%`K\BN(B} */ |
/*&jp \section{$B%W%m%0%i%`K\BN(B} */ |
main(int argc,char *argv[]) { |
main(int argc,char *argv[]) { |
|
extern char *BeginTag; |
|
extern char *EndComment0; |
|
extern char *EndComment1; |
int c; |
int c; |
int tagc,i; |
int tagc,i; |
char *tagv[VSIZE]; |
char *tagv[VSIZE]; |
int tagc2; |
int tagc2; |
char *tagv2[VSIZE]; |
char *tagv2[VSIZE]; |
char *s = "/*\x026"; /* 0x26 = & */ |
int pos; |
Head = Tail = 0; Buf[0] = ' '; /* initialize */ |
Head = Tail = 0; Buf[0] = ' '; /* initialize */ |
|
|
/* $B%3%a%s%H$N$*$o$j$N5-9f(B. sm1 $B$J$i(B 0xa $B$G$"$k(B. */ |
|
tagc2 = 1; tagv2[0] = "*/"; |
|
/*&jp {\tt tagv[]} $B$K%?%0$N$"$D$^$j$r$$$l$k(B. */ |
/*&jp {\tt tagv[]} $B$K%?%0$N$"$D$^$j$r$$$l$k(B. */ |
tagc = 0; |
tagc = tagc2 = 0; |
if (argc <= 1 || argc >= VSIZE) { |
if (argc <= 1 || argc >= VSIZE) { |
usage(); |
usage(); |
exit(); |
exit(); |
Line 51 main(int argc,char *argv[]) { |
|
Line 61 main(int argc,char *argv[]) { |
|
for (i=1; i< argc ; i++) { |
for (i=1; i< argc ; i++) { |
if (strcmp(argv[i],"--source") == 0) { |
if (strcmp(argv[i],"--source") == 0) { |
OutputNoTaggedSegment = 1; |
OutputNoTaggedSegment = 1; |
}else{ |
} else{ |
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+4)); |
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
strcpy(tagv[tagc],s); |
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
|
strcpy(tagv[tagc],BeginTag0); |
strcat(tagv[tagc],argv[i]); |
strcat(tagv[tagc],argv[i]); |
|
tagv2[tagc] = EndComment0; |
|
/* $B%3%a%s%H$N$*$o$j$N5-9f(B. sm1 $B$J$i(B 0xa $B$G$"$k(B. */ |
|
tagc2++; |
tagc++; |
tagc++; |
|
|
|
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
|
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
|
strcpy(tagv[tagc],BeginTag1); |
|
strcat(tagv[tagc],argv[i]); |
|
tagv2[tagc] = EndComment1; |
|
tagc2++; |
|
tagc++; |
} |
} |
} |
} |
} |
} |
Line 77 main(int argc,char *argv[]) { |
|
Line 99 main(int argc,char *argv[]) { |
|
state 2 ==> skip |
state 2 ==> skip |
*/ |
*/ |
while (notEOF()) { |
while (notEOF()) { |
/* We are in the state 0 */ |
/* We are in the state 0. */ |
findNextTag(tagc,tagv,tagc2,tagv2); |
pos = findNextTag(tagc,tagv,tagc2,tagv2); |
/* We are int the state 1 */ |
/* We are in the state 1. */ |
findEndTag(tagc2,tagv2); |
findEndTag(tagc2,tagv2,pos); |
} |
} |
if (BeginVerbatim) { |
if (BeginVerbatim) { |
printf("\n\\end{verbatim\x07d}\n"); |
printf("\n\\end{verbatim\x07d}\n"); |
Line 136 int wgetc(int p) { |
|
Line 158 int wgetc(int p) { |
|
} |
} |
|
|
/*&jp \noindent {\tt findNextTag()} $B$O<!$N(B {\tt /\*\&} $B$J$k%?%0$r$5$,$9(B. |
/*&jp \noindent {\tt findNextTag()} $B$O<!$N(B {\tt /\*\&} $B$J$k%?%0$r$5$,$9(B. |
|
( $B$3$l$O(B, {\tt BeginTag} $B$NCM$rJQ$($k$HJQ99$G$-$k(B.) |
{\tt OutputNoTaggedSegment} $B$,(B 1 $B$J$i%G!<%?$r$=$N$^$^$J$,$9(B. |
{\tt OutputNoTaggedSegment} $B$,(B 1 $B$J$i%G!<%?$r$=$N$^$^$J$,$9(B. |
$BL5;k$9$Y$-%?%0$N$H$-$O(B, $B%?%0FbIt$r%9%-%C%W$7$?$N$A(B |
$BL5;k$9$Y$-%?%0$N$H$-$O(B, $B%?%0FbIt$r%9%-%C%W$7$?$N$A(B |
{\tt findNextTag} $B$r:F5"E*$K8F$V(B. |
{\tt findNextTag} $B$r:F5"E*$K8F$V(B. |
Line 143 int wgetc(int p) { |
|
Line 166 int wgetc(int p) { |
|
findNextTag(int tagc, char *tagv[],int tagc2,char *tagv2[]) { |
findNextTag(int tagc, char *tagv[],int tagc2,char *tagv2[]) { |
int i; |
int i; |
int c,d; |
int c,d; |
|
extern char *BeginTag0; |
|
extern char *BeginTag1; |
do { |
do { |
for (i=0; i<tagc; i++) { |
for (i=0; i<tagc; i++) { |
|
/* fprintf(stderr,"\nChecking %s : ",tagv[i]); */ |
if (wcmp(tagv[i]) == 0) { |
if (wcmp(tagv[i]) == 0) { |
|
/* fprintf(stderr," : matched."); */ |
wgetc(strlen(tagv[i])); |
wgetc(strlen(tagv[i])); |
if (OutputNoTaggedSegment == 1 && BeginVerbatim == 1) { |
if (OutputNoTaggedSegment == 1 && BeginVerbatim == 1) { |
BeginVerbatim = 0; |
BeginVerbatim = 0; |
printf("\\end{verbatim\x07d}\n"); |
printf("\\end{verbatim\x07d}\n"); |
} |
} |
OutputtingTaggedSegment = 1; |
OutputtingTaggedSegment = 1; |
return; /* Now, state is 1. */ |
return(i); /* Now, state is 1. */ |
} |
} |
} |
} |
/*&jp {\tt /\*\&} $B$@$1$I$I$N%?%0$K$b0lCW$7$J$$(B */ |
/*&jp {\tt /\*\&} $B$@$1$I$I$N%?%0$K$b0lCW$7$J$$(B */ |
if (wcmp("/*\x026") == 1) { |
if (wcmp(BeginTag0) == 1) { |
wgetc(3); |
wgetc(strlen(BeginTag0)); |
while ((d=wgetc(1)) > ' ') ; |
while ((d=wgetc(1)) > ' ') ; |
/* We are in the state 2. */ |
/* We are in the state 2. */ |
skipToEndTag(tagc2,tagv2); |
skipToEndTag(tagc2,tagv2,0); |
/* We are in the state 0. */ |
/* We are in the state 0. */ |
findNextTag(tagc,tagv,tagc2,tagv2); |
return(findNextTag(tagc,tagv,tagc2,tagv2)); |
return; |
}else if (wcmp(BeginTag1) == 1) { |
|
wgetc(strlen(BeginTag1)); |
|
while ((d=wgetc(1)) > ' ') ; |
|
/* We are in the state 2. */ |
|
skipToEndTag(tagc2,tagv2,1); |
|
/* We are in the state 0. */ |
|
return(findNextTag(tagc,tagv,tagc2,tagv2)); |
} |
} |
/* We are in the state 0 */ |
/* We are in the state 0 */ |
c = wgetc(1); |
c = wgetc(1); |
Line 178 findNextTag(int tagc, char *tagv[],int tagc2,char *tag |
|
Line 211 findNextTag(int tagc, char *tagv[],int tagc2,char *tag |
|
} |
} |
|
|
/*&jp \noindent {\tt findEndTag()} $B$O<!$N(B {\tt \*\/} $B$J$k%?%0$r$5$,$9(B. |
/*&jp \noindent {\tt findEndTag()} $B$O<!$N(B {\tt \*\/} $B$J$k%?%0$r$5$,$9(B. |
|
( $B$3$l$O(B, EndComment[01] $B$NCM$rJQ$($k$HJQ992DG=(B. ) |
*/ |
*/ |
findEndTag(int tagc,char *tagv[]) { |
findEndTag(int tagc,char *tagv[],int rule) { |
int i; |
int i; |
int c; |
int c; |
/* We are in the state 1. */ |
/* We are in the state 1. */ |
do { |
do { |
for (i=0; i<tagc; i++) { |
i = rule; |
if (wcmp(tagv[i]) == 0) { |
if (wcmp(tagv[i]) == 0) { |
wgetc(strlen(tagv[i])); |
wgetc(strlen(tagv[i])); |
OutputtingTaggedSegment = 0; |
OutputtingTaggedSegment = 0; |
if (OutputNoTaggedSegment) { |
if (OutputNoTaggedSegment) { |
printf("\n{\\footnotesize \\begin{verbatim}\n"); |
printf("\n{\\footnotesize \\begin{verbatim}\n"); |
BeginVerbatim = 1; |
BeginVerbatim = 1; |
} |
|
return; /* Our state is 0. */ |
|
} |
} |
|
return; /* Our state is 0. */ |
} |
} |
/* Our state is 1. */ |
/* Our state is 1. */ |
c = wgetc(1); |
c = wgetc(1); |
Line 203 findEndTag(int tagc,char *tagv[]) { |
|
Line 236 findEndTag(int tagc,char *tagv[]) { |
|
irregularExit(); |
irregularExit(); |
} |
} |
|
|
skipToEndTag(int tagc,char *tagv[]) { |
skipToEndTag(int tagc,char *tagv[],int rule) { |
|
int i; |
|
int c; |
|
extern char *EndComment0; |
|
extern char *EndComment1; |
|
/* our state is 2. */ |
|
do { |
|
if (rule == 0) { |
|
if (wcmp(EndComment0) == 0) { |
|
wgetc(strlen(EndComment0)); |
|
return; /* our state is 0. */ |
|
} |
|
}else if (rule == 1) { |
|
if (wcmp(EndComment1) == 0) { |
|
wgetc(strlen(EndComment1)); |
|
return; /* our state is 0. */ |
|
} |
|
}else{ |
|
for (i=0; i<tagc; i++) { |
|
if (wcmp(tagv[i]) == 0) { |
|
wgetc(strlen(tagv[i])); |
|
return; /* our state is 0. */ |
|
} |
|
} |
|
|
|
} |
|
/* our state is 2. */ |
|
c = wgetc(1); |
|
}while( c!= EOF); |
|
fprintf(stderr,"findEndTag: unexpected EOF.\n"); |
|
irregularExit(); |
|
} |
|
skipToEndTag_old(int tagc,char *tagv[]) { |
int i; |
int i; |
int c; |
int c; |
/* our state is 2. */ |
/* our state is 2. */ |