Index: .github/ISSUE_TEMPLATE/config.yml
==================================================================
--- .github/ISSUE_TEMPLATE/config.yml
+++ .github/ISSUE_TEMPLATE/config.yml
@@ -12,10 +12,15 @@
url: https://objfw.nil.im/forum
about: Please use this if you have questions or want support.
- name: ObjFW Matrix Room
url: https://matrix.to/#/%23objfw:nil.im
about: Please use this for interactive questions and support.
+ - name: ObjFW IRC Channel
+ url: https://webchat.oftc.net/?channels=%23objfw
+ about:
+ Please use this for interactive questions and support - it is bridged to
+ the Matrix room above.
- name: ObjFW Slack Channel
url: https://objfw.nil.im/slack
about:
Please use this for interactive questions and support - it is bridged to
the Matrix room above.
@@ -25,12 +30,7 @@
Please use this for interactive questions and support - it is bridged to
the Matrix room above.
- name: ObjFW Telegram Room
url: https://t.me/objfw
about:
- Please use this for interactive questions and support - it is bridged to
- the Matrix room above.
- - name: ObjFW Gitter Room
- url: https://gitter.im/ObjFW/ObjFW
- about:
Please use this for interactive questions and support - it is bridged to
the Matrix room above.
Index: PLATFORMS.md
==================================================================
--- PLATFORMS.md
+++ PLATFORMS.md
@@ -96,15 +96,14 @@
MorphOS
-------
- * OS Versions: 3.9-3.11
+ * OS Versions: 3.14
* Architectures: PowerPC
- * Compilers: GCC 5.3.0, GCC 5.4.0
+ * Compilers: GCC 9.3.0
* Runtimes: ObjFW
- * Notes: libnix and ixemul are both supported
NetBSD
------
Index: README.md
==================================================================
--- README.md
+++ README.md
@@ -355,17 +355,18 @@
If you have any questions about ObjFW or would like to talk to other ObjFW
users, the following venues are available:
* The [forum](https://objfw.nil.im/forum)
* A [Matrix room](https://matrix.to/#/%23objfw:nil.im)
+ * An IRC channel named `#objfw` on `irc.oftc.net`
+ ([Web chat](https://webchat.oftc.net/?channels=%23objfw)), bridged to the
+ Matrix room above
* A [Slack channel](https://objfw.nil.im/slack), bridged to the Matrix room
above
* A [Discord channel](https://objfw.nil.im/discord), bridged to the Matrix
room above
* A [Telegram room](https://t.me/objfw), bridged to the Matrix room above
- * A [Gitter room](https://gitter.im/ObjFW/ObjFW), bridged to the Matrix room
- above
Please don't hesitate to join any or all of those!
Commercial use
Index: configure.ac
==================================================================
--- configure.ac
+++ configure.ac
@@ -334,27 +334,29 @@
OBJCFLAGS="$OBJCFLAGS -Wno-pointer-sign"
;;
esac
AC_MSG_CHECKING(whether Objective C compiler supports properties)
-AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- id bar;
- }
-
- @property (nonatomic, retain) id bar;
- @end
-], [
- Foo *foo = (id)0;
- [foo setBar: (id)0];
- foo = [foo bar];
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ id bar;
+ }
+
+ @property (nonatomic, retain) id bar;
+ @end
+ ], [[
+ Foo *foo = (id)0;
+ [foo setBar: (id)0];
+ foo = [foo bar];
+ ]])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_ERROR(Compiler does not support properties!)
@@ -481,38 +483,40 @@
AC_MSG_CHECKING([whether -fobjc-runtime=objfw is supported])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Xclang -fobjc-runtime=objfw"
- AC_TRY_LINK([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Test
- + (void)test;
- @end
-
- @implementation Test
- + (void)test
- {
- }
- @end
-
- void *
- objc_msg_lookup(void *obj, void *sel)
- {
- return (void *)0;
- }
-
- void
- __objc_exec_class(void *module)
- {
- }
- ], [
- [Test test];
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Test
+ + (void)test;
+ @end
+
+ @implementation Test
+ + (void)test
+ {
+ }
+ @end
+
+ void *
+ objc_msg_lookup(void *obj, void *sel)
+ {
+ return (void *)0;
+ }
+
+ void
+ __objc_exec_class(void *module)
+ {
+ }
+ ], [[
+ [Test test];
+ ]])
], [
flag="-Xclang -fobjc-runtime=objfw"
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS $flag"
AC_MSG_RESULT(yes)
], [
@@ -561,18 +565,20 @@
AC_DEFINE(OF_SELUID24, 1,
[Whether to use 24 bit selector UIDs])
])
AC_MSG_CHECKING(for exception type)
- AC_TRY_COMPILE([
- extern void foo();
- ], [
- @try {
- foo();
- } @finally {
- foo();
- }
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ extern void foo();
+ ], [
+ @try {
+ foo();
+ } @finally {
+ foo();
+ }
+ ])
], [
AS_IF([$EGREP __gnu_objc_personality_v0 \
conftest.$ac_objext >/dev/null], [
exception_type="DWARF"
])
@@ -684,33 +690,35 @@
esac
AC_MSG_CHECKING(whether Objective C compiler supports ARC)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fobjc-arc -fobjc-arc-exceptions"
-AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
-
- + (id)alloc;
- @end
-
- @implementation Foo
- + (id)alloc
- {
- return (id)0;
- }
- @end
-], [
- __weak id foo = [Foo alloc];
- (void)foo;
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+
+ + (id)alloc;
+ @end
+
+ @implementation Foo
+ + (id)alloc
+ {
+ return (id)0;
+ }
+ @end
+ ], [[
+ __weak id foo = [Foo alloc];
+ (void)foo;
+ ]])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(COMPILER_SUPPORTS_ARC, 1, [Whether the compiler supports ARC])
AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m)
], [
@@ -806,13 +814,14 @@
[Floating point implementation does not conform to IEEE 754!])])
AC_MSG_CHECKING(for floating point endianess)
fp_endianess="unknown"
AS_IF([test x"$ac_cv_c_bigendian" != x"universal"], [
- AC_TRY_COMPILE([
- double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259;
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ double endianess = 2.993700760838795055656993580068609688772747263874402942272934826871811872228512759832626847251963763755836687759498519784550143745834860002945223766052808125982053455555265216112722718870586961456110693379343178124592311441022662940307099598578775368547768968914916965731708568179631324904813506101190853720749196062963892799499230635163056742330563321122389331703618066046034494287335316842529021563862331183541255013987734473643350285400060357711238514186776429325214739886098119655678483017894951556639821088508565036657794343031121375178126860889964700274558728491825977274341798997758923017217660272136611938897932105874133412726223468780517578125e-259;
+ ])
], [
AS_IF([$EGREP BigEnd conftest.$ac_objext >/dev/null], [
AC_DEFINE(OF_FLOAT_BIG_ENDIAN, 1,
[Whether floats are big endian])
fp_endianess="big endian"
@@ -829,25 +838,29 @@
AS_IF([test x"$fp_endianess" = x"unknown"], [
AC_MSG_ERROR(
[Floating point implementation does not conform to IEEE 754!])])
AC_MSG_CHECKING(for INFINITY)
-AC_TRY_COMPILE([
- #include
- #include
-], [
- printf("%f", INFINITY);
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ ], [
+ printf("%f", INFINITY);
+ ])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for __builtin_inf)
- AC_TRY_COMPILE([
- #include
- ], [
- printf("%f", __builtin_inf());
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ printf("%f", __builtin_inf());
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(INFINITY, [(__builtin_inf())],
[Workaround for missing INFINITY])
], [
@@ -858,17 +871,20 @@
])
case "$host_cpu" in
arm* | earm*)
AC_MSG_CHECKING(for VFP2 or above)
- AC_TRY_COMPILE([], [
- #if !defined(__arm64__) && !defined(__aarch64__) && \
- !defined(__ARM64_ARCH_8__)
- __asm__ __volatile__ (
- "vstmdb sp!, {d0-d7}"
- );
- #endif
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([], [
+ #if !defined(__arm64__) && \
+ !defined(__aarch64__) && \
+ !defined(__ARM64_ARCH_8__)
+ __asm__ __volatile__ (
+ "vstmdb sp!, {d0-d7}"
+ );
+ #endif
+ ])
], [
AC_DEFINE(HAVE_VFP2, 1, [Whether we have VFP2 or above])
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
@@ -912,39 +928,37 @@
AC_DEFUN([ENCODING_FLAG], [
AC_ARG_ENABLE($1,
AS_HELP_STRING([--disable-$1],
[Disables support for $3]))
AS_IF([test x"$enable_$2" != x"no"], [
- AC_DEFINE($4, 1,
- [Whether we have support for $3])
- ENCODINGS_SRCS="$ENCODINGS_SRCS $2.m"
+ AC_DEFINE($4, 1, [Whether we have support for $3])
+ ENCODINGS_SRCS="$ENCODINGS_SRCS $1.m"
])
])
ENCODING_FLAG(codepage-437, codepage_437, [Codepage 437], HAVE_CODEPAGE_437)
ENCODING_FLAG(codepage-850, codepage_850, [Codepage 850], HAVE_CODEPAGE_850)
ENCODING_FLAG(codepage-858, codepage_858, [Codepage 858], HAVE_CODEPAGE_858)
-ENCODING_FLAG(iso-8859-2, iso_8859-2, [ISO 8859-2], HAVE_ISO_8859_2)
-ENCODING_FLAG(iso-8859-3, iso_8859-3, [ISO 8859-3], HAVE_ISO_8859_3)
-ENCODING_FLAG(iso-8859-15, iso_8859-15, [ISO 8859-15], HAVE_ISO_8859_15)
-ENCODING_FLAG(koi8-r, koi8-r, [KOI8-R], HAVE_KOI8_R)
-ENCODING_FLAG(koi8-u, koi8-u, [KOI8-U], HAVE_KOI8_U)
+ENCODING_FLAG(iso-8859-2, iso_8859_2, [ISO 8859-2], HAVE_ISO_8859_2)
+ENCODING_FLAG(iso-8859-3, iso_8859_3, [ISO 8859-3], HAVE_ISO_8859_3)
+ENCODING_FLAG(iso-8859-15, iso_8859_15, [ISO 8859-15], HAVE_ISO_8859_15)
+ENCODING_FLAG(koi8-r, koi8_r, [KOI8-R], HAVE_KOI8_R)
+ENCODING_FLAG(koi8-u, koi8_u, [KOI8-U], HAVE_KOI8_U)
ENCODING_FLAG(mac-roman, mac_roman, [Mac Roman encoding], HAVE_MAC_ROMAN)
-ENCODING_FLAG(windows-1251, windows-1251, [Windows-1251], HAVE_WINDOWS_1251)
-ENCODING_FLAG(windows-1252, windows-1252, [Windows-1252], HAVE_WINDOWS_1252)
+ENCODING_FLAG(windows-1251, windows_1251, [Windows-1251], HAVE_WINDOWS_1251)
+ENCODING_FLAG(windows-1252, windows_1252, [Windows-1252], HAVE_WINDOWS_1252)
+AS_IF([test x"$ENCODINGS_SRCS" = x""], [
+ ENCODINGS_SRCS="dummy.m"
+])
AC_SUBST(ENCODINGS_SRCS)
-AS_IF([test x"$ENCODINGS_SRCS" != x""], [
- AC_SUBST(ENCODINGS, "encodings")
-
- AS_IF([test x"$enable_shared" != x"no"], [
- AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a")
- AC_SUBST(ENCODINGS_ENCODINGS_LIB_A, "encodings/encodings.lib.a")
- ])
- AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
- AC_SUBST(ENCODINGS_A, "encodings.a")
- AC_SUBST(ENCODINGS_ENCODINGS_A, "encodings/encodings.a")
- ])
+AS_IF([test x"$enable_shared" != x"no"], [
+ AC_SUBST(ENCODINGS_LIB_A, "encodings.lib.a")
+ AC_SUBST(ENCODINGS_ENCODINGS_LIB_A, "encodings/encodings.lib.a")
+])
+AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [
+ AC_SUBST(ENCODINGS_A, "encodings.a")
+ AC_SUBST(ENCODINGS_ENCODINGS_A, "encodings/encodings.a")
])
AC_CHECK_FUNCS(arc4random arc4random_buf getrandom random, break)
AS_IF([test x"$host_os" != x"morphos"], [
@@ -990,26 +1004,30 @@
CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE"
])
AC_CHECK_LIB(pthread, pthread_create, LIBS="$LIBS -lpthread")
- AC_TRY_LINK([
- #include
- ], [
- pthread_create(NULL, NULL, NULL, NULL);
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ pthread_create(NULL, NULL, NULL, NULL);
+ ])
], [], [
AC_MSG_ERROR(No supported threads found!)
])
AC_DEFINE(OF_HAVE_PTHREADS, 1, [Whether we have pthreads])
- AC_TRY_COMPILE([
- #include
- ], [
- pthread_mutexattr_t attr;
- pthread_mutexattr_settype(&attr,
- PTHREAD_MUTEX_RECURSIVE);
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_settype(&attr,
+ PTHREAD_MUTEX_RECURSIVE);
+ ])
], [
AC_DEFINE(OF_HAVE_RECURSIVE_PTHREAD_MUTEXES, 1,
[If pthread mutexes can be recursive])
])
@@ -1059,22 +1077,26 @@
AC_DEFINE(OF_HAVE_THREADS_H, 1,
[Whether we have threads.h])
])
AC_MSG_CHECKING(whether _Thread_local works)
- AC_TRY_LINK([
- static _Thread_local int x = 0;
- ], [
- x++;
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ static _Thread_local int x = 0;
+ ], [
+ x++;
+ ])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
- AC_TRY_COMPILE([
- static _Thread_local int x = 0;
- ], [
- x++;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ static _Thread_local int x = 0;
+ ], [
+ x++;
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE__THREAD_LOCAL, 1,
[Whether _Thread_local works])
have_thread_local="yes"
@@ -1092,27 +1114,33 @@
AC_MSG_RESULT(no)
])
AS_IF([test x"$have_thread_local" != x"yes"], [
AC_MSG_CHECKING(whether __thread works)
- AC_TRY_LINK([
- /* It seems __thread is buggy with GCC 4.1 */
- #if __GNUC__ == 4 && __GNUC_MINOR__ < 2
- # error buggy
- #endif
-
- __thread int x = 0;
- ], [
- x++;
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ /*
+ * It seems __thread is buggy with
+ * GCC 4.1 */
+ #if __GNUC__ == 4 && __GNUC_MINOR__ < 2
+ # error buggy
+ #endif
+
+ __thread int x = 0;
+ ], [
+ x++;
+ ])
], [
AS_IF([test x"$enable_shared" != x"no"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fPIC"
- AC_TRY_COMPILE([
- __thread int x = 0;
- ], [
- x++;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ __thread int x = 0;
+ ], [
+ x++;
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE___THREAD, 1,
[Whether __thread works]
)
@@ -1147,20 +1175,22 @@
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __atomic_* works)
- AC_TRY_LINK([
- #include
- #include
- ], [
- int32_t i, j;
- if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED))
- j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED);
- while (!__atomic_compare_exchange_n(&i, &j, 1, false,
- __ATOMIC_RELAXED, __ATOMIC_RELAXED));
- __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ ], [
+ int32_t i, j;
+ if (__atomic_add_fetch(&i, 1, __ATOMIC_RELAXED))
+ j = __atomic_sub_fetch(&i, 1, __ATOMIC_RELAXED);
+ while (!__atomic_compare_exchange_n(&i, &j, 1, false,
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED));
+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
+ ])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__atomic_* builtins"
AC_DEFINE(OF_HAVE_ATOMIC_BUILTINS, 1,
@@ -1168,15 +1198,19 @@
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(whether __sync_* works)
- AC_TRY_LINK([#include ], [
- int32_t i, j;
- if (__sync_add_and_fetch(&i, 1))
- j = __sync_sub_and_fetch(&i, 1);
- while (!__sync_bool_compare_and_swap(&i, 0, 1));
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ int32_t i, j;
+ if (__sync_add_and_fetch(&i, 1))
+ j = __sync_sub_and_fetch(&i, 1);
+ while (!__sync_bool_compare_and_swap(&i, 0, 1));
+ ])
], [
AC_MSG_RESULT(yes)
test x"$atomic_ops" = x"none" && \
atomic_ops="__sync_* builtins"
AC_DEFINE(OF_HAVE_SYNC_BUILTINS, 1,
@@ -1242,17 +1276,19 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Werror"
AC_MSG_CHECKING(for readdir_r)
- AC_TRY_COMPILE([
- #include
- ], [
- DIR *dir = 0;
- struct dirent entry, *result;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ DIR *dir = 0;
+ struct dirent entry, *result;
- readdir_r(dir, &entry, &result);
+ readdir_r(dir, &entry, &result);
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_READDIR_R, 1, [Whether we have readdir_r()])
], [
AC_MSG_RESULT(no)
@@ -1267,28 +1303,30 @@
AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l])
AS_IF([test x"$gnu_source" != x"yes" -a \( \
x"$ac_cv_func_strtod_l" = x"yes" -o x"$ac_cv_func_strtof_l" = x"yes" -o \
x"$ac_cv_func_asprintf_l" = x"yes" \)], [
AC_MSG_CHECKING(whether *_l functions need _GNU_SOURCE)
- AC_TRY_COMPILE([
- #include
- #include
-
- #include
- #ifdef HAVE_XLOCALE_H
- # include
- #endif
- ], [
- #ifdef HAVE_STRTOD_L
- (void)strtod_l;
- #endif
- #ifdef HAVE_STRTOF_L
- (void)strtof_l;
- #endif
- #ifdef HAVE_ASPRINTF_L
- (void)asprintf_l;
- #endif
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+
+ #include
+ #ifdef HAVE_XLOCALE_H
+ # include
+ #endif
+ ], [
+ #ifdef HAVE_STRTOD_L
+ (void)strtod_l;
+ #endif
+ #ifdef HAVE_STRTOF_L
+ (void)strtof_l;
+ #endif
+ #ifdef HAVE_ASPRINTF_L
+ (void)asprintf_l;
+ #endif
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
@@ -1297,17 +1335,19 @@
dnl This check needs to happen after the above, as _GNU_SOURCE can change the
dnl return type.
AC_CHECK_FUNCS(strerror_r, [
AC_MSG_CHECKING(for return type of strerror_r)
- AC_TRY_COMPILE([
- #include
- #include
- ], [
- switch (strerror_r(0, NULL, 0)) {
- case 0:;
- }
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ ], [
+ switch (strerror_r(0, NULL, 0)) {
+ case 0:;
+ }
+ ])
], [
AC_MSG_RESULT(int)
], [
AC_MSG_RESULT(char *)
AC_DEFINE(STRERROR_R_RETURNS_CHARP, 1,
@@ -1537,17 +1577,19 @@
])
])
AC_DEFUN([CHECK_BUILTIN_BSWAP], [
AC_MSG_CHECKING(for __builtin_bswap$1)
- AC_TRY_LINK([
- #include
- #include
- #include
- ], [
- uint$1_t i = errno;
- printf("%d", (int)__builtin_bswap$1(i));
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ #include
+ #include
+ ], [
+ uint$1_t i = errno;
+ printf("%d", (int)__builtin_bswap$1(i));
+ ])
], [
AC_MSG_RESULT(yes)
AC_DEFINE(OF_HAVE_BUILTIN_BSWAP$1, 1,
[Whether we have __builtin_bswap$1])
], [
@@ -1562,11 +1604,14 @@
darwin*)
AC_MSG_CHECKING(whether we are compiling for macOS)
AC_EGREP_CPP(egrep_cpp_yes, [
#include
- #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+ #if (!defined(TARGET_OS_IPHONE) || \
+ !TARGET_OS_IPHONE) && \
+ (!defined(TARGET_OS_SIMULATOR) || \
+ !TARGET_OS_SIMULATOR)
egrep_cpp_yes
#endif
], [
AC_MSG_RESULT(yes)
have_processes="yes"
@@ -1643,13 +1688,15 @@
dnl which in old glibc versions uses __block. This is worked around in the code
dnl by providing a wrapper for unistd.h which takes care of this.
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Xclang -fblocks"
-AC_TRY_COMPILE([], [
- int (^foo)(int bar);
- foo = ^ (int bar) { return 0; }
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([], [
+ int (^foo)(int bar);
+ foo = ^ (int bar) { return 0; }
+ ])
], [
OBJFW_OBJCFLAGS="$OBJFW_OBJCFLAGS -Xclang -fblocks"
AC_SUBST(OF_BLOCK_TESTS_M, "OFBlockTests.m")
AC_MSG_RESULT(yes)
], [
@@ -1659,63 +1706,66 @@
AS_IF([test x"$GOBJC" = x"yes"], [
OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror"
AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
- @end
-
- static struct {
- struct objc_class *_isa;
- } object;
- ], [
- Foo *test = (Foo *)&object;
- (void)test; /* Get rid of unused variable warning */
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+ @end
+
+ static struct {
+ struct objc_class *_isa;
+ } object;
+ ], [
+ Foo *test = (Foo *)&object;
+ (void)test; /* Get rid of unused variable warning */
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-strict-aliasing"
])
AC_MSG_CHECKING(
whether we need -Wno-unused-property-ivar due to Clang bugs)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- Foo *_foo;
- }
-
- @property (readonly, nonatomic) Foo *foo;
-
- + (Foo *)foo;
- @end
-
- @implementation Foo
- @synthesize foo = _foo;
-
- + (Foo *)foo
- {
- return (Foo *)0;
- }
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ Foo *_foo;
+ }
+
+ @property (readonly, nonatomic) Foo *foo;
+
+ + (Foo *)foo;
+ @end
+
+ @implementation Foo
+ @synthesize foo = _foo;
+
+ + (Foo *)foo
+ {
+ return (Foo *)0;
+ }
+ @end
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-unused-property-ivar"
@@ -1722,30 +1772,31 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wcast-align"
AC_MSG_CHECKING(whether -Wcast-align is buggy)
- AC_TRY_COMPILE([
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- struct objc_class *_isa;
- }
- @end
-
- @implementation Foo
- - (void)foo
- {
- struct objc_class *c = _isa;
- (void)c;
- }
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ struct objc_class *_isa;
+ }
+ @end
+
+ @implementation Foo
+ - (void)foo
+ {
+ struct objc_class *c = _isa;
+ (void)c;
+ }
+ @end
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
@@ -1752,93 +1803,97 @@
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wunreachable-code"
AC_MSG_CHECKING(whether -Wunreachable-code can be used)
- AC_TRY_COMPILE([
- #include
-
- typedef void *SEL;
-
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Object
- - (void)doesNotRecognizeSelector: (SEL)selector
- #ifdef __clang__
- __attribute__((__noreturn__))
- #endif
- ;
- - (void)dealloc;
- @end
-
- @interface Foo: Object
- @end
-
- void
- test(void)
- {
- if (sizeof(int) == 4)
- __asm__ ("");
- else if (sizeof(int) == 8)
- __asm__ ("");
- else
- abort();
- }
-
- /*
- * Unfortunately, this cannot be shorter, as it only works when
- * it is used inside a macro.
- */
- #ifdef __clang__
- # define OF_DEALLOC_UNSUPPORTED \
- [self doesNotRecognizeSelector: _cmd]; \
- \
- abort(); \
- \
- _Pragma("clang diagnostic push ignore \"-Wunreachable-code\""); \
- [super dealloc]; \
- _Pragma("clang diagnostic pop");
- #else
- # define OF_DEALLOC_UNSUPPORTED \
- [self doesNotRecognizeSelector: _cmd]; \
- \
- abort(); \
- \
- [super dealloc];
- #endif
-
- @implementation Foo
- - (void)dealloc
- {
- OF_DEALLOC_UNSUPPORTED
- }
- @end
- ], [], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+ #include
+
+ typedef void *SEL;
+
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Object
+ - (void)doesNotRecognizeSelector: (SEL)selector
+ #ifdef __clang__
+ __attribute__((__noreturn__))
+ #endif
+ ;
+ - (void)dealloc;
+ @end
+
+ @interface Foo: Object
+ @end
+
+ void
+ test(void)
+ {
+ if (sizeof(int) == 4)
+ __asm__ ("");
+ else if (sizeof(int) == 8)
+ __asm__ ("");
+ else
+ abort();
+ }
+
+ /*
+ * Unfortunately, this cannot be shorter, as it only
+ * works when it is used inside a macro.
+ */
+ #ifdef __clang__
+ # define OF_DEALLOC_UNSUPPORTED \
+ [self doesNotRecognizeSelector: _cmd]; \
+ \
+ abort(); \
+ \
+ _Pragma("clang diagnostic push ignore \
+ \"-Wunreachable-code\""); \
+ [super dealloc]; \
+ _Pragma("clang diagnostic pop");
+ #else
+ # define OF_DEALLOC_UNSUPPORTED \
+ [self doesNotRecognizeSelector: _cmd]; \
+ \
+ abort(); \
+ \
+ [super dealloc];
+ #endif
+
+ @implementation Foo
+ - (void)dealloc
+ {
+ OF_DEALLOC_UNSUPPORTED
+ }
+ @end
+ ]])
+ ], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
])
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -Wdocumentation"
AC_MSG_CHECKING(whether -Wdocumentation works correctly)
- AC_TRY_COMPILE([
- /**
- * @class Test conftest.m conftest.m
- */
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Test
- @end
- ], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ /**
+ * @class Test conftest.m conftest.m
+ */
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Test
+ @end
+ ])
], [
AC_MSG_RESULT(yes)
], [
AC_MSG_RESULT(no)
OBJCFLAGS="$old_OBJCFLAGS"
@@ -1846,55 +1901,59 @@
AS_IF([test x"$check_pedantic" = x"yes"], [
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -pedantic"
AC_MSG_CHECKING(whether -pedantic is buggy)
- AC_TRY_COMPILE([
- #include
-
- #include
-
- #ifdef __has_attribute
- # if __has_attribute(objc_root_class)
- __attribute__((__objc_root_class__))
- # endif
- #endif
- @interface Foo
- {
- void *foo;
- }
- @end
-
- @interface Bar: Foo
- - (void)assert;
- @end
-
- @implementation Bar
- - (void)assert
- {
- /*
- * Some versions of glibc break with -pedantic
- * when using assert.
- */
- assert(1);
- }
- @end
- ], [], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([
+ #include
+
+ #include
+
+ #ifdef __has_attribute
+ # if __has_attribute(objc_root_class)
+ __attribute__((__objc_root_class__))
+ # endif
+ #endif
+ @interface Foo
+ {
+ void *foo;
+ }
+ @end
+
+ @interface Bar: Foo
+ - (void)assert;
+ @end
+
+ @implementation Bar
+ - (void)assert
+ {
+ /*
+ * Some versions of glibc break with
+ * -pedantic when using assert.
+ */
+ assert(1);
+ }
+ @end
+ ])
+ ], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$old_OBJCFLAGS"
])
])
AS_IF([test x"$ac_cv_header_complex_h" = x"yes"], [
AC_MSG_CHECKING(whether we need -Wno-gnu-imaginary-constant)
- AC_TRY_COMPILE([
- #include
- ], [
- complex float f = 0.5 + 0.5 * I;
- (void)f;
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include
+ ], [
+ complex float f = 0.5 + 0.5 * I;
+ (void)f;
+ ])
], [
AC_MSG_RESULT(no)
], [
AC_MSG_RESULT(yes)
OBJCFLAGS="$OBJCFLAGS -Wno-gnu-imaginary-constant"
Index: extra.mk.in
==================================================================
--- extra.mk.in
+++ extra.mk.in
@@ -18,11 +18,10 @@
OBJFWBRIDGE_FRAMEWORK = @OBJFWBRIDGE_FRAMEWORK@
BIN_PREFIX = @BIN_PREFIX@
BRIDGE = @BRIDGE@
CVINCLUDE_INLINE_H = @CVINCLUDE_INLINE_H@
-ENCODINGS = @ENCODINGS@
ENCODINGS_A = @ENCODINGS_A@
ENCODINGS_LIB_A = @ENCODINGS_LIB_A@
ENCODINGS_SRCS = @ENCODINGS_SRCS@
EXCEPTIONS_A = @EXCEPTIONS_A@
EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@
Index: src/Makefile
==================================================================
--- src/Makefile
+++ src/Makefile
@@ -1,8 +1,8 @@
include ../extra.mk
-SUBDIRS = ${RUNTIME} exceptions ${ENCODINGS} forwarding
+SUBDIRS = ${RUNTIME} exceptions encodings forwarding
SUBDIRS_AFTER = ${BRIDGE}
DISTCLEAN = Info.plist objfw-defs.h
SHARED_LIB = ${OBJFW_SHARED_LIB}
STATIC_LIB = ${OBJFW_STATIC_LIB}
Index: src/OFApplication.m
==================================================================
--- src/OFApplication.m
+++ src/OFApplication.m
@@ -94,11 +94,12 @@
if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
[delegate applicationWillTerminate];
[delegate release];
-#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \
+ defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
of_socket_deinit();
#endif
}
int
Index: src/OFOptionsParser.m
==================================================================
--- src/OFOptionsParser.m
+++ src/OFOptionsParser.m
@@ -140,21 +140,19 @@
return self;
}
- (void)dealloc
{
- of_options_parser_option_t *iter;
+ if (_options != NULL)
+ for (of_options_parser_option_t *iter = _options;
+ iter->shortOption != '\0' || iter->longOption != nil;
+ iter++)
+ [iter->longOption release];
free(_options);
[_longOptions release];
- if (_options != NULL)
- for (iter = _options;
- iter->shortOption != '\0' || iter->longOption != nil;
- iter++)
- [iter->longOption release];
-
[_arguments release];
[_argument release];
[super dealloc];
}
Index: src/OFSelectKernelEventObserver.m
==================================================================
--- src/OFSelectKernelEventObserver.m
+++ src/OFSelectKernelEventObserver.m
@@ -52,11 +52,11 @@
@try {
FD_ZERO(&_readFDs);
FD_ZERO(&_writeFDs);
#ifdef OF_AMIGAOS
- _maxFD = 0;
+ _maxFD = -1;
#else
# ifndef OF_WINDOWS
if (_cancelFD[0] >= (int)FD_SETSIZE)
@throw [OFInitializationFailedException
exceptionWithClass: self.class];
Index: src/OFSystemInfo.m
==================================================================
--- src/OFSystemInfo.m
+++ src/OFSystemInfo.m
@@ -242,17 +242,17 @@
static OF_INLINE struct x86_regs OF_CONST_FUNC
x86_cpuid(uint32_t eax, uint32_t ecx)
{
struct x86_regs regs;
-# if defined(OF_X86_64_ASM)
+# if defined(OF_X86_64) && defined(__GNUC__)
__asm__ (
"cpuid"
: "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
: "a"(eax), "c"(ecx)
);
-# elif defined(OF_X86_ASM)
+# elif defined(OF_X86) && defined(__GNUC__)
/*
* This workaround is required by older GCC versions when using -fPIC,
* as ebx is a special register in PIC code. Yes, GCC is indeed not
* able to just push a register onto the stack before the __asm__ block
* and to pop it afterwards.
@@ -530,11 +530,11 @@
}
#endif
+ (OFString *)CPUVendor
{
-#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
+#if (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
struct x86_regs regs = x86_cpuid(0, 0);
uint32_t buffer[3];
if (regs.eax == 0)
return nil;
@@ -551,11 +551,11 @@
#endif
}
+ (OFString *)CPUModel
{
-#if defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
+#if (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
uint32_t buffer[12];
size_t i;
i = 0;
for (uint32_t eax = 0x80000002; eax <= 0x80000004; eax++) {
Index: src/OFThread.m
==================================================================
--- src/OFThread.m
+++ src/OFThread.m
@@ -144,11 +144,11 @@
objc_autoreleasePoolPop((void *)(uintptr_t)-1);
#else
objc_autoreleasePoolPop(thread->_pool);
#endif
-#if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS)
+#if defined(OF_AMIGAOS) && !defined(OF_MORPHOS) && defined(OF_HAVE_SOCKETS)
if (thread.supportsSockets)
of_socket_deinit();
#endif
thread->_running = OF_THREAD_WAITING_FOR_JOIN;
Index: src/atomic.h
==================================================================
--- src/atomic.h
+++ src/atomic.h
@@ -23,13 +23,14 @@
# error No atomic operations available!
#endif
#if !defined(OF_HAVE_THREADS)
# import "atomic_no_threads.h"
-#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
+#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
# import "atomic_x86.h"
-#elif defined(OF_POWERPC_ASM) && !defined(__APPLE_CC__) && !defined(OF_AIX)
+#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
+ !defined(OF_AIX)
# import "atomic_powerpc.h"
#elif defined(OF_HAVE_ATOMIC_BUILTINS)
# import "atomic_builtins.h"
#elif defined(OF_HAVE_SYNC_BUILTINS)
# import "atomic_sync_builtins.h"
Index: src/atomic_x86.h
==================================================================
--- src/atomic_x86.h
+++ src/atomic_x86.h
@@ -26,11 +26,11 @@
"xaddl %0, %2\n\t"
"addl %1, %0"
: "+&r"(i)
: "r"(i), "m"(*p)
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"lock\n\t"
"xaddq %0, %2\n\t"
"addq %1, %0"
@@ -59,21 +59,21 @@
}
static OF_INLINE void *_Nullable
of_atomic_ptr_add(void *volatile _Nullable *_Nonnull p, intptr_t i)
{
-#if defined(OF_X86_64_ASM)
+#if defined(OF_X86_64)
__asm__ __volatile__ (
"lock\n\t"
"xaddq %0, %2\n\t"
"addq %1, %0"
: "+&r"(i)
: "r"(i), "m"(*p)
);
return (void *)i;
-#elif defined(OF_X86_ASM)
+#elif defined(OF_X86)
__asm__ __volatile__ (
"lock\n\t"
"xaddl %0, %2\n\t"
"addl %1, %0"
: "+&r"(i)
@@ -94,11 +94,11 @@
"xaddl %0, %2\n\t"
"subl %1, %0"
: "+&r"(i)
: "r"(i), "m"(*p)
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"negq %0\n\t"
"lock\n\t"
"xaddq %0, %2\n\t"
@@ -129,11 +129,11 @@
}
static OF_INLINE void *_Nullable
of_atomic_ptr_sub(void *volatile _Nullable *_Nonnull p, intptr_t i)
{
-#if defined(OF_X86_64_ASM)
+#if defined(OF_X86_64)
__asm__ __volatile__ (
"negq %0\n\t"
"lock\n\t"
"xaddq %0, %2\n\t"
"subq %1, %0"
@@ -140,11 +140,11 @@
: "+&r"(i)
: "r"(i), "m"(*p)
);
return (void *)i;
-#elif defined(OF_X86_ASM)
+#elif defined(OF_X86)
__asm__ __volatile__ (
"negl %0\n\t"
"lock\n\t"
"xaddl %0, %2\n\t"
"subl %1, %0"
@@ -169,11 +169,11 @@
"xaddl %0, %1\n\t"
"incl %0"
: "=&r"(i)
: "m"(*p)
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"xorq %0, %0\n\t"
"incq %0\n\t"
"lock\n\t"
@@ -220,11 +220,11 @@
"xaddl %0, %1\n\t"
"decl %0"
: "=&r"(i)
: "m"(*p)
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"xorq %0, %0\n\t"
"decq %0\n\t"
"lock\n\t"
@@ -272,11 +272,11 @@
"jne 0b"
: "=&r"(i)
: "r"(i), "m"(*p)
: "eax", "cc"
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"0:\n\t"
"movq %2, %0\n\t"
"movq %0, %%rax\n\t"
@@ -328,11 +328,11 @@
"jne 0b"
: "=&r"(i)
: "r"(i), "m"(*p)
: "eax", "cc"
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"0:\n\t"
"movq %2, %0\n\t"
"movq %0, %%rax\n\t"
@@ -384,11 +384,11 @@
"jne 0b"
: "=&r"(i)
: "r"(i), "m"(*p)
: "eax", "cc"
);
-#ifdef OF_X86_64_ASM
+#ifdef OF_X86_64
else if (sizeof(int) == 8)
__asm__ __volatile__ (
"0:\n\t"
"movq %2, %0\n\t"
"movq %0, %%rax\n\t"
ADDED src/encodings/codepage-437.m
Index: src/encodings/codepage-437.m
==================================================================
--- src/encodings/codepage-437.m
+++ src/encodings/codepage-437.m
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_codepage_437_table[] = {
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
+ 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
+ 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
+ 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
+ 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
+ 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
+};
+const size_t of_codepage_437_table_offset =
+ 256 - (sizeof(of_codepage_437_table) / sizeof(*of_codepage_437_table));
+
+static const unsigned char page0[] = {
+ 0xFF, 0xAD, 0x9B, 0x9C, 0x00, 0x9D, 0x00, 0x00,
+ 0x00, 0x00, 0xA6, 0xAE, 0xAA, 0x00, 0x00, 0x00,
+ 0xF8, 0xF1, 0xFD, 0x00, 0x00, 0xE6, 0x00, 0xFA,
+ 0x00, 0x00, 0xA7, 0xAF, 0xAC, 0xAB, 0x00, 0xA8,
+ 0x00, 0x00, 0x00, 0x00, 0x8E, 0x8F, 0x92, 0x80,
+ 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x9A, 0x00, 0x00, 0xE1,
+ 0x85, 0xA0, 0x83, 0x00, 0x84, 0x86, 0x91, 0x87,
+ 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
+ 0x00, 0xA4, 0x95, 0xA2, 0x93, 0x00, 0x94, 0xF6,
+ 0x00, 0x97, 0xA3, 0x96, 0x81, 0x00, 0x00, 0x98
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0x9F
+};
+static const uint8_t page1Start = 0x92;
+
+static const unsigned char page3[] = {
+ 0xE2, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xE4, 0x00, 0x00, 0xE8, 0x00, 0x00, 0xEA, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00,
+ 0x00, 0xEB, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0x00, 0x00,
+ 0xE5, 0xE7, 0x00, 0xED
+};
+static const uint8_t page3Start = 0x93;
+
+static const unsigned char page20[] = {
+ 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x9E
+};
+static const uint8_t page20Start = 0x7F;
+
+static const unsigned char page22[] = {
+ 0xF9, 0xFB, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xF0, 0x00, 0x00, 0xF3, 0xF2
+};
+static const uint8_t page22Start = 0x19;
+
+static const unsigned char page23[] = {
+ 0xA9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xF4, 0xF5
+};
+static const uint8_t page23Start = 0x10;
+
+static const unsigned char page25[] = {
+ 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
+ 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+ 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xCD, 0xBA, 0xD5, 0xD6, 0xC9, 0xB8, 0xB7, 0xBB,
+ 0xD4, 0xD3, 0xC8, 0xBE, 0xBD, 0xBC, 0xC6, 0xC7,
+ 0xCC, 0xB5, 0xB6, 0xB9, 0xD1, 0xD2, 0xCB, 0xCF,
+ 0xD0, 0xCA, 0xD8, 0xD7, 0xCE, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
+ 0xDB, 0x00, 0x00, 0x00, 0xDD, 0x00, 0x00, 0x00,
+ 0xDE, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFE
+};
+static const uint8_t page25Start = 0x00;
+
+bool
+of_unicode_to_codepage_437(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_ERROR(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(3)
+ CASE_MISSING_IS_ERROR(20)
+ CASE_MISSING_IS_ERROR(22)
+ CASE_MISSING_IS_ERROR(23)
+ CASE_MISSING_IS_ERROR(25)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
ADDED src/encodings/codepage-850.m
Index: src/encodings/codepage-850.m
==================================================================
--- src/encodings/codepage-850.m
+++ src/encodings/codepage-850.m
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_codepage_850_table[] = {
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+ 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
+ 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
+ 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
+ 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+ 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
+};
+const size_t of_codepage_850_table_offset =
+ 256 - (sizeof(of_codepage_850_table) / sizeof(*of_codepage_850_table));
+
+
+static const unsigned char page0[] = {
+ 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
+ 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
+ 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
+ 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
+ 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
+ 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8,
+ 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E,
+ 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1,
+ 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87,
+ 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
+ 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6,
+ 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0xD5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x9F
+};
+static const uint8_t page1Start = 0x31;
+
+static const unsigned char page20[] = {
+ 0xF2
+};
+static const uint8_t page20Start = 0x17;
+
+static const unsigned char page25[] = {
+ 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
+ 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+ 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xCD, 0xBA, 0x00, 0x00, 0xC9, 0x00, 0x00, 0xBB,
+ 0x00, 0x00, 0xC8, 0x00, 0x00, 0xBC, 0x00, 0x00,
+ 0xCC, 0x00, 0x00, 0xB9, 0x00, 0x00, 0xCB, 0x00,
+ 0x00, 0xCA, 0x00, 0x00, 0xCE, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
+ 0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFE
+};
+static const uint8_t page25Start = 0x00;
+
+bool
+of_unicode_to_codepage_850(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_ERROR(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(20)
+ CASE_MISSING_IS_ERROR(25)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
ADDED src/encodings/codepage-858.m
Index: src/encodings/codepage-858.m
==================================================================
--- src/encodings/codepage-858.m
+++ src/encodings/codepage-858.m
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_codepage_858_table[] = {
+ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
+ 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
+ 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
+ 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
+ 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
+ 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
+ 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
+ 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
+ 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
+ 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
+ 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
+ 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
+ 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
+ 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
+ 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
+};
+const size_t of_codepage_858_table_offset =
+ 256 - (sizeof(of_codepage_858_table) / sizeof(*of_codepage_858_table));
+
+
+static const unsigned char page0[] = {
+ 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
+ 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
+ 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
+ 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
+ 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
+ 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8,
+ 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E,
+ 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1,
+ 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87,
+ 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
+ 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6,
+ 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0x9F
+};
+static const uint8_t page1Start = 0x92;
+
+static const unsigned char page20[] = {
+ 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5
+};
+static const uint8_t page20Start = 0x17;
+
+static const unsigned char page25[] = {
+ 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
+ 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+ 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xCD, 0xBA, 0x00, 0x00, 0xC9, 0x00, 0x00, 0xBB,
+ 0x00, 0x00, 0xC8, 0x00, 0x00, 0xBC, 0x00, 0x00,
+ 0xCC, 0x00, 0x00, 0xB9, 0x00, 0x00, 0xCB, 0x00,
+ 0x00, 0xCA, 0x00, 0x00, 0xCE, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
+ 0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFE
+};
+static const uint8_t page25Start = 0x00;
+
+bool
+of_unicode_to_codepage_858(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_ERROR(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(20)
+ CASE_MISSING_IS_ERROR(25)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
DELETED src/encodings/codepage_437.m
Index: src/encodings/codepage_437.m
==================================================================
--- src/encodings/codepage_437.m
+++ src/encodings/codepage_437.m
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_codepage_437_table[] = {
- 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
- 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
- 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
- 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
- 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
- 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
- 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
- 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
- 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
- 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
- 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
- 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
- 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
-};
-const size_t of_codepage_437_table_offset =
- 256 - (sizeof(of_codepage_437_table) / sizeof(*of_codepage_437_table));
-
-static const unsigned char page0[] = {
- 0xFF, 0xAD, 0x9B, 0x9C, 0x00, 0x9D, 0x00, 0x00,
- 0x00, 0x00, 0xA6, 0xAE, 0xAA, 0x00, 0x00, 0x00,
- 0xF8, 0xF1, 0xFD, 0x00, 0x00, 0xE6, 0x00, 0xFA,
- 0x00, 0x00, 0xA7, 0xAF, 0xAC, 0xAB, 0x00, 0xA8,
- 0x00, 0x00, 0x00, 0x00, 0x8E, 0x8F, 0x92, 0x80,
- 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x9A, 0x00, 0x00, 0xE1,
- 0x85, 0xA0, 0x83, 0x00, 0x84, 0x86, 0x91, 0x87,
- 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
- 0x00, 0xA4, 0x95, 0xA2, 0x93, 0x00, 0x94, 0xF6,
- 0x00, 0x97, 0xA3, 0x96, 0x81, 0x00, 0x00, 0x98
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0x9F
-};
-static const uint8_t page1Start = 0x92;
-
-static const unsigned char page3[] = {
- 0xE2, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xE4, 0x00, 0x00, 0xE8, 0x00, 0x00, 0xEA, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00,
- 0x00, 0xEB, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0x00, 0x00,
- 0xE5, 0xE7, 0x00, 0xED
-};
-static const uint8_t page3Start = 0x93;
-
-static const unsigned char page20[] = {
- 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9E
-};
-static const uint8_t page20Start = 0x7F;
-
-static const unsigned char page22[] = {
- 0xF9, 0xFB, 0x00, 0x00, 0x00, 0xEC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xF0, 0x00, 0x00, 0xF3, 0xF2
-};
-static const uint8_t page22Start = 0x19;
-
-static const unsigned char page23[] = {
- 0xA9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xF4, 0xF5
-};
-static const uint8_t page23Start = 0x10;
-
-static const unsigned char page25[] = {
- 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
- 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
- 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xCD, 0xBA, 0xD5, 0xD6, 0xC9, 0xB8, 0xB7, 0xBB,
- 0xD4, 0xD3, 0xC8, 0xBE, 0xBD, 0xBC, 0xC6, 0xC7,
- 0xCC, 0xB5, 0xB6, 0xB9, 0xD1, 0xD2, 0xCB, 0xCF,
- 0xD0, 0xCA, 0xD8, 0xD7, 0xCE, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
- 0xDB, 0x00, 0x00, 0x00, 0xDD, 0x00, 0x00, 0x00,
- 0xDE, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFE
-};
-static const uint8_t page25Start = 0x00;
-
-bool
-of_unicode_to_codepage_437(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_ERROR(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(3)
- CASE_MISSING_IS_ERROR(20)
- CASE_MISSING_IS_ERROR(22)
- CASE_MISSING_IS_ERROR(23)
- CASE_MISSING_IS_ERROR(25)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
DELETED src/encodings/codepage_850.m
Index: src/encodings/codepage_850.m
==================================================================
--- src/encodings/codepage_850.m
+++ src/encodings/codepage_850.m
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_codepage_850_table[] = {
- 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
- 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
- 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
- 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
- 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
- 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
- 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
- 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
- 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
- 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
- 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
- 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
- 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
-};
-const size_t of_codepage_850_table_offset =
- 256 - (sizeof(of_codepage_850_table) / sizeof(*of_codepage_850_table));
-
-
-static const unsigned char page0[] = {
- 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
- 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
- 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
- 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
- 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
- 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8,
- 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E,
- 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1,
- 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87,
- 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
- 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6,
- 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0xD5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x9F
-};
-static const uint8_t page1Start = 0x31;
-
-static const unsigned char page20[] = {
- 0xF2
-};
-static const uint8_t page20Start = 0x17;
-
-static const unsigned char page25[] = {
- 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
- 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
- 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xCD, 0xBA, 0x00, 0x00, 0xC9, 0x00, 0x00, 0xBB,
- 0x00, 0x00, 0xC8, 0x00, 0x00, 0xBC, 0x00, 0x00,
- 0xCC, 0x00, 0x00, 0xB9, 0x00, 0x00, 0xCB, 0x00,
- 0x00, 0xCA, 0x00, 0x00, 0xCE, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
- 0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFE
-};
-static const uint8_t page25Start = 0x00;
-
-bool
-of_unicode_to_codepage_850(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_ERROR(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(20)
- CASE_MISSING_IS_ERROR(25)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
DELETED src/encodings/codepage_858.m
Index: src/encodings/codepage_858.m
==================================================================
--- src/encodings/codepage_858.m
+++ src/encodings/codepage_858.m
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_codepage_858_table[] = {
- 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
- 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
- 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
- 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
- 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
- 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
- 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
- 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
- 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
- 0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x20AC, 0x00CD, 0x00CE,
- 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
- 0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
- 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
- 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
- 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
-};
-const size_t of_codepage_858_table_offset =
- 256 - (sizeof(of_codepage_858_table) / sizeof(*of_codepage_858_table));
-
-
-static const unsigned char page0[] = {
- 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5,
- 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE,
- 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA,
- 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8,
- 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80,
- 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8,
- 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E,
- 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1,
- 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87,
- 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B,
- 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6,
- 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0x9F
-};
-static const uint8_t page1Start = 0x92;
-
-static const unsigned char page20[] = {
- 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5
-};
-static const uint8_t page20Start = 0x17;
-
-static const unsigned char page25[] = {
- 0xC4, 0x00, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xDA, 0x00, 0x00, 0x00,
- 0xBF, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
- 0xD9, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC1, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xCD, 0xBA, 0x00, 0x00, 0xC9, 0x00, 0x00, 0xBB,
- 0x00, 0x00, 0xC8, 0x00, 0x00, 0xBC, 0x00, 0x00,
- 0xCC, 0x00, 0x00, 0xB9, 0x00, 0x00, 0xCB, 0x00,
- 0x00, 0xCA, 0x00, 0x00, 0xCE, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xDF, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00,
- 0xDB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xB0, 0xB1, 0xB2, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xFE
-};
-static const uint8_t page25Start = 0x00;
-
-bool
-of_unicode_to_codepage_858(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_ERROR(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(20)
- CASE_MISSING_IS_ERROR(25)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
ADDED src/encodings/iso-8859-15.m
Index: src/encodings/iso-8859-15.m
==================================================================
--- src/encodings/iso-8859-15.m
+++ src/encodings/iso-8859-15.m
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_iso_8859_15_table[] = {
+ 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7,
+ 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
+ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7,
+ 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF,
+ 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
+};
+const size_t of_iso_8859_15_table_offset =
+ 256 - (sizeof(of_iso_8859_15_table) / sizeof(*of_iso_8859_15_table));
+
+static const unsigned char page0[] = {
+ 0x00, 0xA5, 0x00, 0xA7, 0x00, 0xA9, 0xAA, 0xAB,
+ 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
+ 0x00, 0xB5, 0xB6, 0xB7, 0x00, 0xB9, 0xBA, 0xBB,
+ 0x00, 0x00, 0x00
+};
+static const uint8_t page0Start = 0xA4;
+
+static const unsigned char page1[] = {
+ 0xBC, 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA6, 0xA8,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0x00,
+ 0x00, 0x00, 0x00, 0xB4, 0xB8
+};
+static const uint8_t page1Start = 0x52;
+
+static const unsigned char page20[] = {
+ 0xA4
+};
+static const uint8_t page20Start = 0xAC;
+
+bool
+of_unicode_to_iso_8859_15(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_KEEP(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(20)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
ADDED src/encodings/iso-8859-2.m
Index: src/encodings/iso-8859-2.m
==================================================================
--- src/encodings/iso-8859-2.m
+++ src/encodings/iso-8859-2.m
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_iso_8859_2_table[] = {
+ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
+ 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
+ 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
+ 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
+ 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+ 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+ 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+ 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
+};
+const size_t of_iso_8859_2_table_offset =
+ 256 - (sizeof(of_iso_8859_2_table) / sizeof(*of_iso_8859_2_table));
+
+static const unsigned char page0[] = {
+ 0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0xA7,
+ 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
+ 0xB0, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
+ 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
+ 0x00, 0xC9, 0x00, 0xCB, 0x00, 0xCD, 0xCE, 0x00,
+ 0x00, 0x00, 0x00, 0xD3, 0xD4, 0x00, 0xD6, 0xD7,
+ 0x00, 0x00, 0xDA, 0x00, 0xDC, 0xDD, 0x00, 0xDF,
+ 0x00, 0xE1, 0xE2, 0x00, 0xE4, 0x00, 0x00, 0xE7,
+ 0x00, 0xE9, 0x00, 0xEB, 0x00, 0xED, 0xEE, 0x00,
+ 0x00, 0x00, 0x00, 0xF3, 0xF4, 0x00, 0xF6, 0xF7,
+ 0x00, 0x00, 0xFA, 0x00, 0xFC, 0xFD, 0x00, 0x00
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0xC3, 0xE3, 0xA1, 0xB1, 0xC6, 0xE6, 0x00, 0x00,
+ 0x00, 0x00, 0xC8, 0xE8, 0xCF, 0xEF, 0xD0, 0xF0,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCA, 0xEA,
+ 0xCC, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC5,
+ 0xE5, 0x00, 0x00, 0xA5, 0xB5, 0x00, 0x00, 0xA3,
+ 0xB3, 0xD1, 0xF1, 0x00, 0x00, 0xD2, 0xF2, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0xF5,
+ 0x00, 0x00, 0xC0, 0xE0, 0x00, 0x00, 0xD8, 0xF8,
+ 0xA6, 0xB6, 0x00, 0x00, 0xAA, 0xBA, 0xA9, 0xB9,
+ 0xDE, 0xFE, 0xAB, 0xBB, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xD9, 0xF9, 0xDB, 0xFB,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC,
+ 0xBC, 0xAF, 0xBF, 0xAE, 0xBE
+};
+static const uint8_t page1Start = 0x02;
+
+static const unsigned char page2[] = {
+ 0xB7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xA2, 0xFF, 0x00, 0xB2, 0x00, 0xBD
+};
+static const uint8_t page2Start = 0xC7;
+
+bool
+of_unicode_to_iso_8859_2(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_KEEP(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(2)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
ADDED src/encodings/iso-8859-3.m
Index: src/encodings/iso-8859-3.m
==================================================================
--- src/encodings/iso-8859-3.m
+++ src/encodings/iso-8859-3.m
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_iso_8859_3_table[] = {
+ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFF, 0x0124, 0x00A7,
+ 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFF, 0x017B,
+ 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
+ 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFF, 0x017C,
+ 0x00C0, 0x00C1, 0x00C2, 0xFFFF, 0x00C4, 0x010A, 0x0108, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0xFFFF, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
+ 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0xFFFF, 0x00E4, 0x010B, 0x0109, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0xFFFF, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
+ 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9
+};
+const size_t of_iso_8859_3_table_offset =
+ 256 - (sizeof(of_iso_8859_3_table) / sizeof(*of_iso_8859_3_table));
+
+static const unsigned char page0[] = {
+ 0xA0, 0x00, 0x00, 0xA3, 0xA4, 0x00, 0x00, 0xA7,
+ 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
+ 0xB0, 0x00, 0xB2, 0xB3, 0xB4, 0xB5, 0x00, 0xB7,
+ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
+ 0xC0, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
+ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
+ 0x00, 0xD1, 0xD2, 0xD3, 0xD4, 0x00, 0xD6, 0xD7,
+ 0x00, 0xD9, 0xDA, 0xDB, 0xDC, 0x00, 0x00, 0xDF,
+ 0xE0, 0xE1, 0xE2, 0x00, 0xE4, 0x00, 0x00, 0xE7,
+ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
+ 0x00, 0xF1, 0xF2, 0xF3, 0xF4, 0x00, 0xF6, 0xF7,
+ 0x00, 0xF9, 0xFA, 0xFB, 0xFC, 0x00, 0x00, 0x00
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0xC6, 0xE6, 0xC5, 0xE5, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xD8, 0xF8, 0xAB, 0xBB,
+ 0xD5, 0xF5, 0x00, 0x00, 0xA6, 0xB6, 0xA1, 0xB1,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xA9, 0xB9, 0x00, 0x00, 0xAC, 0xBC, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDE, 0xFE, 0xAA, 0xBA,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xDD, 0xFD, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xAF, 0xBF
+};
+static const uint8_t page1Start = 0x08;
+
+static const unsigned char page2[] = {
+ 0xA2, 0xFF
+};
+static const uint8_t page2Start = 0xD8;
+
+bool
+of_unicode_to_iso_8859_3(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_KEEP(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(2)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
DELETED src/encodings/iso_8859-15.m
Index: src/encodings/iso_8859-15.m
==================================================================
--- src/encodings/iso_8859-15.m
+++ src/encodings/iso_8859-15.m
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_iso_8859_15_table[] = {
- 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7,
- 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
- 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x00B5, 0x00B6, 0x00B7,
- 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF,
- 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
- 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
- 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
- 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
-};
-const size_t of_iso_8859_15_table_offset =
- 256 - (sizeof(of_iso_8859_15_table) / sizeof(*of_iso_8859_15_table));
-
-static const unsigned char page0[] = {
- 0x00, 0xA5, 0x00, 0xA7, 0x00, 0xA9, 0xAA, 0xAB,
- 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
- 0x00, 0xB5, 0xB6, 0xB7, 0x00, 0xB9, 0xBA, 0xBB,
- 0x00, 0x00, 0x00
-};
-static const uint8_t page0Start = 0xA4;
-
-static const unsigned char page1[] = {
- 0xBC, 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA6, 0xA8,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0x00,
- 0x00, 0x00, 0x00, 0xB4, 0xB8
-};
-static const uint8_t page1Start = 0x52;
-
-static const unsigned char page20[] = {
- 0xA4
-};
-static const uint8_t page20Start = 0xAC;
-
-bool
-of_unicode_to_iso_8859_15(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_KEEP(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(20)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
DELETED src/encodings/iso_8859-2.m
Index: src/encodings/iso_8859-2.m
==================================================================
--- src/encodings/iso_8859-2.m
+++ src/encodings/iso_8859-2.m
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_iso_8859_2_table[] = {
- 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
- 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
- 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
- 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
- 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
- 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
- 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
- 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
- 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
- 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
-};
-const size_t of_iso_8859_2_table_offset =
- 256 - (sizeof(of_iso_8859_2_table) / sizeof(*of_iso_8859_2_table));
-
-static const unsigned char page0[] = {
- 0xA0, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0xA7,
- 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
- 0xB0, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
- 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
- 0x00, 0xC9, 0x00, 0xCB, 0x00, 0xCD, 0xCE, 0x00,
- 0x00, 0x00, 0x00, 0xD3, 0xD4, 0x00, 0xD6, 0xD7,
- 0x00, 0x00, 0xDA, 0x00, 0xDC, 0xDD, 0x00, 0xDF,
- 0x00, 0xE1, 0xE2, 0x00, 0xE4, 0x00, 0x00, 0xE7,
- 0x00, 0xE9, 0x00, 0xEB, 0x00, 0xED, 0xEE, 0x00,
- 0x00, 0x00, 0x00, 0xF3, 0xF4, 0x00, 0xF6, 0xF7,
- 0x00, 0x00, 0xFA, 0x00, 0xFC, 0xFD, 0x00, 0x00
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0xC3, 0xE3, 0xA1, 0xB1, 0xC6, 0xE6, 0x00, 0x00,
- 0x00, 0x00, 0xC8, 0xE8, 0xCF, 0xEF, 0xD0, 0xF0,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCA, 0xEA,
- 0xCC, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC5,
- 0xE5, 0x00, 0x00, 0xA5, 0xB5, 0x00, 0x00, 0xA3,
- 0xB3, 0xD1, 0xF1, 0x00, 0x00, 0xD2, 0xF2, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0xF5,
- 0x00, 0x00, 0xC0, 0xE0, 0x00, 0x00, 0xD8, 0xF8,
- 0xA6, 0xB6, 0x00, 0x00, 0xAA, 0xBA, 0xA9, 0xB9,
- 0xDE, 0xFE, 0xAB, 0xBB, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xD9, 0xF9, 0xDB, 0xFB,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC,
- 0xBC, 0xAF, 0xBF, 0xAE, 0xBE
-};
-static const uint8_t page1Start = 0x02;
-
-static const unsigned char page2[] = {
- 0xB7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xA2, 0xFF, 0x00, 0xB2, 0x00, 0xBD
-};
-static const uint8_t page2Start = 0xC7;
-
-bool
-of_unicode_to_iso_8859_2(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_KEEP(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(2)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
DELETED src/encodings/iso_8859-3.m
Index: src/encodings/iso_8859-3.m
==================================================================
--- src/encodings/iso_8859-3.m
+++ src/encodings/iso_8859-3.m
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_iso_8859_3_table[] = {
- 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFF, 0x0124, 0x00A7,
- 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFF, 0x017B,
- 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
- 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFF, 0x017C,
- 0x00C0, 0x00C1, 0x00C2, 0xFFFF, 0x00C4, 0x010A, 0x0108, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- 0xFFFF, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
- 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
- 0x00E0, 0x00E1, 0x00E2, 0xFFFF, 0x00E4, 0x010B, 0x0109, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0xFFFF, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
- 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9
-};
-const size_t of_iso_8859_3_table_offset =
- 256 - (sizeof(of_iso_8859_3_table) / sizeof(*of_iso_8859_3_table));
-
-static const unsigned char page0[] = {
- 0xA0, 0x00, 0x00, 0xA3, 0xA4, 0x00, 0x00, 0xA7,
- 0xA8, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00, 0x00,
- 0xB0, 0x00, 0xB2, 0xB3, 0xB4, 0xB5, 0x00, 0xB7,
- 0xB8, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x00, 0x00,
- 0xC0, 0xC1, 0xC2, 0x00, 0xC4, 0x00, 0x00, 0xC7,
- 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
- 0x00, 0xD1, 0xD2, 0xD3, 0xD4, 0x00, 0xD6, 0xD7,
- 0x00, 0xD9, 0xDA, 0xDB, 0xDC, 0x00, 0x00, 0xDF,
- 0xE0, 0xE1, 0xE2, 0x00, 0xE4, 0x00, 0x00, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0x00, 0xF1, 0xF2, 0xF3, 0xF4, 0x00, 0xF6, 0xF7,
- 0x00, 0xF9, 0xFA, 0xFB, 0xFC, 0x00, 0x00, 0x00
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0xC6, 0xE6, 0xC5, 0xE5, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xD8, 0xF8, 0xAB, 0xBB,
- 0xD5, 0xF5, 0x00, 0x00, 0xA6, 0xB6, 0xA1, 0xB1,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xA9, 0xB9, 0x00, 0x00, 0xAC, 0xBC, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xDE, 0xFE, 0xAA, 0xBA,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xDD, 0xFD, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xAF, 0xBF
-};
-static const uint8_t page1Start = 0x08;
-
-static const unsigned char page2[] = {
- 0xA2, 0xFF
-};
-static const uint8_t page2Start = 0xD8;
-
-bool
-of_unicode_to_iso_8859_3(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_KEEP(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(2)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
ADDED src/encodings/mac-roman.m
Index: src/encodings/mac-roman.m
==================================================================
--- src/encodings/mac-roman.m
+++ src/encodings/mac-roman.m
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "OFString.h"
+
+#import "common.h"
+
+const of_char16_t of_mac_roman_table[] = {
+ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
+ 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
+ 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
+ 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
+ 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+ 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
+ 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
+ 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
+ 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
+ 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
+ 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+ 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
+ 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
+ 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
+ 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
+ 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
+};
+const size_t of_mac_roman_table_offset =
+ 256 - (sizeof(of_mac_roman_table) / sizeof(*of_mac_roman_table));
+
+static const unsigned char page0[] = {
+ 0xCA, 0xC1, 0xA2, 0xA3, 0x00, 0xB4, 0x00, 0xA4,
+ 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
+ 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
+ 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
+ 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
+ 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
+ 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
+ 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
+ 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
+ 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
+ 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
+ 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8
+};
+static const uint8_t page0Start = 0xA0;
+
+static const unsigned char page1[] = {
+ 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xCE, 0xCF, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xC4
+};
+static const uint8_t page1Start = 0x31;
+
+static const unsigned char page2[] = {
+ 0xF6, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xF9, 0xFA, 0xFB, 0xFE, 0xF7, 0xFD
+};
+static const uint8_t page2Start = 0xC6;
+
+static const unsigned char page3[] = {
+ 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB9
+};
+static const uint8_t page3Start = 0xA9;
+
+static const unsigned char page20[] = {
+ 0xD0, 0xD1, 0x00, 0x00, 0x00, 0xD4, 0xD5, 0xE2,
+ 0x00, 0xD2, 0xD3, 0xE3, 0x00, 0xA0, 0xE0, 0xA5,
+ 0x00, 0x00, 0x00, 0xC9, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0xDD,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xDB
+};
+static const uint8_t page20Start = 0x13;
+
+static const unsigned char page21[] = {
+ 0xAA
+};
+static const uint8_t page21Start = 0x22;
+
+static const unsigned char page22[] = {
+ 0xB6, 0x00, 0x00, 0x00, 0xC6, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0x00, 0xB7,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xC3, 0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00,
+ 0x00, 0x00, 0xB2, 0xB3
+};
+static const uint8_t page22Start = 0x02;
+
+static const unsigned char page25[] = {
+ 0xD7
+};
+static const uint8_t page25Start = 0xCA;
+
+static const unsigned char pageF8[] = {
+ 0xF0
+};
+static const uint8_t pageF8Start = 0xFF;
+
+static const unsigned char pageFB[] = {
+ 0xDE, 0xDF
+};
+static const uint8_t pageFBStart = 0x01;
+
+bool
+of_unicode_to_mac_roman(const of_unichar_t *input, unsigned char *output,
+ size_t length, bool lossy)
+{
+ for (size_t i = 0; i < length; i++) {
+ of_unichar_t c = input[i];
+
+ if OF_UNLIKELY (c > 0x7F) {
+ uint8_t idx;
+
+ if OF_UNLIKELY (c > 0xFFFF) {
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+
+ switch (c >> 8) {
+ CASE_MISSING_IS_ERROR(0)
+ CASE_MISSING_IS_ERROR(1)
+ CASE_MISSING_IS_ERROR(2)
+ CASE_MISSING_IS_ERROR(3)
+ CASE_MISSING_IS_ERROR(20)
+ CASE_MISSING_IS_ERROR(21)
+ CASE_MISSING_IS_ERROR(22)
+ CASE_MISSING_IS_ERROR(25)
+ CASE_MISSING_IS_ERROR(F8)
+ CASE_MISSING_IS_ERROR(FB)
+ default:
+ if (lossy) {
+ output[i] = '?';
+ continue;
+ } else
+ return false;
+ }
+ } else
+ output[i] = (unsigned char)c;
+ }
+
+ return true;
+}
DELETED src/encodings/mac_roman.m
Index: src/encodings/mac_roman.m
==================================================================
--- src/encodings/mac_roman.m
+++ src/encodings/mac_roman.m
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
- * 2018, 2019, 2020
- * Jonathan Schleifer
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
- * the packaging of this file.
- *
- * Alternatively, it may be distributed under the terms of the GNU General
- * Public License, either version 2 or 3, which can be found in the file
- * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
- * file.
- */
-
-#include "config.h"
-
-#import "OFString.h"
-
-#import "common.h"
-
-const of_char16_t of_mac_roman_table[] = {
- 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
- 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
- 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
- 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
- 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
- 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
- 0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
- 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
- 0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
- 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
- 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
- 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
- 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
- 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
- 0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
- 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
-};
-const size_t of_mac_roman_table_offset =
- 256 - (sizeof(of_mac_roman_table) / sizeof(*of_mac_roman_table));
-
-static const unsigned char page0[] = {
- 0xCA, 0xC1, 0xA2, 0xA3, 0x00, 0xB4, 0x00, 0xA4,
- 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
- 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
- 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
- 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
- 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
- 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
- 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
- 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
- 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
- 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
- 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8
-};
-static const uint8_t page0Start = 0xA0;
-
-static const unsigned char page1[] = {
- 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xCE, 0xCF, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xC4
-};
-static const uint8_t page1Start = 0x31;
-
-static const unsigned char page2[] = {
- 0xF6, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xF9, 0xFA, 0xFB, 0xFE, 0xF7, 0xFD
-};
-static const uint8_t page2Start = 0xC6;
-
-static const unsigned char page3[] = {
- 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB9
-};
-static const uint8_t page3Start = 0xA9;
-
-static const unsigned char page20[] = {
- 0xD0, 0xD1, 0x00, 0x00, 0x00, 0xD4, 0xD5, 0xE2,
- 0x00, 0xD2, 0xD3, 0xE3, 0x00, 0xA0, 0xE0, 0xA5,
- 0x00, 0x00, 0x00, 0xC9, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0xDD,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xDB
-};
-static const uint8_t page20Start = 0x13;
-
-static const unsigned char page21[] = {
- 0xAA
-};
-static const uint8_t page21Start = 0x22;
-
-static const unsigned char page22[] = {
- 0xB6, 0x00, 0x00, 0x00, 0xC6, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0x00, 0xB7,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC3, 0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC5, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x00,
- 0x00, 0x00, 0xB2, 0xB3
-};
-static const uint8_t page22Start = 0x02;
-
-static const unsigned char page25[] = {
- 0xD7
-};
-static const uint8_t page25Start = 0xCA;
-
-static const unsigned char pageF8[] = {
- 0xF0
-};
-static const uint8_t pageF8Start = 0xFF;
-
-static const unsigned char pageFB[] = {
- 0xDE, 0xDF
-};
-static const uint8_t pageFBStart = 0x01;
-
-bool
-of_unicode_to_mac_roman(const of_unichar_t *input, unsigned char *output,
- size_t length, bool lossy)
-{
- for (size_t i = 0; i < length; i++) {
- of_unichar_t c = input[i];
-
- if OF_UNLIKELY (c > 0x7F) {
- uint8_t idx;
-
- if OF_UNLIKELY (c > 0xFFFF) {
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
-
- switch (c >> 8) {
- CASE_MISSING_IS_ERROR(0)
- CASE_MISSING_IS_ERROR(1)
- CASE_MISSING_IS_ERROR(2)
- CASE_MISSING_IS_ERROR(3)
- CASE_MISSING_IS_ERROR(20)
- CASE_MISSING_IS_ERROR(21)
- CASE_MISSING_IS_ERROR(22)
- CASE_MISSING_IS_ERROR(25)
- CASE_MISSING_IS_ERROR(F8)
- CASE_MISSING_IS_ERROR(FB)
- default:
- if (lossy) {
- output[i] = '?';
- continue;
- } else
- return false;
- }
- } else
- output[i] = (unsigned char)c;
- }
-
- return true;
-}
Index: src/forwarding/forwarding-powerpc-elf.S
==================================================================
--- src/forwarding/forwarding-powerpc-elf.S
+++ src/forwarding/forwarding-powerpc-elf.S
@@ -64,11 +64,11 @@
bl class_respondsToSelector+0x8000@plt
#else
bl object_getClass
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
bl class_respondsToSelector
#endif
cmpwi %r3, 0
beq- 0f
@@ -77,21 +77,21 @@
#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl objc_msg_lookup+0x8000@plt
#else
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
bl objc_msg_lookup
#endif
mtctr %r3
lwz %r3, 8(%r1)
#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
#else
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
#endif
lwz %r5, 12(%r1)
bctrl
cmpwi %r3, 0
@@ -202,11 +202,11 @@
bl class_respondsToSelector+0x8000@plt
#else
bl object_getClass
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
bl class_respondsToSelector
#endif
cmpwi %r3, 0
beq- 0f
@@ -215,21 +215,21 @@
#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
bl objc_msg_lookup+0x8000@plt
#else
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
bl objc_msg_lookup
#endif
mtctr %r3
lwz %r3, 12(%r1)
#ifdef OF_PIC
lwz %r4, .Lgot_sel_forwardingTargetForSelector_-.Lbiased_got2(%r30)
#else
lis %r4, sel_forwardingTargetForSelector_@ha
- addi %r4, %r4, sel_forwardingTargetForSelector_@l
+ la %r4, sel_forwardingTargetForSelector_@l(%r4)
#endif
lwz %r5, 16(%r1)
bctrl
cmpwi %r3, 0
@@ -316,11 +316,11 @@
bl __objc_exec_class+0x8000@plt
lwz %r30, 8(%r1)
#else
lis %r3, module@ha
- addi %r3, %r3, module@l
+ la %r3, module@l(%r3)
bl __objc_exec_class
#endif
lwz %r0, 20(%r1)
addi %r1, %r1, 16
Index: src/macros.h
==================================================================
--- src/macros.h
+++ src/macros.h
@@ -319,46 +319,10 @@
# define OF_DIRECT_MEMBERS __attribute__((__objc_direct_members__))
#else
# define OF_DIRECT_MEMBERS
#endif
-#ifdef __GNUC__
-# ifdef OF_X86_64
-# define OF_X86_64_ASM
-# endif
-# ifdef OF_X86
-# define OF_X86_ASM
-# endif
-# ifdef OF_POWERPC
-# define OF_POWERPC_ASM
-# endif
-# ifdef OF_ARM64
-# define OF_ARM64_ASM
-# endif
-# ifdef OF_ARM
-# define OF_ARM_ASM
-# endif
-# ifdef OF_ARMV7
-# define OF_ARMV7_ASM
-# endif
-# ifdef OF_ARMV6
-# define OF_ARMV6_ASM
-# endif
-# ifdef OF_MIPS64
-# define OF_MIPS64_ASM
-# endif
-# ifdef OF_MIPS
-# define OF_MIPS_ASM
-# endif
-# ifdef OF_PA_RISC
-# define OF_PA_RISC_ASM
-# endif
-# ifdef OF_ITANIUM
-# define OF_ITANIUM_ASM
-# endif
-#endif
-
#ifdef OF_APPLE_RUNTIME
# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_ARM64) || \
defined(OF_ARM) || defined(OF_POWERPC)
# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR
# define OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR_STRET
@@ -467,23 +431,23 @@
static OF_INLINE uint16_t OF_CONST_FUNC
OF_BSWAP16_NONCONST(uint16_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP16)
return __builtin_bswap16(i);
-#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
+#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
__asm__ (
"xchgb %h0, %b0"
: "=Q"(i)
: "0"(i)
);
-#elif defined(OF_POWERPC_ASM)
+#elif defined(OF_POWERPC) && defined(__GNUC__)
__asm__ (
"lhbrx %0, 0, %1"
: "=r"(i)
: "r"(&i), "m"(i)
);
-#elif defined(OF_ARMV6_ASM)
+#elif defined(OF_ARMV6) && defined(__GNUC__)
__asm__ (
"rev16 %0, %0"
: "=r"(i)
: "0"(i)
);
@@ -497,23 +461,23 @@
static OF_INLINE uint32_t OF_CONST_FUNC
OF_BSWAP32_NONCONST(uint32_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP32)
return __builtin_bswap32(i);
-#elif defined(OF_X86_64_ASM) || defined(OF_X86_ASM)
+#elif (defined(OF_X86_64) || defined(OF_X86)) && defined(__GNUC__)
__asm__ (
"bswap %0"
: "=q"(i)
: "0"(i)
);
-#elif defined(OF_POWERPC_ASM)
+#elif defined(OF_POWERPC) && defined(__GNUC__)
__asm__ (
"lwbrx %0, 0, %1"
: "=r"(i)
: "r"(&i), "m"(i)
);
-#elif defined(OF_ARMV6_ASM)
+#elif defined(OF_ARMV6) && defined(__GNUC__)
__asm__ (
"rev %0, %0"
: "=r"(i)
: "0"(i)
);
@@ -529,17 +493,17 @@
static OF_INLINE uint64_t OF_CONST_FUNC
OF_BSWAP64_NONCONST(uint64_t i)
{
#if defined(OF_HAVE_BUILTIN_BSWAP64)
return __builtin_bswap64(i);
-#elif defined(OF_X86_64_ASM)
+#elif defined(OF_X86_64) && defined(__GNUC__)
__asm__ (
"bswap %0"
: "=r"(i)
: "0"(i)
);
-#elif defined(OF_X86_ASM)
+#elif defined(OF_X86) && defined(__GNUC__)
__asm__ (
"bswap %%eax\n\t"
"bswap %%edx\n\t"
"xchgl %%eax, %%edx"
: "=A"(i)
Index: src/platform.h
==================================================================
--- src/platform.h
+++ src/platform.h
@@ -96,19 +96,20 @@
# define OF_RISC_V
#elif defined(__s390x__)
# define OF_S390X
#elif defined(__s390__)
# define OF_S390
+#elif defined(__e2k__)
+# define OF_ELBRUS_2000
#endif
#if defined(__APPLE__)
# include
# if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \
(defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR)
# define OF_IOS
-# endif
-# if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+# else
# define OF_MACOS
# endif
#elif defined(__linux__)
# define OF_LINUX
#elif defined(_WIN32)
Index: src/platform/amiga/thread.m
==================================================================
--- src/platform/amiga/thread.m
+++ src/platform/amiga/thread.m
@@ -27,11 +27,13 @@
#include
#include
#include
+#ifndef OF_MORPHOS
extern void of_tlskey_thread_exited(void);
+#endif
static of_tlskey_t threadKey;
OF_CONSTRUCTOR()
{
OF_ENSURE(of_tlskey_new(&threadKey));
@@ -49,11 +51,13 @@
ObtainSemaphore(&thread->semaphore);
@try {
thread->done = true;
+#ifndef OF_MORPHOS
of_tlskey_thread_exited();
+#endif
if (thread->detached)
detached = true;
else if (thread->joinTask != NULL)
Signal(thread->joinTask, (1ul << thread->joinSigBit));
ADDED src/platform/morphos/tlskey.m
Index: src/platform/morphos/tlskey.m
==================================================================
--- src/platform/morphos/tlskey.m
+++ src/platform/morphos/tlskey.m
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
+ * 2018, 2019, 2020
+ * Jonathan Schleifer
+ *
+ * All rights reserved.
+ *
+ * This file is part of ObjFW. It may be distributed under the terms of the
+ * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
+ * the packaging of this file.
+ *
+ * Alternatively, it may be distributed under the terms of the GNU General
+ * Public License, either version 2 or 3, which can be found in the file
+ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
+ * file.
+ */
+
+#include "config.h"
+
+#import "tlskey.h"
+
+bool
+of_tlskey_new(of_tlskey_t *key)
+{
+ return ((*key = TLSAllocA(NULL)) != TLS_INVALID_INDEX);
+}
+
+bool
+of_tlskey_free(of_tlskey_t key)
+{
+ return TLSFree(key);
+}
Index: src/socket.h
==================================================================
--- src/socket.h
+++ src/socket.h
@@ -287,20 +287,20 @@
extern void of_socket_address_get_ipx_node(
const of_socket_address_t *_Nonnull address,
unsigned char node[_Nonnull IPX_NODE_LEN]);
extern bool of_socket_init(void);
-#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
extern void of_socket_deinit(void);
#endif
extern int of_socket_errno(void);
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
extern int of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen);
#endif
-#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
extern of_tlskey_t of_socket_base_key;
# ifdef OF_AMIGAOS4
extern of_tlskey_t of_socket_interface_key;
# endif
#endif
Index: src/socket.m
==================================================================
--- src/socket.m
+++ src/socket.m
@@ -36,11 +36,11 @@
#import "OFUnlockFailedException.h"
#import "socket.h"
#import "socket_helpers.h"
#ifdef OF_HAVE_THREADS
-# ifndef OF_AMIGAOS
+# if !defined(OF_AMIGAOS) || defined(OF_MORPHOS)
# import "mutex.h"
# else
# import "tlskey.h"
# endif
#endif
@@ -53,19 +53,19 @@
#ifdef OF_NINTENDO_3DS
# include <3ds/types.h>
# include <3ds/services/soc.h>
#endif
-#if defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
static of_mutex_t mutex;
#endif
-#if !defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS)
+#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static bool initSuccessful = false;
#endif
#ifdef OF_AMIGAOS
-# ifdef OF_HAVE_THREADS
+# if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
of_tlskey_t of_socket_base_key;
# ifdef OF_AMIGAOS4
of_tlskey_t of_socket_interface_key;
# endif
# else
@@ -74,11 +74,11 @@
struct SocketIFace *ISocket = NULL;
# endif
# endif
#endif
-#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
OF_CONSTRUCTOR()
{
if (!of_tlskey_new(&of_socket_base_key))
@throw [OFInitializationFailedException exception];
@@ -87,11 +87,11 @@
@throw [OFInitializationFailedException exception];
# endif
}
#endif
-#if !defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS)
+#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static void
init(void)
{
# if defined(OF_WINDOWS)
WSADATA wsa;
@@ -122,11 +122,11 @@
return;
atexit((void (*)(void))socExit);
# endif
-# if defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
+# if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
if (!of_mutex_new(&mutex))
return;
# ifdef OF_WII
if (!of_spinlock_new(&spinlock))
@@ -152,11 +152,11 @@
#endif
bool
of_socket_init(void)
{
-#if !defined(OF_AMIGAOS) || !defined(OF_HAVE_THREADS)
+#if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS)
static of_once_t onceControl = OF_ONCE_INIT;
of_once(&onceControl, init);
return initSuccessful;
#else
@@ -201,11 +201,11 @@
return true;
#endif
}
-#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
+#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
void
of_socket_deinit(void)
{
struct Library *socketBase = of_tlskey_get(of_socket_base_key);
# ifdef OF_AMIGAOS4
@@ -326,19 +326,19 @@
of_getsockname(of_socket_t sock, struct sockaddr *restrict addr,
socklen_t *restrict addrLen)
{
int ret;
-# if defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
+# if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
if (!of_mutex_lock(&mutex))
@throw [OFLockFailedException exception];
# endif
ret = getsockname(sock, addr, addrLen);
-# if defined(OF_HAVE_THREADS) && !defined(OF_AMIGAOS)
+# if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
if (!of_mutex_unlock(&mutex))
@throw [OFUnlockFailedException exception];
# endif
return ret;
Index: src/socket_helpers.h
==================================================================
--- src/socket_helpers.h
+++ src/socket_helpers.h
@@ -57,11 +57,11 @@
# include
# define closesocket(sock) CloseSocket(sock)
# define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg)
# define hstrerror(err) "unknown (no hstrerror)"
# define SOCKET_ERROR -1
-# ifdef OF_HAVE_THREADS
+# if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
# define SocketBase ((struct Library *)of_tlskey_get(of_socket_base_key))
# ifdef OF_AMIGAOS4
# define ISocket \
((struct SocketIFace *)of_tlskey_get(of_socket_interface_key))
# endif
Index: src/tlskey.h
==================================================================
--- src/tlskey.h
+++ src/tlskey.h
@@ -30,10 +30,13 @@
# include
typedef pthread_key_t of_tlskey_t;
#elif defined(OF_WINDOWS)
# include
typedef DWORD of_tlskey_t;
+#elif defined(OF_MORPHOS)
+# include
+typedef ULONG of_tlskey_t;
#elif defined(OF_AMIGAOS)
typedef struct of_tlskey {
struct objc_hashtable *table;
struct of_tlskey *next, *previous;
} *of_tlskey_t;
@@ -72,10 +75,22 @@
static OF_INLINE bool
of_tlskey_set(of_tlskey_t key, void *ptr)
{
return TlsSetValue(key, ptr);
}
+#elif defined(OF_MORPHOS)
+static OF_INLINE void *
+of_tlskey_get(of_tlskey_t key)
+{
+ return (void *)TLSGetValue(key);
+}
+
+static OF_INLINE bool
+of_tlskey_set(of_tlskey_t key, void *ptr)
+{
+ return TLSSetValue(key, (APTR)ptr);
+}
#elif defined(OF_AMIGAOS)
/* Those are too big too inline. */
# ifdef __cplusplus
extern "C" {
# endif
Index: src/tlskey.m
==================================================================
--- src/tlskey.m
+++ src/tlskey.m
@@ -21,8 +21,10 @@
#if defined(OF_HAVE_PTHREADS)
# include "platform/posix/tlskey.m"
#elif defined(OF_WINDOWS)
# include "platform/windows/tlskey.m"
+#elif defined(OF_MORPHOS)
+# include "platform/morphos/tlskey.m"
#elif defined(OF_AMIGAOS)
# include "platform/amiga/tlskey.m"
#endif
Index: utils/ofhttp/OFHTTP.m
==================================================================
--- utils/ofhttp/OFHTTP.m
+++ utils/ofhttp/OFHTTP.m
@@ -777,13 +777,16 @@
key, object];
objc_autoreleasePoolPop(pool);
} else if (statusCode / 100 == 2 && !_detectFileNameRequest) {
[of_stdout writeString: @" "];
- [of_stdout writeLine: OF_LOCALIZED(@"info_name",
- @"Name: %[name]",
- @"name", _currentFileName)];
+
+ if (_currentFileName != nil)
+ [of_stdout writeLine: OF_LOCALIZED(@"info_name",
+ @"Name: %[name]",
+ @"name", _currentFileName)];
+
[of_stdout writeString: @" "];
[of_stdout writeLine: OF_LOCALIZED(@"info_type",
@"Type: %[type]",
@"type", type)];
[of_stdout writeString: @" "];