22 |
|
#include <string.h> |
23 |
|
|
24 |
|
#include "standard.h" |
25 |
+ |
#include "paths.h" |
26 |
|
#include "view.h" |
27 |
|
|
28 |
|
|
77 |
|
|
78 |
|
#define newp(type) (type *)malloc(sizeof(type)) |
79 |
|
|
79 |
– |
char *progname; |
80 |
|
int print_header = 1; |
81 |
|
|
82 |
|
VIEW midview = STDVIEW; |
91 |
|
) |
92 |
|
{ |
93 |
|
struct named_func *funp; |
94 |
– |
char *progtail; |
94 |
|
int i; |
95 |
|
/* get program name */ |
96 |
< |
progname = argv[0]; |
98 |
< |
progtail = strrchr(progname, '/'); /* final component */ |
99 |
< |
if (progtail == NULL) |
100 |
< |
progtail = progname; |
101 |
< |
else |
102 |
< |
progtail++; |
96 |
> |
progname = fixargv0(argv[0]); |
97 |
|
/* get options */ |
98 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
99 |
|
switch (argv[i][1]) { |
100 |
|
case 't': |
101 |
< |
progtail = argv[++i]; |
101 |
> |
progname = argv[++i]; |
102 |
|
break; |
103 |
|
case 'h': |
104 |
|
print_header = 0; |
115 |
|
} |
116 |
|
/* find and run calculation */ |
117 |
|
for (funp = all_funcs; funp->name != NULL; funp++) |
118 |
< |
if (!strcmp(funp->name, progtail)) { |
118 |
> |
if (!strcmp(funp->name, progname)) { |
119 |
|
init(); |
120 |
|
read_input(); |
121 |
|
if (print_header) { |