Skip to content

Commit

Permalink
handle argv[0] without '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Shafer committed Nov 7, 2019
1 parent b99480a commit 5510c85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libxo/libxo.c
Original file line number Diff line number Diff line change
Expand Up @@ -8104,12 +8104,14 @@ xo_parse_args (int argc, char **argv)
cp = strrchr(xo_program, '/');
if (cp)
xo_program = ++cp;
else
cp = argv[0]; /* Reset to front of string */

/* GNU tools add an annoying ".test" as the program extension; remove it */
size_t len = strlen(xo_program);
static const char gnu_ext[] = ".test";
if (len >= sizeof(gnu_ext)) {
cp = &cp[len + 1 - sizeof(gnu_ext)];
cp += len + 1 - sizeof(gnu_ext);
if (xo_streq(cp, gnu_ext))
*cp = '\0';
}
Expand Down

0 comments on commit 5510c85

Please sign in to comment.