Skip to content

Commit

Permalink
Revert "improve null checking"
Browse files Browse the repository at this point in the history
This reverts commit 3cf67b2.
  • Loading branch information
bbrk24 committed Feb 25, 2024
1 parent 67b5201 commit 4a22eea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions src/compat.hh
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,17 @@ typedef float small_float;
#pragma clang diagnostic ignored "-Wnullability-completeness"
// A non-nullable pointer to the specified type.
#define NONNULL_PTR(...) __VA_ARGS__* _Nonnull
// A null-terminated, read-only array of characters. Can only be used for parameters, use `NONNULL_PTR(const char)`
// elsewhere.
// A null-terminated, read-only array of characters.
#define CONST_C_STR const char* _Nonnull
#elif defined(_INCLUDED_SAL)
// A non-nullable pointer to the specified type.
#define NONNULL_PTR(...) _Notnull_ __VA_ARGS__*
// A null-terminated, read-only array of characters. Can only be used for parameters, use `NONNULL_PTR(const char)`
// elsewhere.
// A null-terminated, read-only array of characters.
#define CONST_C_STR _In_z_ const char*
#else
// A non-nullable pointer to the specified type.
#define NONNULL_PTR(...) __VA_ARGS__*
// A null-terminated, read-only array of characters. Can only be used for parameters, use `NONNULL_PTR(const char)`
// elsewhere.
// A null-terminated, read-only array of characters.
#define CONST_C_STR const char*
// gcc's __attribute__((nonnull)) works differently, so I can't wrap it like this.
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static constexpr const char* FLAGS_HELP =
"\t--null, -z \tRead the program until null terminator instead of EOF.";

namespace flag_container {
static CONSTINIT_LAMBDA std::tuple<NONNULL_PTR(const char), char, void (*)(flags&) NOEXCEPT_T> FLAGS[] = {
static CONSTINIT_LAMBDA std::tuple<const char*, char, void (*)(flags&) NOEXCEPT_T> FLAGS[] = {
{ "null", 'z', [](flags& f) NOEXCEPT_T { f.null_terminated = true; } },
{ "debug", 'd', [](flags& f) NOEXCEPT_T { f.debug = true; } },
{ "ascii", 'a', [](flags& f) NOEXCEPT_T { f.assume_ascii = true; } },
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline void execute(const std::string& prg, flags f) {
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>

extern "C" EMSCRIPTEN_KEEPALIVE void wasm_entrypoint(CONST_C_STR program_text, int disassemble, int expand, int debug) {
extern "C" EMSCRIPTEN_KEEPALIVE void wasm_entrypoint(const char* program_text, int disassemble, int expand, int debug) {
// Reset EOF from previous runs
clearerr(stdin);
// Input and output don't need to be synced on the web
Expand All @@ -49,7 +49,7 @@ extern "C" EMSCRIPTEN_KEEPALIVE void wasm_entrypoint(CONST_C_STR program_text, i
execute(program_text, f);
}
#else
int main(int argc, _In_reads_z_(argc) const char** argv) {
int main(int argc, const char** argv) {
flags f;
std::string program_text = parse_args(argc, argv, f);
execute(program_text, f);
Expand Down

0 comments on commit 4a22eea

Please sign in to comment.