X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=misc.c;h=81f8e2b2bd4f0212d258495fb0bed42403a7501b;hp=e7a03984b0fb96739797499247b797e49e984166;hb=6521d49c0752da0bf65769a1d38b583d3a2a1854;hpb=2fac8d1aefb3526618ba0f1e7d25c7c7c81dddf4 diff --git a/misc.c b/misc.c index e7a0398..81f8e2b 100644 --- a/misc.c +++ b/misc.c @@ -15,8 +15,11 @@ void* xmalloc(size_t size) { void* ptr = malloc(size); if (ptr == NULL) { + // LCOV_EXCL_START + // exclude from coverage analysis because we can't simulate an out of memory error in testing fprintf(stderr, "Out of memory!\n"); exit(EXIT_FAILURE); + // LCOV_EXCL_STOP } return (ptr); } @@ -41,18 +44,6 @@ void packed_to_token(long packed, char token[6]) } } -void token_to_packed(char token[6], long* packed) -{ - *packed = 0; - for (size_t i = 0; i < 5; ++i) - { - if (token[4 - i] == '\0') - continue; - char mapped = ascii_to_advent[(int) token[4 - i]]; - *packed |= (mapped << (6 * i)); - } -} - /* Hide the fact that wods are corrently packed longs */ bool wordeq(token_t a, token_t b) @@ -420,7 +411,7 @@ long vocab(long id, long init) lexeme = -1; if (init < 0) return (lexeme); - BUG(REQUIRED_VOCABULARY_WORD_NOT_FOUND); + BUG(REQUIRED_VOCABULARY_WORD_NOT_FOUND); // LCOV_EXCL_LINE } if (init >= 0 && KTAB[i] / 1000 != init) continue; @@ -431,7 +422,7 @@ long vocab(long id, long init) return (lexeme); } } - BUG(RAN_OFF_END_OF_VOCABULARY_TABLE); + BUG(RAN_OFF_END_OF_VOCABULARY_TABLE); // LCOV_EXCL_LINE } void juggle(long object) @@ -699,10 +690,12 @@ void datime(long* d, long* t) *t = (long) tv.tv_usec; } +// LCOV_EXCL_START void bug(enum bugtype num, const char *error_string) { fprintf(stderr, "Fatal error %d, %s.\n", num, error_string); exit(EXIT_FAILURE); } +// LCOV_EXCL_STOP /* end */