Mercurial > hg > CbC > old > examples
changeset 6:477c1dec2a2b draft
fixarg.c
author | one |
---|---|
date | Wed, 07 Jun 2017 14:43:34 +0900 |
parents | 709cdf828033 |
children | db61a5375f9b |
files | arg.c |
diffstat | 1 files changed, 25 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/arg.c Mon Dec 08 19:26:11 2008 +0000 +++ b/arg.c Wed Jun 07 14:43:34 2017 +0900 @@ -4,7 +4,7 @@ // strcmpは使わない // c fileはincludeしない -extern int printf(char*,...); +extern int printf(const char*,...); char* outfile; char* infile; @@ -26,8 +26,8 @@ #endif // evaluates matching table -code -opt5(int j, int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt5(int j, int i, int argc, char** argv, __code (*exit0)(int,void *), void* env) { if(j<LONG_OPTION_NUM){ printf("match(%d): %d\n", j, match[j]); @@ -36,12 +36,12 @@ if(j==0){ // help help=1; printf("help\n"); - goto exit0(0), env; + goto exit0(0, env); }else if(j==1){ // file printf("file\n"); printf("file: %s %s\n", outfile, argv[i]); if(outfile){ - goto exit0(1), env; + goto exit0(1, env); }else{ outfile=argv[i]; i++; @@ -49,19 +49,19 @@ } }else{ printf("unknown\n"); - goto exit0(1), env; + goto exit0(1, env); } } j++; goto opt5(j, i, argc, argv, exit0, env); }else{ - goto exit0(1), env; + goto exit0(1, env); } } // matching test -code -opt4(int k, int j, char* p, int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt4(int k, int j, char* p, int i, int argc, char** argv, __code (*exit0)(int,void*), void* env) { char* o; if(*p!='\0'){ @@ -82,8 +82,8 @@ } // initialize matching table -code -opt3(int j, char* p, int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt3(int j, char* p, int i, int argc, char** argv, __code (*exit0)(int,void*), void* env) { if(j<LONG_OPTION_NUM){ match[j]=0; @@ -95,8 +95,8 @@ } // evaluates one hyphen options such like -f or -h. -code -opt2(char* p, int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt2(char* p, int i, int argc, char** argv, __code (*exit0)(int,void*), void* env) { if(*p=='-'){ p++; @@ -104,39 +104,39 @@ } else if(*(p+1)=='\0'){ if(*p=='h'){ help=1; - goto exit0(0), env; + goto exit0(0, env); }else if(*p=='f'){ if(argv[i]){ if(outfile){ - goto exit0(1), env; + goto exit0(1, env); }else{ outfile=argv[i]; i++; goto opt0(i, argc, argv, exit0, env); } }else{ - goto exit0(1), env; + goto exit0(1, env); } } } - goto exit0(1), env; + goto exit0(1, env); } // sets 'infile' -code -opt1(char* p, int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt1(char* p, int i, int argc, char** argv, __code exit0(int,void*), void* env) { if(infile){ printf("infile exists: infile=%s %s\n", infile, p); - goto exit0(1), env; + goto exit0(1, env); }else{ infile=p; goto opt0(i, argc, argv, exit0, env); } } -code -opt0(int i, int argc, char** argv, (*exit0)(int), void* env) +__code +opt0(int i, int argc, char** argv, __code (*exit0)(int,void*), void* env) { char* p; BREAKP(exit0,env); @@ -151,15 +151,15 @@ } goto opt0(i, argc, argv, exit0, env); }else{ - goto exit0(0), env; + goto exit0(0, env); } } int option(int argc, char** argv) { - BREAKP(return, environment); - goto opt0(1, argc, argv, return, environment); + BREAKP(__return, environment); + goto opt0(1, argc, argv, __return, __environment); return 0; }