=================================================================== RCS file: /home/cvs/OpenXM/src/asir-doc/extract_func.c,v retrieving revision 1.2 retrieving revision 1.6 diff -u -p -r1.2 -r1.6 --- OpenXM/src/asir-doc/extract_func.c 2000/01/20 03:26:22 1.2 +++ OpenXM/src/asir-doc/extract_func.c 2009/02/22 20:27:25 1.6 @@ -1,8 +1,21 @@ -/* $OpenXM: OpenXM/src/asir-doc/extract_func.c,v 1.1.1.1 1999/12/08 05:47:43 noro Exp $ */ +/* $OpenXM: OpenXM/src/asir-doc/extract_func.c,v 1.5 2009/02/22 17:59:25 ohara Exp $ */ #include #include +#include +#include +#include +#include +#if defined(__MINGW32__) +#include +#define mkdir(d,m) ((mkdir)((d))) +#endif + +void create_dir(char *); +int fname(char *,char **); + +int main(argc,argv) int argc; char **argv; @@ -49,6 +62,7 @@ char **argv; if ( i >= 3 && buf1[i] == '\n' ) { fputs(buf,stderr); strcpy(fn,name[0]); + create_dir(fn); fp = fopen(fn,"w"); for ( j = 1; name[j]; j++ ) symlink(fn,name[j]); @@ -66,7 +80,7 @@ char **argv; } else fputs(buf1,fp); } - } else if ( fp ) + } else if ( fp ) { if ( buf[0] == 0x1f ) { fclose(fp); fp = 0; if ( jis ) { @@ -74,32 +88,52 @@ char **argv; fn,fn,fn,fn,fn); system(cmd); } - } else + } else { fputs(buf,fp); + } + } } } +void create_dir(char *fname) +{ + char *p; + + p = fname; + while ( *p && (p = strchr(p,'/')) ) { + *p = 0; + mkdir(fname,0755); + *p = '/'; + p++; + } + +} + int fname(buf,name) char *buf; char **name; { int i,len; - char *quote,*bquote,*comma; + char *quote,*bquote,*comma,*space,*p; - /* XXX */ - if ( *buf != '`' ) - return 0; - + if ( *buf != '`' ) { + /* skip X.X.X if exists */ + space = strchr(buf,' '); + if ( !space ) return 0; + for ( p = buf; p < space; p++ ) + if ( !isdigit(*p) && *p != '.' ) return 0; + buf = space+1; + } i = 0; while ( 1 ) { /* search a back quote */ - bquote = index(buf,'`' ); + bquote = strchr(buf,'`' ); if ( !bquote ) return 0; buf = bquote+1; /* buf points to a function; search a quote */ - quote = index(buf,'\''); + quote = strchr(buf,'\''); if ( !quote ) return 0; len = quote-buf; @@ -109,7 +143,7 @@ char **name; i++; buf = quote+1; /* buf points to ',' or a space char; search a comma */ - comma = index(buf,','); + comma = strchr(buf,','); if ( !comma ) { /* if the rest chars include a non-space char, then return 0 */ while ( *buf && isspace(*buf) ) buf++;