Skip to content

Commit

Permalink
Print at most the first 64 characters of invalid arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
redcode committed Sep 2, 2024
1 parent d940255 commit db06a71
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sources/test-Z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ int main(int argc, char **argv)
{
zboolean all = Z_FALSE;
zuint32 tests_run = 0;
zusize maximum_search_path_size = 0, s;
zusize maximum_search_path_size = 0;
int i = 0, j;

/*--------------------------------------------.
Expand Down Expand Up @@ -843,6 +843,7 @@ int main(int argc, char **argv)

else if (string_is_option(argv[i], "-p", "--path"))
{
zusize s;
char **p;

if (++i == argc) goto incomplete_option;
Expand Down Expand Up @@ -997,10 +998,8 @@ int main(int argc, char **argv)
invalid = "I/O value";

invalid_argument:
if ((s = strcspn(argv[i], " \t\n\r\"'")) > 64) s = 64;

fprintf(stderr, "test-Z80: Invalid %s: '%.*s%s'\n",
invalid, (int)s, argv[i], argv[i][s] ? "..." : "");
fprintf(stderr, "test-Z80: Invalid %s: '%.64s%s'\n",
invalid, argv[i], strlen(argv[i]) > 64 ? "..." : "");

bad_syntax:
fputs("test-Z80: Type 'test-Z80 -h' for help.\n", stderr);
Expand Down

0 comments on commit db06a71

Please sign in to comment.