Skip to content

Commit

Permalink
compat.h: Provide char32_t on MacOS X
Browse files Browse the repository at this point in the history
  • Loading branch information
Nopey committed Nov 1, 2024
1 parent 39cd667 commit 39f3151
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/utils/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
#include "platform.h"
#include <string.h>

#if __APPLE__
// MacOS X does not ship uchar.h
#include <stdint.h>
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#else
#include <uchar.h>
#endif

#ifndef HAVE_STD_STRDUP
char *strdup(const char *s1);
#endif
Expand Down
1 change: 0 additions & 1 deletion src/utils/cp437.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "cp437.h"
#include <assert.h>
#include <uchar.h>

char const *cp437_result_to_string(cp437_result result) {
switch(result) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/cp437.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#ifndef CP437_H
#define CP437_H

#include <stdint.h> // uint8_t
#include <uchar.h> // char32_t
#include "utils/compat.h" // char32_t
#include <stdint.h> // uint8_t

// TODO: Use warn_unused_result on these methods.
// TODO: Maybe expand cp437_result to signal what type of invalid UTF-8 was encountered, or where the error occured?
Expand Down
1 change: 0 additions & 1 deletion testing/test_cp437.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <uchar.h>

#include <locale.h>

Expand Down

0 comments on commit 39f3151

Please sign in to comment.