version 1.5, 1999/12/14 06:41:03 |
version 1.8, 2003/08/22 16:08:23 |
|
|
\maketitle |
\maketitle |
\section{$BA0=q$-(B} |
\section{$BA0=q$-(B} |
*/ |
*/ |
/* $OpenXM: OpenXM/src/kxx/oxweave.c,v 1.4 1999/12/13 14:47:41 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/oxweave.c,v 1.7 2001/05/06 07:53:01 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
|
/* Modify here to change the begin tag and EndComment. Less than 9 characters. |
/* Modify here to change the begin tag and EndComment. Less than 9 characters. |
Line 27 char *EndComment1="\n"; |
|
Line 27 char *EndComment1="\n"; |
|
#define BSIZE 256 |
#define BSIZE 256 |
#define VSIZE 256 |
#define VSIZE 256 |
static int Debug = 0; |
static int Debug = 0; |
|
static int Debug2 = 0; |
static int Plain = 0; |
static int Plain = 0; |
/*&jp \noindent |
/*&jp \noindent |
$B:F5"(B option $B$r(B on $B$K$7$?>l9g(B ({\tt Recursive = 1}, |
$B:F5"(B option $B$r(B on $B$K$7$?>l9g(B ({\tt Recursive = 1}, |
Line 73 main(int argc,char *argv[]) { |
|
Line 74 main(int argc,char *argv[]) { |
|
|
|
/*&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. |
{\tt tagv2[]} $B$KBP1~$9$k%?%0$N$*$o$j$N5-9f$r$$$l$k(B. |
{\tt tagv2[]} $B$KBP1~$9$k%?%0$N$*$o$j$N5-9f$r$$$l$k(B. |
*/ |
*/ |
tagc = tagc2 = 0; |
tagc = tagc2 = 0; |
if (argc <= 1 || argc >= VSIZE) { |
if (argc <= 1 || argc >= VSIZE) { |
usage(); |
usage(); |
exit(); |
exit(0); |
}else{ |
}else{ |
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 if (strcmp(argv[i],"--plain") == 0) { |
}else if (strcmp(argv[i],"--plain") == 0) { |
Plain = 1; OutputNoTaggedSegment = 1; |
Plain = 1; OutputNoTaggedSegment = 1; |
}else if (strcmp(argv[i],"--recursive") == 0) { |
}else if (strcmp(argv[i],"--recursive") == 0) { |
Recursive = 1; |
Recursive = 1; |
|
}else if (strcmp(argv[i],"--debug") == 0) { |
|
Debug2 = 1; |
} else{ |
} else{ |
if (strcmp(argv[i]," ") == 0) { |
if (strcmp(argv[i]," ") == 0) { |
argv[i] = ""; |
argv[i] = ""; |
} |
} |
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
strcpy(tagv[tagc],BeginTag0); |
strcpy(tagv[tagc],BeginTag0); |
strcat(tagv[tagc],argv[i]); |
strcat(tagv[tagc],argv[i]); |
tagv2[tagc] = EndComment0; |
tagv2[tagc] = EndComment0; |
/* $B%3%a%s%H$N$*$o$j$N5-9f(B. */ |
/* $B%3%a%s%H$N$*$o$j$N5-9f(B. */ |
tagc2++; |
tagc2++; |
tagc++; |
tagc++; |
|
|
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
tagv[tagc] = (char *) malloc(sizeof(char)*(strlen(argv[i])+10)); |
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
tagv2[tagc2] = (char *) malloc(sizeof(char)*10); |
strcpy(tagv[tagc],BeginTag1); |
strcpy(tagv[tagc],BeginTag1); |
strcat(tagv[tagc],argv[i]); |
strcat(tagv[tagc],argv[i]); |
tagv2[tagc] = EndComment1; |
tagv2[tagc] = EndComment1; |
tagc2++; |
tagc2++; |
tagc++; |
tagc++; |
} |
} |
} |
} |
} |
} |
Line 125 main(int argc,char *argv[]) { |
|
Line 128 main(int argc,char *argv[]) { |
|
state 0 & OutputNoTaggedSegment ==> putchar() |
state 0 & OutputNoTaggedSegment ==> putchar() |
state 1 ==> putchar() |
state 1 ==> putchar() |
state 2 ==> skip |
state 2 ==> skip |
*/ |
*/ |
while (notEOF()) { |
while (notEOF()) { |
/* We are in the state 0. */ |
/* We are in the state 0. */ |
pos = findNextTag(tagc,tagv,tagc2,tagv2); |
pos = findNextTag(tagc,tagv,tagc2,tagv2); |
Line 199 findNextTag(int tagc, char *tagv[],int tagc2,char *tag |
|
Line 202 findNextTag(int tagc, char *tagv[],int tagc2,char *tag |
|
for (i=0; i<tagc; i++) { |
for (i=0; i<tagc; i++) { |
/* fprintf(stderr,"\nChecking %s : ",tagv[i]); */ |
/* fprintf(stderr,"\nChecking %s : ",tagv[i]); */ |
if (wcmp(tagv[i]) == 0) { |
if (wcmp(tagv[i]) == 0) { |
LevelState1++; |
LevelState1++; |
/* fprintf(stderr," : matched."); */ |
/* fprintf(stderr," : matched."); */ |
wgetc(strlen(tagv[i])+1); |
wgetc(strlen(tagv[i])+1); |
if (OutputNoTaggedSegment == 1 && BeginVerbatim == 1) { |
if (OutputNoTaggedSegment == 1 && BeginVerbatim == 1) { |
BeginVerbatim = 0; |
BeginVerbatim = 0; |
if (!Plain) printf("\\end{verbatim\x07d}\n"); |
if (!Plain) printf("\\end{verbatim\x07d}\n"); |
} |
} |
OutputtingTaggedSegment = 1; |
OutputtingTaggedSegment = 1; |
return(i); /* 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 */ |
Line 252 findEndTag(int tagc,char *tagv[],int rule) { |
|
Line 255 findEndTag(int tagc,char *tagv[],int rule) { |
|
i = rule; |
i = rule; |
if (wcmp(tagv[i]) == 0) { |
if (wcmp(tagv[i]) == 0) { |
LevelState1--; |
LevelState1--; |
/* printf("LevelState1=%d\n",LevelState1);*/ |
if (Debug2) printf("[LevelState1=%d by end of comment in the state 1.]\n",LevelState1); |
if (LevelState1 > 0 && Recursive) { |
if (LevelState1 > 0 && Recursive) { |
wgetc(strlen(tagv[i])); |
wgetc(strlen(tagv[i])); |
printf("%s",tagv[i]); |
printf("%s",tagv[i]); |
return(findEndTag(tagc,tagv,rule)); |
return(findEndTag(tagc,tagv,rule)); |
}else{ |
}else{ |
wgetc(strlen(tagv[i])); |
wgetc(strlen(tagv[i])); |
if (strcmp(tagv[i],"\n")==0) putchar('\n'); |
if (strcmp(tagv[i],"\n")==0) putchar('\n'); |
OutputtingTaggedSegment = 0; |
OutputtingTaggedSegment = 0; |
if (OutputNoTaggedSegment) { |
if (OutputNoTaggedSegment) { |
if (!Plain) printf("\n{\\footnotesize \\begin{verbatim}\n"); |
if (!Plain) 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. */ |
if (wcmp("/*") >= 0 ) { |
if (wcmp("/*") >= 0 ) { |
LevelState1++; |
LevelState1++; |
/* printf("LevelState1++=%d\n",LevelState1); */ |
if (Debug2) printf("[LevelState1++=%d by / * in state 1.]\n",LevelState1); |
} |
} |
c = wgetc(1); |
c = wgetc(1); |
putchar(c); |
putchar(c); |
Line 289 skipToEndTag(int tagc,char *tagv[],int rule) { |
|
Line 292 skipToEndTag(int tagc,char *tagv[],int rule) { |
|
do { |
do { |
if (rule == 0) { |
if (rule == 0) { |
if (wcmp(EndComment0) == 0) { |
if (wcmp(EndComment0) == 0) { |
LevelState2--; |
LevelState2--; |
if (LevelState2 > 0 && Recursive) { |
if (LevelState2 > 0 && Recursive) { |
wgetc(strlen(EndComment0)); |
wgetc(strlen(EndComment0)); |
return(skipToEndTag(tagc,tagv,rule)); |
return(skipToEndTag(tagc,tagv,rule)); |
}else{ |
}else{ |
wgetc(strlen(EndComment0)); |
wgetc(strlen(EndComment0)); |
return; /* our state is 0. */ |
return; /* our state is 0. */ |
} |
} |
} |
} |
}else if (rule == 1) { |
}else if (rule == 1) { |
if (wcmp(EndComment1) == 0) { |
if (wcmp(EndComment1) == 0) { |
LevelState2--; |
LevelState2--; |
if (LevelState2 > 0 && Recursive) { |
if (LevelState2 > 0 && Recursive) { |
wgetc(strlen(EndComment0)); |
wgetc(strlen(EndComment0)); |
return(skipToEndTag(tagc,tagv,rule)); |
return(skipToEndTag(tagc,tagv,rule)); |
}else{ |
}else{ |
wgetc(strlen(EndComment1)); |
wgetc(strlen(EndComment1)); |
return; /* our state is 0. */ |
return; /* our state is 0. */ |
} |
} |
} |
} |
}else{ |
}else{ |
for (i=0; i<tagc; i++) { |
for (i=0; i<tagc; i++) { |
if (wcmp(tagv[i]) == 0) { |
if (wcmp(tagv[i]) == 0) { |
LevelState2--; |
LevelState2--; |
if (LevelState2 > 0 && Recursive) { |
if (LevelState2 > 0 && Recursive) { |
wgetc(strlen(EndComment0)); |
wgetc(strlen(EndComment0)); |
return(skipToEndTag(tagc,tagv,rule)); |
return(skipToEndTag(tagc,tagv,rule)); |
}else{ |
}else{ |
wgetc(strlen(tagv[i])); |
wgetc(strlen(tagv[i])); |
return; /* our state is 0. */ |
return; /* our state is 0. */ |
} |
} |
} |
} |
} |
} |
|
|
} |
} |
Line 378 irregularExit() { |
|
Line 381 irregularExit() { |
|
|
|
|
|
/*&jp |
/*&jp |
\end{document} |
\end{document} |
*/ |
*/ |
/*&eg |
/*&eg |
\end{document} |
\end{document} |
*/ |
*/ |
|
|
|
|