Add syscalls to Blinkenlights and fix bugs

This commit is contained in:
Justine Tunney 2022-05-13 13:31:21 -07:00
parent f6df29cc3d
commit 578cb21591
25 changed files with 187 additions and 108 deletions

View file

@ -79,8 +79,10 @@ hidden char *getopt_place;
char kGetoptEmsg[1] hidden;
static void getopt_print_badch(const char *s) {
fputs(program_invocation_name, stderr);
fputs(": ", stderr);
if (program_invocation_name) {
fputs(program_invocation_name, stderr);
fputs(": ", stderr);
}
fputs(s, stderr);
fputs(" -- ", stderr);
fputc(optopt, stderr);

View file

@ -17,12 +17,13 @@
/* clang-format off */
#include "third_party/make/config.h"
#include "third_party/make/getprogname.h"
#include "libc/bits/safemacros.internal.h"
#include "third_party/make/dirname.h"
char const *
getprogname (void)
{
return program_invocation_short_name;
return firstnonnull(program_invocation_short_name, "unknown");
}
/*

View file

@ -16,6 +16,7 @@
*/
#include "libc/assert.h"
#include "libc/bits/bits.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
@ -1011,8 +1012,8 @@ int execute_tests(int argc, const char **argv, const char *default_filename) {
file = fopen(test_filename, "r");
if (file == NULL) {
WRITE("%s (%s) failed to open test file: %s %m\n",
program_invocation_short_name, GetProgramExecutableName(),
test_filename);
firstnonnull(program_invocation_short_name, "unknown"),
GetProgramExecutableName(), test_filename);
if (outcome_file != NULL) fclose(outcome_file);
return 1;
}