/* * SPDsoft: number of the beast */ static char __ident[] = "@(#)(c) SPDsoft, Sun Jan 24 19:21:51 CET 2021"; #define VERS_STR ((char*)&__ident[4]) #include #include #include #include #define Boolean char #define Float long double /*#define PF "%.45Lf%c"*/ #define PF "%.16Lg%c" #define MAXL 512 void fatalError(char *name,char *str); void usage(char *name); extern char *optarg; extern int optind,opterr; typedef struct { Boolean verbose; char separator[256]; } pref; pref G_Prefs; void fatalError(char *name,char *str) { fprintf(stderr, "%s: Fatal Error: %s. bye...\n",name,str); exit(-2); } main(int argc,char *argv[]) { char s[MAXL],c; int i,j,n,l,t,oper; l=strlen(argv[1]); t=0; o=0; oper=1; c=argv[1]; for (s=0; s max[i] ) max[i] = (Float)atof(argt); if( (Float)atof(argt) < min[i] ) min[i] = (Float)atof(argt); } argt = strtok( NULL, G_Prefs.separator ); i++; if ( i >= MAXL ) { fprintf(stderr,"Error: increase MAXL and recompile\n"); exit(1); } } if (i>NF) NF=i; } for(i=0;i b ? a : b ,i==NF-1?'\n':'\t'); } return(0); } /* ---------------------------------------------------------------*/ Boolean get_options(int argc,char *argv[]) { int opcion; int theError=0; G_Prefs.verbose=0; strcpy(G_Prefs.separator," "); while ( (opcion=getopt(argc,argv,"hvVc:")) != EOF ) { switch(opcion) { case 'c': strcpy(G_Prefs.separator,optarg); break; case 'v': G_Prefs.verbose = 1; break; case 'V': fprintf(stderr,"%s\n",VERS_STR); break; default: usage(argv[0]); } if ( theError!=0) usage(argv[0]); } } void usage(char *name) { fprintf(stderr, "find max and min from tab separated values\n" "usage: %s [-c separator][-v][-V][-h]\n" "-c: use custom separators\n" "-v: verbose\n" "-V: version\n" "-h: This text\n", name ); exit(-1); }