=================================================================== RCS file: /home/cvs/OpenXM/src/util/oxweave.c,v retrieving revision 1.2 retrieving revision 1.4 diff -u -p -r1.2 -r1.4 --- OpenXM/src/util/oxweave.c 2003/08/22 16:08:23 1.2 +++ OpenXM/src/util/oxweave.c 2013/08/31 08:16:02 1.4 @@ -15,10 +15,20 @@ \section{前書き} */ /* OpenXM: OpenXM/src/kxx/oxweave.c,v 1.7 2001/05/06 07:53:01 takayama Exp - $OpenXM: OpenXM/src/util/oxweave.c,v 1.1 2002/04/05 01:12:09 takayama Exp $ + $OpenXM: OpenXM/src/util/oxweave.c,v 1.3 2005/07/03 08:27:38 ohara Exp $ */ #include +#include +#include +void usage(); +void findEndTag(int tagc,char *tagv[],int rule); +int findNextTag(int tagc, char *tagv[],int tagc2,char *tagv2[]); +void skipToEndTag(int tagc,char *tagv[],int rule); +int notEOF(); +void irregularExit(); +int wcmp(char *s); + /* Modify here to change the begin tag and EndComment. Less than 9 characters. */ char *BeginTag0="/*\x026"; /* 0x26 = & */ @@ -59,14 +69,12 @@ int OutputNoTaggedSegment = 0; int OutputtingTaggedSegment = 0; int BeginVerbatim = 0; - /*&jp \section{プログラム本体} */ +int main(int argc,char *argv[]) { - extern char *BeginTag; extern char *EndComment0; extern char *EndComment1; extern int Plain; - int c; int tagc,i; char *tagv[VSIZE]; int tagc2; @@ -145,13 +153,14 @@ main(int argc,char *argv[]) { } /*&jp \noindent 次の関数は利用法を表示する. */ -usage() { +void usage() { #include "oxweaveUsage.h" } #define inc(a) ((a+1) % BSIZE) /*&jp \noindent {\tt wread()} は 標準入力よりのデータを読めるだけ リングバッファ {\tt Buf} へ読み込む.*/ +int wread() { int c,i; static int eof = 0; @@ -195,6 +204,7 @@ int wgetc(int p) { 無視すべきタグのときは, タグ内部をスキップしたのち {\tt findNextTag} を再帰的に呼ぶ. */ +int findNextTag(int tagc, char *tagv[],int tagc2,char *tagv2[]) { int i; int c,d; @@ -249,7 +259,7 @@ findNextTag(int tagc, char *tagv[],int tagc2,char *tag ( これは, EndComment0 の値を変えると変更可能. ) {\tt / /} で始まる場合は, 0xa がおわり. */ -findEndTag(int tagc,char *tagv[],int rule) { +void findEndTag(int tagc,char *tagv[],int rule) { int i; int c; /* We are in the state 1. */ @@ -261,7 +271,8 @@ findEndTag(int tagc,char *tagv[],int rule) { if (LevelState1 > 0 && Recursive) { wgetc(strlen(tagv[i])); printf("%s",tagv[i]); - return(findEndTag(tagc,tagv,rule)); + findEndTag(tagc,tagv,rule); + return; }else{ wgetc(strlen(tagv[i])); if (strcmp(tagv[i],"\n")==0) putchar('\n'); @@ -285,7 +296,7 @@ findEndTag(int tagc,char *tagv[],int rule) { irregularExit(); } -skipToEndTag(int tagc,char *tagv[],int rule) { +void skipToEndTag(int tagc,char *tagv[],int rule) { int i; int c; extern char *EndComment0; @@ -297,7 +308,8 @@ skipToEndTag(int tagc,char *tagv[],int rule) { LevelState2--; if (LevelState2 > 0 && Recursive) { wgetc(strlen(EndComment0)); - return(skipToEndTag(tagc,tagv,rule)); + skipToEndTag(tagc,tagv,rule); + return; }else{ wgetc(strlen(EndComment0)); return; /* our state is 0. */ @@ -308,7 +320,8 @@ skipToEndTag(int tagc,char *tagv[],int rule) { LevelState2--; if (LevelState2 > 0 && Recursive) { wgetc(strlen(EndComment0)); - return(skipToEndTag(tagc,tagv,rule)); + skipToEndTag(tagc,tagv,rule); + return; }else{ wgetc(strlen(EndComment1)); return; /* our state is 0. */ @@ -320,7 +333,8 @@ skipToEndTag(int tagc,char *tagv[],int rule) { LevelState2--; if (LevelState2 > 0 && Recursive) { wgetc(strlen(EndComment0)); - return(skipToEndTag(tagc,tagv,rule)); + skipToEndTag(tagc,tagv,rule); + return; }else{ wgetc(strlen(tagv[i])); return; /* our state is 0. */ @@ -347,6 +361,7 @@ skipToEndTag(int tagc,char *tagv[],int rule) { {\tt s} が 0xa,0 のときは, Buf[Head] が 0xa なら, 0 を戻す. そうでないなら, -1 を戻す. */ +int wcmp(char *s) { int n; int i,j; @@ -368,12 +383,14 @@ wcmp(char *s) { } else return(1); } +int notEOF() { wread(); if (Buf[Head] != -1) return(1); else return(0); } +void irregularExit() { if (BeginVerbatim == 1) { if (!Plain) printf("\\end{verbatim\x07d}\n");