summaryrefslogtreecommitdiff
path: root/zap/source/any/str
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/any/str')
-rw-r--r--zap/source/any/str/fmt.cc43
-rw-r--r--zap/source/any/str/fmtlen.cc37
-rw-r--r--zap/source/any/str/numdig.hh12
-rw-r--r--zap/source/any/str/streq.c17
-rw-r--r--zap/source/any/str/strlen.c13
-rw-r--r--zap/source/any/str/utf8dec.c47
-rw-r--r--zap/source/any/str/utf8declen.c29
-rw-r--r--zap/source/any/str/utf8enc.c44
-rw-r--r--zap/source/any/str/utf8enclen.c29
-rw-r--r--zap/source/any/str/win1252dec.c107
-rw-r--r--zap/source/any/str/win1252enc.c109
11 files changed, 0 insertions, 487 deletions
diff --git a/zap/source/any/str/fmt.cc b/zap/source/any/str/fmt.cc
deleted file mode 100644
index ff6edb1..0000000
--- a/zap/source/any/str/fmt.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.hh>
-
-#include "numdig.hh"
-
-namespace zap {
- namespace impl {
- template<typename signtyp> zap_attr_iln inline static auto fmt(::zap::i02 * buf,signtyp signval,::zap::i8 const bs,::zap::i8 const rtl) noexcept -> void {
- using typ = typename ::zap::usign<signtyp>;
- char32_t const * digs = U"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- if (bs == 0xCu) digs = U"0123456789\u218A\u218B";
- if (signval < 0x0) {
- signval = -signval;
- *buf++ = 0x2212u;
- }
- typ val = static_cast<typ>(signval);
- if (rtl) {
- buf += ::zap::impl::numdig(val,bs) - 0x1u;
- for (;val > 0x0u;val /= bs) *buf-- = static_cast<::zap::i02>(digs[static_cast<::zap::sz>(val % static_cast<typ>(bs))]);
- return;
- }
- for (;val > 0x0u;val /= bs) *buf++ = static_cast<::zap::i02>(digs[static_cast<::zap::sz>(val % static_cast<typ>(bs))]);
- }
- }
-}
-
-extern "C" {
- auto zap_fmti( ::zap::i02 * const buf,int const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtl( ::zap::i02 * const buf,long const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtll( ::zap::i02 * const buf,long long const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmts( ::zap::i02 * const buf,short const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtsc( ::zap::i02 * const buf,signed char const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtuc( ::zap::i02 * const buf,unsigned char const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtui( ::zap::i02 * const buf,unsigned int const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtul( ::zap::i02 * const buf,unsigned long const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtull(::zap::i02 * const buf,unsigned long long const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
- auto zap_fmtus( ::zap::i02 * const buf,unsigned short const val,::zap::i8 const bs,::zap::i8 const rtl) -> void {return ::zap::impl::fmt(buf,val,bs,rtl);}
-}
diff --git a/zap/source/any/str/fmtlen.cc b/zap/source/any/str/fmtlen.cc
deleted file mode 100644
index b5e508c..0000000
--- a/zap/source/any/str/fmtlen.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/math.hh>
-#include <zap/str.hh>
-
-#include "numdig.hh"
-
-namespace zap {
- namespace impl {
- template<typename typ> zap_attr_iln inline static auto fmtlen(typ val,::zap::i8 const bs) noexcept -> ::zap::i8 {
- ::zap::i8 len = 0x0u;
- if (val < 0x0) {
- val = static_cast<typ>(::zap::abs(val));
- len = 0x1u;
- }
- len += ::zap::impl::numdig(val,bs);
- return len;
- }
- }
-}
-
-extern "C" {
- auto zap_fmtleni( int const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenl( long const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenll( long long const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlens( short const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlensc( signed char const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenuc( unsigned char const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenui( unsigned int const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenul( unsigned long const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenull(unsigned long long const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
- auto zap_fmtlenus( unsigned short const val,::zap::i8 const bs) -> ::zap::i8 {return ::zap::impl::fmtlen(val,bs);}
-}
diff --git a/zap/source/any/str/numdig.hh b/zap/source/any/str/numdig.hh
deleted file mode 100644
index ea36f0b..0000000
--- a/zap/source/any/str/numdig.hh
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-namespace zap {
- namespace impl {
- template<typename typ> zap_attr_iln inline static auto numdig(typ fmtval,::zap::i8 const bs) noexcept -> ::zap::i8 {
- ::zap::i8 len = 0x0u;
- if (fmtval == typ {0x0}) return 0x1u;
- for (typ val = fmtval;val > 0x0;val /= static_cast<typ>(bs)) ++len;
- return len;
- }
- }
-}
diff --git a/zap/source/any/str/streq.c b/zap/source/any/str/streq.c
deleted file mode 100644
index 6b1002d..0000000
--- a/zap/source/any/str/streq.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-zap_i8 zap_streq(char const * lstr,char const * rstr) {
- for (;;++lstr,++rstr) {
- char const lchr = *lstr;
- char const rchr = *rstr;
- if (lchr != rchr) return 0x0u;
- if (lchr == '\x0') break;
- }
- return zap_maxval8;
-}
diff --git a/zap/source/any/str/strlen.c b/zap/source/any/str/strlen.c
deleted file mode 100644
index e763701..0000000
--- a/zap/source/any/str/strlen.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-zap_sz zap_strlen(char const * str) {
- char const * const start = str;
- while (*str++ != '\x0');
- return (zap_sz)(str - start) - 0x1u;
-}
diff --git a/zap/source/any/str/utf8dec.c b/zap/source/any/str/utf8dec.c
deleted file mode 100644
index add8697..0000000
--- a/zap/source/any/str/utf8dec.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-void zap_utf8dec(zap_i02 * dest,zap_i8 const * src) {
- for (;;++dest) {
- zap_i8 const oct = *src;
- if (oct == 0x0u) break;
- if (oct >= 0xF0u) { /* Four octets. */
- zap_i02 chr = ((zap_i02)oct ^ 0xF0u) << 0x12u;
- ++src;
- chr += ((zap_i02)*src ^ 0x80u) << 0xCu;
- ++src;
- chr += ((zap_i02)*src ^ 0x80u) << 0x6u;
- ++src;
- chr += (zap_i02)*src ^ 0x80u;
- ++src;
- *dest = chr;
- continue;
- }
- if (oct >= 0xE0u) { /* Three octets. */
- zap_i02 chr = ((zap_i02)oct ^ 0xE0u) << 0xCu;
- ++src;
- chr += ((zap_i02)*src ^ 0x80u) << 0x6u;
- ++src;
- chr += (zap_i02)*src ^ 0x80u;
- ++src;
- *dest = chr;
- continue;
- }
- if (oct >= 0xC0u) { /* Two octets. */
- zap_i02 chr = ((zap_i02)oct ^ 0xC0u) << 0x6u;
- ++src;
- chr += (zap_i02)*src ^ 0x80u;
- ++src;
- *dest = chr;
- continue;
- }
- /* One octet. */
- *dest = oct;
- ++src;
- }
-}
diff --git a/zap/source/any/str/utf8declen.c b/zap/source/any/str/utf8declen.c
deleted file mode 100644
index f8b7ae8..0000000
--- a/zap/source/any/str/utf8declen.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-zap_sz zap_utf8declen(zap_i8 const * buf) {
- zap_sz len = 0x0u;
- for (;;++len) {
- zap_i8 const oct = *buf;
- if (oct == 0x0u) break;
- if (oct >= 0xF0u) {
- buf += 0x4u;
- continue;
- }
- if (oct >= 0xE0u) {
- buf += 0x3u;
- continue;
- }
- if (oct >= 0xC0u) {
- buf += 0x2u;
- continue;
- }
- ++buf;
- }
- return len;
-}
diff --git a/zap/source/any/str/utf8enc.c b/zap/source/any/str/utf8enc.c
deleted file mode 100644
index a6b31c6..0000000
--- a/zap/source/any/str/utf8enc.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-void zap_utf8enc(zap_i8 * dest,zap_i02 const * src) {
- for (;;++src) {
- zap_i02 const chr = *src;
- if (chr > 0xFFFFu) { /* Four octets. */
- *dest = 0xF0u + (chr >> 0x12u);
- ++dest;
- *dest = 0x80u + (chr >> 0xCu & 0x3Fu);
- ++dest;
- *dest = 0x80u + (chr >> 0x6u & 0x3Fu);
- ++dest;
- *dest = 0x80u + (chr & 0x3Fu);
- ++dest;
- continue;
- }
- if (chr >= 0x7FFu) { /* Three octets. */
- *dest = 0xE0u + (zap_i8)(chr >> 0xCu);
- ++dest;
- *dest = 0x80u + (zap_i8)(chr >> 0x6u & 0x3Fu);
- ++dest;
- *dest = 0x80u + (zap_i8)(chr & 0x3Fu);
- ++dest;
- continue;
- }
- if (chr >= 0x7Fu) { /* Two octets. */
- *dest = 0xC0u + (zap_i8)(chr >> 0x6u);
- ++dest;
- *dest = 0x80u + (zap_i8)(chr & 0x3Fu);
- ++dest;
- continue;
- }
- /* One octet. */
- *dest = chr;
- ++dest;
- if (chr == 0x0u) break;
- }
-}
diff --git a/zap/source/any/str/utf8enclen.c b/zap/source/any/str/utf8enclen.c
deleted file mode 100644
index f49031e..0000000
--- a/zap/source/any/str/utf8enclen.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-zap_sz zap_utf8enclen(zap_i02 const * buf) {
- zap_sz len = 0x0u;
- for (;;++buf) {
- zap_i02 const chr = *buf;
- if (chr == 0x0u) break;
- if (chr >= 0x10000u) {
- len += 0x4u;
- continue;
- }
- if (chr >= 0x800u) {
- len += 0x3u;
- continue;
- }
- if (chr >= 0x80u) {
- len += 0x2u;
- continue;
- }
- ++len;
- }
- return len;
-}
diff --git a/zap/source/any/str/win1252dec.c b/zap/source/any/str/win1252dec.c
deleted file mode 100644
index 0e29a5a..0000000
--- a/zap/source/any/str/win1252dec.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-void zap_win1252dec(zap_i02 * dest,zap_i8 const * src) {
- for (;;++src,++dest) {
- zap_i8 const chr = *src;
- if (chr == 0x0u) break;
- switch (chr) {
- default:
- *dest = *src;
- break;
- case 0x81: /* Bad characters. */
- case 0x8D:
- case 0x8F:
- case 0x90:
- case 0x9D:
- *dest = 0xFFFDu; /* REPLACEMENT CHARACTER */
- break;
- case 0x80:
- *dest = 0x20ACu;
- break;
- case 0x82:
- *dest = 0x201Au;
- break;
- case 0x83:
- *dest = 0x192u;
- break;
- case 0x84:
- *dest = 0x201Eu;
- break;
- case 0x85:
- *dest = 0x2026u;
- break;
- case 0x86:
- *dest = 0x2020u;
- break;
- case 0x87:
- *dest = 0x2021u;
- break;
- case 0x88:
- *dest = 0x2C6u;
- break;
- case 0x89:
- *dest = 0x2030u;
- break;
- case 0x8A:
- *dest = 0x160u;
- break;
- case 0x8B:
- *dest = 0x2039u;
- break;
- case 0x8C:
- *dest = 0x152u;
- break;
- case 0x8E:
- *dest = 0x17Du;
- break;
- case 0x91:
- *dest = 0x2018u;
- break;
- case 0x92:
- *dest = 0x2019u;
- break;
- case 0x93:
- *dest = 0x201Cu;
- break;
- case 0x94:
- *dest = 0x201Du;
- break;
- case 0x95:
- *dest = 0x2022u;
- break;
- case 0x96:
- *dest = 0x2013u;
- break;
- case 0x97:
- *dest = 0x2014u;
- break;
- case 0x98:
- *dest = 0x2DCu;
- break;
- case 0x99:
- *dest = 0x2122u;
- break;
- case 0x9A:
- *dest = 0x161u;
- break;
- case 0x9B:
- *dest = 0x203Au;
- break;
- case 0x9C:
- *dest = 0x153u;
- break;
- case 0x9E:
- *dest = 0x17Eu;
- break;
- case 0x9F:
- *dest = 0x178u;
- break;
- }
- }
-}
diff --git a/zap/source/any/str/win1252enc.c b/zap/source/any/str/win1252enc.c
deleted file mode 100644
index d7ae548..0000000
--- a/zap/source/any/str/win1252enc.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- Copyright 2022-2023 Gabriel Jensen.
- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
- If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
-*/
-
-#include <zap/str.h>
-
-void zap_win1252enc(zap_i8 * dest,zap_i02 const * src) {
- for (;;++src,++dest) {
- zap_i02 const chr = *src;
- if (chr == 0x0u) break;
- zap_i8 const bad = 0x3Fu;
- switch (chr) {
- default:
- if (chr > 0xFFu) {
- *dest = bad;
- break;
- }
- if (chr >= 0x80u && chr <= 0x9Fu) {
- *dest = bad;
- break;
- }
- *dest = *src;
- break;
- case 0x20ACu:
- *dest = 0x80u;
- break;
- case 0x201Au:
- *dest = 0x82u;
- break;
- case 0x192u:
- *dest = 0x83u;
- break;
- case 0x201Eu:
- *dest = 0x84u;
- break;
- case 0x2026u:
- *dest = 0x85u;
- break;
- case 0x2020u:
- *dest = 0x86u;
- break;
- case 0x2021u:
- *dest = 0x87u;
- break;
- case 0x2C6u:
- *dest = 0x88u;
- break;
- case 0x2030u:
- *dest = 0x89u;
- break;
- case 0x160u:
- *dest = 0x8Au;
- break;
- case 0x2039u:
- *dest = 0x8Bu;
- break;
- case 0x152u:
- *dest = 0x8Cu;
- break;
- case 0x17Du:
- *dest = 0x8Eu;
- break;
- case 0x2018u:
- *dest = 0x91u;
- break;
- case 0x2019u:
- *dest = 0x92u;
- break;
- case 0x201Cu:
- *dest = 0x93u;
- break;
- case 0x201Du:
- *dest = 0x94u;
- break;
- case 0x2022u:
- *dest = 0x95u;
- break;
- case 0x2013u:
- *dest = 0x96u;
- break;
- case 0x2014u:
- *dest = 0x97u;
- break;
- case 0x2DCu:
- *dest = 0x98u;
- break;
- case 0x2122u:
- *dest = 0x99u;
- break;
- case 0x161u:
- *dest = 0x9Au;
- break;
- case 0x203Au:
- *dest = 0x9Bu;
- break;
- case 0x153u:
- *dest = 0x9Cu;
- break;
- case 0x17Eu:
- *dest = 0x9Eu;
- break;
- case 0x178u:
- *dest = 0x9Fu;
- break;
- }
- }
-}