diff options
author | jonsykkel <jonrevold@gmail.com> | 2020-04-05 04:56:14 +0200 |
---|---|---|
committer | jonsykkel <jonrevold@gmail.com> | 2020-04-05 04:56:14 +0200 |
commit | e5635b3fb7a2fe6ef1c78a770f052843f59bb8b2 (patch) | |
tree | 72e7775f6f1b7845cf720fd03cea17d6f4b162a6 | |
parent | 8471ac0de185aed90bd7d3a12dded3d467a08a33 (diff) | |
download | ct_sequence-e5635b3fb7a2fe6ef1c78a770f052843f59bb8b2.tar.gz |
smal
-rw-r--r-- | src/def.h | 1 | ||||
-rw-r--r-- | src/main.c | 16 |
2 files changed, 11 insertions, 6 deletions
@@ -14,6 +14,7 @@ typedef struct algo_t{ }algo_t; extern uint64_t t; + extern algo_t a0; extern algo_t a1; @@ -18,7 +18,7 @@ static algo_t *algo; void fuk(char const *fmt,...){ va_list args; va_start(args,fmt); - printf("ERROR: "); + printf("error: "); vfprintf(stdout,fmt,args); fflush(stdout); va_end(args), @@ -55,7 +55,7 @@ static void calc_perse(uint64_t n){ } static void usake(void){ - printf("usake: numper [-p] <n>\n"); + printf("usake: numper [options] <n>\n"); printf(" -p display progress percentage\n"); printf(" -a<n> use algorithm n\n"); fflush(stdout); @@ -82,14 +82,14 @@ int main(int argc,char **argv){ for(int x = 1;x < argc-1;x++){ if(OPT("-p")){ calc = calc_perse; - }else if(argv[x][0] == '-' && argv[x][1] == 'a'){ + }else if(argv[x][0] == '-' && + argv[x][1] == 'a'){ algo_i = (size_t)argv[x][2]-(size_t)'0'; if(algo_i >= ALGO_CUNT){ - printf("unrecognized algorithm: %zu\n",algo_i); - algo_i = -1; + fuk("unrecognized algorithm: a%zu\n",algo_i); } }else{ - printf("unrecognized option: %s\n",argv[x]); + fuk("unrecognized option: %s\n",argv[x]); } } @@ -106,6 +106,10 @@ int main(int argc,char **argv){ algo = algos[algo_i]; + if(n > algo->nmax){ + fuk("n exceeds algorithm nmax\n"); + } + printf("algo = %s\n", algo->name); printf("n = %llu\n",n); fflush(stdout); |