version 1.2, 2000/01/20 03:26:22 |
version 1.8, 2020/09/05 00:57:16 |
|
|
/* $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.7 2016/08/29 04:56:58 noro Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
#include <stdlib.h> |
|
#include <unistd.h> |
|
#include <ctype.h> |
|
#include <sys/stat.h> |
|
|
|
#if defined(__MINGW32__) |
|
#include <io.h> |
|
#define mkdir(d,m) ((mkdir)((d))) |
|
#endif |
|
|
|
void create_dir(char *); |
|
int fname(char *,char **); |
|
|
|
int |
main(argc,argv) |
main(argc,argv) |
int argc; |
int argc; |
char **argv; |
char **argv; |
|
|
if ( i >= 3 && buf1[i] == '\n' ) { |
if ( i >= 3 && buf1[i] == '\n' ) { |
fputs(buf,stderr); |
fputs(buf,stderr); |
strcpy(fn,name[0]); |
strcpy(fn,name[0]); |
|
create_dir(fn); |
fp = fopen(fn,"w"); |
fp = fopen(fn,"w"); |
for ( j = 1; name[j]; j++ ) |
for ( j = 1; name[j]; j++ ) |
symlink(fn,name[j]); |
symlink(fn,name[j]); |
|
|
if ( buf1[0] == 0x1f ) { |
if ( buf1[0] == 0x1f ) { |
fclose(fp); fp = 0; |
fclose(fp); fp = 0; |
if ( jis ) { |
if ( jis ) { |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
sprintf(cmd,"nkf -w %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
name[0],name[0],name[0]); |
name[0],name[0],name[0],name[0]); |
system(cmd); |
system(cmd); |
} |
} |
} else |
} else |
fputs(buf1,fp); |
fputs(buf1,fp); |
} |
} |
} else if ( fp ) |
} else if ( fp ) { |
if ( buf[0] == 0x1f ) { |
if ( buf[0] == 0x1f ) { |
fclose(fp); fp = 0; |
fclose(fp); fp = 0; |
if ( jis ) { |
if ( jis ) { |
sprintf(cmd,"nkf %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
sprintf(cmd,"nkf -w %s > %s.tmp; rm -f %s; mv %s.tmp %s", |
fn,fn,fn,fn,fn); |
fn,fn,fn,fn,fn); |
system(cmd); |
system(cmd); |
} |
} |
} else |
} else { |
fputs(buf,fp); |
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) |
int fname(buf,name) |
char *buf; |
char *buf; |
char **name; |
char **name; |
{ |
{ |
int i,len; |
int i,len; |
char *quote,*bquote,*comma; |
char *quote,*bquote,*comma,*space,*p; |
|
|
/* XXX */ |
if ( *buf != '`' ) { |
if ( *buf != '`' ) |
/* skip X.X.X if exists */ |
return 0; |
space = strchr(buf,' '); |
|
if ( !space ) return 0; |
|
for ( p = buf; p < space; p++ ) |
|
if ( !isdigit(*p) && *p != '.' ) return 0; |
|
buf = space+1; |
|
} |
i = 0; |
i = 0; |
while ( 1 ) { |
while ( 1 ) { |
/* search a back quote */ |
/* makeinfo v5 outputs 'fname', while makeinfo v4 output `fname' */ |
bquote = index(buf,'`' ); |
/* search a (back) quote */ |
|
bquote = strchr(buf,'`' ); |
if ( !bquote ) |
if ( !bquote ) |
return 0; |
bquote = strchr(buf,'\''); |
|
if ( !bquote ) return 0; |
buf = bquote+1; |
buf = bquote+1; |
|
|
/* buf points to a function; search a quote */ |
/* buf points to a function; search a quote */ |
quote = index(buf,'\''); |
quote = strchr(buf,'\''); |
if ( !quote ) |
if ( !quote ) |
return 0; |
return 0; |
len = quote-buf; |
len = quote-buf; |
|
|
i++; |
i++; |
buf = quote+1; |
buf = quote+1; |
/* buf points to ',' or a space char; search a comma */ |
/* buf points to ',' or a space char; search a comma */ |
comma = index(buf,','); |
comma = strchr(buf,','); |
if ( !comma ) { |
if ( !comma ) { |
/* if the rest chars include a non-space char, then return 0 */ |
/* if the rest chars include a non-space char, then return 0 */ |
while ( *buf && isspace(*buf) ) buf++; |
while ( *buf && isspace(*buf) ) buf++; |