replace atoi with my own impl to make sure that no errors occour
This commit is contained in:
11
XD.1
11
XD.1
@ -13,6 +13,10 @@
|
|||||||
.Nm
|
.Nm
|
||||||
Displays information using a smiley face like so: :)
|
Displays information using a smiley face like so: :)
|
||||||
to interpret it refer to the following tables:
|
to interpret it refer to the following tables:
|
||||||
|
Displays information using a smiley face.
|
||||||
|
to interpret XD's output refer to the following tables (or
|
||||||
|
.Nm
|
||||||
|
\fB-e\fR):
|
||||||
.Ss Eyes
|
.Ss Eyes
|
||||||
.TS
|
.TS
|
||||||
tab(;) allbox;
|
tab(;) allbox;
|
||||||
@ -42,6 +46,13 @@ c;l.
|
|||||||
/;command not found
|
/;command not found
|
||||||
(;previous signal is failure
|
(;previous signal is failure
|
||||||
.TE
|
.TE
|
||||||
|
.Ss Exit Status:
|
||||||
|
.Nm
|
||||||
|
returns the number that was passed in to allow the user to re-run the program
|
||||||
|
and get the same results. If there's an internal error
|
||||||
|
.Nm
|
||||||
|
returns 1. If you wish to find out more infomation about the error enable ERR
|
||||||
|
in the config.mk.
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Ss -v
|
.Ss -v
|
||||||
Print version information to stdout and exit.
|
Print version information to stdout and exit.
|
||||||
|
36
XD.c
36
XD.c
@ -230,6 +230,34 @@ has_staged(git_repository *repo)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline unsigned
|
||||||
|
numcat(unsigned x, unsigned y)
|
||||||
|
{
|
||||||
|
unsigned pow = 10;
|
||||||
|
while(y >= pow) {
|
||||||
|
pow *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (x * pow) + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
str_to_int(char *str)
|
||||||
|
{
|
||||||
|
int res = -1;
|
||||||
|
char *c;
|
||||||
|
|
||||||
|
for (c = str; (*c != '\0') && isdigit(*c); c++) {
|
||||||
|
if (res == -1) {
|
||||||
|
res = *c - '0';
|
||||||
|
} else {
|
||||||
|
res = numcat(res, *c - '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -282,8 +310,12 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get exit code from user args */
|
/* get exit code from user args */
|
||||||
if (argv[1]) {
|
if (argc > 1 && argv[argc - 1]) {
|
||||||
code = atoi(argv[1]);
|
code = str_to_int(argv[argc - 1]);
|
||||||
|
if (code < 0) {
|
||||||
|
L("Return code, %d, not valid", code);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change mouth based on exit code */
|
/* change mouth based on exit code */
|
||||||
|
Reference in New Issue
Block a user