Answer the question
In order to leave comments, you need to log in
How to parse SimpleTerminal code?
I started to disassemble the SimpleTerminal code and a few misunderstandings arose.
1) Why is the file initially called config.def.h, and there are lines in the Makefile
config.h:
cp config.def.h config.h
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
char argc_;\
char **argv_;\
int brk_;\
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
argv++;\
argc--;\
break;\
}\
int i_;\
for (i_ = 1, brk_ = 0, argv_ = argv;\
argv[0][i_] && !brk_;\
i_++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][i_];\
switch (argc_)
#define ARGEND }\
}
// В x.c используется так
int main(int argc, char *argv[])
{ ...
ARGBEGIN {
case 'a':
allowaltscreen = 0;
break;
case 'c':
opt_class = EARGF(usage());
break;
case 'e':
if (argc > 0)
--argc, ++argv;
goto run;
case 'f':
opt_font = EARGF(usage());
break;
case 'g':
xw.gm = XParseGeometry(EARGF(usage()),
&xw.l, &xw.t, &cols, &rows);
break;
case 'i':
xw.isfixed = 1;
break;
case 'o':
opt_io = EARGF(usage());
break;
case 'l':
opt_line = EARGF(usage());
break;
case 'n':
opt_name = EARGF(usage());
break;
case 't':
case 'T':
opt_title = EARGF(usage());
break;
case 'w':
opt_embed = EARGF(usage());
break;
case 'v':
die("%s " VERSION "\n", argv0);
break;
default:
usage();
} ARGEND;
....
}
What? What for? argv[0] && argv[0][0] == '-'&& argv[0][1];
check the first character (of the file?) for '-'?
Answer the question
In order to leave comments, you need to log in
1) Perhaps this happens with some compilation options? Type a certain default file is taken, and in other cases some other one.
2) Because the first thing there is argv++
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question