From 3e9274040d8794003123bf498c090c82bbfc6ca0 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 30 Apr 2025 14:12:26 +0800 Subject: [PATCH 01/41] Packaging: update debian stuff [ci skip] --- debian/changelog | 6 ++++++ debian/files | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 8abafbd6bf..9a06e87918 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +fastfetch (2.42.0) jammy; urgency=medium + + * Update to 2.42.0 + + -- Carter Li Wed, 30 Apr 2025 14:08:57 +0800 + fastfetch (2.41.0) jammy; urgency=medium * Update to 2.41.0 diff --git a/debian/files b/debian/files index 17177192bf..e8edf7d8f3 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -fastfetch_2.41.0_source.buildinfo universe/utils optional +fastfetch_2.42.0_source.buildinfo universe/utils optional From 5c546ab8e7bac6938963b545264d6c87e65ec18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 30 Apr 2025 14:14:28 +0800 Subject: [PATCH 02/41] Parsing: silence compiler warnings --- src/common/parsing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/parsing.c b/src/common/parsing.c index 84337a9958..7aeea191e8 100644 --- a/src/common/parsing.c +++ b/src/common/parsing.c @@ -200,14 +200,14 @@ void ffParseDuration(uint64_t totalSeconds, FFstrbuf* result) return; } - uint32_t seconds = totalSeconds % 60; + uint32_t seconds = (uint32_t) (totalSeconds % 60); totalSeconds /= 60; if (seconds >= 30) totalSeconds++; - uint32_t minutes = totalSeconds % 60; + uint32_t minutes = (uint32_t) (totalSeconds % 60); totalSeconds /= 60; - uint32_t hours = totalSeconds % 24; + uint32_t hours = (uint32_t) (totalSeconds % 24); totalSeconds /= 24; uint32_t days = (uint32_t) totalSeconds; From 3dd78422eb0623a8cfab954fd9b9b1d416a3809a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 30 Apr 2025 14:47:37 +0800 Subject: [PATCH 03/41] Global: Improve `ARRAY_SIZE` macro using `__is_array` --- src/fastfetch.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fastfetch.h b/src/fastfetch.h index 1c99a8c2a1..d20248e936 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -26,7 +26,9 @@ #include "options/general.h" #ifdef __has_builtin - #if __has_builtin(__builtin_types_compatible_p) + #if __has_builtin(__is_array) + #define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) + #elif __has_builtin(__builtin_types_compatible_p) #define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) #endif #endif From 561574ae94760ad60624f28412f277df8294ad22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 30 Apr 2025 16:10:53 +0800 Subject: [PATCH 04/41] CPU (Windows): always use `XxxW` --- src/detection/cpu/cpu_windows.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index 2f6a703b4d..cf95798f78 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -22,11 +22,11 @@ static const char* detectThermalTemp(double* result) __attribute__((__cleanup__(ffPdhOpenCloseQuery))) HQUERY query = NULL; - if (PdhOpenQuery(NULL, 0, &query) != ERROR_SUCCESS) + if (PdhOpenQueryW(NULL, 0, &query) != ERROR_SUCCESS) return "Failed to open PDH query"; HCOUNTER counter = NULL; - if (PdhAddEnglishCounter(query, + if (PdhAddEnglishCounterW(query, L"\\Thermal Zone Information(*)\\Temperature", 0, &counter) != ERROR_SUCCESS) From 599e0d393d12720cddb3a35581c014922d54404f Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 1 May 2025 21:27:51 +0800 Subject: [PATCH 05/41] Display: use height to calculate scale factor Seems more accurate --- src/modules/display/display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 604f17615f..a8fa7a728c 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -182,7 +182,7 @@ void ffPrintDisplay(FFDisplayOptions* options) else buf[0] = '\0'; - double scaleFactor = (double) result->width / (double) result->scaledWidth; + double scaleFactor = (double) result->height / (double) result->scaledHeight; FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) { FF_FORMAT_ARG(result->width, "width"), From 305776eb947f778a34104cc0892fccd4d94779a6 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 2 May 2025 13:42:48 +0800 Subject: [PATCH 06/41] CPU (SunOS): support physical core count and package count detection --- src/detection/cpu/cpu_sunos.c | 45 ++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/detection/cpu/cpu_sunos.c b/src/detection/cpu/cpu_sunos.c index 474ba24a67..6f9f668bbd 100644 --- a/src/detection/cpu/cpu_sunos.c +++ b/src/detection/cpu/cpu_sunos.c @@ -1,5 +1,6 @@ #include "cpu.h" #include "common/processing.h" +#include "util/stringUtils.h" #include static const char* detectCPUTempByKstat(kstat_ctl_t* kc, FFCPUResult* cpu) @@ -61,6 +62,45 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) kstat_close(*pkc); } +static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) +{ + uint64_t low = 0, high = 0; + for (kstat_t* ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) + { + if (ffStrStartsWith(ksp->ks_module, "cpu_info")) + { + if (kstat_read(kc, ksp, NULL) < 0) + continue; + + kstat_named_t* stat = kstat_data_lookup(ksp, type); + if (!stat) + continue; + + uint32_t id = 0; + switch (stat->data_type) + { + #ifdef _INT64_TYPE + case KSTAT_DATA_INT64: + case KSTAT_DATA_UINT64: + id = (uint32_t) stat->value.ui64; + break; + #endif + case KSTAT_DATA_INT32: + case KSTAT_DATA_UINT32: + id = stat->value.ui32; + break; + default: + continue; + } + if (__builtin_expect(id > 64, false)) + high |= 1ULL << (id - 64); + else + low |= 1ULL << id; + } + } + return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high)); +} + const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); @@ -93,9 +133,12 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) if (ks && kstat_read(kc, ks, NULL) >= 0) { kstat_named_t* kn = kstat_data_lookup(ks, "ncpus"); - if (kn) cpu->coresLogical = cpu->coresPhysical = cpu->coresOnline = (uint16_t) kn->value.ui32; + if (kn) cpu->coresLogical = cpu->coresOnline = (uint16_t) kn->value.ui32; } + cpu->packages = countTypeId(kc, "chip_id"); + cpu->coresPhysical = countTypeId(kc, "core_id"); + if (options->temp) { if (detectCPUTempByKstat(kc, cpu) != NULL) From e3592eb2c34c92217527e9a457b354d1d563a081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 5 May 2025 13:41:12 +0800 Subject: [PATCH 07/41] CPU (FreeBSD): simplify physical core count detection --- src/detection/cpu/cpu_bsd.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 6db4dc1abb..7eed83beaa 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -36,7 +36,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) return "sysctlbyname(hw.model) failed"; cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1); - cpu->coresPhysical = 0; + cpu->coresPhysical = (uint16_t) ffSysctlGetInt("kern.smp.cores", 0); cpu->coresOnline = (uint16_t) ffSysctlGetInt("kern.smp.cpus", cpu->coresLogical); FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); @@ -57,39 +57,8 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) // // // - char* line = NULL; - size_t len = 0; - bool inLvl2 = false, threadGroup = false; - uint32_t cpuCount = 0; - while (ffStrbufGetline(&line, &len, &buffer)) - { - if (!inLvl2) - { - if (ffStrStartsWith(line, " packages++; - } - else - { - if (ffStrEquals(line, " ")) - { - cpu->coresPhysical += threadGroup ? 1 : cpuCount; - inLvl2 = false; - } - else if (cpuCount == 0 && ffStrStartsWith(line, " 0 && ffStrStartsWith(line, " ")) - { - if (ffStrContains(line, "THREAD group")) - threadGroup = true; - } - } - } + for (char* p = buffer.chars; (p = strstr(p, "\n \n")); ++p) + cpu->packages++; } #if FF_HAVE_CPUSET && (__x86_64__ || __i386__) From f59491b25df17022601d5c7e332c2e937bb32061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 5 May 2025 22:02:36 +0800 Subject: [PATCH 08/41] Disk (Linux): fix possible bug on 32-bit platforms Fix #1734 --- src/detection/disk/disk_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 3472c8d303..e67304ac40 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -240,9 +240,9 @@ static void detectStats(FFDisk* disk) if(statvfs(disk->mountpoint.chars, &fs) != 0) memset(&fs, 0, sizeof(fs)); //Set all values to 0, so our values get initialized to 0 too - disk->bytesTotal = fs.f_blocks * fs.f_frsize; - disk->bytesFree = fs.f_bfree * fs.f_frsize; - disk->bytesAvailable = fs.f_bavail * fs.f_frsize; + disk->bytesTotal = fs.f_blocks * (uint64_t) fs.f_frsize; + disk->bytesFree = fs.f_bfree * (uint64_t) fs.f_frsize; + disk->bytesAvailable = fs.f_bavail * (uint64_t) fs.f_frsize; disk->bytesUsed = 0; // To be filled in ./disk.c if (fs.f_files >= fs.f_ffree) From ef7f61309f2fa52b056a711ef3eb377253475db3 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 6 May 2025 09:26:47 +0800 Subject: [PATCH 09/41] GPU (Linux): fix asahi linux support again Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64 --- src/detection/gpu/gpu_asahi.h | 91 ----------------------------------- src/detection/gpu/gpu_linux.c | 63 ++++++++++++------------ 2 files changed, 31 insertions(+), 123 deletions(-) delete mode 100644 src/detection/gpu/gpu_asahi.h diff --git a/src/detection/gpu/gpu_asahi.h b/src/detection/gpu/gpu_asahi.h deleted file mode 100644 index b6cf9b65b4..0000000000 --- a/src/detection/gpu/gpu_asahi.h +++ /dev/null @@ -1,91 +0,0 @@ -#if __aarch64__ && FF_HAVE_DRM - -#include -#include -#include - -#if __has_include() - -#include - -#else - -// https://github.com/AsahiLinux/linux/blob/asahi/include/uapi/drm/asahi_drm.h -/* SPDX-License-Identifier: MIT */ -/* Copyright (C) The Asahi Linux Contributors */ - -#define DRM_ASAHI_UNSTABLE_UABI_VERSION 10011 - -#define DRM_ASAHI_GET_PARAMS 0x00 -#define DRM_ASAHI_MAX_CLUSTERS 32 -struct drm_asahi_params_global -{ - __u32 unstable_uabi_version; - __u32 pad0; - - __u64 feat_compat; - __u64 feat_incompat; - - __u32 gpu_generation; - __u32 gpu_variant; - __u32 gpu_revision; - __u32 chip_id; - - __u32 num_dies; - __u32 num_clusters_total; - __u32 num_cores_per_cluster; - __u32 num_frags_per_cluster; - __u32 num_gps_per_cluster; - __u32 num_cores_total_active; - __u64 core_masks[DRM_ASAHI_MAX_CLUSTERS]; - - __u32 vm_page_size; - __u32 pad1; - __u64 vm_user_start; - __u64 vm_user_end; - __u64 vm_usc_start; - __u64 vm_usc_end; - __u64 vm_kernel_min_size; - - __u32 max_syncs_per_submission; - __u32 max_commands_per_submission; - __u32 max_commands_in_flight; - __u32 max_attachments; - - __u32 timer_frequency_hz; - __u32 min_frequency_khz; - __u32 max_frequency_khz; - __u32 max_power_mw; - - __u32 result_render_size; - __u32 result_compute_size; - - __u32 firmware_version[4]; -}; - -struct drm_asahi_get_params -{ - /** @extensions: Pointer to the first extension struct, if any */ - __u64 extensions; - - /** @param: Parameter group to fetch (MBZ) */ - __u32 param_group; - - /** @pad: MBZ */ - __u32 pad; - - /** @value: User pointer to write parameter struct */ - __u64 pointer; - - /** @value: Size of user buffer, max size supported on return */ - __u64 size; -}; - -enum -{ - DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOWR(DRM_COMMAND_BASE + DRM_ASAHI_GET_PARAMS, struct drm_asahi_get_params), -}; - -#endif // __has_include - -#endif // FF_HAVE_DRM diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index a64ce0de64..30528c8963 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -21,7 +21,12 @@ #include #endif -#include "gpu_asahi.h" +#if defined(FF_HAVE_DRM) && __has_include() + // https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h + // Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64 + #include + #define FF_HAVE_DRM_ASAHI 1 +#endif #define FF_STR_INDIR(x) #x #define FF_STR(x) FF_STR_INDIR(x) @@ -590,13 +595,13 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf #if __aarch64__ -FF_MAYBE_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, FFstrbuf* buffer, const char* drmKey) +FF_MAYBE_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, FF_MAYBE_UNUSED FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey) { if (sscanf(name, "agx-t%lu", &gpu->deviceId) == 1) ffStrbufSetStatic(&gpu->name, ffCPUAppleCodeToName((uint32_t) gpu->deviceId)); ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE); - #if FF_HAVE_DRM + #if FF_HAVE_DRM_ASAHI ffStrbufSetS(buffer, "/dev/dri/"); ffStrbufAppendS(buffer, drmKey); FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY); @@ -609,38 +614,32 @@ FF_MAYBE_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, cons .size = sizeof(paramsGlobal), }) >= 0) { - ffStrbufAppendF(&gpu->driver, " %u", paramsGlobal.unstable_uabi_version); + // They removed `unstable_uabi_version` from the struct. Hopefully they won't introduce new ABI changes. + gpu->coreCount = (int32_t) (paramsGlobal.num_clusters_total * paramsGlobal.num_cores_per_cluster); + gpu->frequency = paramsGlobal.max_frequency_khz / 1000; + gpu->deviceId = paramsGlobal.chip_id; - // FIXME: They will introduce ABI breaking changes. Always check the latest version - // https://www.reddit.com/r/AsahiLinux/comments/1ei2qiv/comment/lgm0v5s/ - if (paramsGlobal.unstable_uabi_version == DRM_ASAHI_UNSTABLE_UABI_VERSION) + if (!gpu->name.length) { - gpu->coreCount = (int) paramsGlobal.num_cores_total_active; - gpu->frequency = paramsGlobal.max_frequency_khz / 1000; - gpu->deviceId = paramsGlobal.chip_id; - - if (!gpu->name.length) - { - const char* variant = " Unknown"; - switch (paramsGlobal.gpu_variant) { - case 'G': - variant = ""; - break; - case 'S': - variant = " Pro"; - break; - case 'C': - variant = " Max"; - break; - case 'D': - variant = " Ultra"; - break; - } - ffStrbufSetF(&gpu->name, "Apple M%d%s (G%d%c %02X)", - paramsGlobal.gpu_generation - 12, variant, - paramsGlobal.gpu_generation, paramsGlobal.gpu_variant, - paramsGlobal.gpu_revision + 0xA0); + const char* variant = " Unknown"; + switch (paramsGlobal.gpu_variant) { + case 'G': + variant = ""; + break; + case 'S': + variant = " Pro"; + break; + case 'C': + variant = " Max"; + break; + case 'D': + variant = " Ultra"; + break; } + ffStrbufSetF(&gpu->name, "Apple M%d%s (G%d%c %02X)", + paramsGlobal.gpu_generation - 12, variant, + paramsGlobal.gpu_generation, paramsGlobal.gpu_variant, + paramsGlobal.gpu_revision + 0xA0); } } } From 1557f0c5564a8288604824e55db47508f65e82c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 6 May 2025 16:04:12 +0800 Subject: [PATCH 10/41] Media (macOS): support macOS 15.4 Fix #1737 --- CMakeLists.txt | 5 +++++ src/data/nowPlaying.scptd | 24 ++++++++++++++++++++++ src/detection/media/media_apple.m | 34 ++++++++++++++++++++++++++++--- src/fastfetch_datatext.h.in | 4 ++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 src/data/nowPlaying.scptd diff --git a/CMakeLists.txt b/CMakeLists.txt index 661fbce4cf..374974ffc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,6 +326,11 @@ endif() fastfetch_encode_c_string("${DATATEXT_JSON_HELP}" DATATEXT_JSON_HELP) fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE) +if(APPLE) + # See src/detection/media/media_apple.m + fastfetch_load_text(src/data/nowPlaying.scptd DATATEXT_NOWPLAYING) +endif() + configure_file(src/fastfetch_config.h.in fastfetch_config.h @ONLY) configure_file(src/fastfetch_datatext.h.in fastfetch_datatext.h @ONLY) if(APPLE) diff --git a/src/data/nowPlaying.scptd b/src/data/nowPlaying.scptd new file mode 100644 index 0000000000..21ce405016 --- /dev/null +++ b/src/data/nowPlaying.scptd @@ -0,0 +1,24 @@ +use scripting additions +use framework "/System/Library/PrivateFrameworks/MediaRemote.framework" + +set MRNowPlayingRequest to current application's NSClassFromString("MRNowPlayingRequest") + +if MRNowPlayingRequest's localNowPlayingItem() is missing value then + return +end if + +if MRNowPlayingRequest's localIsPlaying() then + set status to "Playing" +else + set status to "Paused" +end if + +set infoDict to MRNowPlayingRequest's localNowPlayingItem()'s nowPlayingInfo() +set bundleObj to MRNowPlayingRequest's localNowPlayingPlayerPath()'s client() + +return status & " +" & (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoTitle" as text) & " +" & (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoArtist" as text) & " +" & (infoDict's valueForKey:"kMRMediaRemoteNowPlayingInfoAlbum" as text) & " +" & (bundleObj's bundleIdentifier() as text) & " +" & (bundleObj's displayName() as text) diff --git a/src/detection/media/media_apple.m b/src/detection/media/media_apple.m index 818bf2cbff..1d2356ad22 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -1,8 +1,10 @@ #include "fastfetch.h" #include "detection/media/media.h" #include "common/library.h" +#include "common/processing.h" #include "util/apple/cf_helpers.h" #include "util/apple/osascript.h" +#include "fastfetch_datatext.h" #import #import @@ -13,7 +15,7 @@ extern CFStringRef MRNowPlayingClientGetParentAppBundleIdentifier(id clientObj) __attribute__((weak_import)); void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)) __attribute__((weak_import)); -static const char* getMedia(FFMediaResult* result) +static const char* getMediaByMediaRemote(FFMediaResult* result) { #define FF_TEST_FN_EXISTANCE(fn) if (!fn) return "MediaRemote function " #fn " is not available" FF_TEST_FN_EXISTANCE(MRMediaRemoteGetNowPlayingInfo); @@ -79,8 +81,34 @@ return error; } +static const char* getMediaByOsascript(FFMediaResult* result) +{ + FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); + // The script must be executed by `/usr/bin/osascript`. `ffOsascript` doesn't work here + const char* error = ffProcessAppendStdOut(&buffer, (char* const[]) { + "/usr/bin/osascript", + "-e", + FASTFETCH_DATATEXT_NOWPLAYING, + nil + }); + if (error) return error; + if (buffer.length == 0) return "No media found"; + + // status\ntitle\nartist\nalbum\nbundleName\nappName + FFstrbuf* const varList[] = { &result->status, &result->song, &result->artist, &result->album, &result->playerId, &result->player }; + char* line = NULL; + size_t len = 0; + for (uint32_t i = 0; i < ARRAY_SIZE(varList) && ffStrbufGetline(&line, &len, &buffer); ++i) + ffStrbufSetS(varList[i], line); + return NULL; +} + void ffDetectMediaImpl(FFMediaResult* media) { - const char* error = getMedia(media); - ffStrbufAppendS(&media->error, error); + const char* error; + if (@available(macOS 15.4, *)) + error = getMediaByOsascript(media); + else + error = getMediaByMediaRemote(media); + if (error) ffStrbufAppendS(&media->error, error); } diff --git a/src/fastfetch_datatext.h.in b/src/fastfetch_datatext.h.in index 5c73b9d498..f40367a921 100644 --- a/src/fastfetch_datatext.h.in +++ b/src/fastfetch_datatext.h.in @@ -2,3 +2,7 @@ #define FASTFETCH_DATATEXT_JSON_HELP @DATATEXT_JSON_HELP@ #define FASTFETCH_DATATEXT_STRUCTURE @DATATEXT_STRUCTURE@ + +#ifdef __APPLE__ + #define FASTFETCH_DATATEXT_NOWPLAYING @DATATEXT_NOWPLAYING@ +#endif From 4b62a3c75b7d3af8a260f916734de027495ef4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 6 May 2025 16:07:12 +0800 Subject: [PATCH 11/41] 3rdparty: upgrade yyjson to 0.11.0 --- src/3rdparty/yyjson/repo.json | 2 +- src/3rdparty/yyjson/yyjson.c | 3807 ++++++++++++++++++++++----------- src/3rdparty/yyjson/yyjson.h | 1364 +++++++----- 3 files changed, 3319 insertions(+), 1854 deletions(-) diff --git a/src/3rdparty/yyjson/repo.json b/src/3rdparty/yyjson/repo.json index f0deb32295..b459f526a5 100644 --- a/src/3rdparty/yyjson/repo.json +++ b/src/3rdparty/yyjson/repo.json @@ -1,6 +1,6 @@ { "home": "https://github.com/ibireme/yyjson", "license": "MIT ( embed in source )", - "version": "0.10.0", + "version": "0.11.0", "author": "ibireme" } diff --git a/src/3rdparty/yyjson/yyjson.c b/src/3rdparty/yyjson/yyjson.c index 16ecbacf52..1d55473c8b 100644 --- a/src/3rdparty/yyjson/yyjson.c +++ b/src/3rdparty/yyjson/yyjson.c @@ -1,16 +1,16 @@ /*============================================================================== Copyright (c) 2020 YaoYuan - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,7 +21,7 @@ *============================================================================*/ #include "yyjson.h" -#include +#include /* for `HUGE_VAL/INFINIY/NAN` macros, no libm required */ @@ -119,9 +119,13 @@ uint32_t yyjson_version(void) { /* IEEE 754 floating-point binary representation */ #if defined(__STDC_IEC_559__) || defined(__STDC_IEC_60559_BFP__) # define YYJSON_HAS_IEEE_754 1 -#elif (FLT_RADIX == 2) && (DBL_MANT_DIG == 53) && (DBL_DIG == 15) && \ - (DBL_MIN_EXP == -1021) && (DBL_MAX_EXP == 1024) && \ - (DBL_MIN_10_EXP == -307) && (DBL_MAX_10_EXP == 308) +#elif FLT_RADIX == 2 && \ + FLT_MANT_DIG == 24 && FLT_DIG == 6 && \ + FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128 && \ + FLT_MIN_10_EXP == -37 && FLT_MAX_10_EXP == 38 && \ + DBL_MANT_DIG == 53 && DBL_DIG == 15 && \ + DBL_MIN_EXP == -1021 && DBL_MAX_EXP == 1024 && \ + DBL_MIN_10_EXP == -307 && DBL_MAX_10_EXP == 308 # define YYJSON_HAS_IEEE_754 1 #else # define YYJSON_HAS_IEEE_754 0 @@ -129,35 +133,35 @@ uint32_t yyjson_version(void) { /* Correct rounding in double number computations. - + On the x86 architecture, some compilers may use x87 FPU instructions for floating-point arithmetic. The x87 FPU loads all floating point number as 80-bit double-extended precision internally, then rounds the result to original precision, which may produce inaccurate results. For a more detailed explanation, see the paper: https://arxiv.org/abs/cs/0701192 - + Here are some examples of double precision calculation error: - + 2877.0 / 1e6 == 0.002877, but x87 returns 0.0028770000000000002 43683.0 * 1e21 == 4.3683e25, but x87 returns 4.3683000000000004e25 - + Here are some examples of compiler flags to generate x87 instructions on x86: - + clang -m32 -mno-sse gcc/icc -m32 -mfpmath=387 msvc /arch:SSE or /arch:IA32 - + If we are sure that there's no similar error described above, we can define the YYJSON_DOUBLE_MATH_CORRECT as 1 to enable the fast path calculation. This is not an accurate detection, it's just try to avoid the error at compile-time. An accurate detection can be done at run-time: - + bool is_double_math_correct(void) { volatile double r = 43683.0; r *= 1e21; return r == 4.3683e25; } - + See also: utils.h in https://github.com/google/double-conversion/ */ #if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__) @@ -245,21 +249,22 @@ uint32_t yyjson_version(void) { /* This macro controls how yyjson handles unaligned memory accesses. - - By default, yyjson uses `memcpy()` for memory copying. This takes advantage of - the compiler's automatic optimizations to generate unaligned memory access - instructions when the target architecture supports it. - - However, for some older compilers or architectures where `memcpy()` isn't - optimized well and may generate unnecessary function calls, consider defining - this macro as 1. In such cases, yyjson switches to manual byte-by-byte access, - potentially improving performance. An example of the generated assembly code on - the ARM platform can be found here: https://godbolt.org/z/334jjhxPT - - As this flag has already been enabled for some common architectures in the - following code, users typically don't need to manually specify it. If users are - unsure about it, please review the generated assembly code or perform actual - benchmark to make an informed decision. + + By default, yyjson uses `memcpy()` for memory copying. This allows the compiler + to optimize the code and emit unaligned memory access instructions when + supported by the target architecture. + + However, on some older compilers or architectures where `memcpy()` is not + well-optimized and may result in unnecessary function calls, defining this + macro as 1 may help. In such cases, yyjson switches to manual byte-by-byte + access, which can potentially improve performance. + + An example of the generated assembly code for ARM can be found here: + https://godbolt.org/z/334jjhxPT + + This flag is already enabled for common architectures in the following code, + so manual configuration is usually unnecessary. If unsure, you can check the + generated assembly or run benchmarks to make an informed decision. */ #ifndef YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS # if defined(__ia64) || defined(_IA64) || defined(__IA64__) || \ @@ -283,15 +288,15 @@ uint32_t yyjson_version(void) { /* Estimated initial ratio of the JSON data (data_size / value_count). For example: - + data: {"id":12345678,"name":"Harry"} data_size: 30 value_count: 5 ratio: 6 - + yyjson uses dynamic memory with a growth factor of 1.5 when reading and writing JSON, the ratios below are used to determine the initial memory size. - + A too large ratio will waste memory, and a too small ratio will cause multiple memory growths and degrade performance. Currently, these ratios are generated with some commonly used JSON datasets. @@ -317,6 +322,9 @@ uint32_t yyjson_version(void) { #ifndef YYJSON_DISABLE_WRITER #define YYJSON_DISABLE_WRITER 0 #endif +#ifndef YYJSON_DISABLE_INCR_READER +#define YYJSON_DISABLE_INCR_READER 0 +#endif #ifndef YYJSON_DISABLE_UTILS #define YYJSON_DISABLE_UTILS 0 #endif @@ -348,7 +356,6 @@ uint32_t yyjson_version(void) { #define repeat8_incr(x) { x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) } #define repeat16_incr(x) { x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) \ x(8) x(9) x(10) x(11) x(12) x(13) x(14) x(15) } - #define repeat_in_1_18(x) { x(1) x(2) x(3) x(4) x(5) x(6) x(7) x(8) \ x(9) x(10) x(11) x(12) x(13) x(14) x(15) x(16) \ x(17) x(18) } @@ -374,38 +381,68 @@ uint32_t yyjson_version(void) { /* Used to write u64 literal for C89 which doesn't support "ULL" suffix. */ #undef U64 #define U64(hi, lo) ((((u64)hi##UL) << 32U) + lo##UL) +#undef U32 +#define U32(hi) ((u32)(hi##UL)) /* Used to cast away (remove) const qualifier. */ #define constcast(type) (type)(void *)(size_t)(const void *) -/* flag test */ -#define has_read_flag(_flag) unlikely(read_flag_eq(flg, YYJSON_READ_##_flag)) -#define has_write_flag(_flag) unlikely(write_flag_eq(flg, YYJSON_WRITE_##_flag)) +/* Common error messages. */ +#define MSG_FOPEN "failed to open file" +#define MSG_FREAD "failed to read file" +#define MSG_FWRITE "failed to write file" +#define MSG_FCLOSE "failed to close file" +#define MSG_MALLOC "failed to allocate memory" +#define MSG_CHAT_T "invalid literal, expected 'true'" +#define MSG_CHAR_F "invalid literal, expected 'false'" +#define MSG_CHAR_N "invalid literal, expected 'null'" +#define MSG_CHAR "unexpected character, expected a JSON value" +#define MSG_ARR_END "unexpected character, expected ',' or ']'" +#define MSG_OBJ_KEY "unexpected character, expected a string key" +#define MSG_OBJ_SEP "unexpected character, expected ':' after key" +#define MSG_OBJ_END "unexpected character, expected ',' or '}'" +#define MSG_GARBAGE "unexpected content after document" +#define MSG_NOT_END "unexpected end of data" +#define MSG_COMMENT "unclosed multiline comment" +#define MSG_COMMA "trailing comma is not allowed" +#define MSG_INF_NAN "nan or inf number is not allowed" +#define MSG_ERR_TYPE "invalid JSON value type" +#define MSG_ERR_UTF8 "invalid utf-8 encoding in string" +#define MSG_ERR_BOM "UTF-8 byte order mark (BOM) is not supported" +#define MSG_ERR_UTF16 "UTF-16 encoding is not supported" +#define MSG_ERR_UTF32 "UTF-32 encoding is not supported" +/* + Check flags using a function to avoid `always false` warnings. + When non-standard features are disabled, unnecessary checks + will be evaluated and optimized out at compile-time. + */ static_inline bool read_flag_eq(yyjson_read_flag flg, yyjson_read_flag chk) { #if YYJSON_DISABLE_NON_STANDARD if (chk == YYJSON_READ_ALLOW_INF_AND_NAN || chk == YYJSON_READ_ALLOW_COMMENTS || chk == YYJSON_READ_ALLOW_TRAILING_COMMAS || - chk == YYJSON_READ_ALLOW_INVALID_UNICODE) - return false; /* this should be evaluated at compile-time */ + chk == YYJSON_READ_ALLOW_INVALID_UNICODE || + chk == YYJSON_READ_ALLOW_BOM) + return false; #endif return (flg & chk) != 0; } - static_inline bool write_flag_eq(yyjson_write_flag flg, yyjson_write_flag chk) { #if YYJSON_DISABLE_NON_STANDARD if (chk == YYJSON_WRITE_ALLOW_INF_AND_NAN || chk == YYJSON_WRITE_ALLOW_INVALID_UNICODE) - return false; /* this should be evaluated at compile-time */ + return false; #endif return (flg & chk) != 0; } +#define has_read_flag(_flag) unlikely(read_flag_eq(flg, YYJSON_READ_##_flag)) +#define has_write_flag(_flag) unlikely(write_flag_eq(flg, YYJSON_WRITE_##_flag)) /*============================================================================== - * Integer Constants + * Number Constants *============================================================================*/ /* U64 constant values */ @@ -424,12 +461,6 @@ static_inline bool write_flag_eq(yyjson_write_flag flg, yyjson_write_flag chk) { #undef USIZE_SAFE_DIG #define USIZE_SAFE_DIG (sizeof(usize) == 8 ? U64_SAFE_DIG : U32_SAFE_DIG) - - -/*============================================================================== - * IEEE-754 Double Number Constants - *============================================================================*/ - /* Inf raw value (positive) */ #define F64_RAW_INF U64(0x7FF00000, 0x00000000) @@ -440,44 +471,58 @@ static_inline bool write_flag_eq(yyjson_write_flag flg, yyjson_write_flag chk) { #define F64_RAW_NAN U64(0x7FF80000, 0x00000000) #endif -/* double number bits */ +/* maximum significant digits count in decimal when reading double number */ +#define F64_MAX_DEC_DIG 768 + +/* maximum decimal power of double number (1.7976931348623157e308) */ +#define F64_MAX_DEC_EXP 308 + +/* minimum decimal power of double number (4.9406564584124654e-324) */ +#define F64_MIN_DEC_EXP (-324) + +/* maximum binary power of double number */ +#define F64_MAX_BIN_EXP 1024 + +/* minimum binary power of double number */ +#define F64_MIN_BIN_EXP (-1021) + +/* float/double number bits */ +#define F32_BITS 32 #define F64_BITS 64 -/* double number exponent part bits */ +/* float/double number exponent part bits */ +#define F32_EXP_BITS 8 #define F64_EXP_BITS 11 -/* double number significand part bits */ +/* float/double number significand part bits */ +#define F32_SIG_BITS 23 #define F64_SIG_BITS 52 -/* double number significand part bits (with 1 hidden bit) */ +/* float/double number significand part bits (with 1 hidden bit) */ +#define F32_SIG_FULL_BITS 24 #define F64_SIG_FULL_BITS 53 -/* double number significand bit mask */ +/* float/double number significand bit mask */ +#define F32_SIG_MASK U32(0x007FFFFF) #define F64_SIG_MASK U64(0x000FFFFF, 0xFFFFFFFF) -/* double number exponent bit mask */ +/* float/double number exponent bit mask */ +#define F32_EXP_MASK U32(0x7F800000) #define F64_EXP_MASK U64(0x7FF00000, 0x00000000) -/* double number exponent bias */ +/* float/double number exponent bias */ +#define F32_EXP_BIAS 127 #define F64_EXP_BIAS 1023 -/* double number significant digits count in decimal */ +/* float/double number significant digits count in decimal */ +#define F32_DEC_DIG 9 #define F64_DEC_DIG 17 -/* max significant digits count in decimal when reading double number */ -#define F64_MAX_DEC_DIG 768 - -/* maximum decimal power of double number (1.7976931348623157e308) */ -#define F64_MAX_DEC_EXP 308 - -/* minimum decimal power of double number (4.9406564584124654e-324) */ -#define F64_MIN_DEC_EXP (-324) - -/* maximum binary power of double number */ -#define F64_MAX_BIN_EXP 1024 +/* buffer length required for float/double number writer */ +#define FP_BUF_LEN 40 -/* minimum binary power of double number */ -#define F64_MIN_BIN_EXP (-1021) +/* maximum length of a number in incremental parsing */ +#define INCR_NUM_MAX_LEN 1024 @@ -520,120 +565,72 @@ typedef union v64_uni { v64 v; u64 u; } v64_uni; * Load/Store Utils *============================================================================*/ -#if YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS - #define byte_move_idx(x) ((char *)dst)[x] = ((const char *)src)[x]; static_inline void byte_copy_2(void *dst, const void *src) { - repeat2_incr(byte_move_idx) -} - -static_inline void byte_copy_4(void *dst, const void *src) { - repeat4_incr(byte_move_idx) -} - -static_inline void byte_copy_8(void *dst, const void *src) { - repeat8_incr(byte_move_idx) -} - -static_inline void byte_copy_16(void *dst, const void *src) { - repeat16_incr(byte_move_idx) -} - -static_inline void byte_move_2(void *dst, const void *src) { - repeat2_incr(byte_move_idx) -} - -static_inline void byte_move_4(void *dst, const void *src) { - repeat4_incr(byte_move_idx) -} - -static_inline void byte_move_8(void *dst, const void *src) { - repeat8_incr(byte_move_idx) -} - -static_inline void byte_move_16(void *dst, const void *src) { - repeat16_incr(byte_move_idx) -} - -static_inline bool byte_match_2(void *buf, const char *pat) { - return - ((char *)buf)[0] == ((const char *)pat)[0] && - ((char *)buf)[1] == ((const char *)pat)[1]; -} - -static_inline bool byte_match_4(void *buf, const char *pat) { - return - ((char *)buf)[0] == ((const char *)pat)[0] && - ((char *)buf)[1] == ((const char *)pat)[1] && - ((char *)buf)[2] == ((const char *)pat)[2] && - ((char *)buf)[3] == ((const char *)pat)[3]; -} - -static_inline u16 byte_load_2(const void *src) { - v16_uni uni; - uni.v.c[0] = ((const char *)src)[0]; - uni.v.c[1] = ((const char *)src)[1]; - return uni.u; -} - -static_inline u32 byte_load_3(const void *src) { - v32_uni uni; - uni.v.c[0] = ((const char *)src)[0]; - uni.v.c[1] = ((const char *)src)[1]; - uni.v.c[2] = ((const char *)src)[2]; - uni.v.c[3] = 0; - return uni.u; -} - -static_inline u32 byte_load_4(const void *src) { - v32_uni uni; - uni.v.c[0] = ((const char *)src)[0]; - uni.v.c[1] = ((const char *)src)[1]; - uni.v.c[2] = ((const char *)src)[2]; - uni.v.c[3] = ((const char *)src)[3]; - return uni.u; -} - -#undef byte_move_expr - -#else - -static_inline void byte_copy_2(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(dst, src, 2); +#else + repeat2_incr(byte_move_idx) +#endif } static_inline void byte_copy_4(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(dst, src, 4); +#else + repeat4_incr(byte_move_idx) +#endif } static_inline void byte_copy_8(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(dst, src, 8); +#else + repeat8_incr(byte_move_idx) +#endif } static_inline void byte_copy_16(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(dst, src, 16); +#else + repeat16_incr(byte_move_idx) +#endif } static_inline void byte_move_2(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS u16 tmp; memcpy(&tmp, src, 2); memcpy(dst, &tmp, 2); +#else + repeat2_incr(byte_move_idx) +#endif } static_inline void byte_move_4(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS u32 tmp; memcpy(&tmp, src, 4); memcpy(dst, &tmp, 4); +#else + repeat4_incr(byte_move_idx) +#endif } static_inline void byte_move_8(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS u64 tmp; memcpy(&tmp, src, 8); memcpy(dst, &tmp, 8); +#else + repeat8_incr(byte_move_idx) +#endif } static_inline void byte_move_16(void *dst, const void *src) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS char *pdst = (char *)dst; const char *psrc = (const char *)src; u64 tmp1, tmp2; @@ -641,64 +638,110 @@ static_inline void byte_move_16(void *dst, const void *src) { memcpy(&tmp2, psrc + 8, 8); memcpy(pdst, &tmp1, 8); memcpy(pdst + 8, &tmp2, 8); +#else + repeat16_incr(byte_move_idx) +#endif } static_inline bool byte_match_2(void *buf, const char *pat) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS v16_uni u1, u2; memcpy(&u1, buf, 2); memcpy(&u2, pat, 2); return u1.u == u2.u; +#else + return ((char *)buf)[0] == ((const char *)pat)[0] && + ((char *)buf)[1] == ((const char *)pat)[1]; +#endif } static_inline bool byte_match_4(void *buf, const char *pat) { +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS v32_uni u1, u2; memcpy(&u1, buf, 4); memcpy(&u2, pat, 4); return u1.u == u2.u; +#else + return ((char *)buf)[0] == ((const char *)pat)[0] && + ((char *)buf)[1] == ((const char *)pat)[1] && + ((char *)buf)[2] == ((const char *)pat)[2] && + ((char *)buf)[3] == ((const char *)pat)[3]; +#endif } static_inline u16 byte_load_2(const void *src) { v16_uni uni; +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(&uni, src, 2); +#else + uni.v.c[0] = ((const char *)src)[0]; + uni.v.c[1] = ((const char *)src)[1]; +#endif return uni.u; } static_inline u32 byte_load_3(const void *src) { v32_uni uni; +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(&uni, src, 2); uni.v.c[2] = ((const char *)src)[2]; uni.v.c[3] = 0; +#else + uni.v.c[0] = ((const char *)src)[0]; + uni.v.c[1] = ((const char *)src)[1]; + uni.v.c[2] = ((const char *)src)[2]; + uni.v.c[3] = 0; +#endif return uni.u; } static_inline u32 byte_load_4(const void *src) { v32_uni uni; +#if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(&uni, src, 4); +#else + v32_uni uni; + uni.v.c[0] = ((const char *)src)[0]; + uni.v.c[1] = ((const char *)src)[1]; + uni.v.c[2] = ((const char *)src)[2]; + uni.v.c[3] = ((const char *)src)[3]; +#endif return uni.u; } -#endif - /*============================================================================== * Number Utils * These functions are used to detect and convert NaN and Inf numbers. + * The `memcpy` is used to avoid violating the strict aliasing rule. *============================================================================*/ /** Convert raw binary to double. */ static_inline f64 f64_from_raw(u64 u) { - /* use memcpy to avoid violating the strict aliasing rule */ f64 f; - memcpy(&f, &u, 8); + memcpy(&f, &u, sizeof(u)); + return f; +} + +/** Convert raw binary to float. */ +static_inline f32 f32_from_raw(u32 u) { + f32 f; + memcpy(&f, &u, sizeof(u)); return f; } /** Convert double to raw binary. */ static_inline u64 f64_to_raw(f64 f) { - /* use memcpy to avoid violating the strict aliasing rule */ u64 u; - memcpy(&u, &f, 8); + memcpy(&u, &f, sizeof(u)); + return u; +} + +/** Convert double to raw binary. */ +static_inline u32 f32_to_raw(f32 f) { + u32 u; + memcpy(&u, &f, sizeof(u)); return u; } @@ -724,20 +767,14 @@ static_inline u64 f64_raw_get_nan(bool sign) { #endif } -/** - Convert normalized u64 (highest bit is 1) to f64. - - Some compiler (such as Microsoft Visual C++ 6.0) do not support converting - number from u64 to f64. This function will first convert u64 to i64 and then - to f64, with `to nearest` rounding mode. - */ -static_inline f64 normalized_u64_to_f64(u64 val) { -#if YYJSON_U64_TO_F64_NO_IMPL - i64 sig = (i64)((val >> 1) | (val & 1)); - return ((f64)sig) * (f64)2.0; -#else - return (f64)val; +/** Casting double to float, allow overflow. */ +#if yyjson_has_attribute(no_sanitize) +__attribute__((no_sanitize("undefined"))) +#elif yyjson_gcc_available(4, 9, 0) +__attribute__((__no_sanitize_undefined__)) #endif +static_inline f32 f64_to_f32(f64 val) { + return (f32)val; } @@ -806,10 +843,8 @@ static_inline u32 u64_lz_bits(u64 v) { hi |= 32; return (u32)63 - (u32)(hi_set ? hi : lo); #else - /* - branchless, use de Bruijn sequences - see: https://www.chessprogramming.org/BitScan - */ + /* branchless, use De Bruijn sequence */ + /* see: https://www.chessprogramming.org/BitScan */ const u8 table[64] = { 63, 16, 62, 7, 15, 36, 61, 3, 6, 14, 22, 26, 35, 47, 60, 2, 9, 5, 28, 11, 13, 21, 42, 19, 25, 31, 34, 40, 46, 52, 59, 1, @@ -841,10 +876,8 @@ static_inline u32 u64_tz_bits(u64 v) { hi += 32; return lo_set ? lo : hi; #else - /* - branchless, use de Bruijn sequences - see: https://www.chessprogramming.org/BitScan - */ + /* branchless, use De Bruijn sequence */ + /* see: https://www.chessprogramming.org/BitScan */ const u8 table[64] = { 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, @@ -947,6 +980,7 @@ static_inline usize fread_safe(void *buf, usize size, FILE *file) { /*============================================================================== * Default Memory Allocator + * * This is a simple libc memory allocator wrapper. *============================================================================*/ @@ -963,10 +997,7 @@ static void default_free(void *ctx, void *ptr) { } static const yyjson_alc YYJSON_DEFAULT_ALC = { - default_malloc, - default_realloc, - default_free, - NULL + default_malloc, default_realloc, default_free, NULL }; @@ -991,10 +1022,7 @@ static void null_free(void *ctx, void *ptr) { } static const yyjson_alc YYJSON_NULL_ALC = { - null_malloc, - null_realloc, - null_free, - NULL + null_malloc, null_realloc, null_free, NULL }; @@ -1029,10 +1057,10 @@ static void *pool_malloc(void *ctx_ptr, usize size) { /* assert(size != 0) */ pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *next, *prev = NULL, *cur = ctx->free_list; - + if (unlikely(size >= ctx->size)) return NULL; pool_size_align(&size); - + while (cur) { if (cur->size < size) { /* not enough space, try next chunk */ @@ -1062,7 +1090,7 @@ static void pool_free(void *ctx_ptr, void *ptr) { pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *cur = ((pool_chunk *)ptr) - 1; pool_chunk *prev = NULL, *next = ctx->free_list; - + while (next && next < cur) { prev = next; next = next->next; @@ -1070,7 +1098,7 @@ static void pool_free(void *ctx_ptr, void *ptr) { if (prev) prev->next = cur; else ctx->free_list = cur; cur->next = next; - + if (next && ((u8 *)cur + cur->size) == (u8 *)next) { /* merge cur to higher chunk */ cur->size += next->size; @@ -1088,13 +1116,13 @@ static void *pool_realloc(void *ctx_ptr, void *ptr, /* assert(ptr != NULL && size != 0 && old_size < size) */ pool_ctx *ctx = (pool_ctx *)ctx_ptr; pool_chunk *cur = ((pool_chunk *)ptr) - 1, *prev, *next, *tmp; - + /* check size */ if (unlikely(size >= ctx->size)) return NULL; pool_size_align(&old_size); pool_size_align(&size); if (unlikely(old_size == size)) return ptr; - + /* find next and prev chunk */ prev = NULL; next = ctx->free_list; @@ -1102,7 +1130,7 @@ static void *pool_realloc(void *ctx_ptr, void *ptr, prev = next; next = next->next; } - + if ((u8 *)cur + cur->size == (u8 *)next && cur->size + next->size >= size) { /* merge to higher chunk if they are contiguous */ usize free_size = cur->size + next->size - size; @@ -1133,7 +1161,7 @@ static void *pool_realloc(void *ctx_ptr, void *ptr, bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size) { pool_chunk *chunk; pool_ctx *ctx; - + if (unlikely(!alc)) return false; *alc = YYJSON_NULL_ALC; if (size < sizeof(pool_ctx) * 4) return false; @@ -1141,13 +1169,13 @@ bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size) { if (unlikely(!ctx)) return false; size -= (usize)((u8 *)ctx - (u8 *)buf); size = size_align_down(size, sizeof(pool_ctx)); - + chunk = (pool_chunk *)(ctx + 1); chunk->size = size - sizeof(pool_ctx); chunk->next = NULL; ctx->size = size; ctx->free_list = chunk; - + alc->malloc = pool_malloc; alc->realloc = pool_realloc; alc->free = pool_free; @@ -1211,9 +1239,9 @@ static void *dyn_malloc(void *ctx_ptr, usize size) { /* assert(size != 0) */ const yyjson_alc def = YYJSON_DEFAULT_ALC; dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; - dyn_chunk *chunk, *prev, *next; + dyn_chunk *chunk, *prev; if (unlikely(!dyn_size_align(&size))) return NULL; - + /* freelist is empty, create new chunk */ if (!ctx->free_list.next) { chunk = (dyn_chunk *)def.malloc(def.ctx, size); @@ -1223,7 +1251,7 @@ static void *dyn_malloc(void *ctx_ptr, usize size) { dyn_chunk_list_add(&ctx->used_list, chunk); return (void *)(chunk + 1); } - + /* find a large enough chunk, or resize the largest chunk */ prev = &ctx->free_list; while (true) { @@ -1250,11 +1278,10 @@ static void *dyn_realloc(void *ctx_ptr, void *ptr, /* assert(ptr != NULL && size != 0 && old_size < size) */ const yyjson_alc def = YYJSON_DEFAULT_ALC; dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; - dyn_chunk *prev, *next, *new_chunk; - dyn_chunk *chunk = (dyn_chunk *)ptr - 1; + dyn_chunk *new_chunk, *chunk = (dyn_chunk *)ptr - 1; if (unlikely(!dyn_size_align(&size))) return NULL; if (chunk->size >= size) return ptr; - + dyn_chunk_list_remove(&ctx->used_list, chunk); new_chunk = (dyn_chunk *)def.realloc(def.ctx, chunk, chunk->size, size); if (likely(new_chunk)) { @@ -1269,7 +1296,7 @@ static void dyn_free(void *ctx_ptr, void *ptr) { /* assert(ptr != NULL) */ dyn_ctx *ctx = (dyn_ctx *)ctx_ptr; dyn_chunk *chunk = (dyn_chunk *)ptr - 1, *prev; - + dyn_chunk_list_remove(&ctx->used_list, chunk); for (prev = &ctx->free_list; prev; prev = prev->next) { if (!prev->next || prev->next->size >= chunk->size) { @@ -1340,7 +1367,7 @@ bool unsafe_yyjson_str_pool_grow(yyjson_str_pool *pool, const yyjson_alc *alc, usize len) { yyjson_str_chunk *chunk; usize size, max_len; - + /* create a new chunk */ max_len = USIZE_MAX - sizeof(yyjson_str_chunk); if (unlikely(len > max_len)) return false; @@ -1348,14 +1375,14 @@ bool unsafe_yyjson_str_pool_grow(yyjson_str_pool *pool, size = yyjson_max(pool->chunk_size, size); chunk = (yyjson_str_chunk *)alc->malloc(alc->ctx, size); if (unlikely(!chunk)) return false; - + /* insert the new chunk as the head of the linked list */ chunk->next = pool->chunks; chunk->chunk_size = size; pool->chunks = chunk; pool->cur = (char *)chunk + sizeof(yyjson_str_chunk); pool->end = (char *)chunk + size; - + /* the next chunk is twice the size of the current one */ size = yyjson_min(pool->chunk_size * 2, pool->chunk_size_max); if (size < pool->chunk_size) size = pool->chunk_size_max; /* overflow */ @@ -1367,7 +1394,7 @@ bool unsafe_yyjson_val_pool_grow(yyjson_val_pool *pool, const yyjson_alc *alc, usize count) { yyjson_val_chunk *chunk; usize size, max_count; - + /* create a new chunk */ max_count = USIZE_MAX / sizeof(yyjson_mut_val) - 1; if (unlikely(count > max_count)) return false; @@ -1375,14 +1402,14 @@ bool unsafe_yyjson_val_pool_grow(yyjson_val_pool *pool, size = yyjson_max(pool->chunk_size, size); chunk = (yyjson_val_chunk *)alc->malloc(alc->ctx, size); if (unlikely(!chunk)) return false; - + /* insert the new chunk as the head of the linked list */ chunk->next = pool->chunks; chunk->chunk_size = size; pool->chunks = chunk; pool->cur = (yyjson_mut_val *)(void *)((u8 *)chunk) + 1; pool->end = (yyjson_mut_val *)(void *)((u8 *)chunk + size); - + /* the next chunk is twice the size of the current one */ size = yyjson_min(pool->chunk_size * 2, pool->chunk_size_max); if (size < pool->chunk_size) size = pool->chunk_size_max; /* overflow */ @@ -1420,7 +1447,7 @@ yyjson_mut_doc *yyjson_mut_doc_new(const yyjson_alc *alc) { doc = (yyjson_mut_doc *)alc->malloc(alc->ctx, sizeof(yyjson_mut_doc)); if (!doc) return NULL; memset(doc, 0, sizeof(yyjson_mut_doc)); - + doc->alc = *alc; doc->str_pool.chunk_size = YYJSON_MUT_DOC_STR_POOL_INIT_SIZE; doc->str_pool.chunk_size_max = YYJSON_MUT_DOC_STR_POOL_MAX_SIZE; @@ -1432,7 +1459,7 @@ yyjson_mut_doc *yyjson_mut_doc_new(const yyjson_alc *alc) { yyjson_mut_doc *yyjson_doc_mut_copy(yyjson_doc *doc, const yyjson_alc *alc) { yyjson_mut_doc *m_doc; yyjson_mut_val *m_val; - + if (!doc || !doc->root) return NULL; m_doc = yyjson_mut_doc_new(alc); if (!m_doc) return NULL; @@ -1449,10 +1476,10 @@ yyjson_mut_doc *yyjson_mut_doc_mut_copy(yyjson_mut_doc *doc, const yyjson_alc *alc) { yyjson_mut_doc *m_doc; yyjson_mut_val *m_val; - + if (!doc) return NULL; if (!doc->root) return yyjson_mut_doc_new(alc); - + m_doc = yyjson_mut_doc_new(alc); if (!m_doc) return NULL; m_val = yyjson_mut_val_mut_copy(m_doc, doc->root); @@ -1474,7 +1501,7 @@ yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *m_doc, usize i_vals_len; yyjson_mut_val *m_vals, *m_val; yyjson_val *i_val, *i_end; - + if (!m_doc || !i_vals) return NULL; i_end = unsafe_yyjson_get_next(i_vals); i_vals_len = (usize)(unsafe_yyjson_get_next(i_vals) - i_vals); @@ -1482,7 +1509,7 @@ yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *m_doc, if (!m_vals) return NULL; i_val = i_vals; m_val = m_vals; - + for (; i_val < i_end; i_val++, m_val++) { yyjson_type type = unsafe_yyjson_get_type(i_val); m_val->tag = i_val->tag; @@ -1527,7 +1554,6 @@ yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *m_doc, } } } - return m_vals; } @@ -1543,7 +1569,7 @@ static yyjson_mut_val *unsafe_yyjson_mut_val_mut_copy(yyjson_mut_doc *m_doc, yyjson_mut_val *m_val = unsafe_yyjson_mut_val(m_doc, 1); if (unlikely(!m_val)) return NULL; m_val->tag = m_vals->tag; - + switch (unsafe_yyjson_get_type(m_vals)) { case YYJSON_TYPE_OBJ: case YYJSON_TYPE_ARR: @@ -1562,7 +1588,6 @@ static yyjson_mut_val *unsafe_yyjson_mut_val_mut_copy(yyjson_mut_doc *m_doc, prev->next = (yyjson_mut_val *)m_val->uni.ptr; } break; - case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: { const char *str = m_vals->uni.str; @@ -1571,12 +1596,10 @@ static yyjson_mut_val *unsafe_yyjson_mut_val_mut_copy(yyjson_mut_doc *m_doc, if (!m_val->uni.str) return NULL; break; } - default: m_val->uni = m_vals->uni; break; } - return m_val; } @@ -1663,16 +1686,16 @@ yyjson_doc *yyjson_mut_val_imut_copy(yyjson_mut_val *mval, usize val_num = 0, str_sum = 0, hdr_size, buf_size; yyjson_doc *doc = NULL; yyjson_val *val_hdr = NULL; - + /* This value should be NULL here. Setting a non-null value suppresses warning from the clang analyzer. */ char *str_hdr = (char *)(void *)&str_sum; if (!mval) return NULL; if (!alc) alc = &YYJSON_DEFAULT_ALC; - + /* traverse the input value to get pool size */ yyjson_mut_stat(mval, &val_num, &str_sum); - + /* create doc and val pool */ hdr_size = size_align_up(sizeof(yyjson_doc), sizeof(yyjson_val)); buf_size = hdr_size + val_num * sizeof(yyjson_val); @@ -1682,7 +1705,7 @@ yyjson_doc *yyjson_mut_val_imut_copy(yyjson_mut_val *mval, val_hdr = (yyjson_val *)(void *)((char *)(void *)doc + hdr_size); doc->root = val_hdr; doc->alc = *alc; - + /* create str pool */ if (str_sum > 0) { str_hdr = (char *)alc->malloc(alc->ctx, str_sum); @@ -1692,7 +1715,7 @@ yyjson_doc *yyjson_mut_val_imut_copy(yyjson_mut_val *mval, return NULL; } } - + /* copy vals and strs */ doc->val_read = yyjson_imut_copy(&val_hdr, &str_hdr, mval); doc->dat_read = str_sum + 1; @@ -1724,7 +1747,7 @@ static_inline bool unsafe_yyjson_str_equals(void *lhs, void *rhs) { bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { yyjson_type type = unsafe_yyjson_get_type(lhs); if (type != unsafe_yyjson_get_type(rhs)) return false; - + switch (type) { case YYJSON_TYPE_OBJ: { usize len = unsafe_yyjson_get_len(lhs); @@ -1744,7 +1767,7 @@ bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { /* yyjson allows duplicate keys, so the check may be inaccurate */ return true; } - + case YYJSON_TYPE_ARR: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; @@ -1759,18 +1782,18 @@ bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { } return true; } - + case YYJSON_TYPE_NUM: return unsafe_yyjson_num_equals(lhs, rhs); - + case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: return unsafe_yyjson_str_equals(lhs, rhs); - + case YYJSON_TYPE_NULL: case YYJSON_TYPE_BOOL: return lhs->tag == rhs->tag; - + default: return false; } @@ -1779,7 +1802,7 @@ bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) { bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) { yyjson_type type = unsafe_yyjson_get_type(lhs); if (type != unsafe_yyjson_get_type(rhs)) return false; - + switch (type) { case YYJSON_TYPE_OBJ: { usize len = unsafe_yyjson_get_len(lhs); @@ -1799,7 +1822,7 @@ bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) { /* yyjson allows duplicate keys, so the check may be inaccurate */ return true; } - + case YYJSON_TYPE_ARR: { usize len = unsafe_yyjson_get_len(lhs); if (len != unsafe_yyjson_get_len(rhs)) return false; @@ -1814,36 +1837,54 @@ bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) { } return true; } - + case YYJSON_TYPE_NUM: return unsafe_yyjson_num_equals(lhs, rhs); - + case YYJSON_TYPE_RAW: case YYJSON_TYPE_STR: return unsafe_yyjson_str_equals(lhs, rhs); - + case YYJSON_TYPE_NULL: case YYJSON_TYPE_BOOL: return lhs->tag == rhs->tag; - + default: return false; } } +static_inline bool is_utf8_bom(const u8 *hdr) { + return hdr[0] == 0xEF && hdr[1] == 0xBB && hdr[2] == 0xBF; +} + +static_inline bool is_utf16_bom(const u8 *hdr) { + return ((hdr[0] == 0xFE && hdr[1] == 0xFF) || + (hdr[0] == 0xFF && hdr[1] == 0xFE)); +} + +static_inline bool is_utf32_bom(const u8 *hdr) { + /* need check length to avoid zero padding */ + return ((hdr[0] == 0x00 && hdr[1] == 0x00 && + hdr[2] == 0xFE && hdr[3] == 0xFF) || + (hdr[0] == 0xFF && hdr[1] == 0xFE && + hdr[2] == 0x00 && hdr[3] == 0x00)); +} + bool yyjson_locate_pos(const char *str, size_t len, size_t pos, size_t *line, size_t *col, size_t *chr) { usize line_sum = 0, line_pos = 0, chr_sum = 0; const u8 *cur = (const u8 *)str; const u8 *end = cur + pos; - + if (!str || pos > len) { if (line) *line = 0; if (col) *col = 0; if (chr) *chr = 0; return false; } - + + if (pos >= 3 && is_utf8_bom(cur)) cur += 3; /* don't count BOM */ while (cur < end) { u8 c = *cur; chr_sum += 1; @@ -1860,7 +1901,6 @@ bool yyjson_locate_pos(const char *str, size_t len, size_t pos, else if (c < 0xF8) cur += 4; /* 11110xxx (0xF0-0xF7) 4-byte UTF-8 */ else cur += 1; /* 11111xxx (0xF8-0xFF) Invalid */ } - if (line) *line = line_sum + 1; if (col) *col = chr_sum - line_pos + 1; if (chr) *chr = chr_sum; @@ -1877,9 +1917,8 @@ bool yyjson_locate_pos(const char *str, size_t len, size_t pos, /** Get a token from JSON pointer string. - @param ptr [in,out] - in: string that points to current token prefix `/` - out: string that points to next token prefix `/`, or string end + @param ptr [in] string that points to current token prefix `/` + [out] string that points to next token prefix `/`, or string end @param end [in] end of the entire JSON Pointer string @param len [out] unescaped token length @param esc [out] number of escaped characters in this token @@ -2041,7 +2080,7 @@ static_inline yyjson_mut_val *ptr_mut_arr_get(yyjson_mut_val *arr, if (last) *last = (idx == num || idx == USIZE_MAX); if (unlikely(idx >= num)) return NULL; while (idx-- > 0) val = val->next; - *pre = val; + if (pre) *pre = val; return val->next; } @@ -2065,7 +2104,7 @@ static_inline yyjson_mut_val *ptr_mut_obj_get(yyjson_mut_val *obj, for (; num > 0; num--, pre_key = key) { key = pre_key->next->next; if (ptr_token_eq(key, token, len, esc)) { - *pre = pre_key; + if (pre) *pre = pre_key; return key->next; } } @@ -2120,11 +2159,11 @@ static_inline yyjson_mut_val *ptr_new_key(const char *token, yyjson_val *unsafe_yyjson_ptr_getx(yyjson_val *val, const char *ptr, size_t ptr_len, yyjson_ptr_err *err) { - + const char *hdr = ptr, *end = ptr + ptr_len, *token; usize len, esc; yyjson_type type; - + while (true) { token = ptr_next_token(&ptr, end, &len, &esc); if (unlikely(!token)) return_err_syntax(NULL, ptr - hdr); @@ -2141,18 +2180,16 @@ yyjson_val *unsafe_yyjson_ptr_getx(yyjson_val *val, } } -yyjson_mut_val *unsafe_yyjson_mut_ptr_getx(yyjson_mut_val *val, - const char *ptr, - size_t ptr_len, - yyjson_ptr_ctx *ctx, - yyjson_ptr_err *err) { - +yyjson_mut_val *unsafe_yyjson_mut_ptr_getx( + yyjson_mut_val *val, const char *ptr, size_t ptr_len, + yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { + const char *hdr = ptr, *end = ptr + ptr_len, *token; usize len, esc; yyjson_mut_val *ctn, *pre = NULL; yyjson_type type; bool idx_is_last = false; - + while (true) { token = ptr_next_token(&ptr, end, &len, &esc); if (unlikely(!token)) return_err_syntax(NULL, ptr - hdr); @@ -2177,21 +2214,18 @@ yyjson_mut_val *unsafe_yyjson_mut_ptr_getx(yyjson_mut_val *val, } } -bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, - const char *ptr, size_t ptr_len, - yyjson_mut_val *new_val, - yyjson_mut_doc *doc, - bool create_parent, bool insert_new, - yyjson_ptr_ctx *ctx, - yyjson_ptr_err *err) { - +bool unsafe_yyjson_mut_ptr_putx( + yyjson_mut_val *val, const char *ptr, size_t ptr_len, + yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, + bool insert_new, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { + const char *hdr = ptr, *end = ptr + ptr_len, *token; usize token_len, esc, ctn_len; yyjson_mut_val *ctn, *key, *pre = NULL; yyjson_mut_val *sep_ctn = NULL, *sep_key = NULL, *sep_val = NULL; yyjson_type ctn_type; bool idx_is_last = false; - + /* skip exist parent nodes */ while (true) { token = ptr_next_token(&ptr, end, &token_len, &esc); @@ -2207,11 +2241,11 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, if (!val) break; if (ptr == end) break; /* is last token */ } - + /* create parent nodes if not exist */ if (unlikely(ptr != end)) { /* not last token */ if (!create_parent) return_err_resolve(false, token - hdr); - + /* add value at last index if container is array */ if (ctn_type == YYJSON_TYPE_ARR) { if (!idx_is_last || !insert_new) { @@ -2219,12 +2253,12 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, } val = yyjson_mut_obj(doc); if (!val) return_err_alloc(false); - + /* delay attaching until all operations are completed */ sep_ctn = ctn; sep_key = NULL; sep_val = val; - + /* move to next token */ ctn = val; val = NULL; @@ -2232,14 +2266,14 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, token = ptr_next_token(&ptr, end, &token_len, &esc); if (unlikely(!token)) return_err_resolve(false, token - hdr); } - + /* container is object, create parent nodes */ while (ptr != end) { /* not last token */ key = ptr_new_key(token, token_len, esc, doc); if (!key) return_err_alloc(false); val = yyjson_mut_obj(doc); if (!val) return_err_alloc(false); - + /* delay attaching until all operations are completed */ if (!sep_ctn) { sep_ctn = ctn; @@ -2248,7 +2282,7 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, } else { yyjson_mut_obj_add(ctn, key, val); } - + /* move to next token */ ctn = val; val = NULL; @@ -2256,7 +2290,7 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, if (unlikely(!token)) return_err_syntax(false, ptr - hdr); } } - + /* JSON pointer is resolved, insert or replace target value */ ctn_len = unsafe_yyjson_get_len(ctn); if (ctn_type == YYJSON_TYPE_OBJ) { @@ -2307,7 +2341,7 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, if (ctx) ctx->old = val; } } - + /* all operations are completed, attach the new components to the target */ if (unlikely(sep_ctn)) { if (sep_key) yyjson_mut_obj_add(sep_ctn, sep_key, sep_val); @@ -2319,14 +2353,14 @@ bool unsafe_yyjson_mut_ptr_putx(yyjson_mut_val *val, yyjson_mut_val *unsafe_yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { - + yyjson_mut_val *cur_val; yyjson_ptr_ctx cur_ctx; memset(&cur_ctx, 0, sizeof(cur_ctx)); if (!ctx) ctx = &cur_ctx; cur_val = unsafe_yyjson_mut_ptr_getx(val, ptr, len, ctx, err); if (!cur_val) return NULL; - + if (yyjson_mut_is_obj(ctx->ctn)) { yyjson_mut_val *key = ctx->pre->next->next; yyjson_mut_obj_put(ctx->ctn, key, new_val); @@ -2337,11 +2371,10 @@ yyjson_mut_val *unsafe_yyjson_mut_ptr_replacex( return cur_val; } -yyjson_mut_val *unsafe_yyjson_mut_ptr_removex(yyjson_mut_val *val, - const char *ptr, - size_t len, - yyjson_ptr_ctx *ctx, - yyjson_ptr_err *err) { +yyjson_mut_val *unsafe_yyjson_mut_ptr_removex( + yyjson_mut_val *val, const char *ptr, size_t len, + yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { + yyjson_mut_val *cur_val; yyjson_ptr_ctx cur_ctx; memset(&cur_ctx, 0, sizeof(cur_ctx)); @@ -2434,7 +2467,7 @@ static patch_op patch_op_get(yyjson_val *op) { root, _ptr->uni.str, _ptr##_len, NULL, &err->ptr) #define ptr_replace(_ptr, _val)yyjson_mut_ptr_replacex( \ root, _ptr->uni.str, _ptr##_len, _val, NULL, &err->ptr) - + yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, yyjson_val *orig, yyjson_val *patch, @@ -2447,7 +2480,7 @@ yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, if (!err) err = &err_tmp; memset(err, 0, sizeof(*err)); memset(&iter, 0, sizeof(iter)); - + if (unlikely(!doc || !orig || !patch)) { return_err(INVALID_PARAMETER, "input parameter is NULL"); } @@ -2456,7 +2489,7 @@ yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, } root = yyjson_val_mut_copy(doc, orig); if (unlikely(!root)) return_err_copy(); - + /* iterate through the patch array */ yyjson_arr_iter_init(patch, &iter); while ((obj = yyjson_arr_iter_next(&iter))) { @@ -2467,19 +2500,19 @@ yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, if (unlikely(!unsafe_yyjson_is_obj(obj))) { return_err(INVALID_OPERATION, "JSON patch operation is not object"); } - + /* get required member: op */ op = yyjson_obj_get(obj, "op"); if (unlikely(!op)) return_err_key("`op`"); if (unlikely(!yyjson_is_str(op))) return_err_val("`op`"); op_enum = patch_op_get(op); - + /* get required member: path */ path = yyjson_obj_get(obj, "path"); if (unlikely(!path)) return_err_key("`path`"); if (unlikely(!yyjson_is_str(path))) return_err_val("`path`"); path_len = unsafe_yyjson_get_len(path); - + /* get required member: value, from */ switch ((int)op_enum) { case PATCH_OP_ADD: case PATCH_OP_REPLACE: case PATCH_OP_TEST: @@ -2497,7 +2530,7 @@ yyjson_mut_val *yyjson_patch(yyjson_mut_doc *doc, default: break; } - + /* perform an operation */ switch ((int)op_enum) { case PATCH_OP_ADD: /* add(path, val) */ @@ -2566,7 +2599,7 @@ yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, if (!err) err = &err_tmp; memset(err, 0, sizeof(*err)); memset(&iter, 0, sizeof(iter)); - + if (unlikely(!doc || !orig || !patch)) { return_err(INVALID_PARAMETER, "input parameter is NULL"); } @@ -2575,7 +2608,7 @@ yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, } root = yyjson_mut_val_mut_copy(doc, orig); if (unlikely(!root)) return_err_copy(); - + /* iterate through the patch array */ yyjson_mut_arr_iter_init(patch, &iter); while ((obj = yyjson_mut_arr_iter_next(&iter))) { @@ -2586,19 +2619,19 @@ yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, if (!unsafe_yyjson_is_obj(obj)) { return_err(INVALID_OPERATION, "JSON patch operation is not object"); } - + /* get required member: op */ op = yyjson_mut_obj_get(obj, "op"); if (unlikely(!op)) return_err_key("`op`"); if (unlikely(!yyjson_mut_is_str(op))) return_err_val("`op`"); op_enum = patch_op_get((yyjson_val *)(void *)op); - + /* get required member: path */ path = yyjson_mut_obj_get(obj, "path"); if (unlikely(!path)) return_err_key("`path`"); if (unlikely(!yyjson_mut_is_str(path))) return_err_val("`path`"); path_len = unsafe_yyjson_get_len(path); - + /* get required member: value, from */ switch ((int)op_enum) { case PATCH_OP_ADD: case PATCH_OP_REPLACE: case PATCH_OP_TEST: @@ -2618,7 +2651,7 @@ yyjson_mut_val *yyjson_mut_patch(yyjson_mut_doc *doc, default: break; } - + /* perform an operation */ switch ((int)op_enum) { case PATCH_OP_ADD: /* add(path, val) */ @@ -2699,21 +2732,21 @@ yyjson_mut_val *yyjson_merge_patch(yyjson_mut_doc *doc, usize idx, max; yyjson_val *key, *orig_val, *patch_val, local_orig; yyjson_mut_val *builder, *mut_key, *mut_val, *merged_val; - + if (unlikely(!yyjson_is_obj(patch))) { return yyjson_val_mut_copy(doc, patch); } - + builder = yyjson_mut_obj(doc); if (unlikely(!builder)) return NULL; - + memset(&local_orig, 0, sizeof(local_orig)); if (!yyjson_is_obj(orig)) { orig = &local_orig; orig->tag = builder->tag; orig->uni = builder->uni; } - + /* If orig is contributing, copy any items not modified by the patch */ if (orig != &local_orig) { yyjson_obj_foreach(orig, idx, max, key, orig_val) { @@ -2741,7 +2774,7 @@ yyjson_mut_val *yyjson_merge_patch(yyjson_mut_doc *doc, merged_val = yyjson_merge_patch(doc, orig_val, patch_val); if (!yyjson_mut_obj_add(builder, mut_key, merged_val)) return NULL; } - + return builder; } @@ -2751,21 +2784,21 @@ yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc, usize idx, max; yyjson_mut_val *key, *orig_val, *patch_val, local_orig; yyjson_mut_val *builder, *mut_key, *mut_val, *merged_val; - + if (unlikely(!yyjson_mut_is_obj(patch))) { return yyjson_mut_val_mut_copy(doc, patch); } - + builder = yyjson_mut_obj(doc); if (unlikely(!builder)) return NULL; - + memset(&local_orig, 0, sizeof(local_orig)); if (!yyjson_mut_is_obj(orig)) { orig = &local_orig; orig->tag = builder->tag; orig->uni = builder->uni; } - + /* If orig is contributing, copy any items not modified by the patch */ if (orig != &local_orig) { yyjson_mut_obj_foreach(orig, idx, max, key, orig_val) { @@ -2793,7 +2826,7 @@ yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc, merged_val = yyjson_mut_merge_patch(doc, orig_val, patch_val); if (!yyjson_mut_obj_add(builder, mut_key, merged_val)) return NULL; } - + return builder; } @@ -3496,9 +3529,9 @@ static const u64 pow10_sig_table[] = { }; /** - Get the cached pow10 value from pow10_sig_table. + Get the cached pow10 value from `pow10_sig_table`. @param exp10 The exponent of pow(10, e). This value must in range - POW10_SIG_TABLE_MIN_EXP to POW10_SIG_TABLE_MAX_EXP. + `POW10_SIG_TABLE_MIN_EXP` to `POW10_SIG_TABLE_MAX_EXP`. @param hi The highest 64 bits of pow(10, e). @param lo The lower 64 bits after `hi`. */ @@ -3509,7 +3542,7 @@ static_inline void pow10_table_get_sig(i32 exp10, u64 *hi, u64 *lo) { } /** - Get the exponent (base 2) for highest 64 bits significand in pow10_sig_table. + Get the exponent (base 2) for highest 64 bits significand in `pow10_sig_table`. */ static_inline void pow10_table_get_exp(i32 exp10, i32 *exp2) { /* e2 = floor(log2(pow(10, e))) - 64 + 1 */ @@ -3604,7 +3637,7 @@ static_inline bool char_is_space_or_comment(u8 c) { } /** Match a JSON number: '-', [0-9]. */ -static_inline bool char_is_number(u8 c) { +static_inline bool char_is_num(u8 c) { return char_is_type(c, (char_type)CHAR_TYPE_NUMBER); } @@ -3765,7 +3798,7 @@ static const u8 hex_conv_table[256] = { /** Scans an escaped character sequence as a UTF-16 code unit (branchless). e.g. "\\u005C" should pass "005C" as `cur`. - + This requires the string has 4-byte zero padding. */ static_inline bool read_hex_u16(const u8 *cur, u16 *val) { @@ -3790,10 +3823,9 @@ static_inline bool read_hex_u16(const u8 *cur, u16 *val) { /** Read 'true' literal, '*cur' should be 't'. */ static_inline bool read_true(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; - u8 **end = ptr; if (likely(byte_match_4(cur, "true"))) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; - *end = cur + 4; + *ptr = cur + 4; return true; } return false; @@ -3802,10 +3834,9 @@ static_inline bool read_true(u8 **ptr, yyjson_val *val) { /** Read 'false' literal, '*cur' should be 'f'. */ static_inline bool read_false(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; - u8 **end = ptr; if (likely(byte_match_4(cur + 1, "alse"))) { val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; - *end = cur + 5; + *ptr = cur + 5; return true; } return false; @@ -3814,34 +3845,39 @@ static_inline bool read_false(u8 **ptr, yyjson_val *val) { /** Read 'null' literal, '*cur' should be 'n'. */ static_inline bool read_null(u8 **ptr, yyjson_val *val) { u8 *cur = *ptr; - u8 **end = ptr; if (likely(byte_match_4(cur, "null"))) { val->tag = YYJSON_TYPE_NULL; - *end = cur + 4; + *ptr = cur + 4; return true; } return false; } /** Read 'Inf' or 'Infinity' literal (ignoring case). */ -static_inline bool read_inf(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { +static_inline bool read_inf(bool sign, u8 **ptr, u8 **pre, + yyjson_read_flag flg, yyjson_val *val) { u8 *hdr = *ptr - sign; u8 *cur = *ptr; u8 **end = ptr; if ((cur[0] == 'I' || cur[0] == 'i') && (cur[1] == 'N' || cur[1] == 'n') && (cur[2] == 'F' || cur[2] == 'f')) { - if ((cur[3] == 'I' || cur[3] == 'i') && - (cur[4] == 'N' || cur[4] == 'n') && - (cur[5] == 'I' || cur[5] == 'i') && - (cur[6] == 'T' || cur[6] == 't') && - (cur[7] == 'Y' || cur[7] == 'y')) { - cur += 8; + if (cur[3] == 'I' || cur[3] == 'i') { + if ((cur[4] == 'N' || cur[4] == 'n') && + (cur[5] == 'I' || cur[5] == 'i') && + (cur[6] == 'T' || cur[6] == 't') && + (cur[7] == 'Y' || cur[7] == 'y')) { + cur += 8; + } else { + /* Don't accept INF as a complete value if it's followed by I. + This is to better support incremental parsing. */ + return false; + } } else { cur += 3; } *end = cur; - if (pre) { + if (has_read_flag(NUMBER_AS_RAW)) { /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; *pre = cur; @@ -3857,7 +3893,8 @@ static_inline bool read_inf(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { } /** Read 'NaN' literal (ignoring case). */ -static_inline bool read_nan(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { +static_inline bool read_nan(bool sign, u8 **ptr, u8 **pre, + yyjson_read_flag flg, yyjson_val *val) { u8 *hdr = *ptr - sign; u8 *cur = *ptr; u8 **end = ptr; @@ -3866,7 +3903,7 @@ static_inline bool read_nan(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { (cur[2] == 'N' || cur[2] == 'n')) { cur += 3; *end = cur; - if (pre) { + if (has_read_flag(NUMBER_AS_RAW)) { /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; *pre = cur; @@ -3883,49 +3920,46 @@ static_inline bool read_nan(bool sign, u8 **ptr, u8 **pre, yyjson_val *val) { /** Read 'Inf', 'Infinity' or 'NaN' literal (ignoring case). */ static_inline bool read_inf_or_nan(bool sign, u8 **ptr, u8 **pre, - yyjson_val *val) { - if (read_inf(sign, ptr, pre, val)) return true; - if (read_nan(sign, ptr, pre, val)) return true; + yyjson_read_flag flg, yyjson_val *val) { + if (read_inf(sign, ptr, pre, flg, val)) return true; + if (read_nan(sign, ptr, pre, flg, val)) return true; return false; } /** Read a JSON number as raw string. */ -static_noinline bool read_number_raw(u8 **ptr, - u8 **pre, - yyjson_read_flag flg, - yyjson_val *val, - const char **msg) { - +static_noinline bool read_num_raw(u8 **ptr, u8 **pre, yyjson_read_flag flg, + yyjson_val *val, const char **msg) { + #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) - + #define return_raw() do { \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) - + u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; - + /* add null-terminator for previous raw string */ if (*pre) **pre = '\0'; - + /* skip sign */ cur += (*cur == '-'); - + /* read first digit, check leading zero */ if (unlikely(!digi_is_digit(*cur))) { if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_inf_or_nan(*hdr == '-', &cur, pre, val)) return_raw(); + if (read_inf_or_nan(*hdr == '-', &cur, pre, flg, val)) return_raw(); } return_err(cur, "no digit after minus sign"); } - + /* read integral part */ if (*cur == '0') { cur++; @@ -3937,7 +3971,7 @@ static_noinline bool read_number_raw(u8 **ptr, while (digi_is_digit(*cur)) cur++; if (!digi_is_fp(*cur)) return_raw(); } - + /* read fraction part */ if (*cur == '.') { cur++; @@ -3946,7 +3980,7 @@ static_noinline bool read_number_raw(u8 **ptr, } while (digi_is_digit(*cur)) cur++; } - + /* read exponent part */ if (digi_is_exp(*cur)) { cur += 1 + digi_is_sign(cur[1]); @@ -3955,16 +3989,16 @@ static_noinline bool read_number_raw(u8 **ptr, } while (digi_is_digit(*cur)) cur++; } - + return_raw(); - + #undef return_err #undef return_raw } /** Skips spaces and comments as many as possible. - + It will return false in these cases: 1. No character is skipped. The 'end' pointer is set as input cursor. 2. A multiline comment is not closed. The 'end' pointer is set as the head @@ -4063,7 +4097,7 @@ static_noinline bool is_truncated_end(u8 *hdr, u8 *cur, u8 *end, } if (code == YYJSON_READ_ERROR_INVALID_STRING) { usize len = (usize)(end - cur); - + /* unicode escape sequence */ if (*cur == '\\') { if (len == 1) return true; @@ -4073,11 +4107,31 @@ static_noinline bool is_truncated_end(u8 *hdr, u8 *cur, u8 *end, if (!char_is_hex(*cur)) return false; } return true; + } else if (len <= 11) { + /* incomplete surrogate pair? */ + u16 hi; + if (*++cur != 'u') return false; + if (!read_hex_u16(++cur, &hi)) return false; + if ((hi & 0xF800) != 0xD800) return false; + cur += 4; + if (cur >= end) return true; + /* valid low surrogate is DC00...DFFF */ + if (*cur != '\\') return false; + if (++cur >= end) return true; + if (*cur != 'u') return false; + if (++cur >= end) return true; + if (*cur != 'd' && *cur != 'D') return false; + if (++cur >= end) return true; + if ((*cur < 'c' || *cur > 'f') && (*cur < 'C' || *cur > 'F')) + return false; + if (++cur >= end) return true; + if (!char_is_hex(*cur)) return false; + return true; } return false; } - - /* 2 to 4 bytes UTF-8, see `read_string()` for details. */ + + /* 2 to 4 bytes UTF-8, see `read_str()` for details. */ if (*cur & 0x80) { u8 c0 = cur[0], c1 = cur[1], c2 = cur[2]; if (len == 1) { @@ -4113,6 +4167,25 @@ static_noinline bool is_truncated_end(u8 *hdr, u8 *cur, u8 *end, } } } + if (has_read_flag(ALLOW_COMMENTS)) { + if (code == YYJSON_READ_ERROR_INVALID_COMMENT) { + /* unclosed multiline comment */ + return true; + } + if (code == YYJSON_READ_ERROR_UNEXPECTED_CHARACTER && + *cur == '/' && cur + 1 == end) { + /* truncated beginning of comment */ + return true; + } + } + if (code == YYJSON_READ_ERROR_UNEXPECTED_CHARACTER && + has_read_flag(ALLOW_BOM)) { + /* truncated UTF-8 BOM */ + usize len = (usize)(end - cur); + if (cur == hdr && len < 3 && !memcmp(hdr, "\xEF\xBB\xBF", len)) { + return true; + } + } return false; } @@ -4266,12 +4339,12 @@ static_inline void bigint_set_u64(bigint *big, u64 val) { /** Set a bigint with floating point number string. */ static_noinline void bigint_set_buf(bigint *big, u64 sig, i32 *exp, u8 *sig_cut, u8 *sig_end, u8 *dot_pos) { - + if (unlikely(!sig_cut)) { /* no digit cut, set significant part only */ bigint_set_u64(big, sig); return; - + } else { /* some digits were cut, read them from 'sig_cut' to 'sig_end' */ u8 *hdr = sig_cut; @@ -4281,7 +4354,7 @@ static_noinline void bigint_set_buf(bigint *big, u64 sig, i32 *exp, bool dig_big_cut = false; bool has_dot = (hdr < dot_pos) & (dot_pos < sig_end); u32 dig_len_total = U64_SAFE_DIG + (u32)(sig_end - hdr) - has_dot; - + sig -= (*sig_cut >= '5'); /* sig was rounded before */ if (dig_len_total > F64_MAX_DEC_DIG) { dig_big_cut = true; @@ -4290,7 +4363,7 @@ static_noinline void bigint_set_buf(bigint *big, u64 sig, i32 *exp, dig_len_total = (F64_MAX_DEC_DIG + 1); } *exp -= (i32)dig_len_total - U64_SAFE_DIG; - + big->used = 1; big->bits[0] = sig; while (cur < sig_end) { @@ -4354,14 +4427,14 @@ static_inline u64 diy_fp_to_ieee_raw(diy_fp fp) { i32 exp = fp.exp; u32 lz_bits; if (unlikely(fp.sig == 0)) return 0; - + lz_bits = u64_lz_bits(sig); sig <<= lz_bits; sig >>= F64_BITS - F64_SIG_FULL_BITS; exp -= (i32)lz_bits; exp += F64_BITS - F64_SIG_FULL_BITS; exp += F64_SIG_BITS; - + if (unlikely(exp >= F64_MAX_BIN_EXP)) { /* overflow */ return F64_RAW_INF; @@ -4387,33 +4460,32 @@ static_inline u64 diy_fp_to_ieee_raw(diy_fp fp) { /** Maximum exact pow10 exponent for double value. */ #define F64_POW10_EXP_MAX_EXACT 22 +#if YYJSON_DOUBLE_MATH_CORRECT /** Cached pow10 table. */ static const f64 f64_pow10_table[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22 }; +#endif /** Read a JSON number. - + 1. This function assume that the floating-point number is in IEEE-754 format. 2. This function support uint64/int64/double number. If an integer number cannot fit in uint64/int64, it will returns as a double number. If a double number is infinite, the return value is based on flag. 3. This function (with inline attribute) may generate a lot of instructions. */ -static_inline bool read_number(u8 **ptr, - u8 **pre, - yyjson_read_flag flg, - yyjson_val *val, - const char **msg) { - +static_inline bool read_num(u8 **ptr, u8 **pre, yyjson_read_flag flg, + yyjson_val *val, const char **msg) { + #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) - + #define return_0() do { \ val->tag = YYJSON_TYPE_NUM | (u8)((u8)sign << 3); \ val->uni.u64 = 0; \ @@ -4425,63 +4497,63 @@ static_inline bool read_number(u8 **ptr, val->uni.u64 = (u64)(sign ? (u64)(~(_v) + 1) : (u64)(_v)); \ *end = cur; return true; \ } while (false) - + #define return_f64(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.f64 = sign ? -(f64)(_v) : (f64)(_v); \ *end = cur; return true; \ } while (false) - + #define return_f64_bin(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.u64 = ((u64)sign << 63) | (u64)(_v); \ *end = cur; return true; \ } while (false) - + #define return_inf() do { \ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); \ if (has_read_flag(ALLOW_INF_AND_NAN)) return_f64_bin(F64_RAW_INF); \ else return_err(hdr, "number is infinity when parsed as double"); \ } while (false) - + #define return_raw() do { \ if (*pre) **pre = '\0'; /* add null-terminator for previous raw string */ \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) - + u8 *sig_cut = NULL; /* significant part cutting position for long number */ u8 *sig_end = NULL; /* significant part ending position */ u8 *dot_pos = NULL; /* decimal point position */ - + u64 sig = 0; /* significant part of the number */ i32 exp = 0; /* exponent part of the number */ - + bool exp_sign; /* temporary exponent sign from literal part */ i64 exp_sig = 0; /* temporary exponent number from significant part */ i64 exp_lit = 0; /* temporary exponent number from exponent literal part */ u64 num; /* temporary number for reading */ u8 *tmp; /* temporary cursor for reading */ - + u8 *hdr = *ptr; u8 *cur = *ptr; u8 **end = ptr; bool sign; - + /* read number as raw string if has `YYJSON_READ_NUMBER_AS_RAW` flag */ if (has_read_flag(NUMBER_AS_RAW)) { - return read_number_raw(ptr, pre, flg, val, msg); + return read_num_raw(ptr, pre, flg, val, msg); } - + sign = (*hdr == '-'); cur += sign; - + /* begin with a leading zero or non-digit */ if (unlikely(!digi_is_nonzero(*cur))) { /* 0 or non-digit char */ if (unlikely(*cur != '0')) { /* non-digit char */ if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_inf_or_nan(sign, &cur, pre, val)) { + if (read_inf_or_nan(sign, &cur, pre, flg, val)) { *end = cur; return true; } @@ -4515,13 +4587,13 @@ static_inline bool read_number(u8 **ptr, } return_f64_bin(0); } - + /* begin with non-zero digit */ sig = (u64)(*cur - '0'); - + /* Read integral part, same as the following code. - + for (int i = 1; i <= 18; i++) { num = cur[i] - '0'; if (num <= 9) sig = num + sig * 10; @@ -4533,20 +4605,20 @@ static_inline bool read_number(u8 **ptr, else { goto digi_sepr_##i; } repeat_in_1_18(expr_intg) #undef expr_intg - - + + cur += 19; /* skip continuous 19 digits */ if (!digi_is_digit_or_fp(*cur)) { /* this number is an integer consisting of 19 digits */ if (sign && (sig > ((u64)1 << 63))) { /* overflow */ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); - return_f64(normalized_u64_to_f64(sig)); + return_f64(unsafe_yyjson_u64_to_f64(sig)); } return_i64(sig); } goto digi_intg_more; /* read more digits in integral part */ - - + + /* process first non-digit character */ #define expr_sepr(i) \ digi_sepr_##i: \ @@ -4556,8 +4628,8 @@ static_inline bool read_number(u8 **ptr, cur += i; sig_end = cur; goto digi_exp_more; repeat_in_1_18(expr_sepr) #undef expr_sepr - - + + /* read fraction part */ #define expr_frac(i) \ digi_frac_##i: \ @@ -4566,12 +4638,12 @@ static_inline bool read_number(u8 **ptr, else { goto digi_stop_##i; } repeat_in_1_18(expr_frac) #undef expr_frac - + cur += 20; /* skip 19 digits and 1 decimal point */ if (!digi_is_digit(*cur)) goto digi_frac_end; /* fraction part end */ goto digi_frac_more; /* read more digits in fraction part */ - - + + /* significant part end */ #define expr_stop(i) \ digi_stop_##i: \ @@ -4579,8 +4651,8 @@ static_inline bool read_number(u8 **ptr, goto digi_frac_end; repeat_in_1_18(expr_stop) #undef expr_stop - - + + /* read more digits in integral part */ digi_intg_more: if (digi_is_digit(*cur)) { @@ -4594,26 +4666,26 @@ static_inline bool read_number(u8 **ptr, /* convert to double if overflow */ if (sign) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); - return_f64(normalized_u64_to_f64(sig)); + return_f64(unsafe_yyjson_u64_to_f64(sig)); } return_i64(sig); } } } - + if (digi_is_exp(*cur)) { dot_pos = cur; goto digi_exp_more; } - + if (*cur == '.') { dot_pos = cur++; if (!digi_is_digit(*cur)) { return_err(cur, "no digit after decimal point"); } } - - + + /* read more digits in fraction part */ digi_frac_more: sig_cut = cur; /* too large to fit in u64, excess digits need to be cut */ @@ -4633,7 +4705,7 @@ static_inline bool read_number(u8 **ptr, } exp_sig = (i64)(dot_pos - sig_cut); exp_sig += (dot_pos < sig_cut); - + /* ignore trailing zeros */ tmp = cur - 1; while (*tmp == '0' || *tmp == '.') tmp--; @@ -4642,11 +4714,11 @@ static_inline bool read_number(u8 **ptr, } else { sig_end = cur; } - + if (digi_is_exp(*cur)) goto digi_exp_more; goto digi_exp_finish; - - + + /* fraction part end */ digi_frac_end: if (unlikely(dot_pos + 1 == cur)) { @@ -4663,8 +4735,8 @@ static_inline bool read_number(u8 **ptr, } else { goto digi_exp_more; } - - + + /* read exponent part */ digi_exp_more: exp_sign = (*++cur == '-'); @@ -4673,7 +4745,7 @@ static_inline bool read_number(u8 **ptr, return_err(cur, "no digit after exponent sign"); } while (*cur == '0') cur++; - + /* read exponent literal */ tmp = cur; while (digi_is_digit(*cur)) { @@ -4687,8 +4759,8 @@ static_inline bool read_number(u8 **ptr, } } exp_sig += exp_sign ? -exp_lit : exp_lit; - - + + /* validate exponent value */ digi_exp_finish: if (unlikely(exp_sig < F64_MIN_DEC_EXP - 19)) { @@ -4698,20 +4770,20 @@ static_inline bool read_number(u8 **ptr, return_inf(); /* overflow */ } exp = (i32)exp_sig; - - + + /* all digit read finished */ digi_finish: - + /* Fast path 1: - + 1. The floating-point number calculation should be accurate, see the comments of macro `YYJSON_DOUBLE_MATH_CORRECT`. 2. Correct rounding should be performed (fegetround() == FE_TONEAREST). 3. The input of floating point number calculation does not lose precision, which means: 64 - leading_zero(input) - trailing_zero(input) < 53. - + We don't check all available inputs here, because that would make the code more complicated, and not friendly to branch predictor. */ @@ -4728,10 +4800,10 @@ static_inline bool read_number(u8 **ptr, return_f64(dbl); } #endif - + /* Fast path 2: - + To keep it simple, we only accept normal number here, let the slow path to handle subnormal and infinity number. */ @@ -4741,16 +4813,16 @@ static_inline bool read_number(u8 **ptr, /* The result value is exactly equal to (sig * 10^exp), the exponent part (10^exp) can be converted to (sig2 * 2^exp2). - + The sig2 can be an infinite length number, only the highest 128 bits is cached in the pow10_sig_table. - + Now we have these bits: sig1 (normalized 64bit) : aaaaaaaa sig2 (higher 64bit) : bbbbbbbb sig2_ext (lower 64bit) : cccccccc sig2_cut (extra unknown bits) : dddddddddddd.... - + And the calculation process is: ---------------------------------------- aaaaaaaa * @@ -4764,17 +4836,17 @@ static_inline bool read_number(u8 **ptr, [hi2___][lo2___] + [unknown___________....] ---------------------------------------- - + The addition with carry may affect higher bits, but if there is a 0 in higher bits, the bits higher than 0 will not be affected. - + `lo2` + `unknown` may get a carry bit and may affect `hi2`, the max value of `hi2` is 0xFFFFFFFFFFFFFFFE, so `hi2` will not overflow. - + `lo` + `hi2` may also get a carry bit and may affect `hi`, but only the highest significant 53 bits of `hi` is needed. If there is a 0 in the lower bits of `hi`, then all the following bits can be dropped. - + To convert the result to IEEE-754 double number, we need to perform correct rounding: 1. if bit 54 is 0, round down, @@ -4782,30 +4854,30 @@ static_inline bool read_number(u8 **ptr, 3. if bit 54 is 1 and all bits beyond bit 54 are 0, round to even, as the extra bits is unknown, this case will not be handled here. */ - + u64 raw; u64 sig1, sig2, sig2_ext, hi, lo, hi2, lo2, add, bits; i32 exp2; u32 lz; bool exact = false, carry, round_up; - + /* convert (10^exp) to (sig2 * 2^exp2) */ pow10_table_get_sig(exp, &sig2, &sig2_ext); pow10_table_get_exp(exp, &exp2); - + /* normalize and multiply */ lz = u64_lz_bits(sig); sig1 = sig << lz; exp2 -= (i32)lz; u128_mul(sig1, sig2, &hi, &lo); - + /* The `hi` is in range [0x4000000000000000, 0xFFFFFFFFFFFFFFFE], To get normalized value, `hi` should be shifted to the left by 0 or 1. - + The highest significant 53 bits is used by IEEE-754 double number, and the bit 54 is used to detect rounding direction. - + The lowest (64 - 54 - 1) bits is used to check whether it contains 0. */ bits = hi & (((u64)1 << (64 - 54 - 1)) - 1); @@ -4817,7 +4889,7 @@ static_inline bool read_number(u8 **ptr, after `0`. */ exact = true; - + } else { /* (bits == 0 || bits == 0x1FF) @@ -4825,7 +4897,7 @@ static_inline bool read_number(u8 **ptr, lower bits with another 64-bit multiplication. */ u128_mul(sig1, sig2_ext, &hi2, &lo2); - + add = lo + hi2; if (add + 1 > (u64)1) { /* @@ -4840,24 +4912,24 @@ static_inline bool read_number(u8 **ptr, exact = true; } } - + if (exact) { /* normalize */ lz = hi < ((u64)1 << 63); hi <<= lz; exp2 -= (i32)lz; exp2 += 64; - + /* test the bit 54 and get rounding direction */ round_up = (hi & ((u64)1 << (64 - 54))) > (u64)0; hi += (round_up ? ((u64)1 << (64 - 54)) : (u64)0); - + /* test overflow */ if (hi < ((u64)1 << (64 - 54))) { hi = ((u64)1 << 63); exp2 += 1; } - + /* This is a normal number, convert it to IEEE-754 format. */ hi >>= F64_BITS - F64_SIG_FULL_BITS; exp2 += F64_BITS - F64_SIG_FULL_BITS + F64_SIG_BITS; @@ -4866,12 +4938,12 @@ static_inline bool read_number(u8 **ptr, return_f64_bin(raw); } } - + /* Slow path: read double number exactly with diyfp. 1. Use cached diyfp to get an approximation value. 2. Use bigcomp to check the approximation value if needed. - + This algorithm refers to google's double-conversion project: https://github.com/google/double-conversion */ @@ -4883,7 +4955,7 @@ static_inline bool read_number(u8 **ptr, const i32 DIY_SIG_BITS = 64; const i32 EXP_BIAS = F64_EXP_BIAS + F64_SIG_BITS; const i32 EXP_SUBNORMAL = -EXP_BIAS + 1; - + u64 fp_err; u32 bits; i32 order_of_magnitude; @@ -4891,32 +4963,32 @@ static_inline bool read_number(u8 **ptr, i32 precision_digits_count; u64 precision_bits; u64 half_way; - + u64 raw; diy_fp fp, fp_upper; bigint big_full, big_comp; i32 cmp; - + fp.sig = sig; fp.exp = 0; fp_err = sig_cut ? (u64)(ERR_ULP / 2) : (u64)0; - + /* normalize */ bits = u64_lz_bits(fp.sig); fp.sig <<= bits; fp.exp -= (i32)bits; fp_err <<= bits; - + /* multiply and add error */ fp = diy_fp_mul(fp, diy_fp_get_cached_pow10(exp)); fp_err += (u64)ERR_CACHED_POW + (fp_err != 0) + (u64)ERR_MUL_FIXED; - + /* normalize */ bits = u64_lz_bits(fp.sig); fp.sig <<= bits; fp.exp -= (i32)bits; fp_err <<= bits; - + /* effective significand */ order_of_magnitude = DIY_SIG_BITS + fp.exp; if (likely(order_of_magnitude >= EXP_SUBNORMAL + F64_SIG_FULL_BITS)) { @@ -4926,7 +4998,7 @@ static_inline bool read_number(u8 **ptr, } else { effective_significand_size = order_of_magnitude - EXP_SUBNORMAL; } - + /* precision digits count */ precision_digits_count = DIY_SIG_BITS - effective_significand_size; if (unlikely(precision_digits_count + ERR_ULP_LOG >= DIY_SIG_BITS)) { @@ -4936,18 +5008,18 @@ static_inline bool read_number(u8 **ptr, fp_err = (fp_err >> shr) + 1 + (u32)ERR_ULP; precision_digits_count -= shr; } - + /* half way */ precision_bits = fp.sig & (((u64)1 << precision_digits_count) - 1); precision_bits *= (u32)ERR_ULP; half_way = (u64)1 << (precision_digits_count - 1); half_way *= (u32)ERR_ULP; - + /* rounding */ fp.sig >>= precision_digits_count; fp.sig += (precision_bits >= half_way + fp_err); fp.exp += precision_digits_count; - + /* get IEEE double raw value */ raw = diy_fp_to_ieee_raw(fp); if (unlikely(raw == F64_RAW_INF)) return_inf(); @@ -4956,7 +5028,7 @@ static_inline bool read_number(u8 **ptr, return_f64_bin(raw); /* number is accurate */ } /* now the number is the correct value, or the next lower value */ - + /* upper boundary */ if (raw & F64_EXP_MASK) { fp_upper.sig = (raw & F64_SIG_MASK) + ((u64)1 << F64_SIG_BITS); @@ -4969,7 +5041,7 @@ static_inline bool read_number(u8 **ptr, fp_upper.sig <<= 1; fp_upper.exp -= 1; fp_upper.sig += 1; /* add half ulp */ - + /* compare with bigint */ bigint_set_buf(&big_full, sig, &exp, sig_cut, sig_end, dot_pos); bigint_set_u64(&big_comp, fp_upper.sig); @@ -4991,11 +5063,11 @@ static_inline bool read_number(u8 **ptr, /* falls midway, round to even */ raw += (raw & 1); } - + if (unlikely(raw == F64_RAW_INF)) return_inf(); return_f64_bin(raw); } - + #undef return_err #undef return_inf #undef return_0 @@ -5014,18 +5086,15 @@ static_inline bool read_number(u8 **ptr, This is a fallback function if the custom number reader is disabled. This function use libc's strtod() to read floating-point number. */ -static_inline bool read_number(u8 **ptr, - u8 **pre, - yyjson_read_flag flg, - yyjson_val *val, - const char **msg) { - +static_inline bool read_num(u8 **ptr, u8 **pre, yyjson_read_flag flg, + yyjson_val *val, const char **msg) { + #define return_err(_pos, _msg) do { \ *msg = _msg; \ *end = _pos; \ return false; \ } while (false) - + #define return_0() do { \ val->tag = YYJSON_TYPE_NUM | (u64)((u8)sign << 3); \ val->uni.u64 = 0; \ @@ -5037,32 +5106,32 @@ static_inline bool read_number(u8 **ptr, val->uni.u64 = (u64)(sign ? (u64)(~(_v) + 1) : (u64)(_v)); \ *end = cur; return true; \ } while (false) - + #define return_f64(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.f64 = sign ? -(f64)(_v) : (f64)(_v); \ *end = cur; return true; \ } while (false) - + #define return_f64_bin(_v) do { \ val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; \ val->uni.u64 = ((u64)sign << 63) | (u64)(_v); \ *end = cur; return true; \ } while (false) - + #define return_inf() do { \ if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); \ if (has_read_flag(ALLOW_INF_AND_NAN)) return_f64_bin(F64_RAW_INF); \ else return_err(hdr, "number is infinity when parsed as double"); \ } while (false) - + #define return_raw() do { \ if (*pre) **pre = '\0'; /* add null-terminator for previous raw string */ \ val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \ val->uni.str = (const char *)hdr; \ *pre = cur; *end = cur; return true; \ } while (false) - + u64 sig, num; u8 *hdr = *ptr; u8 *cur = *ptr; @@ -5070,20 +5139,20 @@ static_inline bool read_number(u8 **ptr, u8 *dot = NULL; u8 *f64_end = NULL; bool sign; - + /* read number as raw string if has `YYJSON_READ_NUMBER_AS_RAW` flag */ if (has_read_flag(NUMBER_AS_RAW)) { - return read_number_raw(ptr, pre, flg, val, msg); + return read_num_raw(ptr, pre, flg, val, msg); } - + sign = (*hdr == '-'); cur += sign; sig = (u8)(*cur - '0'); - + /* read first digit, check leading zero */ if (unlikely(!digi_is_digit(*cur))) { if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_inf_or_nan(sign, &cur, pre, val)) { + if (read_inf_or_nan(sign, &cur, pre, flg, val)) { *end = cur; return true; } @@ -5098,14 +5167,14 @@ static_inline bool read_number(u8 **ptr, if (!digi_is_fp(*cur)) return_0(); goto read_double; } - + /* read continuous digits, up to 19 characters */ #define expr_intg(i) \ if (likely((num = (u64)(cur[i] - (u8)'0')) <= 9)) sig = num + sig * 10; \ else { cur += i; goto intg_end; } repeat_in_1_18(expr_intg) #undef expr_intg - + /* here are 19 continuous digits, skip them */ cur += 19; if (digi_is_digit(cur[0]) && !digi_is_digit_or_fp(cur[1])) { @@ -5117,23 +5186,23 @@ static_inline bool read_number(u8 **ptr, cur++; if (sign) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); - return_f64(normalized_u64_to_f64(sig)); + return_f64(unsafe_yyjson_u64_to_f64(sig)); } return_i64(sig); } } - + intg_end: /* continuous digits ended */ if (!digi_is_digit_or_fp(*cur)) { /* this number is an integer consisting of 1 to 19 digits */ if (sign && (sig > ((u64)1 << 63))) { if (has_read_flag(BIGNUM_AS_RAW)) return_raw(); - return_f64(normalized_u64_to_f64(sig)); + return_f64(unsafe_yyjson_u64_to_f64(sig)); } return_i64(sig); } - + read_double: /* this number should be read as double */ while (digi_is_digit(*cur)) cur++; @@ -5159,16 +5228,16 @@ static_inline bool read_number(u8 **ptr, cur++; while (digi_is_digit(*cur)) cur++; } - + /* libc's strtod() is used to parse the floating-point number. - + Note that the decimal point character used by strtod() is locale-dependent, and the rounding direction may affected by fesetround(). - + For currently known locales, (en, zh, ja, ko, am, he, hi) use '.' as the decimal point, while other locales use ',' as the decimal point. - + Here strtod() is called twice for different locales, but if another thread happens calls setlocale() between two strtod(), parsing may still fail. */ @@ -5192,7 +5261,7 @@ static_inline bool read_number(u8 **ptr, val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; *end = cur; return true; - + #undef return_err #undef return_0 #undef return_i64 @@ -5217,13 +5286,11 @@ static_inline bool read_number(u8 **ptr, @param inv Allow invalid unicode. @param val The string value to be written. @param msg The error message pointer. + @param con Continuation for incremental parsing. @return Whether success. */ -static_inline bool read_string(u8 **ptr, - u8 *lst, - bool inv, - yyjson_val *val, - const char **msg) { +static_inline bool read_str(u8 **ptr, u8 *lst, bool inv, yyjson_val *val, + const char **msg, u8 **con) { /* Each unicode code point is encoded as 1 to 4 bytes in UTF-8 encoding, we use 4-byte mask and pattern value to validate UTF-8 byte sequence, @@ -5328,7 +5395,7 @@ static_inline bool read_string(u8 **ptr, u32 b4_err0 = b4_err0_uni.u; u32 b4_err1 = b4_err1_uni.u; #endif - + #define is_valid_seq_1(uni) ( \ ((uni & b1_mask) == b1_patt) \ ) @@ -5337,41 +5404,49 @@ static_inline bool read_string(u8 **ptr, ((uni & b2_mask) == b2_patt) && \ ((uni & b2_requ)) \ ) - + #define is_valid_seq_3(uni) ( \ ((uni & b3_mask) == b3_patt) && \ ((tmp = (uni & b3_requ))) && \ ((tmp != b3_erro)) \ ) - + #define is_valid_seq_4(uni) ( \ ((uni & b4_mask) == b4_patt) && \ ((tmp = (uni & b4_requ))) && \ ((tmp & b4_err0) == 0 || (tmp & b4_err1) == 0) \ ) - + #define return_err(_end, _msg) do { \ *msg = _msg; \ *end = _end; \ + if (con) { con[0] = _end; con[1] = dst; } \ return false; \ } while (false) - + u8 *cur = *ptr; u8 **end = ptr; - u8 *src = ++cur, *dst, *pos; + u8 *src = ++cur, *dst = NULL, *pos; u16 hi, lo; u32 uni, tmp; - + + if (unlikely(con && con[0])) { + /* Resume incremental parsing. */ + src = con[0]; + dst = con[1]; + if (dst) goto copy_ascii; + } + skip_ascii: /* Most strings have no escaped characters, so we can jump them quickly. */ - + skip_ascii_begin: /* We want to make loop unrolling, as shown in the following code. Some compiler may not generate instructions as expected, so we rewrite it with explicit goto statements. We hope the compiler can generate instructions like this: https://godbolt.org/z/8vjsYq - + while (true) repeat16({ if (likely(!(char_is_ascii_stop(*src)))) src++; else break; @@ -5380,28 +5455,28 @@ static_inline bool read_string(u8 **ptr, #define expr_jump(i) \ if (likely(!char_is_ascii_stop(src[i]))) {} \ else goto skip_ascii_stop##i; - + #define expr_stop(i) \ skip_ascii_stop##i: \ src += i; \ goto skip_ascii_end; - + repeat16_incr(expr_jump) src += 16; goto skip_ascii_begin; repeat16_incr(expr_stop) - + #undef expr_jump #undef expr_stop - + skip_ascii_end: - + /* GCC may store src[i] in a register at each line of expr_jump(i) above. These instructions are useless and will degrade performance. This inline asm is a hint for gcc: "the memory has been modified, do not cache it". - + MSVC, Clang, ICC can generate expected instructions without this hint. */ #if YYJSON_IS_REAL_GCC @@ -5413,9 +5488,10 @@ static_inline bool read_string(u8 **ptr, val->uni.str = (const char *)cur; *src = '\0'; *end = src + 1; + if (con) con[0] = con[1] = NULL; return true; } - + skip_utf8: if (*src & 0x80) { /* non-ASCII character */ /* @@ -5462,7 +5538,7 @@ static_inline bool read_string(u8 **ptr, } goto skip_ascii; } - + /* The escape character appears, we need to copy it. */ dst = src; copy_escape: @@ -5499,13 +5575,13 @@ static_inline bool read_string(u8 **ptr, return_err(src - 6, "invalid high surrogate in string"); } if (unlikely(!byte_match_2(src, "\\u"))) { - return_err(src, "no low surrogate in string"); + return_err(src - 6, "no low surrogate in string"); } if (unlikely(!read_hex_u16(src + 2, &lo))) { - return_err(src, "invalid escaped sequence in string"); + return_err(src - 6, "invalid escape in string"); } if (unlikely((lo & 0xFC00) != 0xDC00)) { - return_err(src, "invalid low surrogate in string"); + return_err(src - 6, "invalid low surrogate in string"); } uni = ((((u32)hi - 0xD800) << 10) | ((u32)lo - 0xDC00)) + 0x10000; @@ -5516,24 +5592,25 @@ static_inline bool read_string(u8 **ptr, src += 6; } break; - default: return_err(src, "invalid escaped character in string"); + default: return_err(src - 1, "invalid escaped sequence in string"); } } else if (likely(*src == '"')) { val->tag = ((u64)(dst - cur) << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; val->uni.str = (const char *)cur; *dst = '\0'; *end = src + 1; + if (con) con[0] = con[1] = NULL; return true; } else { if (!inv) return_err(src, "unexpected control character in string"); if (src >= lst) return_err(src, "unclosed string"); *dst++ = *src++; } - + copy_ascii: /* Copy continuous ASCII, loop unrolling, same as the following code: - + while (true) repeat16({ if (unlikely(char_is_ascii_stop(*src))) break; *dst++ = *src++; @@ -5550,12 +5627,12 @@ static_inline bool read_string(u8 **ptr, #endif repeat16_incr(expr_jump) #undef expr_jump - + byte_move_16(dst, src); src += 16; dst += 16; goto copy_ascii; - + /* The memory will be moved forward by at least 1 byte. So the `byte_move` can be one byte more than needed to reduce the number of instructions. @@ -5647,7 +5724,7 @@ static_inline bool read_string(u8 **ptr, src += 15; dst += 15; goto copy_utf8; - + copy_utf8: if (*src & 0x80) { /* non-ASCII character */ pos = src; @@ -5700,13 +5777,13 @@ static_inline bool read_string(u8 **ptr, } #endif if (unlikely(pos == src)) { - if (!inv) return_err(src, "invalid UTF-8 encoding in string"); + if (!inv) return_err(src, MSG_ERR_UTF8); goto copy_ascii_stop_1; } goto copy_ascii; } goto copy_escape; - + #undef return_err #undef is_valid_seq_1 #undef is_valid_seq_2 @@ -5725,18 +5802,16 @@ static_inline bool read_string(u8 **ptr, *============================================================================*/ /** Read single value JSON document. */ -static_noinline yyjson_doc *read_root_single(u8 *hdr, - u8 *cur, - u8 *end, +static_noinline yyjson_doc *read_root_single(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { - + #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ - err->msg = "unexpected end of data"; \ + err->msg = MSG_NOT_END; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ @@ -5745,23 +5820,23 @@ static_noinline yyjson_doc *read_root_single(u8 *hdr, if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) - + usize hdr_len; /* value count used by doc */ usize alc_num; /* value count capacity */ yyjson_val *val_hdr; /* the head of allocated values */ yyjson_val *val; /* current value */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ - + bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ - + hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_num = hdr_len + 1; /* single value */ - + val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_num * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val = val_hdr + hdr_len; @@ -5769,13 +5844,13 @@ static_noinline yyjson_doc *read_root_single(u8 *hdr, inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; - - if (char_is_number(*cur)) { - if (likely(read_number(&cur, pre, flg, val, &msg))) goto doc_end; + + if (char_is_num(*cur)) { + if (likely(read_num(&cur, pre, flg, val, &msg))) goto doc_end; goto fail_number; } if (*cur == '"') { - if (likely(read_string(&cur, end, inv, val, &msg))) goto doc_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto doc_end; goto fail_string; } if (*cur == 't') { @@ -5789,15 +5864,15 @@ static_noinline yyjson_doc *read_root_single(u8 *hdr, if (*cur == 'n') { if (likely(read_null(&cur, val))) goto doc_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_nan(false, &cur, pre, val)) goto doc_end; + if (read_nan(false, &cur, pre, flg, val)) goto doc_end; } goto fail_literal_null; } if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_inf_or_nan(false, &cur, pre, val)) goto doc_end; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto doc_end; } goto fail_character; - + doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { @@ -5810,7 +5885,7 @@ static_noinline yyjson_doc *read_root_single(u8 *hdr, } if (unlikely(cur < end)) goto fail_garbage; } - + if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; @@ -5819,49 +5894,31 @@ static_noinline yyjson_doc *read_root_single(u8 *hdr, doc->val_read = 1; doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; - -fail_string: - return_err(cur, INVALID_STRING, msg); -fail_number: - return_err(cur, INVALID_NUMBER, msg); -fail_alloc: - return_err(cur, MEMORY_ALLOCATION, - "memory allocation failed"); -fail_literal_true: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'true'"); -fail_literal_false: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'false'"); -fail_literal_null: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'null'"); -fail_character: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a valid root value"); -fail_comment: - return_err(cur, INVALID_COMMENT, - "unclosed multiline comment"); -fail_garbage: - return_err(cur, UNEXPECTED_CONTENT, - "unexpected content after document"); - + +fail_string: return_err(cur, INVALID_STRING, msg); +fail_number: return_err(cur, INVALID_NUMBER, msg); +fail_alloc: return_err(cur, MEMORY_ALLOCATION, MSG_MALLOC); +fail_literal_true: return_err(cur, LITERAL, MSG_CHAT_T); +fail_literal_false: return_err(cur, LITERAL, MSG_CHAR_F); +fail_literal_null: return_err(cur, LITERAL, MSG_CHAR_N); +fail_character: return_err(cur, UNEXPECTED_CHARACTER, MSG_CHAR); +fail_comment: return_err(cur, INVALID_COMMENT, MSG_COMMENT); +fail_garbage: return_err(cur, UNEXPECTED_CONTENT, MSG_GARBAGE); + #undef return_err } /** Read JSON document (accept all style, but optimized for minify). */ -static_inline yyjson_doc *read_root_minify(u8 *hdr, - u8 *cur, - u8 *end, +static_inline yyjson_doc *read_root_minify(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { - + #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ - err->msg = "unexpected end of data"; \ + err->msg = MSG_NOT_END; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ @@ -5870,24 +5927,26 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) - + #define val_incr() do { \ val++; \ if (unlikely(val >= val_end)) { \ usize alc_old = alc_len; \ + usize val_ofs = (usize)(val - val_hdr); \ + usize ctn_ofs = (usize)(ctn - val_hdr); \ alc_len += alc_len / 2; \ if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \ val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \ alc_old * sizeof(yyjson_val), \ alc_len * sizeof(yyjson_val)); \ if ((!val_tmp)) goto fail_alloc; \ - val = val_tmp + (usize)(val - val_hdr); \ - ctn = val_tmp + (usize)(ctn - val_hdr); \ + val = val_tmp + val_ofs; \ + ctn = val_tmp + ctn_ofs; \ val_hdr = val_tmp; \ val_end = val_tmp + (alc_len - 2); \ } \ } while (false) - + usize dat_len; /* data length in bytes, hint for allocator */ usize hdr_len; /* value count used by yyjson_doc */ usize alc_len; /* value count allocated */ @@ -5901,19 +5960,19 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ - + bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ - + dat_len = has_read_flag(STOP_WHEN_DONE) ? 256 : (usize)(end - cur); hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_max = USIZE_MAX / sizeof(yyjson_val); alc_len = hdr_len + (dat_len / YYJSON_READER_ESTIMATED_MINIFY_RATIO) + 4; alc_len = yyjson_min(alc_len, alc_max); - + val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_len * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val_end = val_hdr + (alc_len - 2); /* padding for key-value pair reading */ @@ -5924,7 +5983,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; - + if (*cur++ == '{') { ctn->tag = YYJSON_TYPE_OBJ; ctn->uni.ofs = 0; @@ -5934,21 +5993,21 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, ctn->uni.ofs = 0; goto arr_val_begin; } - + arr_begin: /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); - + /* create a new array value, save parent container offset */ val_incr(); val->tag = YYJSON_TYPE_ARR; val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); - + /* push the new array value as current container */ ctn = val; ctn_len = 0; - + arr_val_begin: if (*cur == '{') { cur++; @@ -5958,16 +6017,16 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, cur++; goto arr_begin; } - if (char_is_number(*cur)) { + if (char_is_num(*cur)) { val_incr(); ctn_len++; - if (likely(read_number(&cur, pre, flg, val, &msg))) goto arr_val_end; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto arr_val_end; goto fail_number; } if (*cur == '"') { val_incr(); ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto arr_val_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto arr_val_end; goto fail_string; } if (*cur == 't') { @@ -5987,7 +6046,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, ctn_len++; if (likely(read_null(&cur, val))) goto arr_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_nan(false, &cur, pre, val)) goto arr_val_end; + if (read_nan(false, &cur, pre, flg, val)) goto arr_val_end; } goto fail_literal_null; } @@ -6006,7 +6065,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val_incr(); ctn_len++; - if (read_inf_or_nan(false, &cur, pre, val)) goto arr_val_end; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto arr_val_end; goto fail_character_val; } if (has_read_flag(ALLOW_COMMENTS)) { @@ -6014,7 +6073,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_val; - + arr_val_end: if (*cur == ',') { cur++; @@ -6033,16 +6092,16 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_arr_end; - + arr_end: /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); - + /* save the next sibling value offset */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = ((ctn_len) << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; if (unlikely(ctn == ctn_parent)) goto doc_end; - + /* pop parent as current container */ ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); @@ -6051,7 +6110,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, } else { goto arr_val_end; } - + obj_begin: /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | @@ -6062,12 +6121,12 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); ctn = val; ctn_len = 0; - + obj_key_begin: if (likely(*cur == '"')) { val_incr(); ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_key_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto obj_key_end; goto fail_string; } if (likely(*cur == '}')) { @@ -6086,7 +6145,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_key; - + obj_key_end: if (*cur == ':') { cur++; @@ -6101,18 +6160,18 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_sep; - + obj_val_begin: if (*cur == '"') { val++; ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_val_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto obj_val_end; goto fail_string; } - if (char_is_number(*cur)) { + if (char_is_num(*cur)) { val++; ctn_len++; - if (likely(read_number(&cur, pre, flg, val, &msg))) goto obj_val_end; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto obj_val_end; goto fail_number; } if (*cur == '{') { @@ -6140,7 +6199,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, ctn_len++; if (likely(read_null(&cur, val))) goto obj_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_nan(false, &cur, pre, val)) goto obj_val_end; + if (read_nan(false, &cur, pre, flg, val)) goto obj_val_end; } goto fail_literal_null; } @@ -6152,7 +6211,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val++; ctn_len++; - if (read_inf_or_nan(false, &cur, pre, val)) goto obj_val_end; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto obj_val_end; goto fail_character_val; } if (has_read_flag(ALLOW_COMMENTS)) { @@ -6160,7 +6219,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_val; - + obj_val_end: if (likely(*cur == ',')) { cur++; @@ -6179,7 +6238,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_end; - + obj_end: /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); @@ -6194,7 +6253,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, } else { goto arr_val_end; } - + doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { @@ -6206,7 +6265,7 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, } if (unlikely(cur < end)) goto fail_garbage; } - + if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; @@ -6215,65 +6274,37 @@ static_inline yyjson_doc *read_root_minify(u8 *hdr, doc->val_read = (usize)((val - doc->root) + 1); doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; - -fail_string: - return_err(cur, INVALID_STRING, msg); -fail_number: - return_err(cur, INVALID_NUMBER, msg); -fail_alloc: - return_err(cur, MEMORY_ALLOCATION, - "memory allocation failed"); -fail_trailing_comma: - return_err(cur, JSON_STRUCTURE, - "trailing comma is not allowed"); -fail_literal_true: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'true'"); -fail_literal_false: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'false'"); -fail_literal_null: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'null'"); -fail_character_val: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a valid JSON value"); -fail_character_arr_end: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a comma or a closing bracket"); -fail_character_obj_key: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a string for object key"); -fail_character_obj_sep: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a colon after object key"); -fail_character_obj_end: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a comma or a closing brace"); -fail_comment: - return_err(cur, INVALID_COMMENT, - "unclosed multiline comment"); -fail_garbage: - return_err(cur, UNEXPECTED_CONTENT, - "unexpected content after document"); - + +fail_string: return_err(cur, INVALID_STRING, msg); +fail_number: return_err(cur, INVALID_NUMBER, msg); +fail_alloc: return_err(cur, MEMORY_ALLOCATION, MSG_MALLOC); +fail_trailing_comma: return_err(cur, JSON_STRUCTURE, MSG_COMMA); +fail_literal_true: return_err(cur, LITERAL, MSG_CHAT_T); +fail_literal_false: return_err(cur, LITERAL, MSG_CHAR_F); +fail_literal_null: return_err(cur, LITERAL, MSG_CHAR_N); +fail_character_val: return_err(cur, UNEXPECTED_CHARACTER, MSG_CHAR); +fail_character_arr_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_ARR_END); +fail_character_obj_key: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_KEY); +fail_character_obj_sep: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_SEP); +fail_character_obj_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_END); +fail_comment: return_err(cur, INVALID_COMMENT, MSG_COMMENT); +fail_garbage: return_err(cur, UNEXPECTED_CONTENT, MSG_GARBAGE); + #undef val_incr #undef return_err } /** Read JSON document (accept all style, but optimized for pretty). */ -static_inline yyjson_doc *read_root_pretty(u8 *hdr, - u8 *cur, - u8 *end, +static_inline yyjson_doc *read_root_pretty(u8 *hdr, u8 *cur, u8 *end, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err) { - + #define return_err(_pos, _code, _msg) do { \ if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ err->pos = (usize)(end - hdr); \ err->code = YYJSON_READ_ERROR_UNEXPECTED_END; \ - err->msg = "unexpected end of data"; \ + err->msg = MSG_NOT_END; \ } else { \ err->pos = (usize)(_pos - hdr); \ err->code = YYJSON_READ_ERROR_##_code; \ @@ -6282,24 +6313,26 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (val_hdr) alc.free(alc.ctx, (void *)val_hdr); \ return NULL; \ } while (false) - + #define val_incr() do { \ val++; \ if (unlikely(val >= val_end)) { \ usize alc_old = alc_len; \ + usize val_ofs = (usize)(val - val_hdr); \ + usize ctn_ofs = (usize)(ctn - val_hdr); \ alc_len += alc_len / 2; \ if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \ val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \ alc_old * sizeof(yyjson_val), \ alc_len * sizeof(yyjson_val)); \ if ((!val_tmp)) goto fail_alloc; \ - val = val_tmp + (usize)(val - val_hdr); \ - ctn = val_tmp + (usize)(ctn - val_hdr); \ + val = val_tmp + val_ofs; \ + ctn = val_tmp + ctn_ofs; \ val_hdr = val_tmp; \ val_end = val_tmp + (alc_len - 2); \ } \ } while (false) - + usize dat_len; /* data length in bytes, hint for allocator */ usize hdr_len; /* value count used by yyjson_doc */ usize alc_len; /* value count allocated */ @@ -6313,19 +6346,19 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, yyjson_val *ctn_parent; /* parent of current container */ yyjson_doc *doc; /* the JSON document, equals to val_hdr */ const char *msg; /* error message */ - + bool raw; /* read number as raw */ bool inv; /* allow invalid unicode */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ - + dat_len = has_read_flag(STOP_WHEN_DONE) ? 256 : (usize)(end - cur); hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; alc_max = USIZE_MAX / sizeof(yyjson_val); alc_len = hdr_len + (dat_len / YYJSON_READER_ESTIMATED_PRETTY_RATIO) + 4; alc_len = yyjson_min(alc_len, alc_max); - + val_hdr = (yyjson_val *)alc.malloc(alc.ctx, alc_len * sizeof(yyjson_val)); if (unlikely(!val_hdr)) goto fail_alloc; val_end = val_hdr + (alc_len - 2); /* padding for key-value pair reading */ @@ -6336,7 +6369,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; - + if (*cur++ == '{') { ctn->tag = YYJSON_TYPE_OBJ; ctn->uni.ofs = 0; @@ -6348,22 +6381,22 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (*cur == '\n') cur++; goto arr_val_begin; } - + arr_begin: /* save current container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | (ctn->tag & YYJSON_TAG_MASK); - + /* create a new array value, save parent container offset */ val_incr(); val->tag = YYJSON_TYPE_ARR; val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); - + /* push the new array value as current container */ ctn = val; ctn_len = 0; if (*cur == '\n') cur++; - + arr_val_begin: #if YYJSON_IS_REAL_GCC while (true) repeat16({ @@ -6376,7 +6409,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, else break; }) #endif - + if (*cur == '{') { cur++; goto obj_begin; @@ -6385,16 +6418,16 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, cur++; goto arr_begin; } - if (char_is_number(*cur)) { + if (char_is_num(*cur)) { val_incr(); ctn_len++; - if (likely(read_number(&cur, pre, flg, val, &msg))) goto arr_val_end; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto arr_val_end; goto fail_number; } if (*cur == '"') { val_incr(); ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto arr_val_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto arr_val_end; goto fail_string; } if (*cur == 't') { @@ -6414,7 +6447,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, ctn_len++; if (likely(read_null(&cur, val))) goto arr_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_nan(false, &cur, pre, val)) goto arr_val_end; + if (read_nan(false, &cur, pre, flg, val)) goto arr_val_end; } goto fail_literal_null; } @@ -6433,7 +6466,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val_incr(); ctn_len++; - if (read_inf_or_nan(false, &cur, pre, val)) goto arr_val_end; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto arr_val_end; goto fail_character_val; } if (has_read_flag(ALLOW_COMMENTS)) { @@ -6441,7 +6474,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_val; - + arr_val_end: if (byte_match_2(cur, ",\n")) { cur += 2; @@ -6464,16 +6497,16 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_arr_end; - + arr_end: /* get parent container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); - + /* save the next sibling value offset */ ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); ctn->tag = ((ctn_len) << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; if (unlikely(ctn == ctn_parent)) goto doc_end; - + /* pop parent as current container */ ctn = ctn_parent; ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); @@ -6483,7 +6516,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, } else { goto arr_val_end; } - + obj_begin: /* push container */ ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | @@ -6495,7 +6528,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, ctn = val; ctn_len = 0; if (*cur == '\n') cur++; - + obj_key_begin: #if YYJSON_IS_REAL_GCC while (true) repeat16({ @@ -6511,7 +6544,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (likely(*cur == '"')) { val_incr(); ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_key_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto obj_key_end; goto fail_string; } if (likely(*cur == '}')) { @@ -6530,7 +6563,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_key; - + obj_key_end: if (byte_match_2(cur, ": ")) { cur += 2; @@ -6549,18 +6582,18 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_sep; - + obj_val_begin: if (*cur == '"') { val++; ctn_len++; - if (likely(read_string(&cur, end, inv, val, &msg))) goto obj_val_end; + if (likely(read_str(&cur, end, inv, val, &msg, NULL))) goto obj_val_end; goto fail_string; } - if (char_is_number(*cur)) { + if (char_is_num(*cur)) { val++; ctn_len++; - if (likely(read_number(&cur, pre, flg, val, &msg))) goto obj_val_end; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto obj_val_end; goto fail_number; } if (*cur == '{') { @@ -6588,7 +6621,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, ctn_len++; if (likely(read_null(&cur, val))) goto obj_val_end; if (has_read_flag(ALLOW_INF_AND_NAN)) { - if (read_nan(false, &cur, pre, val)) goto obj_val_end; + if (read_nan(false, &cur, pre, flg, val)) goto obj_val_end; } goto fail_literal_null; } @@ -6600,7 +6633,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, (*cur == 'i' || *cur == 'I' || *cur == 'N')) { val++; ctn_len++; - if (read_inf_or_nan(false, &cur, pre, val)) goto obj_val_end; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto obj_val_end; goto fail_character_val; } if (has_read_flag(ALLOW_COMMENTS)) { @@ -6608,7 +6641,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_val; - + obj_val_end: if (byte_match_2(cur, ",\n")) { cur += 2; @@ -6631,7 +6664,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, if (byte_match_2(cur, "/*")) goto fail_comment; } goto fail_character_obj_end; - + obj_end: /* pop container */ ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); @@ -6647,7 +6680,7 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, } else { goto arr_val_end; } - + doc_end: /* check invalid contents after json document */ if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { @@ -6659,57 +6692,31 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, } if (unlikely(cur < end)) goto fail_garbage; } - + if (pre && *pre) **pre = '\0'; doc = (yyjson_doc *)val_hdr; doc->root = val_hdr + hdr_len; doc->alc = alc; doc->dat_read = (usize)(cur - hdr); - doc->val_read = (usize)((val - val_hdr)) - hdr_len + 1; + doc->val_read = (usize)((val - doc->root) + 1); doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; return doc; - -fail_string: - return_err(cur, INVALID_STRING, msg); -fail_number: - return_err(cur, INVALID_NUMBER, msg); -fail_alloc: - return_err(cur, MEMORY_ALLOCATION, - "memory allocation failed"); -fail_trailing_comma: - return_err(cur, JSON_STRUCTURE, - "trailing comma is not allowed"); -fail_literal_true: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'true'"); -fail_literal_false: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'false'"); -fail_literal_null: - return_err(cur, LITERAL, - "invalid literal, expected a valid literal such as 'null'"); -fail_character_val: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a valid JSON value"); -fail_character_arr_end: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a comma or a closing bracket"); -fail_character_obj_key: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a string for object key"); -fail_character_obj_sep: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a colon after object key"); -fail_character_obj_end: - return_err(cur, UNEXPECTED_CHARACTER, - "unexpected character, expected a comma or a closing brace"); -fail_comment: - return_err(cur, INVALID_COMMENT, - "unclosed multiline comment"); -fail_garbage: - return_err(cur, UNEXPECTED_CONTENT, - "unexpected content after document"); - + +fail_string: return_err(cur, INVALID_STRING, msg); +fail_number: return_err(cur, INVALID_NUMBER, msg); +fail_alloc: return_err(cur, MEMORY_ALLOCATION, MSG_MALLOC); +fail_trailing_comma: return_err(cur, JSON_STRUCTURE, MSG_COMMA); +fail_literal_true: return_err(cur, LITERAL, MSG_CHAT_T); +fail_literal_false: return_err(cur, LITERAL, MSG_CHAR_F); +fail_literal_null: return_err(cur, LITERAL, MSG_CHAR_N); +fail_character_val: return_err(cur, UNEXPECTED_CHARACTER, MSG_CHAR); +fail_character_arr_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_ARR_END); +fail_character_obj_key: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_KEY); +fail_character_obj_sep: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_SEP); +fail_character_obj_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_END); +fail_comment: return_err(cur, INVALID_COMMENT, MSG_COMMENT); +fail_garbage: return_err(cur, UNEXPECTED_CONTENT, MSG_GARBAGE); + #undef val_incr #undef return_err } @@ -6720,12 +6727,11 @@ static_inline yyjson_doc *read_root_pretty(u8 *hdr, * JSON Reader Entrance *============================================================================*/ -yyjson_doc *yyjson_read_opts(char *dat, - usize len, +yyjson_doc *yyjson_read_opts(char *dat, usize len, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err) { - + #define return_err(_pos, _code, _msg) do { \ err->pos = (usize)(_pos); \ err->msg = _msg; \ @@ -6733,26 +6739,17 @@ yyjson_doc *yyjson_read_opts(char *dat, if (!has_read_flag(INSITU) && hdr) alc.free(alc.ctx, (void *)hdr); \ return NULL; \ } while (false) - + yyjson_read_err dummy_err; - yyjson_alc alc; + yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_doc *doc; u8 *hdr = NULL, *end, *cur; - + /* validate input parameters */ if (!err) err = &dummy_err; - if (likely(!alc_ptr)) { - alc = YYJSON_DEFAULT_ALC; - } else { - alc = *alc_ptr; - } - if (unlikely(!dat)) { - return_err(0, INVALID_PARAMETER, "input data is NULL"); - } - if (unlikely(!len)) { - return_err(0, INVALID_PARAMETER, "input length is 0"); - } - + if (unlikely(!dat)) return_err(0, INVALID_PARAMETER, "input data is NULL"); + if (unlikely(!len)) return_err(0, INVALID_PARAMETER, "input length is 0"); + /* add 4-byte zero padding for input data if necessary */ if (has_read_flag(INSITU)) { hdr = (u8 *)dat; @@ -6760,73 +6757,726 @@ yyjson_doc *yyjson_read_opts(char *dat, cur = (u8 *)dat; } else { if (unlikely(len >= USIZE_MAX - YYJSON_PADDING_SIZE)) { - return_err(0, MEMORY_ALLOCATION, "memory allocation failed"); + return_err(0, MEMORY_ALLOCATION, MSG_MALLOC); } hdr = (u8 *)alc.malloc(alc.ctx, len + YYJSON_PADDING_SIZE); if (unlikely(!hdr)) { - return_err(0, MEMORY_ALLOCATION, "memory allocation failed"); + return_err(0, MEMORY_ALLOCATION, MSG_MALLOC); } end = hdr + len; cur = hdr; memcpy(hdr, dat, len); memset(end, 0, YYJSON_PADDING_SIZE); } - - /* skip empty contents before json document */ - if (unlikely(char_is_space_or_comment(*cur))) { - if (has_read_flag(ALLOW_COMMENTS)) { - if (!skip_spaces_and_comments(&cur)) { - return_err(cur - hdr, INVALID_COMMENT, - "unclosed multiline comment"); - } - } else { - if (likely(char_is_space(*cur))) { - while (char_is_space(*++cur)); - } - } - if (unlikely(cur >= end)) { - return_err(0, EMPTY_CONTENT, "input data is empty"); - } + + if (has_read_flag(ALLOW_BOM)) { + if (len >= 3 && is_utf8_bom(cur)) cur += 3; + } + + /* skip empty contents before json document */ + if (unlikely(char_is_space_or_comment(*cur))) { + if (has_read_flag(ALLOW_COMMENTS)) { + if (!skip_spaces_and_comments(&cur)) { + return_err(cur - hdr, INVALID_COMMENT, MSG_COMMENT); + } + } else { + if (likely(char_is_space(*cur))) { + while (char_is_space(*++cur)); + } + } + if (unlikely(cur >= end)) { + return_err(0, EMPTY_CONTENT, "input data is empty"); + } + } + + /* read json document */ + if (likely(char_is_container(*cur))) { + if (char_is_space(cur[1]) && char_is_space(cur[2])) { + doc = read_root_pretty(hdr, cur, end, alc, flg, err); + } else { + doc = read_root_minify(hdr, cur, end, alc, flg, err); + } + } else { + doc = read_root_single(hdr, cur, end, alc, flg, err); + } + + /* check result */ + if (likely(doc)) { + memset(err, 0, sizeof(yyjson_read_err)); + } else { + /* RFC 8259: JSON text MUST be encoded using UTF-8 */ + if (err->pos == 0 && err->code != YYJSON_READ_ERROR_MEMORY_ALLOCATION) { + if (is_utf8_bom(hdr)) err->msg = MSG_ERR_BOM; + else if (len >= 4 && is_utf32_bom(hdr)) err->msg = MSG_ERR_UTF32; + else if (len >= 2 && is_utf16_bom(hdr)) err->msg = MSG_ERR_UTF16; + } + if (!has_read_flag(INSITU)) alc.free(alc.ctx, (void *)hdr); + } + return doc; + +#undef return_err +} + + + +#if !YYJSON_DISABLE_INCR_READER + +/* labels within yyjson_incr_read() to resume incremental parsing */ +#define YYJSON_READ_LABEL_doc_begin 0 +#define YYJSON_READ_LABEL_arr_val_begin 1 +#define YYJSON_READ_LABEL_arr_val_end 2 +#define YYJSON_READ_LABEL_obj_key_begin 3 +#define YYJSON_READ_LABEL_obj_key_end 4 +#define YYJSON_READ_LABEL_obj_val_begin 5 +#define YYJSON_READ_LABEL_obj_val_end 6 +#define YYJSON_READ_LABEL_doc_end 7 + +/** State for incremental JSON reader, opaque in the API. */ +struct yyjson_incr_state { + u32 label; /* current parser goto label */ + const yyjson_alc *alc; /* allocator */ + yyjson_read_flag flg; /* read flags */ + u8 *hdr; /* JSON data */ + u8 *cur; /* current position in JSON data */ + usize len; + usize hdr_len; /* value count used by yyjson_doc */ + usize alc_len; /* value count allocated */ + usize ctn_len; /* the number of elements in current container */ + yyjson_val *val_hdr; /* the head of allocated values */ + yyjson_val *val_end; /* the end of allocated values */ + yyjson_val *val; /* current JSON value */ + yyjson_val *ctn; /* current container */ + u8 *str_con[2]; /* string parser incremental state */ +}; + +yyjson_incr_state *yyjson_incr_new(char *buf, size_t buf_len, + yyjson_read_flag flg, + const yyjson_alc *alc) { + yyjson_incr_state *state = NULL; + if (unlikely(!buf)) goto error; + if (likely(!alc)) alc = &YYJSON_DEFAULT_ALC; + state = (yyjson_incr_state *)alc->malloc(alc->ctx, + sizeof(yyjson_incr_state)); + if (!state) goto error; + memset(state, 0, sizeof(yyjson_incr_state)); + state->alc = alc; + state->flg = flg; + state->len = buf_len; + + /* add 4-byte zero padding for input data if necessary */ + if (has_read_flag(INSITU)) { + state->hdr = (u8 *)buf; + state->cur = (u8 *)buf; + } else { + if (unlikely(buf_len >= USIZE_MAX - YYJSON_PADDING_SIZE)) goto error; + state->hdr = (u8 *)alc->malloc(alc->ctx, buf_len + YYJSON_PADDING_SIZE); + if (unlikely(!state->hdr)) goto error; + state->cur = state->hdr; + memcpy(state->hdr, buf, buf_len); + memset(state->hdr + buf_len, 0, YYJSON_PADDING_SIZE); + } + return state; + +error: + if (state) yyjson_incr_free(state); + return NULL; +} + +void yyjson_incr_free(yyjson_incr_state *state) { + const yyjson_alc *alc = state->alc; + if (state->val_hdr != NULL) { + alc->free(alc->ctx, (void *)state->val_hdr); + } + if (state->hdr != NULL && !(state->flg & YYJSON_READ_INSITU)) { + alc->free(alc->ctx, (void *)state->hdr); + } + alc->free(alc->ctx, (void *)state); +} + +yyjson_doc *yyjson_incr_read(yyjson_incr_state *state, size_t len, + yyjson_read_err *err) { + +#define return_err_inv_param(_msg) do { \ + err->pos = 0; \ + err->msg = _msg; \ + err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; \ + return NULL; \ +} while (false) + +#define return_err(_pos, _code, _msg) do { \ + if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \ + goto unexpected_end; \ + } else { \ + err->pos = (usize)(_pos - hdr); \ + err->code = YYJSON_READ_ERROR_##_code; \ + err->msg = _msg; \ + } \ + return NULL; \ +} while (false) + +#define val_incr() do { \ + val++; \ + if (unlikely(val >= val_end)) { \ + usize alc_old = alc_len; \ + alc_len += alc_len / 2; \ + if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \ + val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \ + alc_old * sizeof(yyjson_val), \ + alc_len * sizeof(yyjson_val)); \ + if ((!val_tmp)) goto fail_alloc; \ + val = val_tmp + (usize)(val - val_hdr); \ + ctn = val_tmp + (usize)(ctn - val_hdr); \ + state->val = val_tmp + (usize)(state->val - val_hdr); \ + state->val_hdr = val_hdr = val_tmp; \ + val_end = val_tmp + (alc_len - 2); \ + state->val_end = val_end; \ + } \ +} while (false) + +#define save_incr_state(_label) do { \ + /* save position where it's possible to resume incremental parsing */ \ + state->label = YYJSON_READ_LABEL_##_label; \ + state->cur = cur; \ + state->val = val; \ + state->ctn_len = ctn_len; \ + state->hdr_len = hdr_len; \ + if (unlikely(cur >= end)) goto unexpected_end; \ +} while (false) + +#define check_maybe_truncated_number() do { \ + if (unlikely(cur >= end)) { \ + if (unlikely(cur > state->cur + INCR_NUM_MAX_LEN)) { \ + msg = "number too long"; \ + goto fail_number; \ + } \ + goto unexpected_end; \ + } \ +} while (false) + + u8 *hdr = NULL, *end = NULL, *cur = NULL; + yyjson_read_flag flg; + yyjson_alc alc; + usize dat_len; /* data length in bytes, hint for allocator */ + usize hdr_len; /* value count used by yyjson_doc */ + usize alc_len; /* value count allocated */ + usize alc_max; /* maximum value count for allocator */ + usize ctn_len; /* the number of elements in current container */ + yyjson_val *val_hdr; /* the head of allocated values */ + yyjson_val *val_end; /* the end of allocated values */ + yyjson_val *val_tmp; /* temporary pointer for realloc */ + yyjson_val *val; /* current JSON value */ + yyjson_val *ctn; /* current container */ + yyjson_val *ctn_parent; /* parent of current container */ + yyjson_doc *doc; /* the JSON document, equals to val_hdr */ + const char *msg; /* error message */ + + bool raw; /* read number as raw */ + bool inv; /* allow invalid unicode */ + u8 *raw_end; /* raw end for null-terminator */ + u8 **pre; /* previous raw end pointer */ + u8 **con = NULL; /* for incremental string parsing */ + u8 saved_end = '\0'; /* saved end char */ + + /* validate input parameters */ + if (unlikely(!err)) { + return NULL; + } + if (unlikely(!state)) { + return_err_inv_param("input state is NULL"); + } + if (unlikely(!len)) { + return_err_inv_param("input length is 0"); + } + if (unlikely(len > state->len)) { + return_err_inv_param("length is greater than total input length"); + } + + hdr = state->hdr; + end = state->hdr + len; + cur = state->cur; + flg = state->flg; + alc = *state->alc; + ctn_len = state->ctn_len; + hdr_len = state->hdr_len; + alc_len = state->alc_len; + val = state->val; + val_hdr = state->val_hdr; + val_end = state->val_end; + ctn = state->ctn; + con = state->str_con; + + alc_max = USIZE_MAX / sizeof(yyjson_val); + raw = has_read_flag(NUMBER_AS_RAW) || has_read_flag(BIGNUM_AS_RAW); + inv = has_read_flag(ALLOW_INVALID_UNICODE) != 0; + raw_end = NULL; + pre = raw ? &raw_end : NULL; + + /* insert null terminator to make us stop at the specified end, even if + the data contains more valid JSON */ + saved_end = *end; + *end = '\0'; + + /* resume parsing from the last save point */ + switch (state->label) { + case YYJSON_READ_LABEL_doc_begin: goto doc_begin; + case YYJSON_READ_LABEL_arr_val_begin: goto arr_val_begin; + case YYJSON_READ_LABEL_arr_val_end: goto arr_val_end; + case YYJSON_READ_LABEL_obj_key_begin: goto obj_key_begin; + case YYJSON_READ_LABEL_obj_key_end: goto obj_key_end; + case YYJSON_READ_LABEL_obj_val_begin: goto obj_val_begin; + case YYJSON_READ_LABEL_obj_val_end: goto obj_val_end; + case YYJSON_READ_LABEL_doc_end: goto doc_end; + default: return_err_inv_param("invalid incremental state"); + } + +doc_begin: + if (cur == hdr && has_read_flag(ALLOW_BOM)) { + if (len >= 3 && is_utf8_bom(cur)) cur += 3; + } + + /* skip empty contents before json document */ + if (unlikely(char_is_space_or_comment(*cur))) { + if (has_read_flag(ALLOW_COMMENTS)) { + if (!skip_spaces_and_comments(&cur)) { + /* unclosed multiline comment */ + goto unexpected_end; + } + } else { + if (likely(char_is_space(*cur))) { + while (char_is_space(*++cur)); + } + } + if (unlikely(cur >= end)) { + /* input data is empty */ + goto unexpected_end; + } + } + + /* allocate memory for document */ + if (!val_hdr) { + hdr_len = sizeof(yyjson_doc) / sizeof(yyjson_val); + hdr_len += (sizeof(yyjson_doc) % sizeof(yyjson_val)) > 0; + if (likely(char_is_container(*cur))) { + dat_len = has_read_flag(STOP_WHEN_DONE) ? 256 : state->len; + alc_len = hdr_len + + (dat_len / YYJSON_READER_ESTIMATED_MINIFY_RATIO) + 4; + alc_len = yyjson_min(alc_len, alc_max); + } else { + alc_len = hdr_len + 1; /* single value */ + } + val_hdr = (yyjson_val *)alc.malloc(alc.ctx, + alc_len * sizeof(yyjson_val)); + if (unlikely(!val_hdr)) goto fail_alloc; + val_end = val_hdr + (alc_len - 2); /* padding for kv pair reading */ + val = val_hdr + hdr_len; + ctn = val; + ctn_len = 0; + state->val_hdr = val_hdr; + state->val_end = val_end; + save_incr_state(doc_begin); + } + + /* read json document */ + if (*cur == '{') { + cur++; + ctn->tag = YYJSON_TYPE_OBJ; + ctn->uni.ofs = 0; + goto obj_key_begin; + } + if (*cur == '[') { + cur++; + ctn->tag = YYJSON_TYPE_ARR; + ctn->uni.ofs = 0; + goto arr_val_begin; + } + if (char_is_num(*cur)) { + if (likely(read_num(&cur, pre, flg, val, &msg))) goto doc_end; + goto fail_number; + } + if (*cur == '"') { + if (likely(read_str(&cur, end, inv, val, &msg, con))) goto doc_end; + goto fail_string; + } + if (*cur == 't') { + if (likely(read_true(&cur, val))) goto doc_end; + goto fail_literal_true; + } + if (*cur == 'f') { + if (likely(read_false(&cur, val))) goto doc_end; + goto fail_literal_false; + } + if (*cur == 'n') { + if (likely(read_null(&cur, val))) goto doc_end; + if (has_read_flag(ALLOW_INF_AND_NAN)) { + if (read_nan(false, &cur, pre, flg, val)) goto doc_end; + } + goto fail_literal_null; + } + if (has_read_flag(ALLOW_INF_AND_NAN)) { + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto doc_end; + } + + msg = "unexpected character, expected a valid root value"; + if (cur == hdr) { + /* RFC 8259: JSON text MUST be encoded using UTF-8 */ + if (is_utf8_bom(hdr)) msg = MSG_ERR_BOM; + else if (len >= 4 && is_utf32_bom(hdr)) msg = MSG_ERR_UTF32; + else if (len >= 2 && is_utf16_bom(hdr)) msg = MSG_ERR_UTF16; + } + return_err(cur, UNEXPECTED_CHARACTER, msg); + +arr_begin: + /* save current container */ + ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | + (ctn->tag & YYJSON_TAG_MASK); + + /* create a new array value, save parent container offset */ + val_incr(); + val->tag = YYJSON_TYPE_ARR; + val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); + + /* push the new array value as current container */ + ctn = val; + ctn_len = 0; + +arr_val_begin: + save_incr_state(arr_val_begin); +arr_val_continue: + if (*cur == '{') { + cur++; + goto obj_begin; + } + if (*cur == '[') { + cur++; + goto arr_begin; + } + if (char_is_num(*cur)) { + val_incr(); + ctn_len++; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto arr_val_maybe_end; + goto fail_number; + } + if (*cur == '"') { + val_incr(); + ctn_len++; + if (likely(read_str(&cur, end, inv, val, &msg, con))) goto arr_val_end; + goto fail_string; + } + if (*cur == 't') { + val_incr(); + ctn_len++; + if (likely(read_true(&cur, val))) goto arr_val_end; + goto fail_literal_true; + } + if (*cur == 'f') { + val_incr(); + ctn_len++; + if (likely(read_false(&cur, val))) goto arr_val_end; + goto fail_literal_false; + } + if (*cur == 'n') { + val_incr(); + ctn_len++; + if (likely(read_null(&cur, val))) goto arr_val_end; + if (has_read_flag(ALLOW_INF_AND_NAN)) { + if (read_nan(false, &cur, pre, flg, val)) goto arr_val_end; + } + goto fail_literal_null; + } + if (*cur == ']') { + cur++; + if (likely(ctn_len == 0)) goto arr_end; + if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto arr_end; + while (*cur != ',') cur--; + goto fail_trailing_comma; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto arr_val_continue; + } + if (has_read_flag(ALLOW_INF_AND_NAN) && + (*cur == 'i' || *cur == 'I' || *cur == 'N')) { + val_incr(); + ctn_len++; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto arr_val_maybe_end; + goto fail_character_val; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto arr_val_continue; + if (byte_match_2(cur, "/*")) goto fail_comment; + } + goto fail_character_val; + +arr_val_maybe_end: + /* if incremental parsing stops in the middle of a number, it may continue + with more digits, so arr val maybe didn't end yet */ + check_maybe_truncated_number(); + +arr_val_end: + save_incr_state(arr_val_end); + if (*cur == ',') { + cur++; + goto arr_val_begin; + } + if (*cur == ']') { + cur++; + goto arr_end; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto arr_val_end; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto arr_val_end; + if (byte_match_2(cur, "/*")) goto fail_comment; + } + goto fail_character_arr_end; + +arr_end: + /* get parent container */ + ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); + + /* save the next sibling value offset */ + ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); + ctn->tag = ((ctn_len) << YYJSON_TAG_BIT) | YYJSON_TYPE_ARR; + if (unlikely(ctn == ctn_parent)) goto doc_end; + + /* pop parent as current container */ + ctn = ctn_parent; + ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); + if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { + goto obj_val_end; + } else { + goto arr_val_end; + } + +obj_begin: + /* push container */ + ctn->tag = (((u64)ctn_len + 1) << YYJSON_TAG_BIT) | + (ctn->tag & YYJSON_TAG_MASK); + val_incr(); + val->tag = YYJSON_TYPE_OBJ; + /* offset to the parent */ + val->uni.ofs = (usize)((u8 *)val - (u8 *)ctn); + ctn = val; + ctn_len = 0; + +obj_key_begin: + save_incr_state(obj_key_begin); +obj_key_continue: + if (likely(*cur == '"')) { + val_incr(); + ctn_len++; + if (likely(read_str(&cur, end, inv, val, &msg, con))) goto obj_key_end; + goto fail_string; + } + if (likely(*cur == '}')) { + cur++; + if (likely(ctn_len == 0)) goto obj_end; + if (has_read_flag(ALLOW_TRAILING_COMMAS)) goto obj_end; + while (*cur != ',') cur--; + goto fail_trailing_comma; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto obj_key_continue; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto obj_key_continue; + if (byte_match_2(cur, "/*")) goto fail_comment; + } + goto fail_character_obj_key; + +obj_key_end: + save_incr_state(obj_key_end); + if (*cur == ':') { + cur++; + goto obj_val_begin; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto obj_key_end; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto obj_key_end; + if (byte_match_2(cur, "/*")) goto fail_comment; + } + goto fail_character_obj_sep; + +obj_val_begin: + save_incr_state(obj_val_begin); +obj_val_continue: + if (*cur == '"') { + val++; + ctn_len++; + if (likely(read_str(&cur, end, inv, val, &msg, con))) goto obj_val_end; + goto fail_string; + } + if (char_is_num(*cur)) { + val++; + ctn_len++; + if (likely(read_num(&cur, pre, flg, val, &msg))) goto obj_val_maybe_end; + goto fail_number; + } + if (*cur == '{') { + cur++; + goto obj_begin; + } + if (*cur == '[') { + cur++; + goto arr_begin; + } + if (*cur == 't') { + val++; + ctn_len++; + if (likely(read_true(&cur, val))) goto obj_val_end; + goto fail_literal_true; + } + if (*cur == 'f') { + val++; + ctn_len++; + if (likely(read_false(&cur, val))) goto obj_val_end; + goto fail_literal_false; + } + if (*cur == 'n') { + val++; + ctn_len++; + if (likely(read_null(&cur, val))) goto obj_val_end; + if (has_read_flag(ALLOW_INF_AND_NAN)) { + if (read_nan(false, &cur, pre, flg, val)) goto obj_val_end; + } + goto fail_literal_null; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto obj_val_continue; + } + if (has_read_flag(ALLOW_INF_AND_NAN) && + (*cur == 'i' || *cur == 'I' || *cur == 'N')) { + val++; + ctn_len++; + if (read_inf_or_nan(false, &cur, pre, flg, val)) goto obj_val_maybe_end; + goto fail_character_val; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto obj_val_continue; + if (byte_match_2(cur, "/*")) goto fail_comment; + } + goto fail_character_val; + +obj_val_maybe_end: + /* if incremental parsing stops in the middle of a number, it may continue + with more digits, so obj val maybe didn't end yet */ + check_maybe_truncated_number(); + +obj_val_end: + save_incr_state(obj_val_end); + if (likely(*cur == ',')) { + cur++; + goto obj_key_begin; + } + if (likely(*cur == '}')) { + cur++; + goto obj_end; + } + if (char_is_space(*cur)) { + while (char_is_space(*++cur)); + goto obj_val_end; + } + if (has_read_flag(ALLOW_COMMENTS)) { + if (skip_spaces_and_comments(&cur)) goto obj_val_end; + if (byte_match_2(cur, "/*")) goto fail_comment; } - - /* read json document */ - if (likely(char_is_container(*cur))) { - if (char_is_space(cur[1]) && char_is_space(cur[2])) { - doc = read_root_pretty(hdr, cur, end, alc, flg, err); - } else { - doc = read_root_minify(hdr, cur, end, alc, flg, err); - } + goto fail_character_obj_end; + +obj_end: + /* pop container */ + ctn_parent = (yyjson_val *)(void *)((u8 *)ctn - ctn->uni.ofs); + /* point to the next value */ + ctn->uni.ofs = (usize)((u8 *)val - (u8 *)ctn) + sizeof(yyjson_val); + ctn->tag = (ctn_len << (YYJSON_TAG_BIT - 1)) | YYJSON_TYPE_OBJ; + if (unlikely(ctn == ctn_parent)) goto doc_end; + ctn = ctn_parent; + ctn_len = (usize)(ctn->tag >> YYJSON_TAG_BIT); + if ((ctn->tag & YYJSON_TYPE_MASK) == YYJSON_TYPE_OBJ) { + goto obj_val_end; } else { - doc = read_root_single(hdr, cur, end, alc, flg, err); + goto arr_val_end; } - - /* check result */ - if (likely(doc)) { - memset(err, 0, sizeof(yyjson_read_err)); - } else { - /* RFC 8259: JSON text MUST be encoded using UTF-8 */ - if (err->pos == 0 && err->code != YYJSON_READ_ERROR_MEMORY_ALLOCATION) { - if ((hdr[0] == 0xEF && hdr[1] == 0xBB && hdr[2] == 0xBF)) { - err->msg = "byte order mark (BOM) is not supported"; - } else if (len >= 4 && - ((hdr[0] == 0x00 && hdr[1] == 0x00 && - hdr[2] == 0xFE && hdr[3] == 0xFF) || - (hdr[0] == 0xFF && hdr[1] == 0xFE && - hdr[2] == 0x00 && hdr[3] == 0x00))) { - err->msg = "UTF-32 encoding is not supported"; - } else if (len >= 2 && - ((hdr[0] == 0xFE && hdr[1] == 0xFF) || - (hdr[0] == 0xFF && hdr[1] == 0xFE))) { - err->msg = "UTF-16 encoding is not supported"; + +doc_end: + /* check invalid contents after json document */ + if (unlikely(cur < end) && !has_read_flag(STOP_WHEN_DONE)) { + save_incr_state(doc_end); + if (has_read_flag(ALLOW_COMMENTS)) { + skip_spaces_and_comments(&cur); + if (byte_match_2(cur, "/*")) goto fail_comment; + if (*cur == '/' && cur + 1 == end) { + /* truncated beginning of comment */ + goto unexpected_end; } + } else { + while (char_is_space(*cur)) cur++; } - if (!has_read_flag(INSITU)) alc.free(alc.ctx, (void *)hdr); + if (unlikely(cur < end)) goto fail_garbage; } + + if (pre && *pre) **pre = '\0'; + doc = (yyjson_doc *)val_hdr; + doc->root = val_hdr + hdr_len; + doc->alc = alc; + doc->dat_read = (usize)(cur - hdr); + doc->val_read = (usize)((val - doc->root) + 1); + doc->str_pool = has_read_flag(INSITU) ? NULL : (char *)hdr; + state->hdr = NULL; + state->val_hdr = NULL; + memset(err, 0, sizeof(yyjson_read_err)); return doc; - + +unexpected_end: + err->pos = len; + if (unlikely(len >= state->len)) { + err->code = YYJSON_READ_ERROR_UNEXPECTED_END; + err->msg = MSG_NOT_END; + return NULL; + } + /* save parser state in extended error struct, in addition to what was + * stored in the last save_incr_state */ + err->code = YYJSON_READ_ERROR_MORE; + err->msg = "need more data"; + state->val_end = val_end; + state->ctn = ctn; + state->alc_len = alc_len; + /* restore the end where we've inserted a null terminator */ + *end = saved_end; + return NULL; + +fail_string: return_err(cur, INVALID_STRING, msg); +fail_number: return_err(cur, INVALID_NUMBER, msg); +fail_alloc: return_err(cur, MEMORY_ALLOCATION, MSG_MALLOC); +fail_trailing_comma: return_err(cur, JSON_STRUCTURE, MSG_COMMA); +fail_literal_true: return_err(cur, LITERAL, MSG_CHAT_T); +fail_literal_false: return_err(cur, LITERAL, MSG_CHAR_F); +fail_literal_null: return_err(cur, LITERAL, MSG_CHAR_N); +fail_character_val: return_err(cur, UNEXPECTED_CHARACTER, MSG_CHAR); +fail_character_arr_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_ARR_END); +fail_character_obj_key: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_KEY); +fail_character_obj_sep: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_SEP); +fail_character_obj_end: return_err(cur, UNEXPECTED_CHARACTER, MSG_OBJ_END); +fail_comment: return_err(cur, INVALID_COMMENT, MSG_COMMENT); +fail_garbage: return_err(cur, UNEXPECTED_CONTENT, MSG_GARBAGE); + +#undef val_incr #undef return_err +#undef return_err_inv_param +#undef save_incr_state +#undef check_maybe_truncated_number } +#endif /* YYJSON_DISABLE_INCR_READER */ + + + yyjson_doc *yyjson_read_file(const char *path, yyjson_read_flag flg, const yyjson_alc *alc_ptr, @@ -6837,21 +7487,21 @@ yyjson_doc *yyjson_read_file(const char *path, err->code = YYJSON_READ_ERROR_##_code; \ return NULL; \ } while (false) - + yyjson_read_err dummy_err; yyjson_doc *doc; FILE *file; - + if (!err) err = &dummy_err; if (unlikely(!path)) return_err(INVALID_PARAMETER, "input path is NULL"); - + file = fopen_readonly(path); - if (unlikely(!file)) return_err(FILE_OPEN, "file opening failed"); - + if (unlikely(!file)) return_err(FILE_OPEN, MSG_FREAD); + doc = yyjson_read_fp(file, flg, alc_ptr, err); fclose(file); return doc; - + #undef return_err } @@ -6866,19 +7516,19 @@ yyjson_doc *yyjson_read_fp(FILE *file, if (buf) alc.free(alc.ctx, buf); \ return NULL; \ } while (false) - + yyjson_read_err dummy_err; yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_doc *doc; - + long file_size = 0, file_pos; void *buf = NULL; usize buf_size = 0; - + /* validate input parameters */ if (!err) err = &dummy_err; if (unlikely(!file)) return_err(INVALID_PARAMETER, "input file is NULL"); - + /* get current position */ file_pos = ftell(file); if (file_pos != -1) { @@ -6889,17 +7539,17 @@ yyjson_doc *yyjson_read_fp(FILE *file, /* get file size from current postion to end */ if (file_size > 0) file_size -= file_pos; } - + /* read file */ if (file_size > 0) { /* read the entire file in one call */ buf_size = (usize)file_size + YYJSON_PADDING_SIZE; buf = alc.malloc(alc.ctx, buf_size); if (buf == NULL) { - return_err(MEMORY_ALLOCATION, "fail to alloc memory"); + return_err(MEMORY_ALLOCATION, MSG_MALLOC); } if (fread_safe(buf, (usize)file_size, file) != (usize)file_size) { - return_err(FILE_READ, "file reading failed"); + return_err(FILE_READ, MSG_FREAD); } } else { /* failed to get file size, read it as a stream */ @@ -6908,31 +7558,31 @@ yyjson_doc *yyjson_read_fp(FILE *file, usize chunk_now = chunk_min; usize read_size; void *tmp; - + buf_size = YYJSON_PADDING_SIZE; while (true) { if (buf_size + chunk_now < buf_size) { /* overflow */ - return_err(MEMORY_ALLOCATION, "fail to alloc memory"); + return_err(MEMORY_ALLOCATION, MSG_MALLOC); } buf_size += chunk_now; if (!buf) { buf = alc.malloc(alc.ctx, buf_size); - if (!buf) return_err(MEMORY_ALLOCATION, "fail to alloc memory"); + if (!buf) return_err(MEMORY_ALLOCATION, MSG_MALLOC); } else { tmp = alc.realloc(alc.ctx, buf, buf_size - chunk_now, buf_size); - if (!tmp) return_err(MEMORY_ALLOCATION, "fail to alloc memory"); + if (!tmp) return_err(MEMORY_ALLOCATION, MSG_MALLOC); buf = tmp; } tmp = ((u8 *)buf) + buf_size - YYJSON_PADDING_SIZE - chunk_now; read_size = fread_safe(tmp, chunk_now, file); file_size += (long)read_size; if (read_size != chunk_now) break; - + chunk_now *= 2; if (chunk_now > chunk_max) chunk_now = chunk_max; } } - + /* read JSON */ memset((u8 *)buf + file_size, 0, YYJSON_PADDING_SIZE); flg |= YYJSON_READ_INSITU; @@ -6944,7 +7594,7 @@ yyjson_doc *yyjson_read_fp(FILE *file, alc.free(alc.ctx, buf); return NULL; } - + #undef return_err } @@ -6959,19 +7609,19 @@ const char *yyjson_read_number(const char *dat, err->code = YYJSON_READ_ERROR_##_code; \ return NULL; \ } while (false) - + u8 *hdr = constcast(u8 *)dat, *cur = hdr; bool raw; /* read number as raw */ u8 *raw_end; /* raw end for null-terminator */ u8 **pre; /* previous raw end pointer */ const char *msg; yyjson_read_err dummy_err; - + #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV u8 buf[128]; usize dat_len; #endif - + if (!err) err = &dummy_err; if (unlikely(!dat)) { return_err(cur, INVALID_PARAMETER, "input data is NULL"); @@ -6979,7 +7629,7 @@ const char *yyjson_read_number(const char *dat, if (unlikely(!val)) { return_err(cur, INVALID_PARAMETER, "output value is NULL"); } - + #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV if (!alc) alc = &YYJSON_DEFAULT_ALC; dat_len = strlen(dat); @@ -6991,19 +7641,19 @@ const char *yyjson_read_number(const char *dat, hdr = (u8 *)alc->malloc(alc->ctx, dat_len + 1); cur = hdr; if (unlikely(!hdr)) { - return_err(cur, MEMORY_ALLOCATION, "memory allocation failed"); + return_err(cur, MEMORY_ALLOCATION, MSG_MALLOC); } memcpy(hdr, dat, dat_len + 1); } hdr[dat_len] = 0; #endif - + raw = (flg & (YYJSON_READ_NUMBER_AS_RAW | YYJSON_READ_BIGNUM_AS_RAW)) != 0; raw_end = NULL; pre = raw ? &raw_end : NULL; - + #if !YYJSON_HAS_IEEE_754 || YYJSON_DISABLE_FAST_FP_CONV - if (!read_number(&cur, pre, flg, val, &msg)) { + if (!read_num(&cur, pre, flg, val, &msg)) { if (dat_len >= sizeof(buf)) alc->free(alc->ctx, hdr); return_err(cur, INVALID_NUMBER, msg); } @@ -7011,12 +7661,12 @@ const char *yyjson_read_number(const char *dat, if (yyjson_is_raw(val)) val->uni.str = dat; return dat + (cur - hdr); #else - if (!read_number(&cur, pre, flg, val, &msg)) { + if (!read_num(&cur, pre, flg, val, &msg)) { return_err(cur, INVALID_NUMBER, msg); } return (const char *)cur; #endif - + #undef return_err } @@ -7092,15 +7742,15 @@ static_inline u8 *write_u32_len_4(u32 val, u8 *buf) { return buf + 4; } -static_inline u8 *write_u32_len_1_8(u32 val, u8 *buf) { +static_inline u8 *write_u32_len_1_to_8(u32 val, u8 *buf) { u32 aa, bb, cc, dd, aabb, bbcc, ccdd, lz; - + if (val < 100) { /* 1-2 digits: aa */ lz = val < 10; /* leading zero: 0 or 1 */ byte_copy_2(buf + 0, digit_table + val * 2 + lz); buf -= lz; return buf + 2; - + } else if (val < 10000) { /* 3-4 digits: aabb */ aa = (val * 5243) >> 19; /* (val / 100) */ bb = val - aa * 100; /* (val % 100) */ @@ -7109,7 +7759,7 @@ static_inline u8 *write_u32_len_1_8(u32 val, u8 *buf) { buf -= lz; byte_copy_2(buf + 2, digit_table + bb * 2); return buf + 4; - + } else if (val < 1000000) { /* 5-6 digits: aabbcc */ aa = (u32)(((u64)val * 429497) >> 32); /* (val / 10000) */ bbcc = val - aa * 10000; /* (val % 10000) */ @@ -7121,7 +7771,7 @@ static_inline u8 *write_u32_len_1_8(u32 val, u8 *buf) { byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); return buf + 6; - + } else { /* 7-8 digits: aabbccdd */ aabb = (u32)(((u64)val * 109951163) >> 40); /* (val / 10000) */ ccdd = val - aabb * 10000; /* (val % 10000) */ @@ -7139,9 +7789,9 @@ static_inline u8 *write_u32_len_1_8(u32 val, u8 *buf) { } } -static_inline u8 *write_u64_len_5_8(u32 val, u8 *buf) { +static_inline u8 *write_u32_len_5_to_8(u32 val, u8 *buf) { u32 aa, bb, cc, dd, aabb, bbcc, ccdd, lz; - + if (val < 1000000) { /* 5-6 digits: aabbcc */ aa = (u32)(((u64)val * 429497) >> 32); /* (val / 10000) */ bbcc = val - aa * 10000; /* (val % 10000) */ @@ -7153,7 +7803,7 @@ static_inline u8 *write_u64_len_5_8(u32 val, u8 *buf) { byte_copy_2(buf + 2, digit_table + bb * 2); byte_copy_2(buf + 4, digit_table + cc * 2); return buf + 6; - + } else { /* 7-8 digits: aabbccdd */ aabb = (u32)(((u64)val * 109951163) >> 40); /* (val / 10000) */ ccdd = val - aabb * 10000; /* (val % 10000) */ @@ -7174,24 +7824,24 @@ static_inline u8 *write_u64_len_5_8(u32 val, u8 *buf) { static_inline u8 *write_u64(u64 val, u8 *buf) { u64 tmp, hgh; u32 mid, low; - + if (val < 100000000) { /* 1-8 digits */ - buf = write_u32_len_1_8((u32)val, buf); + buf = write_u32_len_1_to_8((u32)val, buf); return buf; - + } else if (val < (u64)100000000 * 100000000) { /* 9-16 digits */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ - buf = write_u32_len_1_8((u32)hgh, buf); + buf = write_u32_len_1_to_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; - + } else { /* 17-20 digits */ tmp = val / 100000000; /* (val / 100000000) */ low = (u32)(val - tmp * 100000000); /* (val % 100000000) */ hgh = (u32)(tmp / 10000); /* (tmp / 10000) */ mid = (u32)(tmp - hgh * 10000); /* (tmp % 10000) */ - buf = write_u64_len_5_8((u32)hgh, buf); + buf = write_u32_len_5_to_8((u32)hgh, buf); buf = write_u32_len_4(mid, buf); buf = write_u32_len_8(low, buf); return buf; @@ -7221,23 +7871,30 @@ static const u8 dec_trailing_zero_table[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -/** Write an unsigned integer with a length of 1 to 16. */ +static_inline u8 *write_u32_len_1_to_9(u32 val, u8 *buf) { + if (val >= 100000000) { + u32 hi = val / 10000000; + val = val - hi * 10000000; + *buf++ = (u8)(hi + '0'); + } + return write_u32_len_1_to_8((u32)val, buf); +} + static_inline u8 *write_u64_len_1_to_16(u64 val, u8 *buf) { u64 hgh; u32 low; if (val < 100000000) { /* 1-8 digits */ - buf = write_u32_len_1_8((u32)val, buf); + buf = write_u32_len_1_to_8((u32)val, buf); return buf; } else { /* 9-16 digits */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ - buf = write_u32_len_1_8((u32)hgh, buf); + buf = write_u32_len_1_to_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; } } -/** Write an unsigned integer with a length of 1 to 17. */ static_inline u8 *write_u64_len_1_to_17(u64 val, u8 *buf) { u64 hgh; u32 mid, low, one; @@ -7254,33 +7911,31 @@ static_inline u8 *write_u64_len_1_to_17(u64 val, u8 *buf) { } else if (val >= (u64)100000000){ /* len: 9 to 15 */ hgh = val / 100000000; /* (val / 100000000) */ low = (u32)(val - hgh * 100000000); /* (val % 100000000) */ - buf = write_u32_len_1_8((u32)hgh, buf); + buf = write_u32_len_1_to_8((u32)hgh, buf); buf = write_u32_len_8(low, buf); return buf; - } else { /* len: 1 to 8 */ - buf = write_u32_len_1_8((u32)val, buf); + } else { /* len: 1 to 8 */ + buf = write_u32_len_1_to_8((u32)val, buf); return buf; } } /** - Write an unsigned integer with a length of 15 to 17 with trailing zero trimmed. - These digits are named as "aabbccddeeffgghhii" here. - For example, input 1234567890123000, output "1234567890123". + Write an unsigned integer with a length of 7 to 9 with trailing zero trimmed. + These digits are named as "abbccddee" here. + For example, input 123456000, output "123456". */ -static_inline u8 *write_u64_len_15_to_17_trim(u8 *buf, u64 sig) { - bool lz; /* leading zero */ - u32 tz1, tz2, tz; /* trailing zero */ - - u32 abbccddee = (u32)(sig / 100000000); - u32 ffgghhii = (u32)(sig - (u64)abbccddee * 100000000); - u32 abbcc = abbccddee / 10000; /* (abbccddee / 10000) */ - u32 ddee = abbccddee - abbcc * 10000; /* (abbccddee % 10000) */ +static_inline u8 *write_u32_len_7_to_9_trim(u32 val, u8 *buf) { + bool lz; + u32 tz, tz1, tz2; + + u32 abbcc = val / 10000; /* (abbccddee / 10000) */ + u32 ddee = val - abbcc * 10000; /* (abbccddee % 10000) */ u32 abb = (u32)(((u64)abbcc * 167773) >> 24); /* (abbcc / 100) */ u32 a = (abb * 41) >> 12; /* (abb / 100) */ u32 bb = abb - a * 100; /* (abb % 100) */ u32 cc = abbcc - abb * 100; /* (abbcc % 100) */ - + /* write abbcc */ buf[0] = (u8)(a + '0'); buf += a > 0; @@ -7288,7 +7943,47 @@ static_inline u8 *write_u64_len_15_to_17_trim(u8 *buf, u64 sig) { byte_copy_2(buf + 0, digit_table + bb * 2 + lz); buf -= lz; byte_copy_2(buf + 2, digit_table + cc * 2); - + + if (ddee) { + u32 dd = (ddee * 5243) >> 19; /* (ddee / 100) */ + u32 ee = ddee - dd * 100; /* (ddee % 100) */ + byte_copy_2(buf + 4, digit_table + dd * 2); + byte_copy_2(buf + 6, digit_table + ee * 2); + tz1 = dec_trailing_zero_table[dd]; + tz2 = dec_trailing_zero_table[ee]; + tz = ee ? tz2 : (tz1 + 2); + buf += 8 - tz; + return buf; + } else { + tz1 = dec_trailing_zero_table[bb]; + tz2 = dec_trailing_zero_table[cc]; + tz = cc ? tz2 : (tz1 + tz2); + buf += 4 - tz; + return buf; + } +} + +/** + Write an unsigned integer with a length of 16 or 17 with trailing zero trimmed. + These digits are named as "abbccddeeffgghhii" here. + For example, input 1234567890123000, output "1234567890123". + */ +static_inline u8 *write_u64_len_16_to_17_trim(u64 val, u8 *buf) { + u32 tz, tz1, tz2; + + u32 abbccddee = (u32)(val / 100000000); + u32 ffgghhii = (u32)(val - (u64)abbccddee * 100000000); + u32 abbcc = abbccddee / 10000; + u32 ddee = abbccddee - abbcc * 10000; + u32 abb = (u32)(((u64)abbcc * 167773) >> 24); /* (abbcc / 100) */ + u32 a = (abb * 41) >> 12; /* (abb / 100) */ + u32 bb = abb - a * 100; /* (abb % 100) */ + u32 cc = abbcc - abb * 100; /* (abbcc % 100) */ + buf[0] = (u8)(a + '0'); + buf += a > 0; + byte_copy_2(buf + 0, digit_table + bb * 2); + byte_copy_2(buf + 2, digit_table + cc * 2); + if (ffgghhii) { u32 dd = (ddee * 5243) >> 19; /* (ddee / 100) */ u32 ee = ddee - dd * 100; /* (ddee % 100) */ @@ -7308,14 +8003,12 @@ static_inline u8 *write_u64_len_15_to_17_trim(u8 *buf, u64 sig) { tz1 = dec_trailing_zero_table[hh]; tz2 = dec_trailing_zero_table[ii]; tz = ii ? tz2 : (tz1 + 2); - buf += 16 - tz; - return buf; + return buf + 16 - tz; } else { tz1 = dec_trailing_zero_table[ff]; tz2 = dec_trailing_zero_table[gg]; tz = gg ? tz2 : (tz1 + 2); - buf += 12 - tz; - return buf; + return buf + 12 - tz; } } else { if (ddee) { @@ -7326,313 +8019,778 @@ static_inline u8 *write_u64_len_15_to_17_trim(u8 *buf, u64 sig) { tz1 = dec_trailing_zero_table[dd]; tz2 = dec_trailing_zero_table[ee]; tz = ee ? tz2 : (tz1 + 2); - buf += 8 - tz; - return buf; + return buf + 8 - tz; } else { tz1 = dec_trailing_zero_table[bb]; tz2 = dec_trailing_zero_table[cc]; tz = cc ? tz2 : (tz1 + tz2); - buf += 4 - tz; - return buf; + return buf + 4 - tz; } } } -/** Write a signed integer in the range -324 to 308. */ +/** Write exponent part in range `e-45` to `e38`. */ +static_inline u8 *write_f32_exp(i32 exp, u8 *buf) { + bool lz; + byte_copy_2(buf, "e-"); + buf += 2 - (exp >= 0); + exp = exp < 0 ? -exp : exp; + lz = exp < 10; + byte_copy_2(buf + 0, digit_table + (u32)exp * 2 + lz); + return buf + 2 - lz; +} + +/** Write exponent part in range `e-324` to `e308`. */ static_inline u8 *write_f64_exp(i32 exp, u8 *buf) { - buf[0] = '-'; - buf += exp < 0; + byte_copy_2(buf, "e-"); + buf += 2 - (exp >= 0); exp = exp < 0 ? -exp : exp; if (exp < 100) { - u32 lz = exp < 10; + bool lz = exp < 10; byte_copy_2(buf + 0, digit_table + (u32)exp * 2 + lz); return buf + 2 - lz; } else { - u32 hi = ((u32)exp * 656) >> 16; /* exp / 100 */ - u32 lo = (u32)exp - hi * 100; /* exp % 100 */ + u32 hi = ((u32)exp * 656) >> 16; /* exp / 100 */ + u32 lo = (u32)exp - hi * 100; /* exp % 100 */ buf[0] = (u8)((u8)hi + (u8)'0'); byte_copy_2(buf + 1, digit_table + lo * 2); return buf + 3; } } +/** Magic number for fast `divide by power of 10`. */ +typedef struct { + u64 p10, mul; + u32 shr1, shr2; +} div_pow10_magic; + +/** Generated with llvm, see https://github.com/llvm/llvm-project/ + blob/main/llvm/lib/Support/DivisionByConstantInfo.cpp */ +static const div_pow10_magic div_pow10_table[] = { + { U64(0x00000000, 0x00000001), U64(0x00000000, 0x00000000), 0, 0 }, + { U64(0x00000000, 0x0000000A), U64(0xCCCCCCCC, 0xCCCCCCCD), 0, 3 }, + { U64(0x00000000, 0x00000064), U64(0x28F5C28F, 0x5C28F5C3), 2, 2 }, + { U64(0x00000000, 0x000003E8), U64(0x20C49BA5, 0xE353F7CF), 3, 4 }, + { U64(0x00000000, 0x00002710), U64(0x346DC5D6, 0x3886594B), 0, 11 }, + { U64(0x00000000, 0x000186A0), U64(0x0A7C5AC4, 0x71B47843), 5, 7 }, + { U64(0x00000000, 0x000F4240), U64(0x431BDE82, 0xD7B634DB), 0, 18 }, + { U64(0x00000000, 0x00989680), U64(0xD6BF94D5, 0xE57A42BD), 0, 23 }, + { U64(0x00000000, 0x05F5E100), U64(0xABCC7711, 0x8461CEFD), 0, 26 }, + { U64(0x00000000, 0x3B9ACA00), U64(0x0044B82F, 0xA09B5A53), 9, 11 }, + { U64(0x00000002, 0x540BE400), U64(0xDBE6FECE, 0xBDEDD5BF), 0, 33 }, + { U64(0x00000017, 0x4876E800), U64(0xAFEBFF0B, 0xCB24AAFF), 0, 36 }, + { U64(0x000000E8, 0xD4A51000), U64(0x232F3302, 0x5BD42233), 0, 37 }, + { U64(0x00000918, 0x4E72A000), U64(0x384B84D0, 0x92ED0385), 0, 41 }, + { U64(0x00005AF3, 0x107A4000), U64(0x0B424DC3, 0x5095CD81), 0, 42 }, + { U64(0x00038D7E, 0xA4C68000), U64(0x00024075, 0xF3DCEAC3), 15, 20 }, + { U64(0x002386F2, 0x6FC10000), U64(0x39A5652F, 0xB1137857), 0, 51 }, + { U64(0x01634578, 0x5D8A0000), U64(0x00005C3B, 0xD5191B53), 17, 22 }, + { U64(0x0DE0B6B3, 0xA7640000), U64(0x000049C9, 0x7747490F), 18, 24 }, + { U64(0x8AC72304, 0x89E80000), U64(0x760F253E, 0xDB4AB0d3), 0, 62 }, +}; + +/** Divide a number by power of 10. */ +static_inline void div_pow10(u64 num, u32 exp, u64 *div, u64 *mod, u64 *p10) { + u64 hi, lo; + div_pow10_magic m = div_pow10_table[exp]; + u128_mul(num >> m.shr1, m.mul, &hi, &lo); + *div = hi >> m.shr2; + *mod = num - (*div * m.p10); + *p10 = m.p10; +} + +/** Multiplies 64-bit integer and returns highest 64-bit rounded value. */ +static_inline u32 u64_round_to_odd(u64 u, u32 cp) { + u64 hi, lo; + u32 y_hi, y_lo; + u128_mul(cp, u, &hi, &lo); + y_hi = (u32)hi; + y_lo = (u32)(lo >> 32); + return y_hi | (y_lo > 1); +} + /** Multiplies 128-bit integer and returns highest 64-bit rounded value. */ -static_inline u64 round_to_odd(u64 hi, u64 lo, u64 cp) { +static_inline u64 u128_round_to_odd(u64 hi, u64 lo, u64 cp) { u64 x_hi, x_lo, y_hi, y_lo; u128_mul(cp, lo, &x_hi, &x_lo); u128_mul_add(cp, hi, x_hi, &y_hi, &y_lo); return y_hi | (y_lo > 1); } -/** - Convert double number from binary to decimal. - The output significand is shortest decimal but may have trailing zeros. - - This function use the Schubfach algorithm: - Raffaello Giulietti, The Schubfach way to render doubles (5th version), 2022. - https://drive.google.com/file/d/1gp5xv4CAa78SVgCeWfGqqI4FfYYYuNFb - https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-November/083536.html - https://github.com/openjdk/jdk/pull/3402 (Java implementation) - https://github.com/abolz/Drachennest (C++ implementation) - - See also: - Dragonbox: A New Floating-Point Binary-to-Decimal Conversion Algorithm, 2022. - https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf - https://github.com/jk-jeon/dragonbox - - @param sig_raw The raw value of significand in IEEE 754 format. - @param exp_raw The raw value of exponent in IEEE 754 format. - @param sig_bin The decoded value of significand in binary. - @param exp_bin The decoded value of exponent in binary. - @param sig_dec The output value of significand in decimal. - @param exp_dec The output value of exponent in decimal. - @warning The input double number should not be 0, inf, nan. - */ +/** Convert f32 from binary to decimal (shortest but may have trailing zeros). + The input should not be 0, inf or nan. */ +static_inline void f32_bin_to_dec(u32 sig_raw, u32 exp_raw, + u32 sig_bin, i32 exp_bin, + u32 *sig_dec, i32 *exp_dec) { + + bool is_even, irregular, round_up, trim; + bool u0_inside, u1_inside, w0_inside, w1_inside; + u64 p10_hi, p10_lo, hi, lo; + u32 s, sp, cb, cbl, cbr, vb, vbl, vbr, upper, lower, mid; + i32 k, h; + + /* Fast path, see f64_bin_to_dec(). */ + while (likely(sig_raw)) { + u32 mod, dec, add_1, add_10, s_hi, s_lo; + u32 c, half_ulp, t0, t1; + + /* k = floor(exp_bin * log10(2)); */ + /* h = exp_bin + floor(log2(10) * -k); (h = 0/1/2/3) */ + k = (i32)(exp_bin * 315653) >> 20; + h = exp_bin + ((-k * 217707) >> 16); + pow10_table_get_sig(-k, &p10_hi, &p10_lo); + + /* sig_bin << (1/2/3/4) */ + cb = sig_bin << (h + 1); + u128_mul(cb, p10_hi, &hi, &lo); + s_hi = (u32)(hi); + s_lo = (u32)(lo >> 32); + mod = s_hi % 10; + dec = s_hi - mod; + + /* right shift 4 to fit in u32 */ + c = (mod << (32 - 4)) | (s_lo >> 4); + half_ulp = (u32)(p10_hi >> (32 + 4 - h)); + + /* check w1, u0, w0 range */ + w1_inside = (s_lo >= ((u32)1 << 31)); + if (unlikely(s_lo == ((u32)1 << 31))) break; + u0_inside = (half_ulp >= c); + if (unlikely(half_ulp == c)) break; + t0 = (u32)10 << (32 - 4); + t1 = c + half_ulp; + w0_inside = (t1 >= t0); + if (unlikely(t0 - t1 <= (u32)1)) break; + + trim = (u0_inside | w0_inside); + add_10 = (w0_inside ? 10 : 0); + add_1 = mod + w1_inside; + *sig_dec = dec + (trim ? add_10 : add_1); + *exp_dec = k; + return; + } + + /* Schubfach algorithm, see f64_bin_to_dec(). */ + irregular = (sig_raw == 0 && exp_raw > 1); + is_even = !(sig_bin & 1); + cbl = 4 * sig_bin - 2 + irregular; + cb = 4 * sig_bin; + cbr = 4 * sig_bin + 2; + + /* k = floor(exp_bin * log10(2) + (irregular ? log10(3.0 / 4.0) : 0)); */ + /* h = exp_bin + floor(log2(10) * -k) + 1; (h = 1/2/3/4) */ + k = (i32)(exp_bin * 315653 - (irregular ? 131237 : 0)) >> 20; + h = exp_bin + ((-k * 217707) >> 16) + 1; + pow10_table_get_sig(-k, &p10_hi, &p10_lo); + p10_hi += 1; + + vbl = u64_round_to_odd(p10_hi, cbl << h); + vb = u64_round_to_odd(p10_hi, cb << h); + vbr = u64_round_to_odd(p10_hi, cbr << h); + lower = vbl + !is_even; + upper = vbr - !is_even; + + s = vb / 4; + if (s >= 10) { + sp = s / 10; + u0_inside = (lower <= 40 * sp); + w0_inside = (upper >= 40 * sp + 40); + if (u0_inside != w0_inside) { + *sig_dec = sp * 10 + (w0_inside ? 10 : 0); + *exp_dec = k; + return; + } + } + u1_inside = (lower <= 4 * s); + w1_inside = (upper >= 4 * s + 4); + mid = 4 * s + 2; + round_up = (vb > mid) || (vb == mid && (s & 1) != 0); + *sig_dec = s + ((u1_inside != w1_inside) ? w1_inside : round_up); + *exp_dec = k; +} + +/** Convert f64 from binary to decimal (shortest but may have trailing zeros). + The input should not be 0, inf or nan. */ static_inline void f64_bin_to_dec(u64 sig_raw, u32 exp_raw, u64 sig_bin, i32 exp_bin, u64 *sig_dec, i32 *exp_dec) { - - bool is_even, regular_spacing, u_inside, w_inside, round_up; - u64 s, sp, cb, cbl, cbr, vb, vbl, vbr, pow10hi, pow10lo, upper, lower, mid; - i32 k, h, exp10; - + + bool is_even, irregular, round_up, trim; + bool u0_inside, u1_inside, w0_inside, w1_inside; + u64 s, sp, cb, cbl, cbr, vb, vbl, vbr, p10_hi, p10_lo, upper, lower, mid; + i32 k, h; + + /* + Fast path: + For regular spacing significand 'c', there are 4 candidates: + + u0 u1 c w1 w0 + ----|----|----|----|----|-*--|----|----|----|----|----|----|----|---- + 9 0 1 2 3 4 5 6 7 8 9 0 1 + |___________________|___________________| + 1ulp + + The `1ulp` is in the range [1.0, 10.0). + If (c - 0.5ulp < u0), trim the last digit and round down. + If (c + 0.5ulp > w0), trim the last digit and round up. + If (c - 0.5ulp < u1), round down. + If (c + 0.5ulp > w1), round up. + */ + while (likely(sig_raw)) { + u64 mod, dec, add_1, add_10, s_hi, s_lo; + u64 c, half_ulp, t0, t1; + + /* k = floor(exp_bin * log10(2)); */ + /* h = exp_bin + floor(log2(10) * -k); (h = 0/1/2/3) */ + k = (i32)(exp_bin * 315653) >> 20; + h = exp_bin + ((-k * 217707) >> 16); + pow10_table_get_sig(-k, &p10_hi, &p10_lo); + + /* sig_bin << (1/2/3/4) */ + cb = sig_bin << (h + 1); + u128_mul(cb, p10_lo, &s_hi, &s_lo); + u128_mul_add(cb, p10_hi, s_hi, &s_hi, &s_lo); + mod = s_hi % 10; + dec = s_hi - mod; + + /* right shift 4 to fit in u64 */ + c = (mod << (64 - 4)) | (s_lo >> 4); + half_ulp = p10_hi >> (4 - h); + + /* check w1, u0, w0 range */ + w1_inside = (s_lo >= ((u64)1 << 63)); + if (unlikely(s_lo == ((u64)1 << 63))) break; + u0_inside = (half_ulp >= c); + if (unlikely(half_ulp == c)) break; + t0 = ((u64)10 << (64 - 4)); + t1 = c + half_ulp; + w0_inside = (t1 >= t0); + if (unlikely(t0 - t1 <= (u64)1)) break; + + trim = (u0_inside | w0_inside); + add_10 = (w0_inside ? 10 : 0); + add_1 = mod + w1_inside; + *sig_dec = dec + (trim ? add_10 : add_1); + *exp_dec = k; + return; + } + + /* + Schubfach algorithm: + Raffaello Giulietti, The Schubfach way to render doubles, 2022. + https://drive.google.com/file/d/1gp5xv4CAa78SVgCeWfGqqI4FfYYYuNFb (Paper) + https://github.com/openjdk/jdk/pull/3402 (Java implementation) + https://github.com/abolz/Drachennest (C++ implementation) + */ + irregular = (sig_raw == 0 && exp_raw > 1); is_even = !(sig_bin & 1); - regular_spacing = (sig_raw == 0 && exp_raw > 1); - - cbl = 4 * sig_bin - 2 + regular_spacing; + cbl = 4 * sig_bin - 2 + irregular; cb = 4 * sig_bin; cbr = 4 * sig_bin + 2; - - /* exp_bin: [-1074, 971] */ - /* k = regular_spacing ? floor(log10(pow(2, exp_bin))) */ - /* : floor(log10(pow(2, exp_bin) * 3.0 / 4.0)) */ - /* = regular_spacing ? floor(exp_bin * log10(2)) */ - /* : floor(exp_bin * log10(2) + log10(3.0 / 4.0)) */ - k = (i32)(exp_bin * 315653 - (regular_spacing ? 131237 : 0)) >> 20; - - /* k: [-324, 292] */ - /* h = exp_bin + floor(log2(pow(10, e))) */ - /* = exp_bin + floor(log2(10) * e) */ - exp10 = -k; - h = exp_bin + ((exp10 * 217707) >> 16) + 1; - - pow10_table_get_sig(exp10, &pow10hi, &pow10lo); - pow10lo += (exp10 < POW10_SIG_TABLE_MIN_EXACT_EXP || - exp10 > POW10_SIG_TABLE_MAX_EXACT_EXP); - vbl = round_to_odd(pow10hi, pow10lo, cbl << h); - vb = round_to_odd(pow10hi, pow10lo, cb << h); - vbr = round_to_odd(pow10hi, pow10lo, cbr << h); - + + /* k = floor(exp_bin * log10(2) + (irregular ? log10(3.0 / 4.0) : 0)); */ + /* h = exp_bin + floor(log2(10) * -k) + 1; (h = 1/2/3/4) */ + k = (i32)(exp_bin * 315653 - (irregular ? 131237 : 0)) >> 20; + h = exp_bin + ((-k * 217707) >> 16) + 1; + pow10_table_get_sig(-k, &p10_hi, &p10_lo); + p10_lo += 1; + + vbl = u128_round_to_odd(p10_hi, p10_lo, cbl << h); + vb = u128_round_to_odd(p10_hi, p10_lo, cb << h); + vbr = u128_round_to_odd(p10_hi, p10_lo, cbr << h); lower = vbl + !is_even; upper = vbr - !is_even; - + s = vb / 4; if (s >= 10) { sp = s / 10; - u_inside = (lower <= 40 * sp); - w_inside = (upper >= 40 * sp + 40); - if (u_inside != w_inside) { - *sig_dec = sp + w_inside; - *exp_dec = k + 1; + u0_inside = (lower <= 40 * sp); + w0_inside = (upper >= 40 * sp + 40); + if (u0_inside != w0_inside) { + *sig_dec = sp * 10 + (w0_inside ? 10 : 0); + *exp_dec = k; return; } } - - u_inside = (lower <= 4 * s); - w_inside = (upper >= 4 * s + 4); - - mid = 4 * s + 2; - round_up = (vb > mid) || (vb == mid && (s & 1) != 0); - - *sig_dec = s + ((u_inside != w_inside) ? w_inside : round_up); - *exp_dec = k; + u1_inside = (lower <= 4 * s); + w1_inside = (upper >= 4 * s + 4); + mid = 4 * s + 2; + round_up = (vb > mid) || (vb == mid && (s & 1) != 0); + *sig_dec = s + ((u1_inside != w1_inside) ? w1_inside : round_up); + *exp_dec = k; +} + +/** Convert f64 from binary to decimal (fast but not the shortest). + The input should not be 0, inf, nan. */ +static_inline void f64_bin_to_dec_fast(u64 sig_raw, u32 exp_raw, + u64 sig_bin, i32 exp_bin, + u64 *sig_dec, i32 *exp_dec, + bool *round_up) { + u64 cb, p10_hi, p10_lo, s_hi, s_lo; + i32 k, h; + bool irregular, u; + + irregular = (sig_raw == 0 && exp_raw > 1); + + /* k = floor(exp_bin * log10(2) + (irregular ? log10(3.0 / 4.0) : 0)); */ + /* h = exp_bin + floor(log2(10) * -k) + 1; (h = 1/2/3/4) */ + k = (i32)(exp_bin * 315653 - (irregular ? 131237 : 0)) >> 20; + h = exp_bin + ((-k * 217707) >> 16); + pow10_table_get_sig(-k, &p10_hi, &p10_lo); + + /* sig_bin << (1/2/3/4) */ + cb = sig_bin << (h + 1); + u128_mul(cb, p10_lo, &s_hi, &s_lo); + u128_mul_add(cb, p10_hi, s_hi, &s_hi, &s_lo); + + /* round up */ + u = s_lo >= (irregular ? U64(0x55555555, 0x55555555) : ((u64)1 << 63)); + + *sig_dec = s_hi + u; + *exp_dec = k; + *round_up = u; + return; +} + +/** Write inf/nan if allowed. */ +static_inline u8 *write_inf_or_nan(u8 *buf, yyjson_write_flag flg, + u64 sig_raw, bool sign) { + if (has_write_flag(INF_AND_NAN_AS_NULL)) { + byte_copy_4(buf, "null"); + return buf + 4; + } + if (has_write_flag(ALLOW_INF_AND_NAN)) { + if (sig_raw == 0) { + buf[0] = '-'; + buf += sign; + byte_copy_8(buf, "Infinity"); + return buf + 8; + } else { + byte_copy_4(buf, "NaN"); + return buf + 3; + } + } + return NULL; +} + +/** + Write a float number (requires 40 bytes buffer). + We follow the ECMAScript specification for printing floating-point numbers, + similar to `Number.prototype.toString()`, but with the following changes: + 1. Keep the negative sign of `-0.0` to preserve input information. + 2. Keep decimal point to indicate the number is floating point. + 3. Remove positive sign in the exponent part. + */ +static_noinline u8 *write_f32_raw(u8 *buf, u64 raw_f64, + yyjson_write_flag flg) { + u32 sig_bin, sig_dec, sig_raw; + i32 exp_bin, exp_dec, sig_len, dot_ofs; + u32 exp_raw, raw; + u8 *end; + bool sign; + + /* cast double to float */ + raw = f32_to_raw(f64_to_f32(f64_from_raw(raw_f64))); + + /* decode raw bytes from IEEE-754 double format. */ + sign = (bool)(raw >> (F32_BITS - 1)); + sig_raw = raw & F32_SIG_MASK; + exp_raw = (raw & F32_EXP_MASK) >> F32_SIG_BITS; + + /* return inf or nan */ + if (unlikely(exp_raw == ((u32)1 << F32_EXP_BITS) - 1)) { + return write_inf_or_nan(buf, flg, sig_raw, sign); + } + + /* add sign for all finite number */ + buf[0] = '-'; + buf += sign; + + /* return zero */ + if ((raw << 1) == 0) { + byte_copy_4(buf, "0.0"); + return buf + 3; + } + + if (likely(exp_raw != 0)) { + /* normal number */ + sig_bin = sig_raw | ((u32)1 << F32_SIG_BITS); + exp_bin = (i32)exp_raw - F32_EXP_BIAS - F32_SIG_BITS; + + /* fast path for small integer number without fraction */ + if ((-F32_SIG_BITS <= exp_bin && exp_bin <= 0) && + (u64_tz_bits(sig_bin) >= (u32)-exp_bin)) { + sig_dec = sig_bin >> -exp_bin; /* range: [1, 0xFFFFFF] */ + buf = write_u32_len_1_to_8(sig_dec, buf); + byte_copy_2(buf, ".0"); + return buf + 2; + } + + /* binary to decimal */ + f32_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); + + /* the sig length is 7 or 9 */ + sig_len = 7 + (sig_dec >= (u32)10000000) + (sig_dec >= (u32)100000000); + + /* the decimal point offset relative to the first digit */ + dot_ofs = sig_len + exp_dec; + + if (-6 < dot_ofs && dot_ofs <= 21) { + i32 num_sep_pos, dot_set_pos, pre_ofs; + u8 *num_hdr, *num_end, *num_sep, *dot_end; + bool no_pre_zero; + + /* fill zeros */ + memset(buf, '0', 32); + + /* not prefixed with zero, e.g. 1.234, 1234.0 */ + no_pre_zero = (dot_ofs > 0); + + /* write the number as digits */ + pre_ofs = no_pre_zero ? 0 : (2 - dot_ofs); + num_hdr = buf + pre_ofs; + num_end = write_u32_len_7_to_9_trim(sig_dec, num_hdr); + + /* seperate these digits to leave a space for dot */ + num_sep_pos = no_pre_zero ? dot_ofs : 0; + num_sep = num_hdr + num_sep_pos; + byte_move_8(num_sep + no_pre_zero, num_sep); + num_end += no_pre_zero; + + /* write the dot */ + dot_set_pos = yyjson_max(dot_ofs, 1); + buf[dot_set_pos] = '.'; + + /* return the ending */ + dot_end = buf + dot_ofs + 2; + return yyjson_max(dot_end, num_end); + + } else { + /* write with scientific notation, e.g. 1.234e56 */ + end = write_u32_len_7_to_9_trim(sig_dec, buf + 1); + end -= (end == buf + 2); /* remove '.0', e.g. 2.0e34 -> 2e34 */ + exp_dec += sig_len - 1; + buf[0] = buf[1]; + buf[1] = '.'; + return write_f32_exp(exp_dec, end); + } + + } else { + /* subnormal number */ + sig_bin = sig_raw; + exp_bin = 1 - F32_EXP_BIAS - F32_SIG_BITS; + + /* binary to decimal */ + f32_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); + + /* write significand part */ + end = write_u32_len_1_to_9(sig_dec, buf + 1); + buf[0] = buf[1]; + buf[1] = '.'; + exp_dec += (i32)(end - buf) - 2; + + /* trim trailing zeros */ + end -= *(end - 1) == '0'; /* branchless for last zero */ + end -= *(end - 1) == '0'; /* branchless for second last zero */ + while (*(end - 1) == '0') end--; /* for unlikely more zeros */ + end -= *(end - 1) == '.'; /* remove dot, e.g. 2.e-321 -> 2e-321 */ + + /* write exponent part */ + return write_f32_exp(exp_dec, end); + } } /** - Write a double number (requires 32 bytes buffer). - - We follows the ECMAScript specification to print floating point numbers, - but with the following changes: - 1. Keep the negative sign of 0.0 to preserve input information. + Write a double number (requires 40 bytes buffer). + We follow the ECMAScript specification for printing floating-point numbers, + similar to `Number.prototype.toString()`, but with the following changes: + 1. Keep the negative sign of `-0.0` to preserve input information. 2. Keep decimal point to indicate the number is floating point. - 3. Remove positive sign of exponent part. + 3. Remove positive sign in the exponent part. */ -static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { +static_noinline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { u64 sig_bin, sig_dec, sig_raw; - i32 exp_bin, exp_dec, sig_len, dot_pos, i, max; - u32 exp_raw, hi, lo; - u8 *hdr, *num_hdr, *num_end, *dot_end; + i32 exp_bin, exp_dec, sig_len, dot_ofs; + u32 exp_raw; + u8 *end; bool sign; - + /* decode raw bytes from IEEE-754 double format. */ sign = (bool)(raw >> (F64_BITS - 1)); sig_raw = raw & F64_SIG_MASK; exp_raw = (u32)((raw & F64_EXP_MASK) >> F64_SIG_BITS); - - /* return inf and nan */ + + /* return inf or nan */ if (unlikely(exp_raw == ((u32)1 << F64_EXP_BITS) - 1)) { - if (has_write_flag(INF_AND_NAN_AS_NULL)) { - byte_copy_4(buf, "null"); - return buf + 4; - } - else if (has_write_flag(ALLOW_INF_AND_NAN)) { - if (sig_raw == 0) { - buf[0] = '-'; - buf += sign; - byte_copy_8(buf, "Infinity"); - buf += 8; - return buf; - } else { - byte_copy_4(buf, "NaN"); - return buf + 3; - } - } - return NULL; + return write_inf_or_nan(buf, flg, sig_raw, sign); } - - /* add sign for all finite double value, including 0.0 and inf */ + + /* add sign for all finite number */ buf[0] = '-'; buf += sign; - hdr = buf; - + /* return zero */ if ((raw << 1) == 0) { byte_copy_4(buf, "0.0"); - buf += 3; - return buf; + return buf + 3; } - + if (likely(exp_raw != 0)) { /* normal number */ sig_bin = sig_raw | ((u64)1 << F64_SIG_BITS); exp_bin = (i32)exp_raw - F64_EXP_BIAS - F64_SIG_BITS; - + /* fast path for small integer number without fraction */ - if (-F64_SIG_BITS <= exp_bin && exp_bin <= 0) { - if (u64_tz_bits(sig_bin) >= (u32)-exp_bin) { - /* number is integer in range 1 to 0x1FFFFFFFFFFFFF */ - sig_dec = sig_bin >> -exp_bin; - buf = write_u64_len_1_to_16(sig_dec, buf); - byte_copy_2(buf, ".0"); - buf += 2; - return buf; - } + if ((-F64_SIG_BITS <= exp_bin && exp_bin <= 0) && + (u64_tz_bits(sig_bin) >= (u32)-exp_bin)) { + sig_dec = sig_bin >> -exp_bin; /* range: [1, 0x1FFFFFFFFFFFFF] */ + buf = write_u64_len_1_to_16(sig_dec, buf); + byte_copy_2(buf, ".0"); + return buf + 2; } - + /* binary to decimal */ f64_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); - - /* the sig length is 15 to 17 */ - sig_len = 17; - sig_len -= (sig_dec < (u64)100000000 * 100000000); - sig_len -= (sig_dec < (u64)100000000 * 10000000); - - /* the decimal point position relative to the first digit */ - dot_pos = sig_len + exp_dec; - - if (-6 < dot_pos && dot_pos <= 21) { - /* no need to write exponent part */ - if (dot_pos <= 0) { - /* dot before first digit */ - /* such as 0.1234, 0.000001234 */ - num_hdr = hdr + (2 - dot_pos); - num_end = write_u64_len_15_to_17_trim(num_hdr, sig_dec); - hdr[0] = '0'; - hdr[1] = '.'; - hdr += 2; - max = -dot_pos; - for (i = 0; i < max; i++) hdr[i] = '0'; - return num_end; - } else { - /* dot after first digit */ - /* such as 1.234, 1234.0, 123400000000000000000.0 */ - memset(hdr + 0, '0', 8); - memset(hdr + 8, '0', 8); - memset(hdr + 16, '0', 8); - num_hdr = hdr + 1; - num_end = write_u64_len_15_to_17_trim(num_hdr, sig_dec); - for (i = 0; i < dot_pos; i++) hdr[i] = hdr[i + 1]; - hdr[dot_pos] = '.'; - dot_end = hdr + dot_pos + 2; - return dot_end < num_end ? num_end : dot_end; - } + + /* the sig length is 16 or 17 */ + sig_len = 16 + (sig_dec >= (u64)100000000 * 100000000); + + /* the decimal point offset relative to the first digit */ + dot_ofs = sig_len + exp_dec; + + if (-6 < dot_ofs && dot_ofs <= 21) { + i32 num_sep_pos, dot_set_pos, pre_ofs; + u8 *num_hdr, *num_end, *num_sep, *dot_end; + bool no_pre_zero; + + /* fill zeros */ + memset(buf, '0', 32); + + /* not prefixed with zero, e.g. 1.234, 1234.0 */ + no_pre_zero = (dot_ofs > 0); + + /* write the number as digits */ + pre_ofs = no_pre_zero ? 0 : (2 - dot_ofs); + num_hdr = buf + pre_ofs; + num_end = write_u64_len_16_to_17_trim(sig_dec, num_hdr); + + /* seperate these digits to leave a space for dot */ + num_sep_pos = no_pre_zero ? dot_ofs : 0; + num_sep = num_hdr + num_sep_pos; + byte_move_16(num_sep + no_pre_zero, num_sep); + num_end += no_pre_zero; + + /* write the dot */ + dot_set_pos = yyjson_max(dot_ofs, 1); + buf[dot_set_pos] = '.'; + + /* return the ending */ + dot_end = buf + dot_ofs + 2; + return yyjson_max(dot_end, num_end); + } else { - /* write with scientific notation */ - /* such as 1.234e56 */ - u8 *end = write_u64_len_15_to_17_trim(buf + 1, sig_dec); + /* write with scientific notation, e.g. 1.234e56 */ + end = write_u64_len_16_to_17_trim(sig_dec, buf + 1); end -= (end == buf + 2); /* remove '.0', e.g. 2.0e34 -> 2e34 */ exp_dec += sig_len - 1; - hdr[0] = hdr[1]; - hdr[1] = '.'; - end[0] = 'e'; - buf = write_f64_exp(exp_dec, end + 1); - return buf; + buf[0] = buf[1]; + buf[1] = '.'; + return write_f64_exp(exp_dec, end); } - + } else { /* subnormal number */ sig_bin = sig_raw; exp_bin = 1 - F64_EXP_BIAS - F64_SIG_BITS; - + /* binary to decimal */ f64_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, &sig_dec, &exp_dec); - + /* write significand part */ - buf = write_u64_len_1_to_17(sig_dec, buf + 1); - hdr[0] = hdr[1]; - hdr[1] = '.'; - do { - buf--; - exp_dec++; - } while (*buf == '0'); - exp_dec += (i32)(buf - hdr - 2); - buf += (*buf != '.'); - buf[0] = 'e'; - buf++; - + end = write_u64_len_1_to_17(sig_dec, buf + 1); + buf[0] = buf[1]; + buf[1] = '.'; + exp_dec += (i32)(end - buf) - 2; + + /* trim trailing zeros */ + end -= *(end - 1) == '0'; /* branchless for last zero */ + end -= *(end - 1) == '0'; /* branchless for second last zero */ + while (*(end - 1) == '0') end--; /* for unlikely more zeros */ + end -= *(end - 1) == '.'; /* remove dot, e.g. 2.e-321 -> 2e-321 */ + /* write exponent part */ - buf[0] = '-'; - buf++; - exp_dec = -exp_dec; - hi = ((u32)exp_dec * 656) >> 16; /* exp / 100 */ - lo = (u32)exp_dec - hi * 100; /* exp % 100 */ - buf[0] = (u8)((u8)hi + (u8)'0'); - byte_copy_2(buf + 1, digit_table + lo * 2); - buf += 3; - return buf; + return write_f64_exp(exp_dec, end); + } +} + +/** + Write a double number using fixed-point notation (requires 40 bytes buffer). + + We follow the ECMAScript specification for printing floating-point numbers, + similar to `Number.prototype.toFixed(prec)`, but with the following changes: + 1. Keep the negative sign of `-0.0` to preserve input information. + 2. Keep decimal point to indicate the number is floating point. + 3. Remove positive sign in the exponent part. + 4. Remove trailing zeros and reduce unnecessary precision. + */ +static_noinline u8 *write_f64_raw_fixed(u8 *buf, u64 raw, yyjson_write_flag flg, + u32 prec) { + u64 sig_bin, sig_dec, sig_raw; + i32 exp_bin, exp_dec, sig_len, dot_ofs; + u32 exp_raw; + u8 *end; + bool sign; + + /* decode raw bytes from IEEE-754 double format. */ + sign = (bool)(raw >> (F64_BITS - 1)); + sig_raw = raw & F64_SIG_MASK; + exp_raw = (u32)((raw & F64_EXP_MASK) >> F64_SIG_BITS); + + /* return inf or nan */ + if (unlikely(exp_raw == ((u32)1 << F64_EXP_BITS) - 1)) { + return write_inf_or_nan(buf, flg, sig_raw, sign); + } + + /* add sign for all finite number */ + buf[0] = '-'; + buf += sign; + + /* return zero */ + if ((raw << 1) == 0) { + byte_copy_4(buf, "0.0"); + return buf + 3; + } + + if (likely(exp_raw != 0)) { + /* normal number */ + sig_bin = sig_raw | ((u64)1 << F64_SIG_BITS); + exp_bin = (i32)exp_raw - F64_EXP_BIAS - F64_SIG_BITS; + + /* fast path for small integer number without fraction */ + if ((-F64_SIG_BITS <= exp_bin && exp_bin <= 0) && + (u64_tz_bits(sig_bin) >= (u32)-exp_bin)) { + sig_dec = sig_bin >> -exp_bin; /* range: [1, 0x1FFFFFFFFFFFFF] */ + buf = write_u64_len_1_to_16(sig_dec, buf); + byte_copy_2(buf, ".0"); + return buf + 2; + } + + /* only `fabs(num) < 1e21` are processed here. */ + if ((raw << 1) < (U64(0x444B1AE4, 0xD6E2EF50) << 1)) { + i32 num_sep_pos, dot_set_pos, pre_ofs; + u8 *num_hdr, *num_end, *num_sep; + bool round_up, no_pre_zero; + + /* binary to decimal */ + f64_bin_to_dec_fast(sig_raw, exp_raw, sig_bin, exp_bin, + &sig_dec, &exp_dec, &round_up); + + /* the sig length is 16 or 17 */ + sig_len = 16 + (sig_dec >= (u64)100000000 * 100000000); + + /* limit the length of digits after the decimal point */ + if (exp_dec < -1) { + i32 sig_len_cut = -exp_dec - (i32)prec; + if (sig_len_cut > sig_len) { + byte_copy_4(buf, "0.0"); + return buf + 3; + } + if (sig_len_cut > 0) { + u64 div, mod, p10; + + /* remove round up */ + sig_dec -= round_up; + sig_len = 16 + (sig_dec >= (u64)100000000 * 100000000); + + /* cut off some digits */ + div_pow10(sig_dec, (u32)sig_len_cut, &div, &mod, &p10); + + /* add round up */ + sig_dec = div + (mod >= p10 / 2); + + /* update exp and sig length */ + exp_dec += sig_len_cut; + sig_len -= sig_len_cut; + sig_len += (sig_len >= 0) && + (sig_dec >= div_pow10_table[sig_len].p10); + } + if (sig_len <= 0) { + byte_copy_4(buf, "0.0"); + return buf + 3; + } + } + + /* fill zeros */ + memset(buf, '0', 32); + + /* the decimal point offset relative to the first digit */ + dot_ofs = sig_len + exp_dec; + + /* not prefixed with zero, e.g. 1.234, 1234.0 */ + no_pre_zero = (dot_ofs > 0); + + /* write the number as digits */ + pre_ofs = no_pre_zero ? 0 : (1 - dot_ofs); + num_hdr = buf + pre_ofs; + num_end = write_u64_len_1_to_17(sig_dec, num_hdr); + + /* seperate these digits to leave a space for dot */ + num_sep_pos = no_pre_zero ? dot_ofs : -dot_ofs; + num_sep = buf + num_sep_pos; + byte_move_16(num_sep + 1, num_sep); + num_end += (exp_dec < 0); + + /* write the dot */ + dot_set_pos = yyjson_max(dot_ofs, 1); + buf[dot_set_pos] = '.'; + + /* remove trailing zeros */ + buf += dot_set_pos + 2; + buf = yyjson_max(buf, num_end); + buf -= *(buf - 1) == '0'; /* branchless for last zero */ + buf -= *(buf - 1) == '0'; /* branchless for second last zero */ + while (*(buf - 1) == '0') buf--; /* for unlikely more zeros */ + buf += *(buf - 1) == '.'; /* keep a zero after dot */ + return buf; + + } else { + /* binary to decimal */ + f64_bin_to_dec(sig_raw, exp_raw, sig_bin, exp_bin, + &sig_dec, &exp_dec); + + /* the sig length is 16 or 17 */ + sig_len = 16 + (sig_dec >= (u64)100000000 * 100000000); + + /* write with scientific notation, e.g. 1.234e56 */ + end = write_u64_len_16_to_17_trim(sig_dec, buf + 1); + end -= (end == buf + 2); /* remove '.0', e.g. 2.0e34 -> 2e34 */ + exp_dec += sig_len - 1; + buf[0] = buf[1]; + buf[1] = '.'; + return write_f64_exp(exp_dec, end); + } + } else { + /* subnormal number */ + byte_copy_4(buf, "0.0"); + return buf + 3; } } #else /* FP_WRITER */ -/** Write a double number (requires 32 bytes buffer). */ -static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { - /* - For IEEE 754, `DBL_DECIMAL_DIG` is 17 for round-trip. - For non-IEEE formats, 17 is used to avoid buffer overflow, - round-trip is not guaranteed. - */ -#if defined(DBL_DECIMAL_DIG) && DBL_DECIMAL_DIG != 17 - int dig = DBL_DECIMAL_DIG > 17 ? 17 : DBL_DECIMAL_DIG; -#else - int dig = 17; -#endif - - /* - The snprintf() function is locale-dependent. For currently known locales, - (en, zh, ja, ko, am, he, hi) use '.' as the decimal point, while other - locales use ',' as the decimal point. we need to replace ',' with '.' - to avoid the locale setting. - */ - f64 val = f64_from_raw(raw); #if YYJSON_MSC_VER >= 1400 - int len = sprintf_s((char *)buf, 32, "%.*g", dig, val); +#define snprintf_num(buf, len, fmt, dig, val) \ + sprintf_s((char *)buf, len, fmt, dig, val) #elif defined(snprintf) || (YYJSON_STDC_VER >= 199901L) - int len = snprintf((char *)buf, 32, "%.*g", dig, val); +#define snprintf_num(buf, len, fmt, dig, val) \ + snprintf((char *)buf, len, fmt, dig, val) #else - int len = sprintf((char *)buf, "%.*g", dig, val); +#define snprintf_num(buf, len, fmt, dig, val) \ + sprintf((char *)buf, fmt, dig, val) #endif - + +static_noinline u8 *write_fp_reformat(u8 *buf, int len, + yyjson_write_flag flg, bool fixed) { u8 *cur = buf; if (unlikely(len < 1)) return NULL; cur += (*cur == '-'); @@ -7641,12 +8799,10 @@ static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { if (has_write_flag(INF_AND_NAN_AS_NULL)) { byte_copy_4(buf, "null"); return buf + 4; - } - else if (has_write_flag(ALLOW_INF_AND_NAN)) { + } else if (has_write_flag(ALLOW_INF_AND_NAN)) { if (*cur == 'i') { byte_copy_8(cur, "Infinity"); - cur += 8; - return cur; + return cur + 8; } else if (*cur == 'n') { byte_copy_4(buf, "NaN"); return buf + 3; @@ -7655,34 +8811,121 @@ static_inline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { return NULL; } else { /* finite number */ - int i = 0; - bool fp = false; - for (; i < len; i++) { - if (buf[i] == ',') buf[i] = '.'; - if (digi_is_fp((u8)buf[i])) fp = true; + u8 *end = buf + len, *dot = NULL, *exp = NULL; + + /* + The snprintf() function is locale-dependent. For currently known + locales, (en, zh, ja, ko, am, he, hi) use '.' as the decimal point, + while other locales use ',' as the decimal point. we need to replace + ',' with '.' to avoid the locale setting. + */ + for (; cur < end; cur++) { + switch (*cur) { + case ',': *cur = '.'; /* fallthrough */ + case '.': dot = cur; break; + case 'e': exp = cur; break; + default: break; + } } - if (!fp) { - buf[len++] = '.'; - buf[len++] = '0'; + if (fixed) { + /* remove trailing zeros */ + while (*(end - 1) == '0') end--; + end += *(end - 1) == '.'; + } else { + if (!dot && !exp) { + /* add decimal point, e.g. 123 -> 123.0 */ + byte_copy_2(end, ".0"); + end += 2; + } else if (exp) { + cur = exp + 1; + /* remove positive sign in the exponent part */ + if (*cur == '+') { + memmove(cur, cur + 1, (usize)(end - cur - 1)); + end--; + } + cur += (*cur == '-'); + /* remove leading zeros in the exponent part */ + if (*cur == '0') { + u8 *hdr = cur++; + while (*cur == '0') cur++; + memmove(hdr, cur, (usize)(end - cur)); + end -= (usize)(cur - hdr); + } + } } + return end; } - return buf + len; } -#endif /* FP_WRITER */ +/** Write a double number (requires 40 bytes buffer). */ +static_noinline u8 *write_f64_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { +#if defined(DBL_DECIMAL_DIG) && DBL_DECIMAL_DIG < F64_DEC_DIG + int dig = DBL_DECIMAL_DIG; +#else + int dig = F64_DEC_DIG; +#endif + f64 val = f64_from_raw(raw); + int len = snprintf_num(buf, FP_BUF_LEN, "%.*g", dig, val); + return write_fp_reformat(buf, len, flg, false); +} -/** Write a JSON number (requires 32 bytes buffer). */ -static_inline u8 *write_number(u8 *cur, yyjson_val *val, - yyjson_write_flag flg) { - if (val->tag & YYJSON_SUBTYPE_REAL) { - u64 raw = val->uni.u64; - return write_f64_raw(cur, raw, flg); +/** Write a double number (requires 40 bytes buffer). */ +static_noinline u8 *write_f32_raw(u8 *buf, u64 raw, yyjson_write_flag flg) { +#if defined(FLT_DECIMAL_DIG) && FLT_DECIMAL_DIG < F32_DEC_DIG + int dig = FLT_DECIMAL_DIG; +#else + int dig = F32_DEC_DIG; +#endif + f64 val = (f64)f64_to_f32(f64_from_raw(raw)); + int len = snprintf_num(buf, FP_BUF_LEN, "%.*g", dig, val); + return write_fp_reformat(buf, len, flg, false); +} + +/** Write a double number (requires 40 bytes buffer). */ +static_noinline u8 *write_f64_raw_fixed(u8 *buf, u64 raw, + yyjson_write_flag flg, u32 prec) { + f64 val = (f64)f64_from_raw(raw); + if (-1e21 < val && val < 1e21) { + int len = snprintf_num(buf, FP_BUF_LEN, "%.*f", (int)prec, val); + return write_fp_reformat(buf, len, flg, true); } else { + return write_f64_raw(buf, raw, flg); + } +} + +#endif /* FP_WRITER */ + +/** Write a JSON number (requires 40 bytes buffer). */ +static_inline u8 *write_num(u8 *cur, yyjson_val *val, yyjson_write_flag flg) { + if (!(val->tag & YYJSON_SUBTYPE_REAL)) { u64 pos = val->uni.u64; u64 neg = ~pos + 1; - usize sgn = ((val->tag & YYJSON_SUBTYPE_SINT) > 0) & ((i64)pos < 0); + usize sign = ((val->tag & YYJSON_SUBTYPE_SINT) > 0) & ((i64)pos < 0); *cur = '-'; - return write_u64(sgn ? neg : pos, cur + sgn); + return write_u64(sign ? neg : pos, cur + sign); + } else { + u64 raw = val->uni.u64; + u32 val_fmt = (u32)(val->tag >> 32); + u32 all_fmt = flg; + u32 fmt = val_fmt | all_fmt; + if (likely(!(fmt >> (32 - YYJSON_WRITE_FP_FLAG_BITS)))) { + /* double to shortest */ + return write_f64_raw(cur, raw, flg); + } else if (fmt >> (32 - YYJSON_WRITE_FP_PREC_BITS)) { + /* double to fixed */ + u32 val_prec = val_fmt >> (32 - YYJSON_WRITE_FP_PREC_BITS); + u32 all_prec = all_fmt >> (32 - YYJSON_WRITE_FP_PREC_BITS); + u32 prec = val_prec ? val_prec : all_prec; + return write_f64_raw_fixed(cur, raw, flg, prec); + } else { + if (fmt & YYJSON_WRITE_FP_TO_FLOAT) { + /* float to shortest */ + return write_f32_raw(cur, raw, flg); + } else { + /* double to shortest */ + return write_f64_raw(cur, raw, flg); + } + } } } @@ -7959,7 +9202,7 @@ static_inline u8 *write_raw(u8 *cur, const u8 *raw, usize raw_len) { @param str_len Length of string in bytes. @return The buffer cursor after string. */ -static_inline u8 *write_string_noesc(u8 *cur, const u8 *str, usize str_len) { +static_inline u8 *write_str_noesc(u8 *cur, const u8 *str, usize str_len) { *cur++ = '"'; while (str_len >= 16) { byte_copy_16(cur, str); @@ -7991,11 +9234,11 @@ static_inline u8 *write_string_noesc(u8 *cur, const u8 *str, usize str_len) { @param enc_table Encode type table for character. @return The buffer cursor after string, or NULL on invalid unicode. */ -static_inline u8 *write_string(u8 *cur, bool esc, bool inv, - const u8 *str, usize str_len, - const char_enc_type *enc_table) { - - /* UTF-8 character mask and pattern, see `read_string()` for details. */ +static_inline u8 *write_str(u8 *cur, bool esc, bool inv, + const u8 *str, usize str_len, + const char_enc_type *enc_table) { + + /* UTF-8 character mask and pattern, see `read_str()` for details. */ #if YYJSON_ENDIAN == YYJSON_BIG_ENDIAN const u16 b2_mask = 0xE0C0UL; const u16 b2_patt = 0xC080UL; @@ -8049,36 +9292,36 @@ static_inline u8 *write_string(u8 *cur, bool esc, bool inv, u32 b4_err0 = b4_err0_uni.u; u32 b4_err1 = b4_err1_uni.u; #endif - + #define is_valid_seq_2(uni) ( \ ((uni & b2_mask) == b2_patt) && \ ((uni & b2_requ)) \ ) - + #define is_valid_seq_3(uni) ( \ ((uni & b3_mask) == b3_patt) && \ ((tmp = (uni & b3_requ))) && \ ((tmp != b3_erro)) \ ) - + #define is_valid_seq_4(uni) ( \ ((uni & b4_mask) == b4_patt) && \ ((tmp = (uni & b4_requ))) && \ ((tmp & b4_err0) == 0 || (tmp & b4_err1) == 0) \ ) - + /* The replacement character U+FFFD, used to indicate invalid character. */ const v32 rep = {{ 'F', 'F', 'F', 'D' }}; const v32 pre = {{ '\\', 'u', '0', '0' }}; - + const u8 *src = str; const u8 *end = str + str_len; *cur++ = '"'; - + copy_ascii: /* Copy continuous ASCII, loop unrolling, same as the following code: - + while (end > src) ( if (unlikely(enc_table[*src])) break; *cur++ = *src++; @@ -8086,37 +9329,37 @@ static_inline u8 *write_string(u8 *cur, bool esc, bool inv, */ #define expr_jump(i) \ if (unlikely(enc_table[src[i]])) goto stop_char_##i; - + #define expr_stop(i) \ stop_char_##i: \ memcpy(cur, src, i); \ cur += i; src += i; goto copy_utf8; - + while (end - src >= 16) { repeat16_incr(expr_jump) byte_copy_16(cur, src); cur += 16; src += 16; } - + while (end - src >= 4) { repeat4_incr(expr_jump) byte_copy_4(cur, src); cur += 4; src += 4; } - + while (end > src) { expr_jump(0) *cur++ = *src++; } - + *cur++ = '"'; return cur; - + repeat16_incr(expr_stop) - + #undef expr_jump #undef expr_stop - + copy_utf8: if (unlikely(src + 4 > end)) { if (end == src) goto copy_end; @@ -8250,20 +9493,20 @@ static_inline u8 *write_string(u8 *cur, bool esc, bool inv, } default: break; } - + copy_end: *cur++ = '"'; return cur; - + err_one: if (esc) goto err_esc; else goto err_cpy; - + err_cpy: if (!inv) return NULL; *cur++ = *src++; goto copy_utf8; - + err_esc: if (!inv) return NULL; byte_copy_2(cur + 0, &pre); @@ -8271,7 +9514,7 @@ static_inline u8 *write_string(u8 *cur, bool esc, bool inv, cur += 6; src += 1; goto copy_utf8; - + #undef is_valid_seq_2 #undef is_valid_seq_3 #undef is_valid_seq_4 @@ -8326,27 +9569,27 @@ static bool write_dat_to_fp(FILE *fp, u8 *dat, usize len, /** Write data to file. */ static bool write_dat_to_file(const char *path, u8 *dat, usize len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ err->msg = _msg; \ err->code = YYJSON_WRITE_ERROR_##_code; \ if (file) fclose(file); \ return false; \ } while (false) - + FILE *file = fopen_writeonly(path); if (file == NULL) { - return_err(FILE_OPEN, "file opening failed"); + return_err(FILE_OPEN, MSG_FOPEN); } if (fwrite(dat, len, 1, file) != 1) { - return_err(FILE_WRITE, "file writing failed"); + return_err(FILE_WRITE, MSG_FWRITE); } if (fclose(file) != 0) { file = NULL; - return_err(FILE_WRITE, "file closing failed"); + return_err(FILE_WRITE, MSG_FCLOSE); } return true; - + #undef return_err } @@ -8378,7 +9621,7 @@ static_inline u8 *yyjson_write_single(yyjson_val *val, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ if (hdr) alc.free(alc.ctx, (void *)hdr); \ *dat_len = 0; \ @@ -8386,18 +9629,18 @@ static_inline u8 *yyjson_write_single(yyjson_val *val, err->msg = _msg; \ return NULL; \ } while (false) - + #define incr_len(_len) do { \ hdr = (u8 *)alc.malloc(alc.ctx, _len); \ if (!hdr) goto fail_alloc; \ cur = hdr; \ } while (false) - + #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) - + u8 *hdr = NULL, *cur; usize str_len; const u8 *str_ptr; @@ -8407,7 +9650,7 @@ static_inline u8 *yyjson_write_single(yyjson_val *val, bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; const usize end_len = 2; /* '\n' and '\0' */ - + switch (unsafe_yyjson_get_type(val)) { case YYJSON_TYPE_RAW: str_len = unsafe_yyjson_get_len(val); @@ -8416,67 +9659,63 @@ static_inline u8 *yyjson_write_single(yyjson_val *val, incr_len(str_len + end_len); cur = write_raw(cur, str_ptr, str_len); break; - + case YYJSON_TYPE_STR: str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); incr_len(str_len * 6 + 2 + end_len); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { - cur = write_string_noesc(cur, str_ptr, str_len); + cur = write_str_noesc(cur, str_ptr, str_len); } else { - cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); + cur = write_str(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } break; - + case YYJSON_TYPE_NUM: - incr_len(32 + end_len); - cur = write_number(cur, val, flg); + incr_len(FP_BUF_LEN + end_len); + cur = write_num(cur, val, flg); if (unlikely(!cur)) goto fail_num; break; - + case YYJSON_TYPE_BOOL: incr_len(8); cur = write_bool(cur, unsafe_yyjson_get_bool(val)); break; - + case YYJSON_TYPE_NULL: incr_len(8); cur = write_null(cur); break; - + case YYJSON_TYPE_ARR: incr_len(2 + end_len); byte_copy_2(cur, "[]"); cur += 2; break; - + case YYJSON_TYPE_OBJ: incr_len(2 + end_len); byte_copy_2(cur, "{}"); cur += 2; break; - + default: goto fail_type; } - + if (newline) *cur++ = '\n'; *cur = '\0'; *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; - -fail_alloc: - return_err(MEMORY_ALLOCATION, "memory allocation failed"); -fail_type: - return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); -fail_num: - return_err(NAN_OR_INF, "nan or inf number is not allowed"); -fail_str: - return_err(INVALID_STRING, "invalid utf-8 encoding in string"); - + +fail_alloc: return_err(MEMORY_ALLOCATION, MSG_MALLOC); +fail_type: return_err(INVALID_VALUE_TYPE, MSG_ERR_TYPE); +fail_num: return_err(NAN_OR_INF, MSG_INF_NAN); +fail_str: return_err(INVALID_STRING, MSG_ERR_UTF8); + #undef return_err #undef check_str_len #undef incr_len @@ -8489,7 +9728,7 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, const yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ @@ -8497,10 +9736,13 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) - + #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ + usize ctx_pos = (usize)((u8 *)ctx - hdr); \ + usize cur_pos = (usize)(cur - hdr); \ + ctx_len = (usize)(end - (u8 *)ctx); \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ @@ -8508,21 +9750,20 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ - ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ - memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ + memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \ ctx = ctx_tmp; \ - cur = tmp + (cur - hdr); \ + cur = tmp + cur_pos; \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) - + #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) - + yyjson_val *val; yyjson_type val_type; usize ctn_len, ctn_len_tmp; @@ -8536,7 +9777,7 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; - + alc_len = root->uni.ofs / sizeof(yyjson_val); alc_len = alc_len * YYJSON_WRITER_ESTIMATED_MINIFY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_write_ctx)); @@ -8545,7 +9786,7 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, cur = hdr; end = hdr + alc_len; ctx = (yyjson_write_ctx *)(void *)end; - + doc_begin: val = constcast(yyjson_val *)root; val_type = unsafe_yyjson_get_type(val); @@ -8553,7 +9794,7 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, ctn_len = unsafe_yyjson_get_len(val) << (u8)ctn_obj; *cur++ = (u8)('[' | ((u8)ctn_obj << 5)); val++; - + val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { @@ -8563,17 +9804,17 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, check_str_len(str_len); incr_len(str_len * 6 + 16); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { - cur = write_string_noesc(cur, str_ptr, str_len); + cur = write_str_noesc(cur, str_ptr, str_len); } else { - cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); + cur = write_str(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { - incr_len(32); - cur = write_number(cur, val, flg); + incr_len(FP_BUF_LEN); + cur = write_num(cur, val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; goto val_end; @@ -8621,13 +9862,13 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, goto val_end; } goto fail_type; - + val_end: val++; ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; goto val_begin; - + ctn_end: cur--; *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); @@ -8640,7 +9881,7 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, } else { goto ctn_end; } - + doc_end: if (newline) { incr_len(2); @@ -8651,16 +9892,12 @@ static_inline u8 *yyjson_write_minify(const yyjson_val *root, *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; - -fail_alloc: - return_err(MEMORY_ALLOCATION, "memory allocation failed"); -fail_type: - return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); -fail_num: - return_err(NAN_OR_INF, "nan or inf number is not allowed"); -fail_str: - return_err(INVALID_STRING, "invalid utf-8 encoding in string"); - + +fail_alloc: return_err(MEMORY_ALLOCATION, MSG_MALLOC); +fail_type: return_err(INVALID_VALUE_TYPE, MSG_ERR_TYPE); +fail_num: return_err(NAN_OR_INF, MSG_INF_NAN); +fail_str: return_err(INVALID_STRING, MSG_ERR_UTF8); + #undef return_err #undef incr_len #undef check_str_len @@ -8673,7 +9910,7 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, const yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ @@ -8681,10 +9918,13 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) - + #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ + usize ctx_pos = (usize)((u8 *)ctx - hdr); \ + usize cur_pos = (usize)(cur - hdr); \ + ctx_len = (usize)(end - (u8 *)ctx); \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ @@ -8692,21 +9932,20 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ - ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ - memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ + memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \ ctx = ctx_tmp; \ - cur = tmp + (cur - hdr); \ + cur = tmp + cur_pos; \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) - + #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) - + yyjson_val *val; yyjson_type val_type; usize ctn_len, ctn_len_tmp; @@ -8721,7 +9960,7 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; usize spaces = has_write_flag(PRETTY_TWO_SPACES) ? 2 : 4; bool newline = has_write_flag(NEWLINE_AT_END) != 0; - + alc_len = root->uni.ofs / sizeof(yyjson_val); alc_len = alc_len * YYJSON_WRITER_ESTIMATED_PRETTY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_write_ctx)); @@ -8730,7 +9969,7 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, cur = hdr; end = hdr + alc_len; ctx = (yyjson_write_ctx *)(void *)end; - + doc_begin: val = constcast(yyjson_val *)root; val_type = unsafe_yyjson_get_type(val); @@ -8740,7 +9979,7 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, *cur++ = '\n'; val++; level = 1; - + val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { @@ -8752,9 +9991,9 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, incr_len(str_len * 6 + 16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { - cur = write_string_noesc(cur, str_ptr, str_len); + cur = write_str_noesc(cur, str_ptr, str_len); } else { - cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); + cur = write_str(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; @@ -8763,9 +10002,9 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, } if (val_type == YYJSON_TYPE_NUM) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); - incr_len(32 + (no_indent ? 0 : level * 4)); + incr_len(FP_BUF_LEN + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); - cur = write_number(cur, val, flg); + cur = write_num(cur, val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; *cur++ = '\n'; @@ -8816,23 +10055,25 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, goto val_end; } if (val_type == YYJSON_TYPE_RAW) { + no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); - incr_len(str_len + 3); + incr_len(str_len + 3 + (no_indent ? 0 : level * 4)); + cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; *cur++ = '\n'; goto val_end; } goto fail_type; - + val_end: val++; ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; goto val_begin; - + ctn_end: cur -= 2; *cur++ = '\n'; @@ -8849,7 +10090,7 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, } else { goto ctn_end; } - + doc_end: if (newline) { incr_len(2); @@ -8859,16 +10100,12 @@ static_inline u8 *yyjson_write_pretty(const yyjson_val *root, *dat_len = (usize)(cur - hdr); memset(err, 0, sizeof(yyjson_write_err)); return hdr; - -fail_alloc: - return_err(MEMORY_ALLOCATION, "memory allocation failed"); -fail_type: - return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); -fail_num: - return_err(NAN_OR_INF, "nan or inf number is not allowed"); -fail_str: - return_err(INVALID_STRING, "invalid utf-8 encoding in string"); - + +fail_alloc: return_err(MEMORY_ALLOCATION, MSG_MALLOC); +fail_type: return_err(INVALID_VALUE_TYPE, MSG_ERR_TYPE); +fail_num: return_err(NAN_OR_INF, MSG_INF_NAN); +fail_str: return_err(INVALID_STRING, MSG_ERR_UTF8); + #undef return_err #undef incr_len #undef check_str_len @@ -8883,17 +10120,17 @@ char *yyjson_val_write_opts(const yyjson_val *val, usize dummy_dat_len; yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_val *root = constcast(yyjson_val *)val; - + err = err ? err : &dummy_err; dat_len = dat_len ? dat_len : &dummy_dat_len; - + if (unlikely(!root)) { *dat_len = 0; err->msg = "input JSON is NULL"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return NULL; } - + if (!unsafe_yyjson_is_ctn(root) || unsafe_yyjson_get_len(root) == 0) { return (char *)yyjson_write_single(root, flg, alc, dat_len, err); } else if (flg & (YYJSON_WRITE_PRETTY | YYJSON_WRITE_PRETTY_TWO_SPACES)) { @@ -8918,23 +10155,23 @@ bool yyjson_val_write_file(const char *path, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; + yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; u8 *dat; usize dat_len = 0; yyjson_val *root = constcast(yyjson_val *)val; bool suc; - - alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; + err = err ? err : &dummy_err; if (unlikely(!path || !*path)) { err->msg = "input path is invalid"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return false; } - - dat = (u8 *)yyjson_val_write_opts(root, flg, alc_ptr, &dat_len, err); + + dat = (u8 *)yyjson_val_write_opts(root, flg, &alc, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_file(path, dat, dat_len, err); - alc_ptr->free(alc_ptr->ctx, dat); + alc.free(alc.ctx, dat); return suc; } @@ -8944,23 +10181,23 @@ bool yyjson_val_write_fp(FILE *fp, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; + yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; u8 *dat; usize dat_len = 0; yyjson_val *root = constcast(yyjson_val *)val; bool suc; - - alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; + err = err ? err : &dummy_err; if (unlikely(!fp)) { err->msg = "input fp is invalid"; err->code = YYJSON_READ_ERROR_INVALID_PARAMETER; return false; } - - dat = (u8 *)yyjson_val_write_opts(root, flg, alc_ptr, &dat_len, err); + + dat = (u8 *)yyjson_val_write_opts(root, flg, &alc, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_fp(fp, dat, dat_len, err); - alc_ptr->free(alc_ptr->ctx, dat); + alc.free(alc.ctx, dat); return suc; } @@ -8974,10 +10211,10 @@ bool yyjson_write_file(const char *path, } bool yyjson_write_fp(FILE *fp, - const yyjson_doc *doc, - yyjson_write_flag flg, + const yyjson_doc *doc, + yyjson_write_flag flg, const yyjson_alc *alc_ptr, - yyjson_write_err *err) { + yyjson_write_err *err) { yyjson_val *root = doc ? doc->root : NULL; return yyjson_val_write_fp(fp, root, flg, alc_ptr, err); } @@ -9041,7 +10278,7 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ @@ -9049,10 +10286,13 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) - + #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ + usize ctx_pos = (usize)((u8 *)ctx - hdr); \ + usize cur_pos = (usize)(cur - hdr); \ + ctx_len = (usize)(end - (u8 *)ctx); \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ @@ -9060,21 +10300,20 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ - ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ - memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ + memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \ ctx = ctx_tmp; \ - cur = tmp + (cur - hdr); \ + cur = tmp + cur_pos; \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) - + #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) - + yyjson_mut_val *val, *ctn; yyjson_type val_type; usize ctn_len, ctn_len_tmp; @@ -9088,7 +10327,7 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, bool esc = has_write_flag(ESCAPE_UNICODE) != 0; bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; bool newline = has_write_flag(NEWLINE_AT_END) != 0; - + alc_len = estimated_val_num * YYJSON_WRITER_ESTIMATED_MINIFY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_mut_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); @@ -9096,7 +10335,7 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, cur = hdr; end = hdr + alc_len; ctx = (yyjson_mut_write_ctx *)(void *)end; - + doc_begin: val = constcast(yyjson_mut_val *)root; val_type = unsafe_yyjson_get_type(val); @@ -9106,7 +10345,7 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, ctn = val; val = (yyjson_mut_val *)val->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; - + val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { @@ -9116,17 +10355,17 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, check_str_len(str_len); incr_len(str_len * 6 + 16); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { - cur = write_string_noesc(cur, str_ptr, str_len); + cur = write_str_noesc(cur, str_ptr, str_len); } else { - cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); + cur = write_str(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; goto val_end; } if (val_type == YYJSON_TYPE_NUM) { - incr_len(32); - cur = write_number(cur, (yyjson_val *)val, flg); + incr_len(FP_BUF_LEN); + cur = write_num(cur, (yyjson_val *)val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; goto val_end; @@ -9176,13 +10415,13 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, goto val_end; } goto fail_type; - + val_end: ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; val = val->next; goto val_begin; - + ctn_end: cur--; *cur++ = (u8)(']' | ((u8)ctn_obj << 5)); @@ -9196,7 +10435,7 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, } else { goto ctn_end; } - + doc_end: if (newline) { incr_len(2); @@ -9206,18 +10445,14 @@ static_inline u8 *yyjson_mut_write_minify(const yyjson_mut_val *root, *--cur = '\0'; *dat_len = (usize)(cur - hdr); err->code = YYJSON_WRITE_SUCCESS; - err->msg = "success"; + err->msg = NULL; return hdr; - -fail_alloc: - return_err(MEMORY_ALLOCATION, "memory allocation failed"); -fail_type: - return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); -fail_num: - return_err(NAN_OR_INF, "nan or inf number is not allowed"); -fail_str: - return_err(INVALID_STRING, "invalid utf-8 encoding in string"); - + +fail_alloc: return_err(MEMORY_ALLOCATION, MSG_MALLOC); +fail_type: return_err(INVALID_VALUE_TYPE, MSG_ERR_TYPE); +fail_num: return_err(NAN_OR_INF, MSG_INF_NAN); +fail_str: return_err(INVALID_STRING, MSG_ERR_UTF8); + #undef return_err #undef incr_len #undef check_str_len @@ -9231,7 +10466,7 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, yyjson_alc alc, usize *dat_len, yyjson_write_err *err) { - + #define return_err(_code, _msg) do { \ *dat_len = 0; \ err->code = YYJSON_WRITE_ERROR_##_code; \ @@ -9239,10 +10474,13 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, if (hdr) alc.free(alc.ctx, hdr); \ return NULL; \ } while (false) - + #define incr_len(_len) do { \ ext_len = (usize)(_len); \ if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \ + usize ctx_pos = (usize)((u8 *)ctx - hdr); \ + usize cur_pos = (usize)(cur - hdr); \ + ctx_len = (usize)(end - (u8 *)ctx); \ alc_inc = yyjson_max(alc_len / 2, ext_len); \ alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \ if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \ @@ -9250,21 +10488,20 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, alc_len += alc_inc; \ tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \ if (unlikely(!tmp)) goto fail_alloc; \ - ctx_len = (usize)(end - (u8 *)ctx); \ ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \ - memmove((void *)ctx_tmp, (void *)(tmp + ((u8 *)ctx - hdr)), ctx_len); \ + memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \ ctx = ctx_tmp; \ - cur = tmp + (cur - hdr); \ + cur = tmp + cur_pos; \ end = tmp + alc_len; \ hdr = tmp; \ } \ } while (false) - + #define check_str_len(_len) do { \ if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \ goto fail_alloc; \ } while (false) - + yyjson_mut_val *val, *ctn; yyjson_type val_type; usize ctn_len, ctn_len_tmp; @@ -9279,7 +10516,7 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, bool inv = has_write_flag(ALLOW_INVALID_UNICODE) != 0; usize spaces = has_write_flag(PRETTY_TWO_SPACES) ? 2 : 4; bool newline = has_write_flag(NEWLINE_AT_END) != 0; - + alc_len = estimated_val_num * YYJSON_WRITER_ESTIMATED_PRETTY_RATIO + 64; alc_len = size_align_up(alc_len, sizeof(yyjson_mut_write_ctx)); hdr = (u8 *)alc.malloc(alc.ctx, alc_len); @@ -9287,7 +10524,7 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, cur = hdr; end = hdr + alc_len; ctx = (yyjson_mut_write_ctx *)(void *)end; - + doc_begin: val = constcast(yyjson_mut_val *)root; val_type = unsafe_yyjson_get_type(val); @@ -9299,7 +10536,7 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, val = (yyjson_mut_val *)val->uni.ptr; /* tail */ val = ctn_obj ? val->next->next : val->next; level = 1; - + val_begin: val_type = unsafe_yyjson_get_type(val); if (val_type == YYJSON_TYPE_STR) { @@ -9311,9 +10548,9 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, incr_len(str_len * 6 + 16 + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); if (likely(cpy) && unsafe_yyjson_get_subtype(val)) { - cur = write_string_noesc(cur, str_ptr, str_len); + cur = write_str_noesc(cur, str_ptr, str_len); } else { - cur = write_string(cur, esc, inv, str_ptr, str_len, enc_table); + cur = write_str(cur, esc, inv, str_ptr, str_len, enc_table); if (unlikely(!cur)) goto fail_str; } *cur++ = is_key ? ':' : ','; @@ -9322,9 +10559,9 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, } if (val_type == YYJSON_TYPE_NUM) { no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); - incr_len(32 + (no_indent ? 0 : level * 4)); + incr_len(FP_BUF_LEN + (no_indent ? 0 : level * 4)); cur = write_indent(cur, no_indent ? 0 : level, spaces); - cur = write_number(cur, (yyjson_val *)val, flg); + cur = write_num(cur, (yyjson_val *)val, flg); if (unlikely(!cur)) goto fail_num; *cur++ = ','; *cur++ = '\n'; @@ -9377,23 +10614,25 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, goto val_end; } if (val_type == YYJSON_TYPE_RAW) { + no_indent = (bool)((u8)ctn_obj & (u8)ctn_len); str_len = unsafe_yyjson_get_len(val); str_ptr = (const u8 *)unsafe_yyjson_get_str(val); check_str_len(str_len); - incr_len(str_len + 3); + incr_len(str_len + 3 + (no_indent ? 0 : level * 4)); + cur = write_indent(cur, no_indent ? 0 : level, spaces); cur = write_raw(cur, str_ptr, str_len); *cur++ = ','; *cur++ = '\n'; goto val_end; } goto fail_type; - + val_end: ctn_len--; if (unlikely(ctn_len == 0)) goto ctn_end; val = val->next; goto val_begin; - + ctn_end: cur -= 2; *cur++ = '\n'; @@ -9411,7 +10650,7 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, } else { goto ctn_end; } - + doc_end: if (newline) { incr_len(2); @@ -9420,18 +10659,14 @@ static_inline u8 *yyjson_mut_write_pretty(const yyjson_mut_val *root, *cur = '\0'; *dat_len = (usize)(cur - hdr); err->code = YYJSON_WRITE_SUCCESS; - err->msg = "success"; + err->msg = NULL; return hdr; - -fail_alloc: - return_err(MEMORY_ALLOCATION, "memory allocation failed"); -fail_type: - return_err(INVALID_VALUE_TYPE, "invalid JSON value type"); -fail_num: - return_err(NAN_OR_INF, "nan or inf number is not allowed"); -fail_str: - return_err(INVALID_STRING, "invalid utf-8 encoding in string"); - + +fail_alloc: return_err(MEMORY_ALLOCATION, MSG_MALLOC); +fail_type: return_err(INVALID_VALUE_TYPE, MSG_ERR_TYPE); +fail_num: return_err(NAN_OR_INF, MSG_INF_NAN); +fail_str: return_err(INVALID_STRING, MSG_ERR_UTF8); + #undef return_err #undef incr_len #undef check_str_len @@ -9447,17 +10682,17 @@ static char *yyjson_mut_write_opts_impl(const yyjson_mut_val *val, usize dummy_dat_len; yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; - + err = err ? err : &dummy_err; dat_len = dat_len ? dat_len : &dummy_dat_len; - + if (unlikely(!root)) { *dat_len = 0; err->msg = "input JSON is NULL"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return NULL; } - + if (!unsafe_yyjson_is_ctn(root) || unsafe_yyjson_get_len(root) == 0) { return (char *)yyjson_mut_write_single(root, flg, alc, dat_len, err); } else if (flg & (YYJSON_WRITE_PRETTY | YYJSON_WRITE_PRETTY_TWO_SPACES)) { @@ -9501,23 +10736,23 @@ bool yyjson_mut_val_write_file(const char *path, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; + yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; u8 *dat; usize dat_len = 0; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; bool suc; - - alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; + err = err ? err : &dummy_err; if (unlikely(!path || !*path)) { err->msg = "input path is invalid"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return false; } - - dat = (u8 *)yyjson_mut_val_write_opts(root, flg, alc_ptr, &dat_len, err); + + dat = (u8 *)yyjson_mut_val_write_opts(root, flg, &alc, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_file(path, dat, dat_len, err); - alc_ptr->free(alc_ptr->ctx, dat); + alc.free(alc.ctx, dat); return suc; } @@ -9527,23 +10762,23 @@ bool yyjson_mut_val_write_fp(FILE *fp, const yyjson_alc *alc_ptr, yyjson_write_err *err) { yyjson_write_err dummy_err; + yyjson_alc alc = alc_ptr ? *alc_ptr : YYJSON_DEFAULT_ALC; u8 *dat; usize dat_len = 0; yyjson_mut_val *root = constcast(yyjson_mut_val *)val; bool suc; - - alc_ptr = alc_ptr ? alc_ptr : &YYJSON_DEFAULT_ALC; + err = err ? err : &dummy_err; if (unlikely(!fp)) { err->msg = "input fp is invalid"; err->code = YYJSON_WRITE_ERROR_INVALID_PARAMETER; return false; } - - dat = (u8 *)yyjson_mut_val_write_opts(root, flg, alc_ptr, &dat_len, err); + + dat = (u8 *)yyjson_mut_val_write_opts(root, flg, &alc, &dat_len, err); if (unlikely(!dat)) return false; suc = write_dat_to_fp(fp, dat, dat_len, err); - alc_ptr->free(alc_ptr->ctx, dat); + alc.free(alc.ctx, dat); return suc; } diff --git a/src/3rdparty/yyjson/yyjson.h b/src/3rdparty/yyjson/yyjson.h index 88cec2b09e..d26dc49b7d 100644 --- a/src/3rdparty/yyjson/yyjson.h +++ b/src/3rdparty/yyjson/yyjson.h @@ -1,16 +1,16 @@ /*============================================================================== Copyright (c) 2020 YaoYuan - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -20,7 +20,7 @@ SOFTWARE. *============================================================================*/ -/** +/** @file yyjson.h @date 2019-03-09 @author YaoYuan @@ -49,130 +49,102 @@ *============================================================================*/ /* - Define as 1 to disable JSON reader if JSON parsing is not required. - - This will disable these functions at compile-time: - - yyjson_read() - - yyjson_read_opts() - - yyjson_read_file() - - yyjson_read_number() - - yyjson_mut_read_number() - - This will reduce the binary size by about 60%. + Define as 1 to disable JSON reader at compile-time. + This disables functions with "read" in their name. + Reduces binary size by about 60%. */ #ifndef YYJSON_DISABLE_READER #endif /* - Define as 1 to disable JSON writer if JSON serialization is not required. - - This will disable these functions at compile-time: - - yyjson_write() - - yyjson_write_file() - - yyjson_write_opts() - - yyjson_val_write() - - yyjson_val_write_file() - - yyjson_val_write_opts() - - yyjson_mut_write() - - yyjson_mut_write_file() - - yyjson_mut_write_opts() - - yyjson_mut_val_write() - - yyjson_mut_val_write_file() - - yyjson_mut_val_write_opts() - - This will reduce the binary size by about 30%. + Define as 1 to disable JSON writer at compile-time. + This disables functions with "write" in their name. + Reduces binary size by about 30%. */ #ifndef YYJSON_DISABLE_WRITER #endif +/* + Define as 1 to disable JSON incremental reader at compile-time. + This disables functions with "incr" in their name. + */ +#ifndef YYJSON_DISABLE_INCR_READER +#endif + /* Define as 1 to disable JSON Pointer, JSON Patch and JSON Merge Patch supports. - - This will disable these functions at compile-time: - - yyjson_ptr_xxx() - - yyjson_mut_ptr_xxx() - - yyjson_doc_ptr_xxx() - - yyjson_mut_doc_ptr_xxx() - - yyjson_patch() - - yyjson_mut_patch() - - yyjson_merge_patch() - - yyjson_mut_merge_patch() + This disables functions with "ptr" or "patch" in their name. */ #ifndef YYJSON_DISABLE_UTILS #endif /* - Define as 1 to disable the fast floating-point number conversion in yyjson, - and use libc's `strtod/snprintf` instead. - - This will reduce the binary size by about 30%, but significantly slow down the + Define as 1 to disable the fast floating-point number conversion in yyjson. + Libc's `strtod/snprintf` will be used instead. + + This reduces binary size by about 30%, but significantly slows down the floating-point read/write speed. */ #ifndef YYJSON_DISABLE_FAST_FP_CONV #endif /* - Define as 1 to disable non-standard JSON support at compile-time: - - Reading and writing inf/nan literal, such as `NaN`, `-Infinity`. - - Single line and multiple line comments. - - Single trailing comma at the end of an object or array. - - Invalid unicode in string value. - - This will also invalidate these run-time options: - - YYJSON_READ_ALLOW_INF_AND_NAN - - YYJSON_READ_ALLOW_COMMENTS - - YYJSON_READ_ALLOW_TRAILING_COMMAS - - YYJSON_READ_ALLOW_INVALID_UNICODE - - YYJSON_WRITE_ALLOW_INF_AND_NAN - - YYJSON_WRITE_ALLOW_INVALID_UNICODE - - This will reduce the binary size by about 10%, and speed up the reading and - writing speed by about 2% to 6%. + Define as 1 to disable non-standard JSON features support at compile-time: + - YYJSON_READ_ALLOW_INF_AND_NAN + - YYJSON_READ_ALLOW_COMMENTS + - YYJSON_READ_ALLOW_TRAILING_COMMAS + - YYJSON_READ_ALLOW_INVALID_UNICODE + - YYJSON_READ_ALLOW_BOM + - YYJSON_WRITE_ALLOW_INF_AND_NAN + - YYJSON_WRITE_ALLOW_INVALID_UNICODE + + This reduces binary size by about 10%, and slightly improves performance. */ #ifndef YYJSON_DISABLE_NON_STANDARD #endif /* - Define as 1 to disable UTF-8 validation at compile time. - - If all input strings are guaranteed to be valid UTF-8 encoding (for example, - some language's String object has already validated the encoding), using this - flag can avoid redundant UTF-8 validation in yyjson. - - This flag can speed up the reading and writing speed of non-ASCII encoded - strings by about 3% to 7%. - - Note: If this flag is used while passing in illegal UTF-8 strings, the - following errors may occur: + Define as 1 to disable UTF-8 validation at compile-time. + + Use this if all input strings are guaranteed to be valid UTF-8 + (e.g. language-level String types are already validated). + + Disabling UTF-8 validation improves performance for non-ASCII strings by about + 3% to 7%. + + Note: If this flag is enabled while passing illegal UTF-8 strings, + the following errors may occur: - Escaped characters may be ignored when parsing JSON strings. - - Ending quotes may be ignored when parsing JSON strings, causing the string - to be concatenated to the next value. - - When accessing `yyjson_mut_val` for serialization, the string ending may be - accessed out of bounds, causing a segmentation fault. + - Ending quotes may be ignored when parsing JSON strings, causing the + string to merge with the next value. + - When serializing with `yyjson_mut_val`, the string's end may be accessed + out of bounds, potentially causing a segmentation fault. */ #ifndef YYJSON_DISABLE_UTF8_VALIDATION #endif /* - Define as 1 to indicate that the target architecture does not support unaligned - memory access. Please refer to the comments in the C file for details. + Define as 1 to improve performance on architectures that do not support + unaligned memory access. + + Normally, this does not need to be set manually. See the C file for details. */ #ifndef YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS #endif -/* Define as 1 to export symbols when building this library as Windows DLL. */ +/* Define as 1 to export symbols when building this library as a Windows DLL. */ #ifndef YYJSON_EXPORTS #endif -/* Define as 1 to import symbols when using this library as Windows DLL. */ +/* Define as 1 to import symbols when using this library as a Windows DLL. */ #ifndef YYJSON_IMPORTS #endif -/* Define as 1 to include for compiler which doesn't support C99. */ +/* Define as 1 to include for compilers without C99 support. */ #ifndef YYJSON_HAS_STDINT_H #endif -/* Define as 1 to include for compiler which doesn't support C99. */ +/* Define as 1 to include for compilers without C99 support. */ #ifndef YYJSON_HAS_STDBOOL_H #endif @@ -508,7 +480,7 @@ extern "C" { # pragma clang diagnostic ignored "-Wunused-parameter" #elif defined(__GNUC__) # if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic push +# pragma GCC diagnostic push # endif # pragma GCC diagnostic ignored "-Wunused-function" # pragma GCC diagnostic ignored "-Wunused-parameter" @@ -527,16 +499,16 @@ extern "C" { #define YYJSON_VERSION_MAJOR 0 /** The minor version of yyjson. */ -#define YYJSON_VERSION_MINOR 10 +#define YYJSON_VERSION_MINOR 11 /** The patch version of yyjson. */ #define YYJSON_VERSION_PATCH 0 /** The version of yyjson in hex: `(major << 16) | (minor << 8) | (patch)`. */ -#define YYJSON_VERSION_HEX 0x000A00 +#define YYJSON_VERSION_HEX 0x000B00 /** The version string of yyjson. */ -#define YYJSON_VERSION_STRING "0.10.0" +#define YYJSON_VERSION_STRING "0.11.0" /** The version of yyjson in hex, same as `YYJSON_VERSION_HEX`. */ yyjson_api uint32_t yyjson_version(void); @@ -611,7 +583,7 @@ typedef uint8_t yyjson_subtype; /** A memory allocator. - + Typically you don't need to use it, unless you want to customize your own memory allocator. */ @@ -628,19 +600,19 @@ typedef struct yyjson_alc { /** A pool allocator uses fixed length pre-allocated memory. - - This allocator may be used to avoid malloc/realloc calls. The pre-allocated + + This allocator may be used to avoid malloc/realloc calls. The pre-allocated memory should be held by the caller. The maximum amount of memory required to read a JSON can be calculated using the `yyjson_read_max_memory_usage()` - function, but the amount of memory required to write a JSON cannot be directly + function, but the amount of memory required to write a JSON cannot be directly calculated. - + This is not a general-purpose allocator. It is designed to handle a single JSON data at a time. If it is used for overly complex memory tasks, such as parsing multiple JSON documents using the same allocator but releasing only a few of them, it may cause memory fragmentation, resulting in performance degradation and memory waste. - + @param alc The allocator to be initialized. If this parameter is NULL, the function will fail and return false. If `buf` or `size` is invalid, this will be set to an empty allocator. @@ -650,33 +622,33 @@ typedef struct yyjson_alc { If this parameter is less than 8 words (32/64 bytes on 32/64-bit OS), the function will fail and return false. @return true if the `alc` has been successfully initialized. - - @par Example + + @b Example @code // parse JSON with stack memory char buf[1024]; yyjson_alc alc; yyjson_alc_pool_init(&alc, buf, 1024); - + const char *json = "{\"name\":\"Helvetica\",\"size\":16}" yyjson_doc *doc = yyjson_read_opts(json, strlen(json), 0, &alc, NULL); // the memory of `doc` is on the stack @endcode - + @warning This Allocator is not thread-safe. */ yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size); /** A dynamic allocator. - + This allocator has a similar usage to the pool allocator above. However, when there is not enough memory, this allocator will dynamically request more memory using libc's `malloc` function, and frees it all at once when it is destroyed. - + @return A new dynamic allocator, or NULL if memory allocation failed. @note The returned value should be freed with `yyjson_alc_dyn_free()`. - + @warning This Allocator is not thread-safe. */ yyjson_api yyjson_alc *yyjson_alc_dyn_new(void); @@ -689,6 +661,30 @@ yyjson_api void yyjson_alc_dyn_free(yyjson_alc *alc); +/*============================================================================== + * Text Locating + *============================================================================*/ + +/** + Locate the line and column number for a byte position in a string. + This can be used to get better description for error position. + + @param str The input string. + @param len The byte length of the input string. + @param pos The byte position within the input string. + @param line A pointer to receive the line number, starting from 1. + @param col A pointer to receive the column number, starting from 1. + @param chr A pointer to receive the character index, starting from 0. + @return true on success, false if `str` is NULL or `pos` is out of bounds. + @note Line/column/character are calculated based on Unicode characters for + compatibility with text editors. For multi-byte UTF-8 characters, + the returned value may not directly correspond to the byte position. + */ +yyjson_api bool yyjson_locate_pos(const char *str, size_t len, size_t pos, + size_t *line, size_t *col, size_t *chr); + + + /*============================================================================== * JSON Structure *============================================================================*/ @@ -772,7 +768,7 @@ static const yyjson_read_flag YYJSON_READ_NUMBER_AS_RAW = 1 << 5; Invalid characters will be allowed to appear in the string values, but invalid escape sequences will still be reported as errors. This flag does not affect the performance of correctly encoded strings. - + @warning Strings in JSON values may contain incorrect encoding when this option is used, you need to handle these strings carefully to avoid security risks. */ @@ -784,6 +780,9 @@ static const yyjson_read_flag YYJSON_READ_ALLOW_INVALID_UNICODE = 1 << 6; The flag will be overridden by `YYJSON_READ_NUMBER_AS_RAW` flag. */ static const yyjson_read_flag YYJSON_READ_BIGNUM_AS_RAW = 1 << 7; +/** Allow UTF-8 BOM and skip it before parsing if any (non-standard). */ +static const yyjson_read_flag YYJSON_READ_ALLOW_BOM = 1 << 8; + /** Result code for JSON reader. */ @@ -831,6 +830,9 @@ static const yyjson_read_code YYJSON_READ_ERROR_FILE_OPEN = 12; /** Failed to read a file. */ static const yyjson_read_code YYJSON_READ_ERROR_FILE_READ = 13; +/** Unexpected ending during incremental parsing. Parsing state is saved. */ +static const yyjson_read_code YYJSON_READ_ERROR_MORE = 14; + /** Error information for JSON reader. */ typedef struct yyjson_read_err { /** Error code, see `yyjson_read_code` for all possible values. */ @@ -841,33 +843,17 @@ typedef struct yyjson_read_err { size_t pos; } yyjson_read_err; -/** - Locate the line and column number for a byte position in a string. - This can be used to get better description for error position. - - @param str The input string. - @param len The byte length of the input string. - @param pos The byte position within the input string. - @param line A pointer to receive the line number, starting from 1. - @param col A pointer to receive the column number, starting from 1. - @param chr A pointer to receive the character index, starting from 0. - @return true on success, false if `str` is NULL or `pos` is out of bounds. - @note Line/column/character are calculated based on Unicode characters for - compatibility with text editors. For multi-byte UTF-8 characters, - the returned value may not directly correspond to the byte position. - */ -yyjson_api bool yyjson_locate_pos(const char *str, size_t len, size_t pos, - size_t *line, size_t *col, size_t *chr); +#if !defined(YYJSON_DISABLE_READER) || !YYJSON_DISABLE_READER /** Read JSON with options. - + This function is thread-safe when: 1. The `dat` is not modified by other threads. 2. The `alc` is thread-safe or NULL. - + @param dat The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. The `dat` will not be modified without the flag `YYJSON_READ_INSITU`, so you @@ -892,11 +878,11 @@ yyjson_api yyjson_doc *yyjson_read_opts(char *dat, /** Read a JSON file. - + This function is thread-safe when: 1. The file is not modified by other threads. 2. The `alc` is thread-safe or NULL. - + @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return NULL. @param flg The JSON read options. @@ -907,7 +893,7 @@ yyjson_api yyjson_doc *yyjson_read_opts(char *dat, Pass NULL if you don't need error information. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. - + @warning On 32-bit operating system, files larger than 2GB may fail to read. */ yyjson_api yyjson_doc *yyjson_read_file(const char *path, @@ -917,7 +903,7 @@ yyjson_api yyjson_doc *yyjson_read_file(const char *path, /** Read JSON from a file pointer. - + @param fp The file pointer. The data will be read from the current position of the FILE to the end. If this fp is NULL or invalid, the function will fail and return NULL. @@ -929,7 +915,7 @@ yyjson_api yyjson_doc *yyjson_read_file(const char *path, Pass NULL if you don't need error information. @return A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with `yyjson_doc_free()`. - + @warning On 32-bit operating system, files larger than 2GB may fail to read. */ yyjson_api yyjson_doc *yyjson_read_fp(FILE *fp, @@ -939,9 +925,9 @@ yyjson_api yyjson_doc *yyjson_read_fp(FILE *fp, /** Read a JSON string. - + This function is thread-safe. - + @param dat The JSON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. @param len The length of JSON data in bytes. @@ -959,31 +945,90 @@ yyjson_api_inline yyjson_doc *yyjson_read(const char *dat, len, flg, NULL, NULL); } + + +#if !defined(YYJSON_DISABLE_INCR_READER) || !YYJSON_DISABLE_INCR_READER + +/** Opaque state for incremental JSON reader. */ +typedef struct yyjson_incr_state yyjson_incr_state; + +/** + Initialize state for incremental read. + + To read a large JSON document incrementally: + 1. Call `yyjson_incr_new()` to create the state for incremental reading. + 2. Call `yyjson_incr_read()` repeatedly. + 3. Call `yyjson_incr_free()` to free the state. + + @param buf The JSON data, null-terminator is not required. + If this parameter is NULL, the function will fail and return NULL. + @param buf_len The length of the JSON data in `buf`. + If use `YYJSON_READ_INSITU`, `buf_len` should not include the padding size. + @param flg The JSON read options. + Multiple options can be combined with `|` operator. + @param alc The memory allocator used by JSON reader. + Pass NULL to use the libc's default allocator. + @return A state for incremental reading. + It should be freed with `yyjson_incr_free()`. + NULL is returned if memory allocation fails. +*/ +yyjson_api yyjson_incr_state *yyjson_incr_new(char *buf, size_t buf_len, + yyjson_read_flag flg, + const yyjson_alc *alc); + +/** + Performs incremental read of up to `len` bytes. + + If NULL is returned and `err->code` is set to `YYJSON_READ_ERROR_MORE`, it + indicates that more data is required to continue parsing. Then, call this + function again with incremented `len`. Continue until a document is returned or + an error other than `YYJSON_READ_ERROR_MORE` is returned. + + Note: Parsing in very small increments is not efficient. An increment of + several kilobytes or megabytes is recommended. + + @param state The state for incremental reading, created using + `yyjson_incr_new()`. + @param len The number of bytes of JSON data available to parse. + If this parameter is 0, the function will fail and return NULL. + @param err A pointer to receive error information. + @return A new JSON document, or NULL if an error occurs. + When the document is no longer needed, it should be freed with + `yyjson_doc_free()`. +*/ +yyjson_api yyjson_doc *yyjson_incr_read(yyjson_incr_state *state, size_t len, + yyjson_read_err *err); + +/** Release the incremental read state and free the memory. */ +yyjson_api void yyjson_incr_free(yyjson_incr_state *state); + +#endif /* YYJSON_DISABLE_INCR_READER */ + /** Returns the size of maximum memory usage to read a JSON data. - + You may use this value to avoid malloc() or calloc() call inside the reader to get better performance, or read multiple JSON with one piece of memory. - + @param len The length of JSON data in bytes. @param flg The JSON read options. @return The maximum memory size to read this JSON, or 0 if overflow. - - @par Example + + @b Example @code // read multiple JSON with same pre-allocated memory - + char *dat1, *dat2, *dat3; // JSON data size_t len1, len2, len3; // JSON length size_t max_len = MAX(len1, MAX(len2, len3)); yyjson_doc *doc; - + // use one allocator for multiple JSON size_t size = yyjson_read_max_memory_usage(max_len, 0); void *buf = malloc(size); yyjson_alc alc; yyjson_alc_pool_init(&alc, buf, size); - + // no more alloc() or realloc() call during reading doc = yyjson_read_opts(dat1, len1, 0, &alc, NULL); yyjson_doc_free(doc); @@ -991,7 +1036,7 @@ yyjson_api_inline yyjson_doc *yyjson_read(const char *dat, yyjson_doc_free(doc); doc = yyjson_read_opts(dat3, len3, 0, &alc, NULL); yyjson_doc_free(doc); - + free(buf); @endcode @see yyjson_alc_pool_init() @@ -1005,7 +1050,7 @@ yyjson_api_inline size_t yyjson_read_max_memory_usage(size_t len, for example: "[[[[[[[[". 3. yyjson use 16 bytes per value, see struct yyjson_val. 4. yyjson use dynamic memory with a growth factor of 1.5. - + The max memory size is (json_size / 2 * 16 * 1.5 + padding). */ size_t mul = (size_t)12 + !(flg & YYJSON_READ_INSITU); @@ -1072,6 +1117,9 @@ yyjson_api_inline const char *yyjson_mut_read_number(const char *dat, return yyjson_read_number(dat, (yyjson_val *)val, flg, alc, err); } +#endif /* YYJSON_DISABLE_READER) */ + + /*============================================================================== * JSON Writer API @@ -1120,6 +1168,28 @@ static const yyjson_write_flag YYJSON_WRITE_NEWLINE_AT_END = 1 << 7; +/** The highest 8 bits of `yyjson_write_flag` and real number value's `tag` + are reserved for controlling the output format of floating-point numbers. */ +#define YYJSON_WRITE_FP_FLAG_BITS 8 + +/** The highest 4 bits of flag are reserved for precision value. */ +#define YYJSON_WRITE_FP_PREC_BITS 4 + +/** Write floating-point number using fixed-point notation. + - This is similar to ECMAScript `Number.prototype.toFixed(prec)`, + but with trailing zeros removed. The `prec` ranges from 1 to 15. + - This will produce shorter output but may lose some precision. */ +#define YYJSON_WRITE_FP_TO_FIXED(prec) ((yyjson_write_flag)( \ + (uint32_t)((uint32_t)(prec)) << (32 - 4) )) + +/** Write floating-point numbers using single-precision (float). + - This casts `double` to `float` before serialization. + - This will produce shorter output, but may lose some precision. + - This flag is ignored if `YYJSON_WRITE_FP_TO_FIXED(prec)` is also used. */ +#define YYJSON_WRITE_FP_TO_FLOAT ((yyjson_write_flag)(1 << (32 - 5))) + + + /** Result code for JSON writer */ typedef uint32_t yyjson_write_code; @@ -1157,16 +1227,18 @@ typedef struct yyjson_write_err { +#if !defined(YYJSON_DISABLE_WRITER) || !YYJSON_DISABLE_WRITER + /*============================================================================== * JSON Document Writer API *============================================================================*/ /** Write a document to JSON string with options. - + This function is thread-safe when: The `alc` is thread-safe or NULL. - + @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. @@ -1189,7 +1261,7 @@ yyjson_api char *yyjson_write_opts(const yyjson_doc *doc, /** Write a document to JSON file with options. - + This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `alc` is thread-safe or NULL. @@ -1206,7 +1278,7 @@ yyjson_api char *yyjson_write_opts(const yyjson_doc *doc, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_write_file(const char *path, @@ -1217,7 +1289,7 @@ yyjson_api bool yyjson_write_file(const char *path, /** Write a document to file pointer with options. - + @param fp The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. @@ -1230,7 +1302,7 @@ yyjson_api bool yyjson_write_file(const char *path, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_write_fp(FILE *fp, @@ -1241,9 +1313,9 @@ yyjson_api bool yyjson_write_fp(FILE *fp, /** Write a document to JSON string. - + This function is thread-safe. - + @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. @@ -1264,7 +1336,7 @@ yyjson_api_inline char *yyjson_write(const yyjson_doc *doc, /** Write a document to JSON string with options. - + This function is thread-safe when: 1. The `doc` is not modified by other threads. 2. The `alc` is thread-safe or NULL. @@ -1291,12 +1363,12 @@ yyjson_api char *yyjson_mut_write_opts(const yyjson_mut_doc *doc, /** Write a document to JSON file with options. - + This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `doc` is not modified by other threads. 3. The `alc` is thread-safe or NULL. - + @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @@ -1309,7 +1381,7 @@ yyjson_api char *yyjson_mut_write_opts(const yyjson_mut_doc *doc, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_write_file(const char *path, @@ -1320,7 +1392,7 @@ yyjson_api bool yyjson_mut_write_file(const char *path, /** Write a document to file pointer with options. - + @param fp The file pointer. The data will be written to the current position of the file. If this fp is NULL or invalid, the function will fail and return false. @@ -1333,7 +1405,7 @@ yyjson_api bool yyjson_mut_write_file(const char *path, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_write_fp(FILE *fp, @@ -1344,10 +1416,10 @@ yyjson_api bool yyjson_mut_write_fp(FILE *fp, /** Write a document to JSON string. - + This function is thread-safe when: The `doc` is not modified by other threads. - + @param doc The JSON document. If this doc is NULL or has no root, the function will fail and return false. @param flg The JSON write options. @@ -1372,10 +1444,10 @@ yyjson_api_inline char *yyjson_mut_write(const yyjson_mut_doc *doc, /** Write a value to JSON string with options. - + This function is thread-safe when: The `alc` is thread-safe or NULL. - + @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. @@ -1398,11 +1470,11 @@ yyjson_api char *yyjson_val_write_opts(const yyjson_val *val, /** Write a value to JSON file with options. - + This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `alc` is thread-safe or NULL. - + @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @@ -1415,7 +1487,7 @@ yyjson_api char *yyjson_val_write_opts(const yyjson_val *val, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_val_write_file(const char *path, @@ -1426,7 +1498,7 @@ yyjson_api bool yyjson_val_write_file(const char *path, /** Write a value to file pointer with options. - + @param fp The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. @@ -1439,7 +1511,7 @@ yyjson_api bool yyjson_val_write_file(const char *path, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_val_write_fp(FILE *fp, @@ -1450,9 +1522,9 @@ yyjson_api bool yyjson_val_write_fp(FILE *fp, /** Write a value to JSON string. - + This function is thread-safe. - + @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. @@ -1471,11 +1543,11 @@ yyjson_api_inline char *yyjson_val_write(const yyjson_val *val, /** Write a value to JSON string with options. - + This function is thread-safe when: 1. The `val` is not modified by other threads. 2. The `alc` is thread-safe or NULL. - + @param val The mutable JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. @@ -1498,12 +1570,12 @@ yyjson_api char *yyjson_mut_val_write_opts(const yyjson_mut_val *val, /** Write a value to JSON file with options. - + This function is thread-safe when: 1. The file is not accessed by other threads. 2. The `val` is not modified by other threads. 3. The `alc` is thread-safe or NULL. - + @param path The JSON file's path. If this path is NULL or invalid, the function will fail and return false. If this file is not empty, the content will be discarded. @@ -1516,7 +1588,7 @@ yyjson_api char *yyjson_mut_val_write_opts(const yyjson_mut_val *val, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_val_write_file(const char *path, @@ -1527,7 +1599,7 @@ yyjson_api bool yyjson_mut_val_write_file(const char *path, /** Write a value to JSON file with options. - + @param fp The file pointer. The data will be written to the current position of the file. If this path is NULL or invalid, the function will fail and return false. @@ -1540,7 +1612,7 @@ yyjson_api bool yyjson_mut_val_write_file(const char *path, @param err A pointer to receive error information. Pass NULL if you don't need error information. @return true if successful, false if an error occurs. - + @warning On 32-bit operating system, files larger than 2GB may fail to write. */ yyjson_api bool yyjson_mut_val_write_fp(FILE *fp, @@ -1551,10 +1623,10 @@ yyjson_api bool yyjson_mut_val_write_fp(FILE *fp, /** Write a value to JSON string. - + This function is thread-safe when: The `val` is not modified by other threads. - + @param val The JSON root value. If this parameter is NULL, the function will fail and return NULL. @param flg The JSON write options. @@ -1571,6 +1643,8 @@ yyjson_api_inline char *yyjson_mut_val_write(const yyjson_mut_val *val, return yyjson_mut_val_write_opts(val, flg, NULL, len, NULL); } +#endif /* YYJSON_DISABLE_WRITER */ + /*============================================================================== @@ -1765,11 +1839,33 @@ yyjson_api_inline bool yyjson_set_sint(yyjson_val *val, int64_t num); @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_int(yyjson_val *val, int num); +/** Set the value to float. + Returns false if input is NULL or `val` is object or array. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_set_float(yyjson_val *val, float num); + +/** Set the value to double. + Returns false if input is NULL or `val` is object or array. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_set_double(yyjson_val *val, double num); + /** Set the value to real. Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ yyjson_api_inline bool yyjson_set_real(yyjson_val *val, double num); +/** Set the floating-point number's output format to fixed-point notation. + Returns false if input is NULL or `val` is not real type. + @see YYJSON_WRITE_FP_TO_FIXED flag. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_set_fp_to_fixed(yyjson_val *val, int prec); + +/** Set the floating-point number's output format to single-precision. + Returns false if input is NULL or `val` is not real type. + @see YYJSON_WRITE_FP_TO_FLOAT flag. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_set_fp_to_float(yyjson_val *val, bool flt); + /** Set the value to string (null-terminated). Returns false if input is NULL or `val` is object or array. @warning This will modify the `immutable` value, use with caution. */ @@ -1781,6 +1877,14 @@ yyjson_api_inline bool yyjson_set_str(yyjson_val *val, const char *str); yyjson_api_inline bool yyjson_set_strn(yyjson_val *val, const char *str, size_t len); +/** Marks this string as not needing to be escaped during JSON writing. + This can be used to avoid the overhead of escaping if the string contains + only characters that do not require escaping. + Returns false if input is NULL or `val` is not string. + @see YYJSON_SUBTYPE_NOESC subtype. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_set_str_noesc(yyjson_val *val, bool noesc); + /*============================================================================== @@ -1815,8 +1919,8 @@ yyjson_api_inline yyjson_val *yyjson_arr_get_last(yyjson_val *arr); /** A JSON array iterator. - - @par Example + + @b Example @code yyjson_val *val; yyjson_arr_iter iter = yyjson_arr_iter_with(arr); @@ -1833,13 +1937,13 @@ typedef struct yyjson_arr_iter { /** Initialize an iterator for this array. - + @param arr The array to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_arr_iter_init(yyjson_val *arr, @@ -1847,11 +1951,11 @@ yyjson_api_inline bool yyjson_arr_iter_init(yyjson_val *arr, /** Create an iterator with an array , same as `yyjson_arr_iter_init()`. - + @param arr The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. @return A new iterator for the array. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_arr_iter yyjson_arr_iter_with(yyjson_val *arr); @@ -1871,8 +1975,8 @@ yyjson_api_inline yyjson_val *yyjson_arr_iter_next(yyjson_arr_iter *iter); /** Macro for iterating over an array. It works like iterator, but with a more intuitive API. - - @par Example + + @b Example @code size_t idx, max; yyjson_val *val; @@ -1902,19 +2006,19 @@ yyjson_api_inline size_t yyjson_obj_size(yyjson_val *obj); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. - + The `key` should be a null-terminated UTF-8 string. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_val *yyjson_obj_get(yyjson_val *obj, const char *key); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. - + The `key` should be a UTF-8 string, null-terminator is not required. The `key_len` should be the length of the key, in bytes. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_val *yyjson_obj_getn(yyjson_val *obj, const char *key, size_t key_len); @@ -1927,8 +2031,8 @@ yyjson_api_inline yyjson_val *yyjson_obj_getn(yyjson_val *obj, const char *key, /** A JSON object iterator. - - @par Example + + @b Example @code yyjson_val *key, *val; yyjson_obj_iter iter = yyjson_obj_iter_with(obj); @@ -1937,7 +2041,7 @@ yyjson_api_inline yyjson_val *yyjson_obj_getn(yyjson_val *obj, const char *key, your_func(key, val); } @endcode - + If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups: @code @@ -1958,13 +2062,13 @@ typedef struct yyjson_obj_iter { /** Initialize an iterator for this object. - + @param obj The object to be iterated over. If this parameter is NULL or not an object, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_obj_iter_init(yyjson_val *obj, @@ -1972,11 +2076,11 @@ yyjson_api_inline bool yyjson_obj_iter_init(yyjson_val *obj, /** Create an iterator with an object, same as `yyjson_obj_iter_init()`. - + @param obj The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. @return A new iterator for the object. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_obj_iter yyjson_obj_iter_with(yyjson_val *obj); @@ -2001,18 +2105,18 @@ yyjson_api_inline yyjson_val *yyjson_obj_iter_get_val(yyjson_val *key); /** Iterates to a specified key and returns the value. - + This function does the same thing as `yyjson_obj_get()`, but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. - + @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string with null-terminator. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. - + @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_get(yyjson_obj_iter *iter, @@ -2026,13 +2130,13 @@ yyjson_api_inline yyjson_val *yyjson_obj_iter_get(yyjson_obj_iter *iter, order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. - + @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string, null-terminator is not required. @param key_len The the length of `key`, in bytes. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. - + @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_val *yyjson_obj_iter_getn(yyjson_obj_iter *iter, @@ -2042,8 +2146,8 @@ yyjson_api_inline yyjson_val *yyjson_obj_iter_getn(yyjson_obj_iter *iter, /** Macro for iterating over an object. It works like iterator, but with a more intuitive API. - - @par Example + + @b Example @code size_t idx, max; yyjson_val *key, *val; @@ -2081,11 +2185,11 @@ yyjson_api_inline void yyjson_mut_doc_set_root(yyjson_mut_doc *doc, Set the string pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed. - + If the caller knows the approximate bytes of strings that the document needs to store (e.g. copy string with `yyjson_mut_strcpy` function), setting a larger size can avoid multiple memory allocations and improve performance. - + @param doc The mutable document. @param len The desired string pool size in bytes (total string length). @return true if successful, false if size is 0 or overflow. @@ -2097,11 +2201,11 @@ yyjson_api bool yyjson_mut_doc_set_str_pool_size(yyjson_mut_doc *doc, Set the value pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed. - + If the caller knows the approximate number of values that the document needs to store (e.g. create new value with `yyjson_mut_xxx` functions), setting a larger size can avoid multiple memory allocations and improve performance. - + @param doc The mutable document. @param count The desired value pool size (number of `yyjson_mut_val`). @return true if successful, false if size is 0 or overflow. @@ -2338,11 +2442,35 @@ yyjson_api_inline bool yyjson_mut_set_sint(yyjson_mut_val *val, int64_t num); @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_int(yyjson_mut_val *val, int num); +/** Set the value to float. + Returns false if input is NULL. + @warning This function should not be used on an existing object or array. */ +yyjson_api_inline bool yyjson_mut_set_float(yyjson_mut_val *val, float num); + +/** Set the value to double. + Returns false if input is NULL. + @warning This function should not be used on an existing object or array. */ +yyjson_api_inline bool yyjson_mut_set_double(yyjson_mut_val *val, double num); + /** Set the value to real. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ yyjson_api_inline bool yyjson_mut_set_real(yyjson_mut_val *val, double num); +/** Set the floating-point number's output format to fixed-point notation. + Returns false if input is NULL or `val` is not real type. + @see YYJSON_WRITE_FP_TO_FIXED flag. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_mut_set_fp_to_fixed(yyjson_mut_val *val, + int prec); + +/** Set the floating-point number's output format to single-precision. + Returns false if input is NULL or `val` is not real type. + @see YYJSON_WRITE_FP_TO_FLOAT flag. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_mut_set_fp_to_float(yyjson_mut_val *val, + bool flt); + /** Set the value to string (null-terminated). Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ @@ -2354,6 +2482,15 @@ yyjson_api_inline bool yyjson_mut_set_str(yyjson_mut_val *val, const char *str); yyjson_api_inline bool yyjson_mut_set_strn(yyjson_mut_val *val, const char *str, size_t len); +/** Marks this string as not needing to be escaped during JSON writing. + This can be used to avoid the overhead of escaping if the string contains + only characters that do not require escaping. + Returns false if input is NULL or `val` is not string. + @see YYJSON_SUBTYPE_NOESC subtype. + @warning This will modify the `immutable` value, use with caution. */ +yyjson_api_inline bool yyjson_mut_set_str_noesc(yyjson_mut_val *val, + bool noesc); + /** Set the value to array. Returns false if input is NULL. @warning This function should not be used on an existing object or array. */ @@ -2372,7 +2509,7 @@ yyjson_api_inline bool yyjson_mut_set_obj(yyjson_mut_val *val); /** Creates and returns a raw value, returns NULL on error. The `str` should be a null-terminated UTF-8 string. - + @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_raw(yyjson_mut_doc *doc, @@ -2380,7 +2517,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_raw(yyjson_mut_doc *doc, /** Creates and returns a raw value, returns NULL on error. The `str` should be a UTF-8 string, null-terminator is not required. - + @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_rawn(yyjson_mut_doc *doc, @@ -2425,7 +2562,15 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_sint(yyjson_mut_doc *doc, yyjson_api_inline yyjson_mut_val *yyjson_mut_int(yyjson_mut_doc *doc, int64_t num); -/** Creates and returns an real number value, returns NULL on error. */ +/** Creates and returns a float number value, returns NULL on error. */ +yyjson_api_inline yyjson_mut_val *yyjson_mut_float(yyjson_mut_doc *doc, + float num); + +/** Creates and returns a double number value, returns NULL on error. */ +yyjson_api_inline yyjson_mut_val *yyjson_mut_double(yyjson_mut_doc *doc, + double num); + +/** Creates and returns a real number value, returns NULL on error. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_real(yyjson_mut_doc *doc, double num); @@ -2489,11 +2634,11 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_get_last(yyjson_mut_val *arr); /** A mutable JSON array iterator. - + @warning You should not modify the array while iterating over it, but you can use `yyjson_mut_arr_iter_remove()` to remove current value. - - @par Example + + @b Example @code yyjson_mut_val *val; yyjson_mut_arr_iter iter = yyjson_mut_arr_iter_with(arr); @@ -2515,13 +2660,13 @@ typedef struct yyjson_mut_arr_iter { /** Initialize an iterator for this array. - + @param arr The array to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_mut_arr_iter_init(yyjson_mut_val *arr, @@ -2529,11 +2674,11 @@ yyjson_api_inline bool yyjson_mut_arr_iter_init(yyjson_mut_val *arr, /** Create an iterator with an array , same as `yyjson_mut_arr_iter_init()`. - + @param arr The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. @return A new iterator for the array. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_mut_arr_iter yyjson_mut_arr_iter_with( @@ -2563,10 +2708,10 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_remove( /** Macro for iterating over an array. It works like iterator, but with a more intuitive API. - + @warning You should not modify the array while iterating over it. - - @par Example + + @b Example @code size_t idx, max; yyjson_mut_val *val; @@ -2598,14 +2743,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr(yyjson_mut_doc *doc); /** Creates and returns a new mutable array with the given boolean values. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of boolean values. @param count The value count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const bool vals[3] = { true, false, true }; yyjson_mut_val *arr = yyjson_mut_arr_with_bool(doc, vals, 3); @@ -2616,14 +2761,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_bool( /** Creates and returns a new mutable array with the given sint numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of sint numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const int64_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3); @@ -2634,14 +2779,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint( /** Creates and returns a new mutable array with the given uint numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const uint64_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint(doc, vals, 3); @@ -2652,14 +2797,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint( /** Creates and returns a new mutable array with the given real numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of real numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const double vals[3] = { 0.1, 0.2, 0.3 }; yyjson_mut_val *arr = yyjson_mut_arr_with_real(doc, vals, 3); @@ -2670,14 +2815,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_real( /** Creates and returns a new mutable array with the given int8 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int8 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const int8_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint8(doc, vals, 3); @@ -2688,14 +2833,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint8( /** Creates and returns a new mutable array with the given int16 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int16 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const int16_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint16(doc, vals, 3); @@ -2706,14 +2851,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint16( /** Creates and returns a new mutable array with the given int32 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int32 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const int32_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint32(doc, vals, 3); @@ -2724,14 +2869,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint32( /** Creates and returns a new mutable array with the given int64 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of int64 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const int64_t vals[3] = { -1, 0, 1 }; yyjson_mut_val *arr = yyjson_mut_arr_with_sint64(doc, vals, 3); @@ -2742,14 +2887,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint64( /** Creates and returns a new mutable array with the given uint8 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint8 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const uint8_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint8(doc, vals, 3); @@ -2760,14 +2905,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint8( /** Creates and returns a new mutable array with the given uint16 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint16 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const uint16_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint16(doc, vals, 3); @@ -2778,14 +2923,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint16( /** Creates and returns a new mutable array with the given uint32 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint32 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const uint32_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint32(doc, vals, 3); @@ -2796,14 +2941,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint32( /** Creates and returns a new mutable array with the given uint64 numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of uint64 numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const uint64_t vals[3] = { 0, 1, 0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_uint64(doc, vals, 3); @@ -2814,14 +2959,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint64( /** Creates and returns a new mutable array with the given float numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of float numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const float vals[3] = { -1.0f, 0.0f, 1.0f }; yyjson_mut_val *arr = yyjson_mut_arr_with_float(doc, vals, 3); @@ -2832,14 +2977,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_float( /** Creates and returns a new mutable array with the given double numbers. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of double numbers. @param count The number count. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const double vals[3] = { -1.0, 0.0, 1.0 }; yyjson_mut_val *arr = yyjson_mut_arr_with_double(doc, vals, 3); @@ -2851,7 +2996,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_double( /** Creates and returns a new mutable array with the given strings, these strings will not be copied. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 null-terminator strings. @@ -2859,12 +3004,12 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_double( @param count The number of values in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - + @warning The input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use `yyjson_mut_arr_with_strcpy()` instead. - - @par Example + + @b Example @code const char *vals[3] = { "a", "b", "c" }; yyjson_mut_val *arr = yyjson_mut_arr_with_str(doc, vals, 3); @@ -2876,7 +3021,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_str( /** Creates and returns a new mutable array with the given strings and string lengths, these strings will not be copied. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 strings, null-terminator is not required. @@ -2885,12 +3030,12 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_str( @param count The number of strings in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - + @warning The input strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. If these strings will be modified, you should use `yyjson_mut_arr_with_strncpy()` instead. - - @par Example + + @b Example @code const char *vals[3] = { "a", "bb", "c" }; const size_t lens[3] = { 1, 2, 1 }; @@ -2903,7 +3048,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strn( /** Creates and returns a new mutable array with the given strings, these strings will be copied. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 null-terminator strings. @@ -2911,8 +3056,8 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strn( @param count The number of values in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const char *vals[3] = { "a", "b", "c" }; yyjson_mut_val *arr = yyjson_mut_arr_with_strcpy(doc, vals, 3); @@ -2924,7 +3069,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strcpy( /** Creates and returns a new mutable array with the given strings and string lengths, these strings will be copied. - + @param doc A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. @param vals A C array of UTF-8 strings, null-terminator is not required. @@ -2933,8 +3078,8 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strcpy( @param count The number of strings in `vals`. If this value is 0, an empty array will return. @return The new array. NULL if input is invalid or memory allocation failed. - - @par Example + + @b Example @code const char *vals[3] = { "a", "bb", "c" }; const size_t lens[3] = { 1, 2, 1 }; @@ -3140,7 +3285,7 @@ yyjson_api_inline bool yyjson_mut_arr_add_sint(yyjson_mut_doc *doc, int64_t num); /** - Adds a integer value at the end of the array. + Adds an integer value at the end of the array. @param doc The `doc` is only used for memory allocation. @param arr The array to which the value is to be inserted. Returns false if it is NULL or not an array. @@ -3151,6 +3296,30 @@ yyjson_api_inline bool yyjson_mut_arr_add_int(yyjson_mut_doc *doc, yyjson_mut_val *arr, int64_t num); +/** + Adds a float value at the end of the array. + @param doc The `doc` is only used for memory allocation. + @param arr The array to which the value is to be inserted. + Returns false if it is NULL or not an array. + @param num The number to be added. + @return Whether successful. + */ +yyjson_api_inline bool yyjson_mut_arr_add_float(yyjson_mut_doc *doc, + yyjson_mut_val *arr, + float num); + +/** + Adds a double value at the end of the array. + @param doc The `doc` is only used for memory allocation. + @param arr The array to which the value is to be inserted. + Returns false if it is NULL or not an array. + @param num The number to be added. + @return Whether successful. + */ +yyjson_api_inline bool yyjson_mut_arr_add_double(yyjson_mut_doc *doc, + yyjson_mut_val *arr, + double num); + /** Adds a double value at the end of the array. @param doc The `doc` is only used for memory allocation. @@ -3252,9 +3421,9 @@ yyjson_api_inline size_t yyjson_mut_obj_size(yyjson_mut_val *obj); /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. - + The `key` should be a null-terminated UTF-8 string. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_get(yyjson_mut_val *obj, const char *key); @@ -3262,10 +3431,10 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_get(yyjson_mut_val *obj, /** Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if `obj/key` is NULL, or type is not object. - + The `key` should be a UTF-8 string, null-terminator is not required. The `key_len` should be the length of the key, in bytes. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_getn(yyjson_mut_val *obj, const char *key, @@ -3279,11 +3448,11 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_getn(yyjson_mut_val *obj, /** A mutable JSON object iterator. - + @warning You should not modify the object while iterating over it, but you can use `yyjson_mut_obj_iter_remove()` to remove current value. - - @par Example + + @b Example @code yyjson_mut_val *key, *val; yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj); @@ -3295,7 +3464,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_getn(yyjson_mut_val *obj, } } @endcode - + If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups: @code @@ -3317,13 +3486,13 @@ typedef struct yyjson_mut_obj_iter { /** Initialize an iterator for this object. - + @param obj The object to be iterated over. If this parameter is NULL or not an array, `iter` will be set to empty. @param iter The iterator to be initialized. If this parameter is NULL, the function will fail and return false. @return true if the `iter` has been successfully initialized. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline bool yyjson_mut_obj_iter_init(yyjson_mut_val *obj, @@ -3331,11 +3500,11 @@ yyjson_api_inline bool yyjson_mut_obj_iter_init(yyjson_mut_val *obj, /** Create an iterator with an object, same as `yyjson_obj_iter_init()`. - + @param obj The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. @return A new iterator for the object. - + @note The iterator does not need to be destroyed. */ yyjson_api_inline yyjson_mut_obj_iter yyjson_mut_obj_iter_with( @@ -3371,18 +3540,18 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_remove( /** Iterates to a specified key and returns the value. - + This function does the same thing as `yyjson_mut_obj_get()`, but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. - + @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string with null-terminator. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. - + @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get( @@ -3390,19 +3559,19 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_get( /** Iterates to a specified key and returns the value. - + This function does the same thing as `yyjson_mut_obj_getn()` but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned. - + @param iter The object iterator, should not be NULL. @param key The key, should be a UTF-8 string, null-terminator is not required. @param key_len The the length of `key`, in bytes. @return The value to which the specified key is mapped. NULL if this object contains no mapping for the key or input is invalid. - + @warning This function takes a linear search time if the key is not nearby. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_getn( @@ -3411,14 +3580,14 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_iter_getn( /** Macro for iterating over an object. It works like iterator, but with a more intuitive API. - + @warning You should not modify the object while iterating over it. - - @par Example + + @b Example @code size_t idx, max; - yyjson_val *key, *val; - yyjson_obj_foreach(obj, idx, max, key, val) { + yyjson_mut_val *key, *val; + yyjson_mut_obj_foreach(obj, idx, max, key, val) { your_func(key, val); } @endcode @@ -3446,11 +3615,11 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj(yyjson_mut_doc *doc); Creates and returns a mutable object with keys and values, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string. - + @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. - - @par Example + + @b Example @code const char *keys[2] = { "id", "name" }; const char *vals[2] = { "01", "Harry" }; @@ -3466,11 +3635,11 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_with_str(yyjson_mut_doc *doc, Creates and returns a mutable object with key-value pairs and pair count, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string. - + @warning The input string is not copied, you should keep this string unmodified for the lifetime of this JSON document. - - @par Example + + @b Example @code const char *kv_pairs[4] = { "id", "01", "name", "Harry" }; yyjson_mut_val *obj = yyjson_mut_obj_with_kv(doc, kv_pairs, 2); @@ -3599,7 +3768,7 @@ yyjson_api_inline bool yyjson_mut_obj_rotate(yyjson_mut_val *obj, /** Adds a `null` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, @@ -3609,7 +3778,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, /** Adds a `true` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, @@ -3619,7 +3788,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, /** Adds a `false` value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, @@ -3629,7 +3798,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, /** Adds a bool value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, @@ -3639,7 +3808,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, /** Adds an unsigned integer value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, @@ -3649,7 +3818,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, /** Adds a signed integer value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, @@ -3659,17 +3828,37 @@ yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, /** Adds an int value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *key, int64_t val); +/** Adds a float value at the end of the object. + The `key` should be a null-terminated UTF-8 string. + This function allows duplicated key in one object. + + @warning The key string is not copied, you should keep the string + unmodified for the lifetime of this JSON document. */ +yyjson_api_inline bool yyjson_mut_obj_add_float(yyjson_mut_doc *doc, + yyjson_mut_val *obj, + const char *key, float val); + /** Adds a double value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + + @warning The key string is not copied, you should keep the string + unmodified for the lifetime of this JSON document. */ +yyjson_api_inline bool yyjson_mut_obj_add_double(yyjson_mut_doc *doc, + yyjson_mut_val *obj, + const char *key, double val); + +/** Adds a real value at the end of the object. + The `key` should be a null-terminated UTF-8 string. + This function allows duplicated key in one object. + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, @@ -3679,7 +3868,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, /** Adds a string value at the end of the object. The `key` and `val` should be null-terminated UTF-8 strings. This function allows duplicated key in one object. - + @warning The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, @@ -3691,7 +3880,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, The `val` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the `val`, in bytes. This function allows duplicated key in one object. - + @warning The key/value strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc, @@ -3703,7 +3892,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc, The `key` and `val` should be null-terminated UTF-8 strings. The value string is copied. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc, @@ -3716,7 +3905,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc, The `val` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the `val`, in bytes. This function allows duplicated key in one object. - + @warning The key strings are not copied, you should keep these strings unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc, @@ -3728,7 +3917,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc, Creates and adds a new array to the target object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. @return The new array, or NULL on error. @@ -3741,7 +3930,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_arr(yyjson_mut_doc *doc, Creates and adds a new object to the target object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep these strings unmodified for the lifetime of this JSON document. @return The new object, or NULL on error. @@ -3753,7 +3942,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_obj(yyjson_mut_doc *doc, /** Adds a JSON value at the end of the object. The `key` should be a null-terminated UTF-8 string. This function allows duplicated key in one object. - + @warning The key string is not copied, you should keep the string unmodified for the lifetime of this JSON document. */ yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc, @@ -3765,7 +3954,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc, Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The `key` should be a null-terminated UTF-8 string. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_str( yyjson_mut_val *obj, const char *key); @@ -3775,7 +3964,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_str( object contains no mapping for the key. The `key` should be a UTF-8 string, null-terminator is not required. The `len` should be the length of the key, in bytes. - + @warning This function takes a linear search time. */ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_strn( yyjson_mut_val *obj, const char *key, size_t len); @@ -3784,7 +3973,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_remove_strn( Returns true if at least one key was renamed. The `key` and `new_key` should be a null-terminated UTF-8 string. The `new_key` is copied and held by doc. - + @warning This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys. */ @@ -3797,7 +3986,7 @@ yyjson_api_inline bool yyjson_mut_obj_rename_key(yyjson_mut_doc *doc, Returns true if at least one key was renamed. The `key` and `new_key` should be a UTF-8 string, null-terminator is not required. The `new_key` is copied and held by doc. - + @warning This function takes a linear search time. If `new_key` already exists, it will cause duplicate keys. */ @@ -3810,6 +3999,8 @@ yyjson_api_inline bool yyjson_mut_obj_rename_keyn(yyjson_mut_doc *doc, +#if !defined(YYJSON_DISABLE_UTILS) || !YYJSON_DISABLE_UTILS + /*============================================================================== * JSON Pointer API (RFC 6901) * https://tools.ietf.org/html/rfc6901 @@ -3851,12 +4042,12 @@ typedef struct yyjson_ptr_err { /** A context for JSON pointer operation. - + This struct stores the context of JSON Pointer operation result. The struct can be used with three helper functions: `ctx_append()`, `ctx_replace()`, and `ctx_remove()`, which perform the corresponding operations on the container without re-parsing the JSON Pointer. - + For example: @code // doc before: {"a":[0,1,null]} @@ -4492,6 +4683,8 @@ yyjson_api yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc, yyjson_mut_val *orig, yyjson_mut_val *patch); +#endif /* YYJSON_DISABLE_UTILS */ + /*============================================================================== @@ -4539,14 +4732,14 @@ struct yyjson_doc { Whether the string does not need to be escaped for serialization. This function is used to optimize the writing speed of small constant strings. This function works only if the compiler can evaluate it at compile time. - + Clang supports it since v8.0, earlier versions do not support constant_p(strlen) and return false. GCC supports it since at least v4.4, earlier versions may compile it as run-time instructions. ICC supports it since at least v16, earlier versions are uncertain. - + @param str The C string. @param len The returnd value from strlen(str). */ @@ -4556,12 +4749,12 @@ yyjson_api_inline bool unsafe_yyjson_is_str_noesc(const char *str, size_t len) { if (yyjson_constant_p(len) && len <= 32) { /* Same as the following loop: - + for (size_t i = 0; i < len; i++) { char c = str[i]; if (c < ' ' || c > '~' || c == '"' || c == '\\') return false; } - + GCC evaluates it at compile time only if the string length is within 17 and -O3 (which turns on the -fpeel-loops flag) is used. So the loop is unrolled for GCC. @@ -4587,6 +4780,19 @@ yyjson_api_inline bool unsafe_yyjson_is_str_noesc(const char *str, size_t len) { return false; } +yyjson_api_inline double unsafe_yyjson_u64_to_f64(uint64_t num) { +#if YYJSON_U64_TO_F64_NO_IMPL + uint64_t msb = ((uint64_t)1) << 63; + if ((num & msb) == 0) { + return (double)(int64_t)num; + } else { + return ((double)(int64_t)((num >> 1) | (num & 1))) * (double)2.0; + } +#else + return (double)num; +#endif +} + yyjson_api_inline yyjson_type unsafe_yyjson_get_type(void *val) { uint8_t tag = (uint8_t)((yyjson_val *)val)->tag; return (yyjson_type)(tag & YYJSON_TYPE_MASK); @@ -4704,17 +4910,7 @@ yyjson_api_inline double unsafe_yyjson_get_num(void *val) { } else if (tag == (YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT)) { return (double)((yyjson_val *)val)->uni.i64; } else if (tag == (YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT)) { -#if YYJSON_U64_TO_F64_NO_IMPL - uint64_t msb = ((uint64_t)1) << 63; - uint64_t num = ((yyjson_val *)val)->uni.u64; - if ((num & msb) == 0) { - return (double)(int64_t)num; - } else { - return ((double)(int64_t)((num >> 1) | (num & 1))) * (double)2.0; - } -#else - return (double)((yyjson_val *)val)->uni.u64; -#endif + return unsafe_yyjson_u64_to_f64(((yyjson_val *)val)->uni.u64); } return 0.0; } @@ -4762,6 +4958,14 @@ yyjson_api_inline void unsafe_yyjson_set_len(void *val, size_t len) { ((yyjson_val *)val)->tag = tag; } +yyjson_api_inline void unsafe_yyjson_set_tag(void *val, yyjson_type type, + yyjson_subtype subtype, + size_t len) { + uint64_t tag = (uint64_t)len << YYJSON_TAG_BIT; + tag |= (type | subtype); + ((yyjson_val *)val)->tag = tag; +} + yyjson_api_inline void unsafe_yyjson_inc_len(void *val) { uint64_t tag = ((yyjson_val *)val)->tag; tag += (uint64_t)(1 << YYJSON_TAG_BIT); @@ -4770,64 +4974,81 @@ yyjson_api_inline void unsafe_yyjson_inc_len(void *val) { yyjson_api_inline void unsafe_yyjson_set_raw(void *val, const char *raw, size_t len) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_RAW, YYJSON_SUBTYPE_NONE); - unsafe_yyjson_set_len(val, len); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_RAW, YYJSON_SUBTYPE_NONE, len); ((yyjson_val *)val)->uni.str = raw; } yyjson_api_inline void unsafe_yyjson_set_null(void *val) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_NULL, YYJSON_SUBTYPE_NONE); - unsafe_yyjson_set_len(val, 0); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NULL, YYJSON_SUBTYPE_NONE, 0); } yyjson_api_inline void unsafe_yyjson_set_bool(void *val, bool num) { yyjson_subtype subtype = num ? YYJSON_SUBTYPE_TRUE : YYJSON_SUBTYPE_FALSE; - unsafe_yyjson_set_type(val, YYJSON_TYPE_BOOL, subtype); - unsafe_yyjson_set_len(val, 0); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_BOOL, subtype, 0); } yyjson_api_inline void unsafe_yyjson_set_uint(void *val, uint64_t num) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_UINT); - unsafe_yyjson_set_len(val, 0); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_UINT, 0); ((yyjson_val *)val)->uni.u64 = num; } yyjson_api_inline void unsafe_yyjson_set_sint(void *val, int64_t num) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_SINT); - unsafe_yyjson_set_len(val, 0); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_SINT, 0); ((yyjson_val *)val)->uni.i64 = num; } +yyjson_api_inline void unsafe_yyjson_set_fp_to_fixed(void *val, int prec) { + ((yyjson_val *)val)->tag &= ~((uint64_t)YYJSON_WRITE_FP_TO_FIXED(15) << 32); + ((yyjson_val *)val)->tag |= (uint64_t)YYJSON_WRITE_FP_TO_FIXED(prec) << 32; +} + +yyjson_api_inline void unsafe_yyjson_set_fp_to_float(void *val, bool flt) { + uint64_t flag = (uint64_t)YYJSON_WRITE_FP_TO_FLOAT << 32; + if (flt) ((yyjson_val *)val)->tag |= flag; + else ((yyjson_val *)val)->tag &= ~flag; +} + +yyjson_api_inline void unsafe_yyjson_set_float(void *val, float num) { + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL, 0); + ((yyjson_val *)val)->tag |= (uint64_t)YYJSON_WRITE_FP_TO_FLOAT << 32; + ((yyjson_val *)val)->uni.f64 = (double)num; +} + +yyjson_api_inline void unsafe_yyjson_set_double(void *val, double num) { + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL, 0); + ((yyjson_val *)val)->uni.f64 = num; +} + yyjson_api_inline void unsafe_yyjson_set_real(void *val, double num) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL); - unsafe_yyjson_set_len(val, 0); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL, 0); ((yyjson_val *)val)->uni.f64 = num; } -yyjson_api_inline void unsafe_yyjson_set_str(void *val, const char *str) { - size_t len = strlen(str); - bool noesc = unsafe_yyjson_is_str_noesc(str, len); - yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; - unsafe_yyjson_set_type(val, YYJSON_TYPE_STR, sub); - unsafe_yyjson_set_len(val, len); - ((yyjson_val *)val)->uni.str = str; +yyjson_api_inline void unsafe_yyjson_set_str_noesc(void *val, bool noesc) { + ((yyjson_val *)val)->tag &= ~(uint64_t)YYJSON_SUBTYPE_MASK; + if (noesc) ((yyjson_val *)val)->tag |= (uint64_t)YYJSON_SUBTYPE_NOESC; } yyjson_api_inline void unsafe_yyjson_set_strn(void *val, const char *str, size_t len) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_STR, YYJSON_SUBTYPE_NONE); - unsafe_yyjson_set_len(val, len); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_STR, YYJSON_SUBTYPE_NONE, len); + ((yyjson_val *)val)->uni.str = str; +} + +yyjson_api_inline void unsafe_yyjson_set_str(void *val, const char *str) { + size_t len = strlen(str); + bool noesc = unsafe_yyjson_is_str_noesc(str, len); + yyjson_subtype subtype = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; + unsafe_yyjson_set_tag(val, YYJSON_TYPE_STR, subtype, len); ((yyjson_val *)val)->uni.str = str; } yyjson_api_inline void unsafe_yyjson_set_arr(void *val, size_t size) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_ARR, YYJSON_SUBTYPE_NONE); - unsafe_yyjson_set_len(val, size); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_ARR, YYJSON_SUBTYPE_NONE, size); } yyjson_api_inline void unsafe_yyjson_set_obj(void *val, size_t size) { - unsafe_yyjson_set_type(val, YYJSON_TYPE_OBJ, YYJSON_SUBTYPE_NONE); - unsafe_yyjson_set_len(val, size); + unsafe_yyjson_set_tag(val, YYJSON_TYPE_OBJ, YYJSON_SUBTYPE_NONE, size); } @@ -5051,12 +5272,36 @@ yyjson_api_inline bool yyjson_set_int(yyjson_val *val, int num) { return true; } +yyjson_api_inline bool yyjson_set_float(yyjson_val *val, float num) { + if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; + unsafe_yyjson_set_float(val, num); + return true; +} + +yyjson_api_inline bool yyjson_set_double(yyjson_val *val, double num) { + if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; + unsafe_yyjson_set_double(val, num); + return true; +} + yyjson_api_inline bool yyjson_set_real(yyjson_val *val, double num) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; unsafe_yyjson_set_real(val, num); return true; } +yyjson_api_inline bool yyjson_set_fp_to_fixed(yyjson_val *val, int prec) { + if (yyjson_unlikely(!yyjson_is_real(val))) return false; + unsafe_yyjson_set_fp_to_fixed(val, prec); + return true; +} + +yyjson_api_inline bool yyjson_set_fp_to_float(yyjson_val *val, bool flt) { + if (yyjson_unlikely(!yyjson_is_real(val))) return false; + unsafe_yyjson_set_fp_to_float(val, flt); + return true; +} + yyjson_api_inline bool yyjson_set_str(yyjson_val *val, const char *str) { if (yyjson_unlikely(!val || unsafe_yyjson_is_ctn(val))) return false; if (yyjson_unlikely(!str)) return false; @@ -5072,6 +5317,12 @@ yyjson_api_inline bool yyjson_set_strn(yyjson_val *val, return true; } +yyjson_api_inline bool yyjson_set_str_noesc(yyjson_val *val, bool noesc) { + if (yyjson_unlikely(!yyjson_is_str(val))) return false; + unsafe_yyjson_set_str_noesc(val, noesc); + return true; +} + /*============================================================================== @@ -5574,12 +5825,38 @@ yyjson_api_inline bool yyjson_mut_set_int(yyjson_mut_val *val, int num) { return true; } +yyjson_api_inline bool yyjson_mut_set_float(yyjson_mut_val *val, float num) { + if (yyjson_unlikely(!val)) return false; + unsafe_yyjson_set_float(val, num); + return true; +} + +yyjson_api_inline bool yyjson_mut_set_double(yyjson_mut_val *val, double num) { + if (yyjson_unlikely(!val)) return false; + unsafe_yyjson_set_double(val, num); + return true; +} + yyjson_api_inline bool yyjson_mut_set_real(yyjson_mut_val *val, double num) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_real(val, num); return true; } +yyjson_api_inline bool yyjson_mut_set_fp_to_fixed(yyjson_mut_val *val, + int prec) { + if (yyjson_unlikely(!yyjson_mut_is_real(val))) return false; + unsafe_yyjson_set_fp_to_fixed(val, prec); + return true; +} + +yyjson_api_inline bool yyjson_mut_set_fp_to_float(yyjson_mut_val *val, + bool flt) { + if (yyjson_unlikely(!yyjson_mut_is_real(val))) return false; + unsafe_yyjson_set_fp_to_float(val, flt); + return true; +} + yyjson_api_inline bool yyjson_mut_set_str(yyjson_mut_val *val, const char *str) { if (yyjson_unlikely(!val || !str)) return false; @@ -5594,6 +5871,13 @@ yyjson_api_inline bool yyjson_mut_set_strn(yyjson_mut_val *val, return true; } +yyjson_api_inline bool yyjson_mut_set_str_noesc(yyjson_mut_val *val, + bool noesc) { + if (yyjson_unlikely(!yyjson_mut_is_str(val))) return false; + unsafe_yyjson_set_str_noesc(val, noesc); + return true; +} + yyjson_api_inline bool yyjson_mut_set_arr(yyjson_mut_val *val) { if (yyjson_unlikely(!val)) return false; unsafe_yyjson_set_arr(val, 0); @@ -5612,201 +5896,141 @@ yyjson_api_inline bool yyjson_mut_set_obj(yyjson_mut_val *val) { * Mutable JSON Value Creation API (Implementation) *============================================================================*/ +#define yyjson_mut_val_one(func) \ + if (yyjson_likely(doc)) { \ + yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); \ + if (yyjson_likely(val)) { \ + func \ + return val; \ + } \ + } \ + return NULL + +#define yyjson_mut_val_one_str(func) \ + if (yyjson_likely(doc && str)) { \ + yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); \ + if (yyjson_likely(val)) { \ + func \ + return val; \ + } \ + } \ + return NULL + yyjson_api_inline yyjson_mut_val *yyjson_mut_raw(yyjson_mut_doc *doc, const char *str) { - if (yyjson_likely(str)) return yyjson_mut_rawn(doc, str, strlen(str)); - return NULL; + yyjson_mut_val_one_str({ unsafe_yyjson_set_raw(val, str, strlen(str)); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawn(yyjson_mut_doc *doc, const char *str, size_t len) { - if (yyjson_likely(doc && str)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; - val->uni.str = str; - return val; - } - } - return NULL; + yyjson_mut_val_one_str({ unsafe_yyjson_set_raw(val, str, len); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawcpy(yyjson_mut_doc *doc, const char *str) { - if (yyjson_likely(str)) return yyjson_mut_rawncpy(doc, str, strlen(str)); - return NULL; + yyjson_mut_val_one_str({ + size_t len = strlen(str); + char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_raw(val, new_str, len); + }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_rawncpy(yyjson_mut_doc *doc, const char *str, size_t len) { - if (yyjson_likely(doc && str)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); + yyjson_mut_val_one_str({ char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); - if (yyjson_likely(val && new_str)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; - val->uni.str = new_str; - return val; - } - } - return NULL; + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_raw(val, new_str, len); + }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_null(yyjson_mut_doc *doc) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_null(val); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_true(yyjson_mut_doc *doc) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_bool(val, true); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_false(yyjson_mut_doc *doc) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_bool(val, false); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_bool(yyjson_mut_doc *doc, bool _val) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - _val = !!_val; - val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)_val << 3); - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_bool(val, _val); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_uint(yyjson_mut_doc *doc, uint64_t num) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = num; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_uint(val, num); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_sint(yyjson_mut_doc *doc, int64_t num) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = num; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_sint(val, num); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_int(yyjson_mut_doc *doc, int64_t num) { - return yyjson_mut_sint(doc, num); + yyjson_mut_val_one({ unsafe_yyjson_set_sint(val, num); }); +} + +yyjson_api_inline yyjson_mut_val *yyjson_mut_float(yyjson_mut_doc *doc, + float num) { + yyjson_mut_val_one({ unsafe_yyjson_set_float(val, num); }); +} + +yyjson_api_inline yyjson_mut_val *yyjson_mut_double(yyjson_mut_doc *doc, + double num) { + yyjson_mut_val_one({ unsafe_yyjson_set_double(val, num); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_real(yyjson_mut_doc *doc, double num) { - if (yyjson_likely(doc)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; - val->uni.f64 = num; - return val; - } - } - return NULL; + yyjson_mut_val_one({ unsafe_yyjson_set_real(val, num); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_str(yyjson_mut_doc *doc, const char *str) { - if (yyjson_likely(doc && str)) { - size_t len = strlen(str); - bool noesc = unsafe_yyjson_is_str_noesc(str, len); - yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | - (uint64_t)(YYJSON_TYPE_STR | sub); - val->uni.str = str; - return val; - } - } - return NULL; + yyjson_mut_val_one_str({ unsafe_yyjson_set_str(val, str); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_strn(yyjson_mut_doc *doc, const char *str, size_t len) { - if (yyjson_likely(doc && str)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); - if (yyjson_likely(val)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = str; - return val; - } - } - return NULL; + yyjson_mut_val_one_str({ unsafe_yyjson_set_strn(val, str, len); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_strcpy(yyjson_mut_doc *doc, const char *str) { - if (yyjson_likely(doc && str)) { + yyjson_mut_val_one_str({ size_t len = strlen(str); bool noesc = unsafe_yyjson_is_str_noesc(str, len); yyjson_subtype sub = noesc ? YYJSON_SUBTYPE_NOESC : YYJSON_SUBTYPE_NONE; - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); - if (yyjson_likely(val && new_str)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | - (uint64_t)(YYJSON_TYPE_STR | sub); - val->uni.str = new_str; - return val; - } - } - return NULL; + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_tag(val, YYJSON_TYPE_STR, sub, len); + val->uni.str = new_str; + }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_strncpy(yyjson_mut_doc *doc, const char *str, size_t len) { - if (yyjson_likely(doc && str)) { - yyjson_mut_val *val = unsafe_yyjson_mut_val(doc, 1); + yyjson_mut_val_one_str({ char *new_str = unsafe_yyjson_mut_strncpy(doc, str, len); - if (yyjson_likely(val && new_str)) { - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = new_str; - return val; - } - } - return NULL; + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_strn(val, new_str, len); + }); } +#undef yyjson_mut_val_one +#undef yyjson_mut_val_one_str + /*============================================================================== @@ -5897,7 +6121,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_remove( iter->max--; unsafe_yyjson_set_len(iter->arr, iter->max); prev->next = next; - iter->cur = next; + iter->cur = prev; return cur; } return NULL; @@ -5944,8 +6168,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr(yyjson_mut_doc *doc) { yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_bool( yyjson_mut_doc *doc, const bool *vals, size_t count) { yyjson_mut_arr_with_func({ - bool _val = !!vals[i]; - val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)_val << 3); + unsafe_yyjson_set_bool(val, vals[i]); }); } @@ -5961,96 +6184,86 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint( yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_real( yyjson_mut_doc *doc, const double *vals, size_t count) { - return yyjson_mut_arr_with_double(doc, vals, count); + yyjson_mut_arr_with_func({ + unsafe_yyjson_set_real(val, vals[i]); + }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint8( yyjson_mut_doc *doc, const int8_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = (int64_t)vals[i]; + unsafe_yyjson_set_sint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint16( yyjson_mut_doc *doc, const int16_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = vals[i]; + unsafe_yyjson_set_sint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint32( yyjson_mut_doc *doc, const int32_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = vals[i]; + unsafe_yyjson_set_sint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_sint64( yyjson_mut_doc *doc, const int64_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = vals[i]; + unsafe_yyjson_set_sint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint8( yyjson_mut_doc *doc, const uint8_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = vals[i]; + unsafe_yyjson_set_uint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint16( yyjson_mut_doc *doc, const uint16_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = vals[i]; + unsafe_yyjson_set_uint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint32( yyjson_mut_doc *doc, const uint32_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = vals[i]; + unsafe_yyjson_set_uint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_uint64( yyjson_mut_doc *doc, const uint64_t *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = vals[i]; + unsafe_yyjson_set_uint(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_float( yyjson_mut_doc *doc, const float *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; - val->uni.f64 = (double)vals[i]; + unsafe_yyjson_set_float(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_double( yyjson_mut_doc *doc, const double *vals, size_t count) { yyjson_mut_arr_with_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; - val->uni.f64 = vals[i]; + unsafe_yyjson_set_double(val, vals[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_str( yyjson_mut_doc *doc, const char **vals, size_t count) { yyjson_mut_arr_with_func({ - uint64_t len = (uint64_t)strlen(vals[i]); - val->tag = (len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = vals[i]; - if (yyjson_unlikely(!val->uni.str)) return NULL; + if (yyjson_unlikely(!vals[i])) return NULL; + unsafe_yyjson_set_str(val, vals[i]); }); } @@ -6058,37 +6271,37 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strn( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count) { if (yyjson_unlikely(count > 0 && !lens)) return NULL; yyjson_mut_arr_with_func({ - val->tag = ((uint64_t)lens[i] << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = vals[i]; - if (yyjson_unlikely(!val->uni.str)) return NULL; + if (yyjson_unlikely(!vals[i])) return NULL; + unsafe_yyjson_set_strn(val, vals[i], lens[i]); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strcpy( yyjson_mut_doc *doc, const char **vals, size_t count) { size_t len; - const char *str; + const char *str, *new_str; yyjson_mut_arr_with_func({ str = vals[i]; - if (!str) return NULL; + if (yyjson_unlikely(!str)) return NULL; len = strlen(str); - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = unsafe_yyjson_mut_strncpy(doc, str, len); - if (yyjson_unlikely(!val->uni.str)) return NULL; + new_str = unsafe_yyjson_mut_strncpy(doc, str, len); + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_strn(val, new_str, len); }); } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_with_strncpy( yyjson_mut_doc *doc, const char **vals, const size_t *lens, size_t count) { size_t len; - const char *str; + const char *str, *new_str; if (yyjson_unlikely(count > 0 && !lens)) return NULL; yyjson_mut_arr_with_func({ str = vals[i]; + if (yyjson_unlikely(!str)) return NULL; len = lens[i]; - val->tag = ((uint64_t)len << YYJSON_TAG_BIT) | YYJSON_TYPE_STR; - val->uni.str = unsafe_yyjson_mut_strncpy(doc, str, len); - if (yyjson_unlikely(!val->uni.str)) return NULL; + new_str = unsafe_yyjson_mut_strncpy(doc, str, len); + if (yyjson_unlikely(!new_str)) return NULL; + unsafe_yyjson_set_strn(val, new_str, len); }); } @@ -6382,6 +6595,26 @@ yyjson_api_inline bool yyjson_mut_arr_add_int(yyjson_mut_doc *doc, return false; } +yyjson_api_inline bool yyjson_mut_arr_add_float(yyjson_mut_doc *doc, + yyjson_mut_val *arr, + float num) { + if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { + yyjson_mut_val *val = yyjson_mut_float(doc, num); + return yyjson_mut_arr_append(arr, val); + } + return false; +} + +yyjson_api_inline bool yyjson_mut_arr_add_double(yyjson_mut_doc *doc, + yyjson_mut_val *arr, + double num) { + if (yyjson_likely(doc && yyjson_mut_is_arr(arr))) { + yyjson_mut_val *val = yyjson_mut_double(doc, num); + return yyjson_mut_arr_append(arr, val); + } + return false; +} + yyjson_api_inline bool yyjson_mut_arr_add_real(yyjson_mut_doc *doc, yyjson_mut_val *arr, double num) { @@ -6871,75 +7104,68 @@ yyjson_api_inline bool yyjson_mut_obj_rotate(yyjson_mut_val *obj, yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_null(val); }); } yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_TRUE; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_bool(val, true); }); } yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_BOOL | YYJSON_SUBTYPE_FALSE; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_bool(val, false); }); } yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, bool _val) { - yyjson_mut_obj_add_func({ - _val = !!_val; - val->tag = YYJSON_TYPE_BOOL | (uint8_t)((uint8_t)(_val) << 3); - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_bool(val, _val); }); } yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, uint64_t _val) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_UINT; - val->uni.u64 = _val; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_uint(val, _val); }); } yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, int64_t _val) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = _val; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_sint(val, _val); }); } yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, int64_t _val) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_SINT; - val->uni.i64 = _val; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_sint(val, _val); }); +} + +yyjson_api_inline bool yyjson_mut_obj_add_float(yyjson_mut_doc *doc, + yyjson_mut_val *obj, + const char *_key, + float _val) { + yyjson_mut_obj_add_func({ unsafe_yyjson_set_float(val, _val); }); +} + +yyjson_api_inline bool yyjson_mut_obj_add_double(yyjson_mut_doc *doc, + yyjson_mut_val *obj, + const char *_key, + double _val) { + yyjson_mut_obj_add_func({ unsafe_yyjson_set_double(val, _val); }); } yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc, yyjson_mut_val *obj, const char *_key, double _val) { - yyjson_mut_obj_add_func({ - val->tag = YYJSON_TYPE_NUM | YYJSON_SUBTYPE_REAL; - val->uni.f64 = _val; - }); + yyjson_mut_obj_add_func({ unsafe_yyjson_set_real(val, _val); }); } yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc, @@ -7077,6 +7303,8 @@ yyjson_api_inline bool yyjson_mut_obj_rename_keyn(yyjson_mut_doc *doc, +#if !defined(YYJSON_DISABLE_UTILS) || !YYJSON_DISABLE_UTILS + /*============================================================================== * JSON Pointer API (Implementation) *============================================================================*/ @@ -7203,7 +7431,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_getx(yyjson_mut_doc *doc, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7241,7 +7469,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_getx(yyjson_mut_val *val, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!val || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7278,7 +7506,7 @@ yyjson_api_inline bool yyjson_mut_doc_ptr_addx(yyjson_mut_doc *doc, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!doc || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; @@ -7341,7 +7569,7 @@ yyjson_api_inline bool yyjson_mut_ptr_addx(yyjson_mut_val *val, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!val || !ptr || !new_val || !doc)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; @@ -7379,7 +7607,7 @@ yyjson_api_inline bool yyjson_mut_doc_ptr_setx(yyjson_mut_doc *doc, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; @@ -7445,7 +7673,7 @@ yyjson_api_inline bool yyjson_mut_ptr_setx(yyjson_mut_val *val, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!val || !ptr || !doc)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return false; @@ -7479,10 +7707,10 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacen( yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_replacex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { - + yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!doc || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7523,10 +7751,10 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacen( yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_replacex( yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { - + yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!val || !ptr || !new_val)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7556,10 +7784,10 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removen( yyjson_api_inline yyjson_mut_val *yyjson_mut_doc_ptr_removex( yyjson_mut_doc *doc, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err) { - + yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!doc || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7600,7 +7828,7 @@ yyjson_api_inline yyjson_mut_val *yyjson_mut_ptr_removex(yyjson_mut_val *val, yyjson_ptr_err *err) { yyjson_ptr_set_err(NONE, NULL); if (ctx) memset(ctx, 0, sizeof(*ctx)); - + if (yyjson_unlikely(!val || !ptr)) { yyjson_ptr_set_err(PARAMETER, "input parameter is NULL"); return NULL; @@ -7622,7 +7850,7 @@ yyjson_api_inline bool yyjson_ptr_ctx_append(yyjson_ptr_ctx *ctx, yyjson_mut_val *ctn, *pre_key, *pre_val, *cur_key, *cur_val; if (!ctx || !ctx->ctn || !val) return false; ctn = ctx->ctn; - + if (yyjson_mut_is_obj(ctn)) { if (!key) return false; key->next = val; @@ -7919,6 +8147,8 @@ yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_get_pointer( return unsafe_yyjson_mut_ptr_getx(val, ptr, len, NULL, &err); } +#endif /* YYJSON_DISABLE_UTILS */ + /*============================================================================== @@ -7929,7 +8159,7 @@ yyjson_api_inline yyjson_mut_val *unsafe_yyjson_mut_get_pointer( # pragma clang diagnostic pop #elif defined(__GNUC__) # if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic pop +# pragma GCC diagnostic pop # endif #elif defined(_MSC_VER) # pragma warning(pop) From f2702557705b604d9dc92b91cd8be51b264049e9 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Tue, 6 May 2025 16:18:53 +0800 Subject: [PATCH 12/41] DisplayServer (Linux): fix xcb_connect error handling (#1735) --- src/detection/displayserver/linux/xcb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index d714348201..beb6aac0ad 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -335,6 +335,7 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) { FF_LIBRARY_LOAD(xcbRandr, "dlopen libxcb-randr failed", "libxcb-randr" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_connect) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_connection_has_error) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_get_setup) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_setup_roots_iterator) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_screen_next) @@ -368,8 +369,11 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) data.connection = ffxcb_connect(NULL, NULL); - if(data.connection == NULL) + if(ffxcb_connection_has_error(data.connection) > 0) + { + ffxcb_disconnect(data.connection); return "xcb_connect() failed"; + } data.result = result; From 1c7aa89228f3946eded41cfb8ed65cd003e98f2a Mon Sep 17 00:00:00 2001 From: apocelipes Date: Tue, 6 May 2025 18:49:29 +0800 Subject: [PATCH 13/41] TerminalShell: use ffBinaryExtractStrings result as possible (#1739) --- src/detection/terminalshell/terminalshell.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index f4c8a076e5..d8cc0cd7ea 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -69,6 +69,7 @@ static bool getShellVersionBash(FFstrbuf* exe, FFstrbuf* exePath, FFstrbuf* vers if (*path == '\0') path = exe->chars; ffBinaryExtractStrings(path, extractBashVersion, version, (uint32_t) strlen("@(#)Bash version 0.0.0(0) release GNU")); + if (version->length > 0) return true; if(!getExeVersionRaw(exe, version)) return false; From 20cd4ce125a13997a9988f56ff574f4f0cfaafdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 May 2025 10:19:23 +0800 Subject: [PATCH 14/41] Logo (Builtin): `sd '\$\{c(\d)\}' '$$$1' *` --- CMakeLists.txt | 1 - src/logo/ascii/ada.txt | 42 ++++++++++----------- src/logo/ascii/adelie.txt | 22 +++++------ src/logo/ascii/afterglow.txt | 30 +++++++-------- src/logo/ascii/alpine2_small.txt | 10 ++--- src/logo/ascii/amogos.txt | 8 ++-- src/logo/ascii/anarchy.txt | 56 ++++++++++++++-------------- src/logo/ascii/antergos.txt | 24 ++++++------ src/logo/ascii/aoscos.txt | 34 ++++++++--------- src/logo/ascii/aoscosretro.txt | 32 ++++++++-------- src/logo/ascii/aoscosretro_small.txt | 16 ++++---- src/logo/ascii/arch_old.txt | 20 +++++----- src/logo/ascii/archcraft.txt | 40 ++++++++++---------- src/logo/ascii/archstrike.txt | 22 +++++------ src/logo/ascii/arco_small.txt | 6 +-- src/logo/ascii/arya.txt | 30 +++++++-------- src/logo/ascii/asteroidos.txt | 34 ++++++++--------- src/logo/ascii/astra_linux.txt | 40 ++++++++++---------- src/logo/ascii/athena.txt | 48 ++++++++++++------------ src/logo/ascii/azos.txt | 34 ++++++++--------- src/logo/ascii/biglinux.txt | 4 +- src/logo/ascii/blackarch.txt | 40 ++++++++++---------- src/logo/ascii/blackpanther.txt | 4 +- src/logo/ascii/blankon.txt | 34 ++++++++--------- src/logo/ascii/bluelight.txt | 30 +++++++-------- src/logo/ascii/bodhi.txt | 36 +++++++++--------- src/logo/ascii/bonsai.txt | 24 ++++++------ src/logo/ascii/calculate.txt | 10 ++--- src/logo/ascii/chapeau.txt | 26 ++++++------- src/logo/ascii/chimera_linux.txt | 34 ++++++++--------- src/logo/ascii/chrom.txt | 30 +++++++-------- src/logo/ascii/clear_linux.txt | 24 ++++++------ src/logo/ascii/clover.txt | 4 +- src/logo/ascii/cobalt.txt | 28 +++++++------- src/logo/ascii/condres.txt | 34 ++++++++--------- src/logo/ascii/crux_small.txt | 12 +++--- src/logo/ascii/cucumber.txt | 36 +++++++++--------- src/logo/ascii/cutefishos.txt | 2 +- src/logo/ascii/cuteos.txt | 22 +++++------ src/logo/ascii/cyberos.txt | 20 +++++----- src/logo/ascii/darkos.txt | 40 ++++++++++---------- src/logo/ascii/dietpi.txt | 18 ++++----- src/logo/ascii/dragonfly.txt | 18 ++++----- src/logo/ascii/dragonfly_old.txt | 24 ++++++------ src/logo/ascii/dragonfly_small.txt | 10 ++--- src/logo/ascii/droidian.txt | 14 +++---- src/logo/ascii/elive.txt | 34 ++++++++--------- src/logo/ascii/endeavouros_small.txt | 12 +++--- src/logo/ascii/eurolinux.txt | 18 ++++----- src/logo/ascii/eweos.txt | 12 +++--- src/logo/ascii/fedora_coreos.txt | 24 ++++++------ src/logo/ascii/finnix.txt | 2 +- src/logo/ascii/frugalware.txt | 14 +++---- src/logo/ascii/galliumos.txt | 14 +++---- src/logo/ascii/grombyang.txt | 26 ++++++------- src/logo/ascii/haiku2.txt | 34 ++++++++--------- src/logo/ascii/hamonikr.txt | 12 +++--- src/logo/ascii/hardclanz.txt | 32 ++++++++-------- src/logo/ascii/huayra.txt | 6 +-- src/logo/ascii/hybrid.txt | 32 ++++++++-------- src/logo/ascii/interix.txt | 30 +++++++-------- src/logo/ascii/itc.txt | 20 +++++----- src/logo/ascii/januslinux.txt | 8 ++-- src/logo/ascii/kali.txt | 2 +- src/logo/ascii/kernelos.txt | 16 ++++---- src/logo/ascii/kibojoe.txt | 18 ++++----- src/logo/ascii/korora.txt | 30 +++++++-------- src/logo/ascii/krassos.txt | 38 +++++++++---------- src/logo/ascii/kslinux.txt | 2 +- src/logo/ascii/lainos.txt | 30 +++++++-------- src/logo/ascii/libreelec.txt | 40 ++++++++++---------- src/logo/ascii/linspire.txt | 24 ++++++------ src/logo/ascii/linuxlite_small.txt | 10 ++--- src/logo/ascii/lubuntu.txt | 30 +++++++-------- src/logo/ascii/lunar.txt | 8 ++-- src/logo/ascii/macos3.txt | 32 ++++++++-------- src/logo/ascii/mageia.txt | 2 +- src/logo/ascii/mageia_small.txt | 2 +- src/logo/ascii/magix.txt | 20 +++++----- src/logo/ascii/magpieos.txt | 22 +++++------ src/logo/ascii/meowix.txt | 20 +++++----- src/logo/ascii/nekos.txt | 8 ++-- src/logo/ascii/omnios.txt | 8 ++-- src/logo/ascii/openeuler.txt | 26 ++++++------- src/logo/ascii/openindiana.txt | 20 +++++----- src/logo/ascii/openmamba.txt | 6 +-- src/logo/ascii/opnsense.txt | 10 ++--- src/logo/ascii/orchid.txt | 38 +++++++++---------- src/logo/ascii/orchid_small.txt | 24 ++++++------ src/logo/ascii/panwah.txt | 22 +++++------ src/logo/ascii/parsix.txt | 42 ++++++++++----------- src/logo/ascii/pclinuxos.txt | 14 +++---- src/logo/ascii/pengwin.txt | 30 +++++++-------- src/logo/ascii/pentoo.txt | 20 +++++----- src/logo/ascii/peppermint.txt | 42 ++++++++++----------- src/logo/ascii/pisi.txt | 24 ++++++------ src/logo/ascii/pnm_linux.txt | 36 +++++++++--------- src/logo/ascii/proxmox.txt | 32 ++++++++-------- src/logo/ascii/q4os.txt | 18 ++++----- src/logo/ascii/qubyt.txt | 28 +++++++------- src/logo/ascii/quibian.txt | 4 +- src/logo/ascii/radix.txt | 2 +- src/logo/ascii/regata.txt | 36 +++++++++--------- src/logo/ascii/rhel_old.txt | 4 +- src/logo/ascii/rhino.txt | 24 ++++++------ src/logo/ascii/rosa.txt | 24 ++++++------ src/logo/ascii/sabayon.txt | 24 ++++++------ src/logo/ascii/salentos.txt | 34 ++++++++--------- src/logo/ascii/scientific.txt | 4 +- src/logo/ascii/semc.txt | 8 ++-- src/logo/ascii/septor.txt | 22 +++++------ src/logo/ascii/skiffos.txt | 18 ++++----- src/logo/ascii/soda.txt | 24 ++++++------ src/logo/ascii/swagarch.txt | 20 +++++----- src/logo/ascii/t2_small.txt | 12 +++--- src/logo/ascii/tileos.txt | 40 ++++++++++---------- src/logo/ascii/torizoncore.txt | 38 +++++++++---------- src/logo/ascii/trisquel.txt | 6 +-- src/logo/ascii/twister.txt | 46 +++++++++++------------ src/logo/ascii/ubuntu_cinnamon.txt | 28 +++++++------- src/logo/ascii/ubuntu_gnome.txt | 22 +++++------ src/logo/ascii/ubuntu_old2.txt | 34 ++++++++--------- src/logo/ascii/ubuntu_studio.txt | 36 +++++++++--------- src/logo/ascii/ubuntu_sway.txt | 32 ++++++++-------- src/logo/ascii/ubuntu_touch.txt | 6 +-- src/logo/ascii/ubuntu_unity.txt | 40 ++++++++++---------- src/logo/ascii/ultramarine.txt | 22 +++++------ src/logo/ascii/univention.txt | 28 +++++++------- src/logo/ascii/urukos.txt | 40 ++++++++++---------- src/logo/ascii/uwuntu.txt | 26 ++++++------- src/logo/ascii/vnux.txt | 28 +++++++------- src/logo/ascii/vzlinux.txt | 16 ++++---- src/logo/ascii/xcp_ng.txt | 30 +++++++-------- src/logo/ascii/xenia.txt | 42 ++++++++++----------- src/logo/ascii/xeroarch.txt | 38 +++++++++---------- src/logo/ascii/yiffos.txt | 12 +++--- 136 files changed, 1560 insertions(+), 1561 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 374974ffc4..de4860b78c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,7 +347,6 @@ foreach(file ${LOGO_FILES}) fastfetch_load_text("${file}" content) get_filename_component(file "${file}" NAME_WE) string(TOUPPER "${file}" file) - string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" content "${content}") set(LOGO_BUILTIN_H "${LOGO_BUILTIN_H}#define FASTFETCH_DATATEXT_LOGO_${file} ${content}\n") endforeach() file(GENERATE OUTPUT logo_builtin.h CONTENT "${LOGO_BUILTIN_H}") diff --git a/src/logo/ascii/ada.txt b/src/logo/ascii/ada.txt index f5d7df52cf..8b2d66d645 100644 --- a/src/logo/ascii/ada.txt +++ b/src/logo/ascii/ada.txt @@ -1,21 +1,21 @@ - ${c1}rrrrrraaaaaaaaaaaayyyy - ${c1}xxrrrrrrrraaaaaaaaaaaayyyyyyyyy - ${c1}xxxxxrrrrrrrraaaaaaaaaaaayyyyyyy${c3}yyyyy${c2}yyyyyyyyyy - ${c1}xxxxxxxrrrrrrrraaaaa ${c2}aaaaayyyyyyyyyyyyyyyyyyy - ${c1}xxxxxx${c3}xxx${c1}rrrrrrrraaaa ${c2}aaaaaaayyyyyyyyyyyyyyyyy - ${c1}xxxxxx${c3}xxxxxr${c1}rrrrrrraa ${c2}aaaaaaaaay${c3}yyyyyyyyy${c2}yyyy ${c1}yy - ${c1}xxxxxxx${c3}xxx${c1}xxrrrrrrrra ${c2}aaaaaaaaa${c3}ayyyyyyyyyyyy${c1}yyyyyy - ${c1}xxxxxxxxxxxxrrrrrrrr ${c2}aaaaaaaaaaa${c3}yyyyyyyyyyyy${c1}yyyyyyy -${c1}xxxxxxxxxxxxxrrrrrr ${c2}raaaaaaaaaaaayyy${c3}yyyyyyyy${c1}yyyyyy${c1}yyy -${c1}xxxxxxxxxxxxxrrrrr ${c2}rraaaaaaaaaaaayyyyy${c3}yy${c2}yyyyyy ${c1}yyyyyy -${c1}xxxxxxxx${c3}xxxx${c1}xrrrrr${c2}rr${c3}raaaaaaa${c2}aaaaayyyyyyyyyy ${c1}yyyyyyyyy -${c1}xxxxxxx${c3}xxxx${c1}xxrrrrrrr${c3}raaaaaa${c2}aaaaaayyyyyyy ${c1}yyyyyyyyyyyy -${c1}xxxxxxx${c3}xxx${c1}xxxrrrrrrrr${c3}aaaaaa${c2}aaaaaayyyy ${c1}yyyyyyyyyyyyyy - ${c1}xxxxxxxxxxxxrrrrrrrra ${c2}aaaaaaaaaay ${c1}yyyyyyyyyyyyyyyy - ${c1}xxxxxxxxxxxrrrrrrr ${c2}aaaaaaaaaaaayyyy${c1}yyyyyyyyyyyyy - ${c1}xxxxxxx${c3}xxxrr${c1}rrrr ${c2}raaaaaaaaaaaa ${c1}yyyyyyyyyyyyyyy - ${c1}xxxxxxxxrrrr ${c2}rrraaaaaaaaa ${c1}aayyyyyyyyyyyyyy - ${c1}xxxxxxrrrrrrr ${c2}aaaaaa ${c1}aaaayyyyyyyyyyyy - ${c1}xxxrrrrrr ${c2}raaa ${c1}aaaaaaayyyyyyyyy - ${c1}rrrr ${c2}rr ${c1}aaaaaaaaaayyyyyy - ${c2}r ${c1}aaaaaaaaaa \ No newline at end of file + $1rrrrrraaaaaaaaaaaayyyy + $1xxrrrrrrrraaaaaaaaaaaayyyyyyyyy + $1xxxxxrrrrrrrraaaaaaaaaaaayyyyyyy$3yyyyy$2yyyyyyyyyy + $1xxxxxxxrrrrrrrraaaaa $2aaaaayyyyyyyyyyyyyyyyyyy + $1xxxxxx$3xxx$1rrrrrrrraaaa $2aaaaaaayyyyyyyyyyyyyyyyy + $1xxxxxx$3xxxxxr$1rrrrrrraa $2aaaaaaaaay$3yyyyyyyyy$2yyyy $1yy + $1xxxxxxx$3xxx$1xxrrrrrrrra $2aaaaaaaaa$3ayyyyyyyyyyyy$1yyyyyy + $1xxxxxxxxxxxxrrrrrrrr $2aaaaaaaaaaa$3yyyyyyyyyyyy$1yyyyyyy +$1xxxxxxxxxxxxxrrrrrr $2raaaaaaaaaaaayyy$3yyyyyyyy$1yyyyyy$1yyy +$1xxxxxxxxxxxxxrrrrr $2rraaaaaaaaaaaayyyyy$3yy$2yyyyyy $1yyyyyy +$1xxxxxxxx$3xxxx$1xrrrrr$2rr$3raaaaaaa$2aaaaayyyyyyyyyy $1yyyyyyyyy +$1xxxxxxx$3xxxx$1xxrrrrrrr$3raaaaaa$2aaaaaayyyyyyy $1yyyyyyyyyyyy +$1xxxxxxx$3xxx$1xxxrrrrrrrr$3aaaaaa$2aaaaaayyyy $1yyyyyyyyyyyyyy + $1xxxxxxxxxxxxrrrrrrrra $2aaaaaaaaaay $1yyyyyyyyyyyyyyyy + $1xxxxxxxxxxxrrrrrrr $2aaaaaaaaaaaayyyy$1yyyyyyyyyyyyy + $1xxxxxxx$3xxxrr$1rrrr $2raaaaaaaaaaaa $1yyyyyyyyyyyyyyy + $1xxxxxxxxrrrr $2rrraaaaaaaaa $1aayyyyyyyyyyyyyy + $1xxxxxxrrrrrrr $2aaaaaa $1aaaayyyyyyyyyyyy + $1xxxrrrrrr $2raaa $1aaaaaaayyyyyyyyy + $1rrrr $2rr $1aaaaaaaaaayyyyyy + $2r $1aaaaaaaaaa \ No newline at end of file diff --git a/src/logo/ascii/adelie.txt b/src/logo/ascii/adelie.txt index 3185950e1a..923072f178 100644 --- a/src/logo/ascii/adelie.txt +++ b/src/logo/ascii/adelie.txt @@ -1,16 +1,16 @@ - ${c3} ,-^-___ -${c3} /\\\/// -${c2}refined.${c1} /\\\\// -${c2}reliable.${c1} /\\\/// -${c2}ready.${c1} /\\/////\ + $3 ,-^-___ +$3 /\\\/// +$2refined.$1 /\\\\// +$2reliable.$1 /\\\/// +$2ready.$1 /\\/////\ __///\\\\/////\ -${c3} _//////\\\\\\\//// -${c1} ///////${c3}\\\\\\\\\\// - //////${c1}\\\\\/ +$3 _//////\\\\\\\//// +$1 ///////$3\\\\\\\\\\// + //////$1\\\\\/ /////\\\\\/ - /////${c3}\\\\/ + /////$3\\\\/ /\\///\\\/ - /\\\/${c1}\\/ + /\\\/$1\\/ /\\\\// ////// - /// ${c3}\\\\\ \ No newline at end of file + /// $3\\\\\ \ No newline at end of file diff --git a/src/logo/ascii/afterglow.txt b/src/logo/ascii/afterglow.txt index 40127217d5..6b8bbed4bf 100644 --- a/src/logo/ascii/afterglow.txt +++ b/src/logo/ascii/afterglow.txt @@ -1,15 +1,15 @@ - ${c2}. - ${c1}. ${c2}.{! - ${c1}.L! ${c2}J@||* - ${c1}gJJJJL` ${c2}g@FFS" - ${c1},@FFFJF`${c2}_g@@LLP` - ${c1}_@FFFFF`${c2}_@@@@@P` ${c4}. - ${c1}J@@@LLF ${c2}_@@@@@P` ${c4}.J! - ${c1}g@@@@@" ${c2}_@@@@@P`${c3}. ${c4}.L|||* -${c1}g@@@@M" ${c2}"VP`${c3}.L! ${c4}<@JJJJ` - ${c1}"@N" ${c3}:||||! ${c4}JFFFFS" - ${c3}.{JJ||F`${c4}_gFFFF@' - ${c3}.@FJJJF`${c4},@LFFFF` - ${c3}_@FFFFF ${c4}VLLLP` - ${c3}J@@LL@" ${c4}`" - ${c3}V@@" \ No newline at end of file + $2. + $1. $2.{! + $1.L! $2J@||* + $1gJJJJL` $2g@FFS" + $1,@FFFJF`$2_g@@LLP` + $1_@FFFFF`$2_@@@@@P` $4. + $1J@@@LLF $2_@@@@@P` $4.J! + $1g@@@@@" $2_@@@@@P`$3. $4.L|||* +$1g@@@@M" $2"VP`$3.L! $4<@JJJJ` + $1"@N" $3:||||! $4JFFFFS" + $3.{JJ||F`$4_gFFFF@' + $3.@FJJJF`$4,@LFFFF` + $3_@FFFFF $4VLLLP` + $3J@@LL@" $4`" + $3V@@" \ No newline at end of file diff --git a/src/logo/ascii/alpine2_small.txt b/src/logo/ascii/alpine2_small.txt index 723575064a..65be837c17 100644 --- a/src/logo/ascii/alpine2_small.txt +++ b/src/logo/ascii/alpine2_small.txt @@ -1,6 +1,6 @@ -${c1} /\ /\ - /${c2}/ ${c1}\ \ - /${c2}// ${c1}\ \ -/${c2}// ${c1}\ \ -${c2}// ${c1}\ \ +$1 /\ /\ + /$2/ $1\ \ + /$2// $1\ \ +/$2// $1\ \ +$2// $1\ \ \ \ No newline at end of file diff --git a/src/logo/ascii/amogos.txt b/src/logo/ascii/amogos.txt index 99c759a44a..8f79c3a183 100644 --- a/src/logo/ascii/amogos.txt +++ b/src/logo/ascii/amogos.txt @@ -1,9 +1,9 @@ ___________ / \ - / ${c2}______${c1} \ - / ${c2}/ \${c1} \ - | ${c2}( )${c1} \ - / ${c2}\______/${c1} | + / $2______$1 \ + / $2/ \$1 \ + | $2( )$1 \ + / $2\______/$1 | | | / \ | | diff --git a/src/logo/ascii/anarchy.txt b/src/logo/ascii/anarchy.txt index d0f5a14025..75456bd7f1 100644 --- a/src/logo/ascii/anarchy.txt +++ b/src/logo/ascii/anarchy.txt @@ -1,28 +1,28 @@ - ${c2}..${c1} - ${c2}..${c1} - ${c2}:..${c1} - ${c2}:+++.${c1} - .:::++${c2}++++${c1}+::. - .:+######${c2}++++${c1}######+:. - .+#########${c2}+++++${c1}##########:. - .+##########${c2}+++++++${c1}##${c2}+${c1}#########+. - +###########${c2}+++++++++${c1}############: - +##########${c2}++++++${c1}#${c2}++++${c1}#${c2}+${c1}###########+ - +###########${c2}+++++${c1}###${c2}++++${c1}#${c2}+${c1}###########+ - :##########${c2}+${c1}#${c2}++++${c1}####${c2}++++${c1}#${c2}+${c1}############: - ###########${c2}+++++${c1}#####${c2}+++++${c1}#${c2}+${c1}###${c2}++${c1}######+ -.##########${c2}++++++${c1}#####${c2}++++++++++++${c1}#######. -.##########${c2}+++++++++++++++++++${c1}###########. - #####${c2}++++++++++++++${c1}###${c2}++++++++${c1}#########+ - :###${c2}++++++++++${c1}#########${c2}+++++++${c1}#########: - +######${c2}+++++${c1}##########${c2}++++++++${c1}#######+ - +####${c2}+++++${c1}###########${c2}+++++++++${c1}#####+ - :##${c2}++++++${c1}############${c2}++++++++++${c1}##: - .${c2}++++++${c1}#############${c2}++++++++++${c1}+. - :${c2}++++${c1}###############${c2}+++++++${c1}:: - .${c2}++. .:+${c1}##############${c2}+++++++${c1}.. - ${c2}.:.${c1} ..::++++++::..:${c2}++++${c1}+. - ${c2}.${c1} ${c2}.:+++${c1}. - ${c2}.:${c1}: - ${c2}..${c1} - ${c2}..${c1} \ No newline at end of file + $2..$1 + $2..$1 + $2:..$1 + $2:+++.$1 + .:::++$2++++$1+::. + .:+######$2++++$1######+:. + .+#########$2+++++$1##########:. + .+##########$2+++++++$1##$2+$1#########+. + +###########$2+++++++++$1############: + +##########$2++++++$1#$2++++$1#$2+$1###########+ + +###########$2+++++$1###$2++++$1#$2+$1###########+ + :##########$2+$1#$2++++$1####$2++++$1#$2+$1############: + ###########$2+++++$1#####$2+++++$1#$2+$1###$2++$1######+ +.##########$2++++++$1#####$2++++++++++++$1#######. +.##########$2+++++++++++++++++++$1###########. + #####$2++++++++++++++$1###$2++++++++$1#########+ + :###$2++++++++++$1#########$2+++++++$1#########: + +######$2+++++$1##########$2++++++++$1#######+ + +####$2+++++$1###########$2+++++++++$1#####+ + :##$2++++++$1############$2++++++++++$1##: + .$2++++++$1#############$2++++++++++$1+. + :$2++++$1###############$2+++++++$1:: + .$2++. .:+$1##############$2+++++++$1.. + $2.:.$1 ..::++++++::..:$2++++$1+. + $2.$1 $2.:+++$1. + $2.:$1: + $2..$1 + $2..$1 \ No newline at end of file diff --git a/src/logo/ascii/antergos.txt b/src/logo/ascii/antergos.txt index 81e2b71f1b..f7b0ebaf1f 100644 --- a/src/logo/ascii/antergos.txt +++ b/src/logo/ascii/antergos.txt @@ -1,19 +1,19 @@ -${c2} `.-/::/-`` +$2 `.-/::/-`` .-/osssssssso/. :osyysssssssyyys+- `.+yyyysssssssssyyyyy+. `/syyyyyssssssssssyyyyys-` - `/yhyyyyysss${c1}++${c2}ssosyyyyhhy/` - .ohhhyyyys${c1}o++/+o${c2}so${c1}+${c2}syy${c1}+${c2}shhhho. - .shhhhys${c1}oo++//+${c2}sss${c1}+++${c2}yyy${c1}+s${c2}hhhhs. - -yhhhhs${c1}+++++++o${c2}ssso${c1}+++${c2}yyy${c1}s+o${c2}hhddy: - -yddhhy${c1}o+++++o${c2}syyss${c1}++++${c2}yyy${c1}yooy${c2}hdddy- - .yddddhs${c1}o++o${c2}syyyyys${c1}+++++${c2}yyhh${c1}sos${c2}hddddy` -`odddddhyosyhyyyyyy${c1}++++++${c2}yhhhyosddddddo -.dmdddddhhhhhhhyyyo${c1}+++++${c2}shhhhhohddddmmh. -ddmmdddddhhhhhhhso${c1}++++++${c2}yhhhhhhdddddmmdy -dmmmdddddddhhhyso${c1}++++++${c2}shhhhhddddddmmmmh --dmmmdddddddhhys${c1}o++++o${c2}shhhhdddddddmmmmd- + `/yhyyyyysss$1++$2ssosyyyyhhy/` + .ohhhyyyys$1o++/+o$2so$1+$2syy$1+$2shhhho. + .shhhhys$1oo++//+$2sss$1+++$2yyy$1+s$2hhhhs. + -yhhhhs$1+++++++o$2ssso$1+++$2yyy$1s+o$2hhddy: + -yddhhy$1o+++++o$2syyss$1++++$2yyy$1yooy$2hdddy- + .yddddhs$1o++o$2syyyyys$1+++++$2yyhh$1sos$2hddddy` +`odddddhyosyhyyyyyy$1++++++$2yhhhyosddddddo +.dmdddddhhhhhhhyyyo$1+++++$2shhhhhohddddmmh. +ddmmdddddhhhhhhhso$1++++++$2yhhhhhhdddddmmdy +dmmmdddddddhhhyso$1++++++$2shhhhhddddddmmmmh +-dmmmdddddddhhys$1o++++o$2shhhhdddddddmmmmd- .smmmmddddddddhhhhhhhhhdddddddddmmmms. `+ydmmmdddddddddddddddddddmmmmdy/. `.:+ooyyddddddddddddyyso+:.` \ No newline at end of file diff --git a/src/logo/ascii/aoscos.txt b/src/logo/ascii/aoscos.txt index c0a0255a9d..3df0782805 100644 --- a/src/logo/ascii/aoscos.txt +++ b/src/logo/ascii/aoscos.txt @@ -1,17 +1,17 @@ - ${c2}__ - ${c2}gpBBBBBBBBBP - ${c2}_gBBBBBBBBBRP - ${c2}4BBBBBBBBRP ${c4},_____ - ${c2}`"" ${c4}_g@@@@@@@@@@@@@%g> - ${c4}__@@@@@@@@@@@@@@@@P" ${c1}___ - ${c4}_g@@@@@@@@@@@@@@@N"` ${c1}_gN@@@@@N^ - ${c4}_w@@@@@@@@@@@@@@@@P" ${c1}_g@@@@@@@P" - ${c4}_g@@@@@@@@@@@@@@@N"` ${c1}VMNN@NNNM^` -${c4}^MMM@@@@@@@@@@@MP" ${c3},ggppww__ - ${c4}`""""" ${c3}_wNNNNNNNNNNNNNNNNNNN - ${c3}_gBNNNNNNNNNNNNNNNNNP" - ${c3}_wNNNNNNNNNNNNNNNNNNMP` - ${c3}_gBNNNNNNNNNNNNNNNNNP" - ${c3}_wNNNNNNNNNNNNNNNNNNNM^ - ${c3}""Y^^MNNNNNNNNNNNNP` - ${c3}`""""""" \ No newline at end of file + $2__ + $2gpBBBBBBBBBP + $2_gBBBBBBBBBRP + $24BBBBBBBBRP $4,_____ + $2`"" $4_g@@@@@@@@@@@@@%g> + $4__@@@@@@@@@@@@@@@@P" $1___ + $4_g@@@@@@@@@@@@@@@N"` $1_gN@@@@@N^ + $4_w@@@@@@@@@@@@@@@@P" $1_g@@@@@@@P" + $4_g@@@@@@@@@@@@@@@N"` $1VMNN@NNNM^` +$4^MMM@@@@@@@@@@@MP" $3,ggppww__ + $4`""""" $3_wNNNNNNNNNNNNNNNNNNN + $3_gBNNNNNNNNNNNNNNNNNP" + $3_wNNNNNNNNNNNNNNNNNNMP` + $3_gBNNNNNNNNNNNNNNNNNP" + $3_wNNNNNNNNNNNNNNNNNNNM^ + $3""Y^^MNNNNNNNNNNNNP` + $3`""""""" \ No newline at end of file diff --git a/src/logo/ascii/aoscosretro.txt b/src/logo/ascii/aoscosretro.txt index 7f563d68ff..88e0ea8f98 100644 --- a/src/logo/ascii/aoscosretro.txt +++ b/src/logo/ascii/aoscosretro.txt @@ -1,18 +1,18 @@ -${c2} ......... +$2 ......... ................... - .....................${c1}################${c2} - .............. ....${c1}################${c2} -.............. ...${c1}################${c2} -............. ..${c1}****************${c2} -............ . .${c1}****************${c2} -........... ... ${c1}................${c2} -.......... ..... ${c1}...............${c2} + .....................$1################$2 + .............. ....$1################$2 +.............. ...$1################$2 +............. ..$1****************$2 +............ . .$1****************$2 +........... ... $1................$2 +.......... ..... $1...............$2 ......... ....... ... - .${c3}...... ${c2}. - ${c3}..... .....${c2}.... ${c4}........... - ${c3}.... ......${c2}. ${c4}........... - ${c3}... ....... ${c4}........... - ${c3}................ ${c4}*********** - ${c3}................ ${c4}########### - ${c3}**************** - ${c3}################ \ No newline at end of file + .$3...... $2. + $3..... .....$2.... $4........... + $3.... ......$2. $4........... + $3... ....... $4........... + $3................ $4*********** + $3................ $4########### + $3**************** + $3################ \ No newline at end of file diff --git a/src/logo/ascii/aoscosretro_small.txt b/src/logo/ascii/aoscosretro_small.txt index 604f920490..cf8ec45861 100644 --- a/src/logo/ascii/aoscosretro_small.txt +++ b/src/logo/ascii/aoscosretro_small.txt @@ -1,9 +1,9 @@ -${c2} _____ ${c1}_____${c2} - -' '-${c1}| |${c2} - / ___ ${c1}| |${c2} -| / _ \${c1}|_____|${c2} +$2 _____ $1_____$2 + -' '-$1| |$2 + / ___ $1| |$2 +| / _ \$1|_____|$2 ' / /_\ \ - \ / _____ \${c4}___ - ${c3}|${c2}/_/ ${c3}| ${c4}| | - ${c3}| | ${c4}|___| - ${c3}|_____| \ No newline at end of file + \ / _____ \$4___ + $3|$2/_/ $3| $4| | + $3| | $4|___| + $3|_____| \ No newline at end of file diff --git a/src/logo/ascii/arch_old.txt b/src/logo/ascii/arch_old.txt index 010050afdb..a0391b7f5a 100644 --- a/src/logo/ascii/arch_old.txt +++ b/src/logo/ascii/arch_old.txt @@ -2,15 +2,15 @@ _=(SDGJT=_ _GTDJHGGFCVS) ,GTDJGGDTDFBGX0 -${c1} JDJDIJHRORVFSBSVL${c2}-=+=,_ -${c1} IJFDUFHJNXIXCDXDSV,${c2} "DEBL -${c1} [LKDSDJTDU=OUSCSBFLD.${c2} '?ZWX, -${c1} ,LMDSDSWH' `DCBOSI${c2} DRDS], -${c1} SDDFDFH' !YEWD,${c2} )HDROD -${c1} !KMDOCG &GSU|${c2}\_GFHRGO\' -${c1} HKLSGP'${c2} __${c1}\TKM0${c2}\GHRBV)' -${c1}JSNRVW'${c2} __+MNAEC${c1}\IOI,${c2}\BN' -${c1}HELK['${c2} __,=OFFXCBGHC${c1}\FD) -${c1}?KGHE ${c2}\_-#DASDFLSV='${c1} 'EF +$1 JDJDIJHRORVFSBSVL$2-=+=,_ +$1 IJFDUFHJNXIXCDXDSV,$2 "DEBL +$1 [LKDSDJTDU=OUSCSBFLD.$2 '?ZWX, +$1 ,LMDSDSWH' `DCBOSI$2 DRDS], +$1 SDDFDFH' !YEWD,$2 )HDROD +$1 !KMDOCG &GSU|$2\_GFHRGO\' +$1 HKLSGP'$2 __$1\TKM0$2\GHRBV)' +$1JSNRVW'$2 __+MNAEC$1\IOI,$2\BN' +$1HELK['$2 __,=OFFXCBGHC$1\FD) +$1?KGHE $2\_-#DASDFLSV='$1 'EF 'EHTI !H `0F' '! \ No newline at end of file diff --git a/src/logo/ascii/archcraft.txt b/src/logo/ascii/archcraft.txt index f0126e777e..1cebab967a 100644 --- a/src/logo/ascii/archcraft.txt +++ b/src/logo/ascii/archcraft.txt @@ -1,20 +1,20 @@ -${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢰⡆${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢠⣿⣿⡄${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⡀${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣷⡀${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⣿⣷${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢼⣿⣿⣿⣿⣿⣿⣿⣿⣧${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣤⣈⠻⢿⣿⣿⣿⣿⣿⣿⣧${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣮⣿⣿⣿⣿⣿⣿⣿⣧${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c3}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c4}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ -${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⡿⣿⣿⡟${c6}⠄⠄${c1}⠸⣿⣿⡿⣿⣿⣿⣿⣿⣷⡀${c6}⠄⠄⠄⠄⠄⠄⠄⠄ -${c1}⠄⠄⠄⠄⠄⠄⠄⠄${c1}⣼⣿⣿⣿⣿⣿⡏${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠈⣿⣿⣿⣿⣿⣷⡀${c1}⠄⠄⠄⠄⠄⠄⠄ -${c2}⠄⠄⠄⠄⠄⠄${c1}⢀⣼⣿⣿⣿⣿⣿⣿⡗${c2}⠄⠄⠄${c1}⢀⣠⣤⣀⠄⠄⠄${c1}⠸⣿⣿⣿⣿⣿⣿⣷⡀${c2}⠄⠄⠄⠄⠄⠄ -${c3}⠄⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⣿⣿⡏⠁${c3}⠄⠄⠄${c1}⢠⣿⣿⣿⣿⡇${c3}⠄⠄⠄⠄${c1}⢙⣿⣿⣻⠿⣿⣷⡀${c3}⠄⠄⠄⠄⠄ -${c4}⠄⠄⠄⠄${c1}⢀⣾⣿⣿⣿⣿⣿⣿⣷⣤⡀${c4}⠄⠄⠄${c1}⠻⣿⣿⡿⠃${c4}⠄⠄⠄${c1}⢀⣼⣿⣿⣿⣿⣦⣌⠙⠄${c4}⠄⠄⠄⠄ -${c5}⠄⠄⠄${c1}⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏${c5}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⢿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀${c5}⠄⠄⠄ -${c6}⠄⠄${c1}⢠⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠁${c6}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⡄${c6}⠄⠄ -${c1}⠄${c1}⣠⣿⣿⣿⣿⠿⠛⠋⠁${c1}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠉⠙⠻⢿⣿⣿⣿⣿⣆${c1}⠄ -${c1}⡰⠟⠛⠉⠁${c2}⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄${c1}⠉⠙⠛⠿⢆ \ No newline at end of file +$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⢰⡆$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$2⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⢠⣿⣿⡄$2⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$3⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⢀⣾⣿⣿⣿⡀$3⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$4⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣼⣿⣿⣿⣿⣷⡀$4⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$5⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣼⣿⣿⣿⣿⣿⣿⣷$5⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$6⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⢼⣿⣿⣿⣿⣿⣿⣿⣿⣧$6⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣰⣤⣈⠻⢿⣿⣿⣿⣿⣿⣿⣧$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$2⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣰⣿⣿⣿⣿⣮⣿⣿⣿⣿⣿⣿⣿⣧$2⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$3⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧$3⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$4⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧$4⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$5⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧$5⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄ +$6⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⣼⣿⣿⣿⣿⣿⡿⣿⣿⡟$6⠄⠄$1⠸⣿⣿⡿⣿⣿⣿⣿⣿⣷⡀$6⠄⠄⠄⠄⠄⠄⠄⠄ +$1⠄⠄⠄⠄⠄⠄⠄⠄$1⣼⣿⣿⣿⣿⣿⡏$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⠈⣿⣿⣿⣿⣿⣷⡀$1⠄⠄⠄⠄⠄⠄⠄ +$2⠄⠄⠄⠄⠄⠄$1⢀⣼⣿⣿⣿⣿⣿⣿⡗$2⠄⠄⠄$1⢀⣠⣤⣀⠄⠄⠄$1⠸⣿⣿⣿⣿⣿⣿⣷⡀$2⠄⠄⠄⠄⠄⠄ +$3⠄⠄⠄⠄⠄$1⢀⣾⣿⣿⣿⣿⣿⡏⠁$3⠄⠄⠄$1⢠⣿⣿⣿⣿⡇$3⠄⠄⠄⠄$1⢙⣿⣿⣻⠿⣿⣷⡀$3⠄⠄⠄⠄⠄ +$4⠄⠄⠄⠄$1⢀⣾⣿⣿⣿⣿⣿⣿⣷⣤⡀$4⠄⠄⠄$1⠻⣿⣿⡿⠃$4⠄⠄⠄$1⢀⣼⣿⣿⣿⣿⣦⣌⠙⠄$4⠄⠄⠄⠄ +$5⠄⠄⠄$1⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏$5⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⢿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀$5⠄⠄⠄ +$6⠄⠄$1⢠⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠁$6⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⠙⠻⣿⣿⣿⣿⣿⣿⣿⣿⡄$6⠄⠄ +$1⠄$1⣠⣿⣿⣿⣿⠿⠛⠋⠁$1⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⠉⠙⠻⢿⣿⣿⣿⣿⣆$1⠄ +$1⡰⠟⠛⠉⠁$2⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄$1⠉⠙⠛⠿⢆ \ No newline at end of file diff --git a/src/logo/ascii/archstrike.txt b/src/logo/ascii/archstrike.txt index 444665a4dc..7fc46d2786 100644 --- a/src/logo/ascii/archstrike.txt +++ b/src/logo/ascii/archstrike.txt @@ -1,17 +1,17 @@ -${c1} * +$1 * **. **** ****** ******* ** ******* **** ******* - ${c1}****${c2}_____${c1}***${c2}/${c1}* - ***${c2}/${c1}*******${c2}//${c1}*** - **${c2}/${c1}********${c2}///${c1}*${c2}/${c1}** - **${c2}/${c1}*******${c2}////${c1}***${c2}/${c1}** - **${c2}/${c1}****${c2}//////.,${c1}****${c2}/${c1}** - ***${c2}/${c1}*****${c2}/////////${c1}**${c2}/${c1}*** - ****${c2}/${c1}**** ${c2}/////${c1}***${c2}/${c1}**** - ******${c2}/${c1}*** ${c2}//// ${c1}**${c2}/${c1}****** - ********${c2}/${c1}* ${c2}/// ${c1}*${c2}/${c1}******** - ,****** ${c2}// ______ / ${c1}******, \ No newline at end of file + $1****$2_____$1***$2/$1* + ***$2/$1*******$2//$1*** + **$2/$1********$2///$1*$2/$1** + **$2/$1*******$2////$1***$2/$1** + **$2/$1****$2//////.,$1****$2/$1** + ***$2/$1*****$2/////////$1**$2/$1*** + ****$2/$1**** $2/////$1***$2/$1**** + ******$2/$1*** $2//// $1**$2/$1****** + ********$2/$1* $2/// $1*$2/$1******** + ,****** $2// ______ / $1******, \ No newline at end of file diff --git a/src/logo/ascii/arco_small.txt b/src/logo/ascii/arco_small.txt index ecbae5a7bc..66fdc5a503 100644 --- a/src/logo/ascii/arco_small.txt +++ b/src/logo/ascii/arco_small.txt @@ -6,6 +6,6 @@ ooooo ooooo ooooo ooooo ooooo ooooo - ooooo ${c2}${c1} - ooooo ${c2}${c1} -ooooo ${c2} \ No newline at end of file + ooooo $2$1 + ooooo $2$1 +ooooo $2 \ No newline at end of file diff --git a/src/logo/ascii/arya.txt b/src/logo/ascii/arya.txt index 5e4342bf1b..a6758e663e 100644 --- a/src/logo/ascii/arya.txt +++ b/src/logo/ascii/arya.txt @@ -1,15 +1,15 @@ -${c1} `oyyy/${c2}-yyyyyy+ -${c1} -syyyy/${c2}-yyyyyy+ -${c1} .syyyyy/${c2}-yyyyyy+ -${c1} :yyyyyy/${c2}-yyyyyy+ -${c1} `/ :yyyyyy/${c2}-yyyyyy+ -${c1} .+s :yyyyyy/${c2}-yyyyyy+ -${c1} .oys :yyyyyy/${c2}-yyyyyy+ -${c1} -oyys :yyyyyy/${c2}-yyyyyy+ -${c1} :syyys :yyyyyy/${c2}-yyyyyy+ -${c1} /syyyys :yyyyyy/${c2}-yyyyyy+ -${c1} +yyyyyys :yyyyyy/${c2}-yyyyyy+ -${c1} .oyyyyyyo. :yyyyyy/${c2}-yyyyyy+ --------- -${c1} .syyyyyy+` :yyyyyy/${c2}-yyyyy+-+syyyyyyyy -${c1} -syyyyyy/ :yyyyyy/${c2}-yyys:.syyyyyyyyyy -${c1}:syyyyyy/ :yyyyyy/${c2}-yyo.:syyyyyyyyyyy \ No newline at end of file +$1 `oyyy/$2-yyyyyy+ +$1 -syyyy/$2-yyyyyy+ +$1 .syyyyy/$2-yyyyyy+ +$1 :yyyyyy/$2-yyyyyy+ +$1 `/ :yyyyyy/$2-yyyyyy+ +$1 .+s :yyyyyy/$2-yyyyyy+ +$1 .oys :yyyyyy/$2-yyyyyy+ +$1 -oyys :yyyyyy/$2-yyyyyy+ +$1 :syyys :yyyyyy/$2-yyyyyy+ +$1 /syyyys :yyyyyy/$2-yyyyyy+ +$1 +yyyyyys :yyyyyy/$2-yyyyyy+ +$1 .oyyyyyyo. :yyyyyy/$2-yyyyyy+ --------- +$1 .syyyyyy+` :yyyyyy/$2-yyyyy+-+syyyyyyyy +$1 -syyyyyy/ :yyyyyy/$2-yyys:.syyyyyyyyyy +$1:syyyyyy/ :yyyyyy/$2-yyo.:syyyyyyyyyyy \ No newline at end of file diff --git a/src/logo/ascii/asteroidos.txt b/src/logo/ascii/asteroidos.txt index 9511b356d5..d7dfca62fd 100644 --- a/src/logo/ascii/asteroidos.txt +++ b/src/logo/ascii/asteroidos.txt @@ -1,17 +1,17 @@ -${c1} *** -${c1} ***** -${c1} ********** -${c1} *************** -${c1} *///****////****////. -${c2} (/////// /////// ///////( -${c2} /(((((//* //, //((((((. -${c2} ((((((((((( ((( (((((((( -${c2} *((((((((((((((((((((((( (((((((( -${c3} (((((#(((((((#((((( ((#((((( -${c3} (#(#(#####(#(#, ####(#(# -${c3} ######### ######## -${c3} /######## ######## -${c4} #######%####### -${c4} (#%%%%%%%# -${c4} %%%%% -${c4} %%% \ No newline at end of file +$1 *** +$1 ***** +$1 ********** +$1 *************** +$1 *///****////****////. +$2 (/////// /////// ///////( +$2 /(((((//* //, //((((((. +$2 ((((((((((( ((( (((((((( +$2 *((((((((((((((((((((((( (((((((( +$3 (((((#(((((((#((((( ((#((((( +$3 (#(#(#####(#(#, ####(#(# +$3 ######### ######## +$3 /######## ######## +$4 #######%####### +$4 (#%%%%%%%# +$4 %%%%% +$4 %%% \ No newline at end of file diff --git a/src/logo/ascii/astra_linux.txt b/src/logo/ascii/astra_linux.txt index aec44eb8e2..f35a66d219 100644 --- a/src/logo/ascii/astra_linux.txt +++ b/src/logo/ascii/astra_linux.txt @@ -1,22 +1,22 @@ AA AaaA - Aa${c2}/\${c1}aA -${c1} Aa${c2}/${c1}aa${c2}\${c1}aA -${c1} Aa${c2}/${c1}aAAa${c2}\${c1}aA -${c1} aA${c2}/${c1}aaAAaa${c2}\${c1}Aa -${c1} aA${c2}/${c1}aaAAAAaa${c2}\${c1}Aa -${c1} aaaaaaAAAAa${c2}/${c1}aaAAAAAAaa${c2}\${c1}aAAAAaaaaa -${c1}aAAa${c2}-----${c1}aaaaaAAAAAAAAAAaaaaa${c2}-----${c1}aAAa -${c1} aAA${c2}\ ${c1}aAAAAAAAAAAAAAAAAAAAAAAa${c2} /${c1}AAa -${c1} aAa${c2}\${c1}aAAA${c2}\${c1}AAAA${c2}\${c1}AAAA${c2}\${c1}AAA${c2}\${c1}AAa${c2}/${c1}aAa -${c1} aAa${c2}\${c1}aA${c2}\\${c1}AAA${c2}\\${c1}AAA${c2}\\${c1}AA${c2}\\/${c1}aAa -${c1} aAA${c2}\${c1}aA${c2}\\${c1}AAA${c2}\\${c1}AAA${c2}\\${c1}Aa${c2}/${c1}AAa -${c1} aA${c2}\${c1}aA${c2}\\${c1}AAA${c2}\\${c1}AAA${c2}\\/${c1}Aa -${c1} aA${c2}/${c1}AA${c2}\\\${c1}AA${c2}\\\${c1}AA${c2}\\\${c1}Aa -${c1} aA${c2}/\${c1}AAa${c2}\\\${c1}Aa${c2}\\\${c1}Aa${c2}\\\${c1}Aa -${c1} aA${c2}/\\${c1}AAa${c2}\\/\${c1}a${c2}\\\${c1}Aa${c2}\\${c1}Aa -${c1} aA${c2}/${c1}a${c2}\\\${c1}Aa${c2}\/${c1}AA${c2}\\\\\${c1}Aa${c2}\\${c1}Aa -${c1} aA${c2}/${c1}aA${c2}\\/${c1}aAa aAa${c2}\\\${c1}Aa${c2}\${c1}Aa -${c1} aA${c2}/\${c1}A${c2}\/${c1}Aa aA${c2}\\${c1}A${c2}\\${c1}Aa -${c1} A${c2}|/${c1}aaAa aAaa${c2}\|${c1}A -${c1} aAaa aaAa \ No newline at end of file + Aa$2/\$1aA +$1 Aa$2/$1aa$2\$1aA +$1 Aa$2/$1aAAa$2\$1aA +$1 aA$2/$1aaAAaa$2\$1Aa +$1 aA$2/$1aaAAAAaa$2\$1Aa +$1 aaaaaaAAAAa$2/$1aaAAAAAAaa$2\$1aAAAAaaaaa +$1aAAa$2-----$1aaaaaAAAAAAAAAAaaaaa$2-----$1aAAa +$1 aAA$2\ $1aAAAAAAAAAAAAAAAAAAAAAAa$2 /$1AAa +$1 aAa$2\$1aAAA$2\$1AAAA$2\$1AAAA$2\$1AAA$2\$1AAa$2/$1aAa +$1 aAa$2\$1aA$2\\$1AAA$2\\$1AAA$2\\$1AA$2\\/$1aAa +$1 aAA$2\$1aA$2\\$1AAA$2\\$1AAA$2\\$1Aa$2/$1AAa +$1 aA$2\$1aA$2\\$1AAA$2\\$1AAA$2\\/$1Aa +$1 aA$2/$1AA$2\\\$1AA$2\\\$1AA$2\\\$1Aa +$1 aA$2/\$1AAa$2\\\$1Aa$2\\\$1Aa$2\\\$1Aa +$1 aA$2/\\$1AAa$2\\/\$1a$2\\\$1Aa$2\\$1Aa +$1 aA$2/$1a$2\\\$1Aa$2\/$1AA$2\\\\\$1Aa$2\\$1Aa +$1 aA$2/$1aA$2\\/$1aAa aAa$2\\\$1Aa$2\$1Aa +$1 aA$2/\$1A$2\/$1Aa aA$2\\$1A$2\\$1Aa +$1 A$2|/$1aaAa aAaa$2\|$1A +$1 aAaa aaAa \ No newline at end of file diff --git a/src/logo/ascii/athena.txt b/src/logo/ascii/athena.txt index dcdbb5d339..bc9626706a 100644 --- a/src/logo/ascii/athena.txt +++ b/src/logo/ascii/athena.txt @@ -1,24 +1,24 @@ -${c1} . .. -${c1} :####: ####. -${c1} .################ -${c1} :################## -${c1}.###################. -${c1}######## ####### -${c1}####### ${c2}####${c1} ##### -${c1}:#######. #### -${c1} ######### ${c2}#${c1} ## # -${c1} ####### ${c2}##${c1} #### -${c1}######## ${c2}####${c1} ####### -${c1}######## ${c2}#####${c1} ######## -${c1}######## ${c2}#######${c1} ####### -${c1} ####### ${c2}########${c1} ####### -${c1} ######## ${c2}#########${c1} ###### -${c1} ######## ${c2}#########${c1} ##### -${c1} ####### ${c2}#########${c1} #### -${c1} ####### ${c2}#########${c1} ## -${c1} ####### ${c2}########${c1} ## -${c1} ###### ${c2}########${c1} # -${c1} ### ${c2}#######${c1} -${c1} ${c2}######${c1} -${c1} ${c2}####${c1} -${c1} ${c2}##${c1} \ No newline at end of file +$1 . .. +$1 :####: ####. +$1 .################ +$1 :################## +$1.###################. +$1######## ####### +$1####### $2####$1 ##### +$1:#######. #### +$1 ######### $2#$1 ## # +$1 ####### $2##$1 #### +$1######## $2####$1 ####### +$1######## $2#####$1 ######## +$1######## $2#######$1 ####### +$1 ####### $2########$1 ####### +$1 ######## $2#########$1 ###### +$1 ######## $2#########$1 ##### +$1 ####### $2#########$1 #### +$1 ####### $2#########$1 ## +$1 ####### $2########$1 ## +$1 ###### $2########$1 # +$1 ### $2#######$1 +$1 $2######$1 +$1 $2####$1 +$1 $2##$1 \ No newline at end of file diff --git a/src/logo/ascii/azos.txt b/src/logo/ascii/azos.txt index 366fb3cb12..e341d3fc8a 100644 --- a/src/logo/ascii/azos.txt +++ b/src/logo/ascii/azos.txt @@ -1,17 +1,17 @@ -${c1} ////. ${c2} ((((( -${c1}//////// ${c2} @(((((((( -${c1}//////// ${c2} @(((((((( -${c1}//////// /////// ${c2} ((((((( @(((((((( -${c1}//////// ///////// ${c2} ((((((((( @(((((((( -${c1}//////// ///////// ${c2} ((((((((( @(((((((( -${c1}//////// ///////// ////// ${c2} (((((( ((((((((( @(((((((( -${c1}//////// ///////// //////// ${c2} (((((((( ((((((((( @(((((((( -${c1}//////// ///////// //////// ${c2} (((((((( ((((((((( @(((((((( -${c1}//////// ///////// //////// ${c2} ((((((( ((((((((( @(((((((( -${c1}//////// ///////// /// ${c2} ( ((((((((( @(((((((( -${c1}//////// ///////// ${c2} ((((((((( @(((((((( -${c1}//////// ///////// ${c2} &(((((((( @(((((((( -${c1}//////// ////// ${c2} @(((( @(((((((( -${c1}//////// ${c2} @(((((((( -${c1}//////// ${c2} @(((((((( -${c1} ///// ${c2} ((((( \ No newline at end of file +$1 ////. $2 ((((( +$1//////// $2 @(((((((( +$1//////// $2 @(((((((( +$1//////// /////// $2 ((((((( @(((((((( +$1//////// ///////// $2 ((((((((( @(((((((( +$1//////// ///////// $2 ((((((((( @(((((((( +$1//////// ///////// ////// $2 (((((( ((((((((( @(((((((( +$1//////// ///////// //////// $2 (((((((( ((((((((( @(((((((( +$1//////// ///////// //////// $2 (((((((( ((((((((( @(((((((( +$1//////// ///////// //////// $2 ((((((( ((((((((( @(((((((( +$1//////// ///////// /// $2 ( ((((((((( @(((((((( +$1//////// ///////// $2 ((((((((( @(((((((( +$1//////// ///////// $2 &(((((((( @(((((((( +$1//////// ////// $2 @(((( @(((((((( +$1//////// $2 @(((((((( +$1//////// $2 @(((((((( +$1 ///// $2 ((((( \ No newline at end of file diff --git a/src/logo/ascii/biglinux.txt b/src/logo/ascii/biglinux.txt index c8457566b8..b61a3a6a91 100644 --- a/src/logo/ascii/biglinux.txt +++ b/src/logo/ascii/biglinux.txt @@ -5,14 +5,14 @@ : xMMMMMW. kMMMMNc lW. :x NMMMMMO ,MMMM0. 'l Xx "lkk" kMMMX .okx, -${c2}.MX .cc;. .xXKx. KMMM: .OMMMMMl +$2.MX .cc;. .xXKx. KMMM: .OMMMMMl :MM' 'KMMMMWK: 0MMMMk xMMM. lWMMMMMMM' cMMN:;xMMMMk::MMO oMMMMX .XMM. .KMMMWOOMMMd 'MMMMMMMMN, NMMx OMMMMl .kM0OMMMMk. ;MMd xMMMMMMd .MMMW :NMMMd .ckKKx' KMc dWMNd. oMMMN lkNMX, oM. ;. ;MMMMx "MM:. cO -${c3} .X. oMMMMW. l. +$3 .X. oMMMMW. l. dMk:..;xWMMMMW, kMMMMMMMMMMX. :XMMMMMMK: diff --git a/src/logo/ascii/blackarch.txt b/src/logo/ascii/blackarch.txt index dfffbcdd7e..440d5f88b0 100644 --- a/src/logo/ascii/blackarch.txt +++ b/src/logo/ascii/blackarch.txt @@ -1,21 +1,21 @@ -${c3} 00 +$3 00 11 - ====${c1} - .${c3}//${c1} - `o${c3}//${c1}: - `+o${c3}//${c1}o: - `+oo${c3}//${c1}oo: - -+oo${c3}//${c1}oo+: - `/:-:+${c3}//${c1}ooo+: - `/+++++${c3}//${c1}+++++: - `/++++++${c3}//${c1}++++++: - `/+++o${c2}ooo${c3}//${c2}ooo${c1}oooo/` -${c2} ${c1}./${c2}ooosssso${c3}//${c2}osssssso${c1}+` -${c2} .oossssso-`${c3}//${c1}`/ossssss+` - -osssssso. ${c3}//${c1} :ssssssso. - :osssssss/ ${c3}//${c1} osssso+++. - /ossssssss/ ${c3}//${c1} +ssssooo/- - `/ossssso+/:- ${c3}//${c1} -:/+osssso+- - `+sso+:-` ${c3}//${c1} `.-/+oso: - `++:. ${c3}//${c1} `-/+/ - .` ${c3}/${c1} `/ \ No newline at end of file + ====$1 + .$3//$1 + `o$3//$1: + `+o$3//$1o: + `+oo$3//$1oo: + -+oo$3//$1oo+: + `/:-:+$3//$1ooo+: + `/+++++$3//$1+++++: + `/++++++$3//$1++++++: + `/+++o$2ooo$3//$2ooo$1oooo/` +$2 $1./$2ooosssso$3//$2osssssso$1+` +$2 .oossssso-`$3//$1`/ossssss+` + -osssssso. $3//$1 :ssssssso. + :osssssss/ $3//$1 osssso+++. + /ossssssss/ $3//$1 +ssssooo/- + `/ossssso+/:- $3//$1 -:/+osssso+- + `+sso+:-` $3//$1 `.-/+oso: + `++:. $3//$1 `-/+/ + .` $3/$1 `/ \ No newline at end of file diff --git a/src/logo/ascii/blackpanther.txt b/src/logo/ascii/blackpanther.txt index f96da9141a..a96f7e63ef 100644 --- a/src/logo/ascii/blackpanther.txt +++ b/src/logo/ascii/blackpanther.txt @@ -1,7 +1,7 @@ -${c3} ........ +$3 ........ .,»╔╗╗╬▄▄╫█▀▓▄▄╬╗╗g≈,. ,j╗╬╣▓▓███████▌;»╙▀▀▀▀█▄▄╗j, - .≈╗╬▓██▀▀▀▀▀╠╙░░»»;:`${c2}``>${c1}▄ ${c3}▐ ▓╫╗⌂, + .≈╗╬▓██▀▀▀▀▀╠╙░░»»;:`$2``>$1▄ $3▐ ▓╫╗⌂, .j╬▓█▀▒░░░░░░░░░»»»;:```` ╙▀█▌╬░, ;╗▓█▄▄███████▀░░»»»»;```` ╓▄▄█▄▄φ ██▌Ñ>. .j╣█████▀▀░░░░░░░░»»╓▄▄¿``▄███████/▄████▓╬U. diff --git a/src/logo/ascii/blankon.txt b/src/logo/ascii/blankon.txt index 8331431b28..a7862e2f70 100644 --- a/src/logo/ascii/blankon.txt +++ b/src/logo/ascii/blankon.txt @@ -1,17 +1,17 @@ -${c2} `./ohdNMMMMNmho+.` ${c1} .+oo:` -${c2} -smMMMMMMMMMMMMMMMMmy-` ${c1}`yyyyy+ -${c2} `:dMMMMMMMMMMMMMMMMMMMMMMd/` ${c1}`yyyyys -${c2} .hMMMMMMMNmhso/++symNMMMMMMMh- ${c1}`yyyyys -${c2} -mMMMMMMms-` -omMMMMMMN-${c1}.yyyyys -${c2}.mMMMMMMy. .yMMMMMMm:${c1}yyyyys -${c2}sMMMMMMy `sMMMMMMh${c1}yyyyys -${c2}NMMMMMN: .NMMMMMN${c1}yyyyys -${c2}MMMMMMm. NMMMMMN${c1}yyyyys -${c2}hMMMMMM+ /MMMMMMN${c1}yyyyys -${c2}:NMMMMMN: :mMMMMMM+${c1}yyyyys -${c2} oMMMMMMNs- .sNMMMMMMs.${c1}yyyyys -${c2} +MMMMMMMNho:.` `.:ohNMMMMMMNo ${c1}`yyyyys -${c2} -hMMMMMMMMNNNmmNNNMMMMMMMMh- ${c1}`yyyyys -${c2} :yNMMMMMMMMMMMMMMMMMMNy:` ${c1}`yyyyys -${c2} .:sdNMMMMMMMMMMNds/. ${c1}`yyyyyo -${c2} `.:/++++/:.` ${c1}:oys+. \ No newline at end of file +$2 `./ohdNMMMMNmho+.` $1 .+oo:` +$2 -smMMMMMMMMMMMMMMMMmy-` $1`yyyyy+ +$2 `:dMMMMMMMMMMMMMMMMMMMMMMd/` $1`yyyyys +$2 .hMMMMMMMNmhso/++symNMMMMMMMh- $1`yyyyys +$2 -mMMMMMMms-` -omMMMMMMN-$1.yyyyys +$2.mMMMMMMy. .yMMMMMMm:$1yyyyys +$2sMMMMMMy `sMMMMMMh$1yyyyys +$2NMMMMMN: .NMMMMMN$1yyyyys +$2MMMMMMm. NMMMMMN$1yyyyys +$2hMMMMMM+ /MMMMMMN$1yyyyys +$2:NMMMMMN: :mMMMMMM+$1yyyyys +$2 oMMMMMMNs- .sNMMMMMMs.$1yyyyys +$2 +MMMMMMMNho:.` `.:ohNMMMMMMNo $1`yyyyys +$2 -hMMMMMMMMNNNmmNNNMMMMMMMMh- $1`yyyyys +$2 :yNMMMMMMMMMMMMMMMMMMNy:` $1`yyyyys +$2 .:sdNMMMMMMMMMMNds/. $1`yyyyyo +$2 `.:/++++/:.` $1:oys+. \ No newline at end of file diff --git a/src/logo/ascii/bluelight.txt b/src/logo/ascii/bluelight.txt index 00765ef193..946bd126d2 100644 --- a/src/logo/ascii/bluelight.txt +++ b/src/logo/ascii/bluelight.txt @@ -2,18 +2,18 @@ oMMMMMMMMMMMMMMMMMMMMMMMMM oMMMMMMMMMMMMMMMMMMMMMMMMM oMMMMMMMMMMMMMMMMMMMMMMMMM - -+++++++++++++++++++++++mM${c2} - ```````````````````````..${c1}dM${c2} - ```````````````````````....${c1}dM${c2} - ```````````````````````......${c1}dM${c2} - ```````````````````````........${c1}dM${c2} - ```````````````````````..........${c1}dM${c2} - ```````````````````````............${c1}dM${c2} -.::::::::::::::::::::::-..............${c1}dM${c2} - `-+yyyyyyyyyyyyyyyyyyyo............${c1}+mMM${c2} - -+yyyyyyyyyyyyyyyyo..........${c1}+mMMMM${c2} - ./syyyyyyyyyyyyo........${c1}+mMMMMMM${c2} - ./oyyyyyyyyyo......${c1}+mMMMMMMMM${c2} - omdyyyyyyo....${c1}+mMMMMMMMMMM${c2} - ${c1}oMMM${c2}mdhyyo..${c1}+mMMMMMMMMMMMM - oNNNNNNm${c2}dso${c1}mMMMMMMMMMMMMMM \ No newline at end of file + -+++++++++++++++++++++++mM$2 + ```````````````````````..$1dM$2 + ```````````````````````....$1dM$2 + ```````````````````````......$1dM$2 + ```````````````````````........$1dM$2 + ```````````````````````..........$1dM$2 + ```````````````````````............$1dM$2 +.::::::::::::::::::::::-..............$1dM$2 + `-+yyyyyyyyyyyyyyyyyyyo............$1+mMM$2 + -+yyyyyyyyyyyyyyyyo..........$1+mMMMM$2 + ./syyyyyyyyyyyyo........$1+mMMMMMM$2 + ./oyyyyyyyyyo......$1+mMMMMMMMM$2 + omdyyyyyyo....$1+mMMMMMMMMMM$2 + $1oMMM$2mdhyyo..$1+mMMMMMMMMMMMM + oNNNNNNm$2dso$1mMMMMMMMMMMMMMM \ No newline at end of file diff --git a/src/logo/ascii/bodhi.txt b/src/logo/ascii/bodhi.txt index d3350dacc6..77b6c9d05a 100644 --- a/src/logo/ascii/bodhi.txt +++ b/src/logo/ascii/bodhi.txt @@ -1,18 +1,18 @@ -${c1}| ${c2},,mmKKKKKKKKWm,, - ${c1}' ${c2},aKKP${c1}LL**********|L*${c2}TKp, - ${c1}t ${c2}aKP${c1}L**``` ```**L${c2}*Kp - IX${c1}EL${c3}L,wwww, ${c1}``*||${c2}Kp - ,#P${c1}L|${c3}KKKpPP@IPPTKmw, ${c1}`*||${c2}K - ,K${c1}LL*${c3}{KKKKKKPPb$KPhpKKPKp ${c1}`||${c2}K - #${c1}PL ${c3}!KKKKKKPhKPPP$KKEhKKKKp ${c1}`||${c2}K -!H${c1}L* ${c3}1KKKKKKKphKbPKKKKKK$KKp ${c1}`|I${c2}W -$$$${c1}bL ${c3}KKKKKKKKBQKhKbKKKKKKKK ${c1}|I${c2}N -$$$${c1}bL ${c3}!KKKKKKKKKKNKKKKKKKPP` ${c1}|I${c2}b -TH${c1}L* ${c3}TKKKKKK##KKKN@KKKK^ ${c1}|I${c2}M - K@${c1}L ${c3}*KKKKKKKKKKKEKE5 ${c1}||${c2}K - `NL${c1}L ${c3}`KKKKKKKKKK"```|L ${c1}||${c2}#P - `K@${c1}LL ${c3}`"**"` ${c1}'. :||${c2}#P - Yp${c1}LL ${c1}' |L${c2}$M` - `Tp${c1}pLL, ,|||${c2}p'L - "Kpp${c1}LL++,., ,,|||$$$${c2}#K* ${c1}'. - ${c2}`"MKWpppppppp#KM"` ${c1}`h, \ No newline at end of file +$1| $2,,mmKKKKKKKKWm,, + $1' $2,aKKP$1LL**********|L*$2TKp, + $1t $2aKP$1L**``` ```**L$2*Kp + IX$1EL$3L,wwww, $1``*||$2Kp + ,#P$1L|$3KKKpPP@IPPTKmw, $1`*||$2K + ,K$1LL*$3{KKKKKKPPb$KPhpKKPKp $1`||$2K + #$1PL $3!KKKKKKPhKPPP$KKEhKKKKp $1`||$2K +!H$1L* $31KKKKKKKphKbPKKKKKK$KKp $1`|I$2W +$$$$1bL $3KKKKKKKKBQKhKbKKKKKKKK $1|I$2N +$$$$1bL $3!KKKKKKKKKKNKKKKKKKPP` $1|I$2b +TH$1L* $3TKKKKKK##KKKN@KKKK^ $1|I$2M + K@$1L $3*KKKKKKKKKKKEKE5 $1||$2K + `NL$1L $3`KKKKKKKKKK"```|L $1||$2#P + `K@$1LL $3`"**"` $1'. :||$2#P + Yp$1LL $1' |L$2$M` + `Tp$1pLL, ,|||$2p'L + "Kpp$1LL++,., ,,|||$$$$2#K* $1'. + $2`"MKWpppppppp#KM"` $1`h, \ No newline at end of file diff --git a/src/logo/ascii/bonsai.txt b/src/logo/ascii/bonsai.txt index 974ee9c223..994b200877 100644 --- a/src/logo/ascii/bonsai.txt +++ b/src/logo/ascii/bonsai.txt @@ -1,15 +1,15 @@ -${c2} ,####, - ${c2}#######, ${c2},#####, - ${c2}#####',# ${c2}'###### - ${c2}''###'${c3}';,,,'${c2}###' - ${c3} ,; '''' - ${c3} ;;; ${c2},#####, - ${c3} ;;;' ,,;${c2};;### - ${c3} ';;;;''${c2}'####' - ${c3} ;;; - ${c3} ,.;;';'',,, - ${c3} ' ' -${c1} # +$2 ,####, + $2#######, $2,#####, + $2#####',# $2'###### + $2''###'$3';,,,'$2###' + $3 ,; '''' + $3 ;;; $2,#####, + $3 ;;;' ,,;$2;;### + $3 ';;;;''$2'####' + $3 ;;; + $3 ,.;;';'',,, + $3 ' ' +$1 # # O ##, ,##,',##, ,## ,#, , # # # # #''# #,, # # # diff --git a/src/logo/ascii/calculate.txt b/src/logo/ascii/calculate.txt index e005d19e8e..7ac7bc88ff 100644 --- a/src/logo/ascii/calculate.txt +++ b/src/logo/ascii/calculate.txt @@ -1,7 +1,7 @@ ...... ,,+++++++,. - .,,,....,,,${c2}+**+,,.${c1} - ............,${c2}++++,,,${c1} + .,,,....,,,$2+**+,,.$1 + ............,$2++++,,,$1 ............... ......,,,........ .....+*#####+,,,*+. @@ -15,6 +15,6 @@ ..... ..+##***#################*. .,.*#*****##############*. ..,,*********#####****+. - ${c2}.,++*****+++${c1}*****************${c2}+++++,.${c1} - ${c2},++++++**+++++${c1}***********${c2}+++++++++,${c1} - ${c2}.,,,,++++,.. .,,,,,.....,+++,.,,${c1} \ No newline at end of file + $2.,++*****+++$1*****************$2+++++,.$1 + $2,++++++**+++++$1***********$2+++++++++,$1 + $2.,,,,++++,.. .,,,,,.....,+++,.,,$1 \ No newline at end of file diff --git a/src/logo/ascii/chapeau.txt b/src/logo/ascii/chapeau.txt index d9739d00d9..f96d531cab 100644 --- a/src/logo/ascii/chapeau.txt +++ b/src/logo/ascii/chapeau.txt @@ -1,18 +1,18 @@ .-/-. ////////. - ////////${c2}y+${c1}//. - ////////${c2}mMN${c1}/////. - ////////${c2}mMN+${c1}////////. + ////////$2y+$1//. + ////////$2mMN$1/////. + ////////$2mMN+$1////////. ////////////////////////. - /////////+${c2}shhddhyo${c1}+////////. - ////////${c2}ymMNmdhhdmNNdo${c1}///////. -///////+${c2}mMms${c1}////////${c2}hNMh${c1}///////. -///////${c2}NMm+${c1}//////////${c2}sMMh${c1}/////// -//////${c2}oMMNmmmmmmmmmmmmMMm${c1}/////// -//////${c2}+MMmssssssssssssss+${c1}/////// -`//////${c2}yMMy${c1}//////////////////// - `//////${c2}smMNhso++oydNm${c1}//////// - `///////${c2}ohmNMMMNNdy+${c1}/////// - `//////////${c2}++${c1}////////// + /////////+$2shhddhyo$1+////////. + ////////$2ymMNmdhhdmNNdo$1///////. +///////+$2mMms$1////////$2hNMh$1///////. +///////$2NMm+$1//////////$2sMMh$1/////// +//////$2oMMNmmmmmmmmmmmmMMm$1/////// +//////$2+MMmssssssssssssss+$1/////// +`//////$2yMMy$1//////////////////// + `//////$2smMNhso++oydNm$1//////// + `///////$2ohmNMMMNNdy+$1/////// + `//////////$2++$1////////// `////////////////. -////////- \ No newline at end of file diff --git a/src/logo/ascii/chimera_linux.txt b/src/logo/ascii/chimera_linux.txt index c66b6db795..d0bc304864 100644 --- a/src/logo/ascii/chimera_linux.txt +++ b/src/logo/ascii/chimera_linux.txt @@ -1,18 +1,18 @@ -${c3}ddddddddddddddc ${c1},cc: -${c3}ddddddddddddddc ${c1},cc: -${c3}ddddddddddddddd ${c1},cc: -${c3}ddddddddddddl:' ${c1},cc: -${c3}dddddddddl' ${c1}..;cc: -${c3}dddddddo. ${c1},:cccccc: -${c3}ddddddl ${c1},ccc:''''' -${c3}dddddo. ${c1};ccc. ............ +$3ddddddddddddddc $1,cc: +$3ddddddddddddddc $1,cc: +$3ddddddddddddddd $1,cc: +$3ddddddddddddl:' $1,cc: +$3dddddddddl' $1..;cc: +$3dddddddo. $1,:cccccc: +$3ddddddl $1,ccc:''''' +$3dddddo. $1;ccc. ............ .ccc. cccccccccccc -${c2}...... ${c1}.ccc. .ccc''''''''' -${c2}OOOOOk. ${c1};ccc. .ccc; ...... -${c2}OOOOOOd ${c1}'ccc:,....,:ccc' ${c4}coooooo -${c2}OOOOOOOx. ${c1}':cccccccc:' ${c4}.looooooo -${c2}OOOOOOOOOd, ${c1}`'''` ${c4}.coooooooo -${c2}OOOOOOOOOOOOdc,. ${c4}..,coooooooooooo -${c2}OOOOOOOOOOOOOOOO' ${c4}.oooooooooooooooo -${c2}OOOOOOOOOOOOOOOO' ${c4}.oooooooooooooooo -${c2}OOOOOOOOOOOOOOOO' ${c4}.oooooooooooooooo \ No newline at end of file +$2...... $1.ccc. .ccc''''''''' +$2OOOOOk. $1;ccc. .ccc; ...... +$2OOOOOOd $1'ccc:,....,:ccc' $4coooooo +$2OOOOOOOx. $1':cccccccc:' $4.looooooo +$2OOOOOOOOOd, $1`'''` $4.coooooooo +$2OOOOOOOOOOOOdc,. $4..,coooooooooooo +$2OOOOOOOOOOOOOOOO' $4.oooooooooooooooo +$2OOOOOOOOOOOOOOOO' $4.oooooooooooooooo +$2OOOOOOOOOOOOOOOO' $4.oooooooooooooooo \ No newline at end of file diff --git a/src/logo/ascii/chrom.txt b/src/logo/ascii/chrom.txt index 1f872b0729..d72922ac70 100644 --- a/src/logo/ascii/chrom.txt +++ b/src/logo/ascii/chrom.txt @@ -1,18 +1,18 @@ -${c2} .,:loool:,. +$2 .,:loool:,. .,coooooooooooooc,. .,lllllllllllllllllllll,. ;ccccccccccccccccccccccccc; -${c1} '${c2}ccccccccccccccccccccccccccccc. -${c1} ,oo${c2}c::::::::okO${c5}000${c3}0OOkkkkkkkkkkk: -${c1}.ooool${c2};;;;:x${c5}K0${c4}kxxxxxk${c5}0X${c3}K0000000000. -${c1}:oooool${c2};,;O${c5}K${c4}ddddddddddd${c5}KX${c3}000000000d -${c1}lllllool${c2};l${c5}N${c4}dllllllllllld${c5}N${c3}K000000000 -${c1}lllllllll${c2}o${c5}M${c4}dccccccccccco${c5}W${c3}K000000000 -${c1};cllllllllX${c5}X${c4}c:::::::::c${c5}0X${c3}000000000d -${c1}.ccccllllllO${c5}Nk${c4}c;,,,;cx${c5}KK${c3}0000000000. -${c1} .cccccclllllxOO${c5}OOO${c1}Okx${c3}O0000000000; -${c1} .:ccccccccllllllllo${c3}O0000000OOO, -${c1} ,:ccccccccclllcd${c3}0000OOOOOOl. -${c1} '::ccccccccc${c3}dOOOOOOOkx:. -${c1} ..,::cccc${c3}xOOOkkko;. -${c1} ..,:${c3}dOkxl:. \ No newline at end of file +$1 '$2ccccccccccccccccccccccccccccc. +$1 ,oo$2c::::::::okO$5000$30OOkkkkkkkkkkk: +$1.ooool$2;;;;:x$5K0$4kxxxxxk$50X$3K0000000000. +$1:oooool$2;,;O$5K$4ddddddddddd$5KX$3000000000d +$1lllllool$2;l$5N$4dllllllllllld$5N$3K000000000 +$1lllllllll$2o$5M$4dccccccccccco$5W$3K000000000 +$1;cllllllllX$5X$4c:::::::::c$50X$3000000000d +$1.ccccllllllO$5Nk$4c;,,,;cx$5KK$30000000000. +$1 .cccccclllllxOO$5OOO$1Okx$3O0000000000; +$1 .:ccccccccllllllllo$3O0000000OOO, +$1 ,:ccccccccclllcd$30000OOOOOOl. +$1 '::ccccccccc$3dOOOOOOOkx:. +$1 ..,::cccc$3xOOOkkko;. +$1 ..,:$3dOkxl:. \ No newline at end of file diff --git a/src/logo/ascii/clear_linux.txt b/src/logo/ascii/clear_linux.txt index 2e2d6269da..e3201f466b 100644 --- a/src/logo/ascii/clear_linux.txt +++ b/src/logo/ascii/clear_linux.txt @@ -3,18 +3,18 @@ BBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBBBB BBBBBBBBBBB BBB - BBBBBBBB${c2}YYYYY -${c1} BBBBBBBB${c2}YYYYYY -${c1} BBBBBBBB${c2}YYYYYYY -${c1} BBBBBBBBB${c2}YYYYY${c3}W -${c4} GG${c1}BBBBBBBY${c2}YYYY${c3}WWW -${c4} GGG${c1}BBBBBBB${c2}YY${c3}WWWWWWWW -${c4} GGGGGG${c1}BBBBBB${c3}WWWWWWWW -${c4} GGGGGGGG${c1}BBBB${c3}WWWWWWWW -${c4}GGGGGGGGGGG${c1}BBB${c3}WWWWWWW -${c4}GGGGGGGGGGGGG${c1}B${c3}WWWWWW -${c4}GGGGGGGG${c3}WWWWWWWWWWW -${c4}GG${c3}WWWWWWWWWWWWWWWW + BBBBBBBB$2YYYYY +$1 BBBBBBBB$2YYYYYY +$1 BBBBBBBB$2YYYYYYY +$1 BBBBBBBBB$2YYYYY$3W +$4 GG$1BBBBBBBY$2YYYY$3WWW +$4 GGG$1BBBBBBB$2YY$3WWWWWWWW +$4 GGGGGG$1BBBBBB$3WWWWWWWW +$4 GGGGGGGG$1BBBB$3WWWWWWWW +$4GGGGGGGGGGG$1BBB$3WWWWWWW +$4GGGGGGGGGGGGG$1B$3WWWWWW +$4GGGGGGGG$3WWWWWWWWWWW +$4GG$3WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WWWWWWWWWW WWW \ No newline at end of file diff --git a/src/logo/ascii/clover.txt b/src/logo/ascii/clover.txt index e2ab77296a..bc21d89778 100644 --- a/src/logo/ascii/clover.txt +++ b/src/logo/ascii/clover.txt @@ -7,8 +7,8 @@ `oNMMMNo` `sNMMMMMMNs` `oNMMMNo` `oNMMMMMMMNo` `oNMMNs` `oNMMMMMMMNo` oNMMMMMMMMMMMNo` `sy` `oNMMMMMMMMMMMNo -`sNMMMMMMMMMMMMNo.${c2}oNNs${c1}.oNMMMMMMMMMMMMNs` -`oNMMMMMMMMMMMMNs.${c2}oNNs${c1}.oNMMMMMMMMMMMMNo` +`sNMMMMMMMMMMMMNo.$2oNNs$1.oNMMMMMMMMMMMMNs` +`oNMMMMMMMMMMMMNs.$2oNNs$1.oNMMMMMMMMMMMMNo` oNMMMMMMMMMMMNs` `sy` `oNMMMMMMMMMMMNo `oNMMMMMMMNs` `oNMMNo` `oNMMMMMMMNs` `oNMMMNs` `sNMMMMMMNs` `oNMMMNs` diff --git a/src/logo/ascii/cobalt.txt b/src/logo/ascii/cobalt.txt index dcf4a714ea..4ed0219edc 100644 --- a/src/logo/ascii/cobalt.txt +++ b/src/logo/ascii/cobalt.txt @@ -1,16 +1,16 @@ -${c1} /// -${c1} ,////////////// -${c1} /////////////////////////////// -${c1} ///////////////${c5}***********${c1}////// - ////${c5}***********************${c1}///// - /////${c5}***********************${c1}//// - //////${c5},,,,,,,,,,,,,,,,,,,,,,${c1}/// - //////${c5},,,,,,,,,,,,,,,,,,,,,,,,,${c1}///// - /////${c5},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c1}///// -${c4} *****${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}***** - ******${c3},,,,,,,,,,,,,,,,,,,,,,,,,,,,${c4}***** - *******${c3},,,,,,,,,,,,,,,,,,,,,,,,,${c4}****** - *******${c3}......................${c4}******* - ******${c3}....${c4}*********************** +$1 /// +$1 ,////////////// +$1 /////////////////////////////// +$1 ///////////////$5***********$1////// + ////$5***********************$1///// + /////$5***********************$1//// + //////$5,,,,,,,,,,,,,,,,,,,,,,$1/// + //////$5,,,,,,,,,,,,,,,,,,,,,,,,,$1///// + /////$5,,,,,,,,,,,,,,,,,,,,,,,,,,,,$1///// +$4 *****$3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,$4***** + ******$3,,,,,,,,,,,,,,,,,,,,,,,,,,,,$4***** + *******$3,,,,,,,,,,,,,,,,,,,,,,,,,$4****** + *******$3......................$4******* + ******$3....$4*********************** **************************** ***** \ No newline at end of file diff --git a/src/logo/ascii/condres.txt b/src/logo/ascii/condres.txt index 880f3cff63..10241846da 100644 --- a/src/logo/ascii/condres.txt +++ b/src/logo/ascii/condres.txt @@ -1,17 +1,17 @@ -${c1}syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+${c3}.+. -${c1}`oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+${c3}:++. -${c2}/o${c1}+oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/${c3}oo++. -${c2}/y+${c1}syyyyyyyyyyyyyyyyyyyyyyyyyyyyy${c3}+ooo++. -${c2}/hy+${c1}oyyyhhhhhhhhhhhhhhyyyyyyyyy${c3}+oo+++++. -${c2}/hhh+${c1}shhhhhdddddhhhhhhhyyyyyyy${c3}+oo++++++. -${c2}/hhdd+${c1}oddddddddddddhhhhhyyyys${c3}+oo+++++++. -${c2}/hhddd+${c1}odmmmdddddddhhhhyyyy${c3}+ooo++++++++. -${c2}/hhdddmo${c1}odmmmdddddhhhhhyyy${c3}+oooo++++++++. -${c2}/hdddmmms${c1}/dmdddddhhhhyyys${c3}+oooo+++++++++. -${c2}/hddddmmmy${c1}/hdddhhhhyyyyo${c3}+oooo++++++++++: -${c2}/hhdddmmmmy${c1}:yhhhhyyyyy+${c3}+oooo+++++++++++: -${c2}/hhddddddddy${c1}-syyyyyys+${c3}ooooo++++++++++++: -${c2}/hhhddddddddy${c1}-+yyyy+${c3}/ooooo+++++++++++++: -${c2}/hhhhhdddddhhy${c1}./yo:${c3}+oooooo+++++++++++++/ -${c2}/hhhhhhhhhhhhhy${c1}:-.${c3}+sooooo+++++++++++///: -${c2}:sssssssssssso++${c1}${c3}`:/:--------.```````` \ No newline at end of file +$1syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+$3.+. +$1`oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+$3:++. +$2/o$1+oyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/$3oo++. +$2/y+$1syyyyyyyyyyyyyyyyyyyyyyyyyyyyy$3+ooo++. +$2/hy+$1oyyyhhhhhhhhhhhhhhyyyyyyyyy$3+oo+++++. +$2/hhh+$1shhhhhdddddhhhhhhhyyyyyyy$3+oo++++++. +$2/hhdd+$1oddddddddddddhhhhhyyyys$3+oo+++++++. +$2/hhddd+$1odmmmdddddddhhhhyyyy$3+ooo++++++++. +$2/hhdddmo$1odmmmdddddhhhhhyyy$3+oooo++++++++. +$2/hdddmmms$1/dmdddddhhhhyyys$3+oooo+++++++++. +$2/hddddmmmy$1/hdddhhhhyyyyo$3+oooo++++++++++: +$2/hhdddmmmmy$1:yhhhhyyyyy+$3+oooo+++++++++++: +$2/hhddddddddy$1-syyyyyys+$3ooooo++++++++++++: +$2/hhhddddddddy$1-+yyyy+$3/ooooo+++++++++++++: +$2/hhhhhdddddhhy$1./yo:$3+oooooo+++++++++++++/ +$2/hhhhhhhhhhhhhy$1:-.$3+sooooo+++++++++++///: +$2:sssssssssssso++$1$3`:/:--------.```````` \ No newline at end of file diff --git a/src/logo/ascii/crux_small.txt b/src/logo/ascii/crux_small.txt index 8e202bc1a2..5f597b27b4 100644 --- a/src/logo/ascii/crux_small.txt +++ b/src/logo/ascii/crux_small.txt @@ -1,7 +1,7 @@ ___ - (${c3}.· ${c1}| - (${c2}<> ${c1}| - / ${c3}__ ${c1}\ - ( ${c3}/ \ ${c1}/| -${c2}_${c1}/\ ${c3}__)${c1}/${c2}_${c1}) -${c2}\/${c1}-____${c2}\/ \ No newline at end of file + ($3.· $1| + ($2<> $1| + / $3__ $1\ + ( $3/ \ $1/| +$2_$1/\ $3__)$1/$2_$1) +$2\/$1-____$2\/ \ No newline at end of file diff --git a/src/logo/ascii/cucumber.txt b/src/logo/ascii/cucumber.txt index 0f605dcf3d..e899fb8222 100644 --- a/src/logo/ascii/cucumber.txt +++ b/src/logo/ascii/cucumber.txt @@ -1,20 +1,20 @@ `.-://++++++//:-.` - `:/+//${c2}::--------${c1}:://+/:` - -++/:${c2}----..........----${c1}:/++- - .++:${c2}---...........-......---${c1}:++. - /+:${c2}---....-::/:/--//:::-....---${c1}:+/ - `++:${c2}--.....:---::/--/::---:.....--${c1}:++` - /+:${c2}--.....--.--::::-/::--.--.....--${c1}:+/ --o:${c2}--.......-:::://--/:::::-.......--${c1}:o- -/+:${c2}--...-:-::---:::..:::---:--:-...--${c1}:+/ -o/:${c2}-...-:.:.-/:::......::/:.--.:-...-${c1}:/o -o/${c2}--...::-:/::/:-......-::::::-/-...-${c1}:/o -/+:${c2}--..-/:/:::--:::..:::--::////-..--${c1}:+/ --o:${c2}--...----::/:::/--/:::::-----...--${c1}:o- - /+:${c2}--....://:::.:/--/:.::://:....--${c1}:+/ - `++:${c2}--...-:::.--.:..:.--.:/:-...--${c1}:++` - /+:${c2}---....----:-..-:----....---${c1}:+/ - .++:${c2}---..................---${c1}:++. - -/+/:${c2}----..........----${c1}:/+/- - `:/+//${c2}::--------:::${c1}/+/:` + `:/+//$2::--------$1:://+/:` + -++/:$2----..........----$1:/++- + .++:$2---...........-......---$1:++. + /+:$2---....-::/:/--//:::-....---$1:+/ + `++:$2--.....:---::/--/::---:.....--$1:++` + /+:$2--.....--.--::::-/::--.--.....--$1:+/ +-o:$2--.......-:::://--/:::::-.......--$1:o- +/+:$2--...-:-::---:::..:::---:--:-...--$1:+/ +o/:$2-...-:.:.-/:::......::/:.--.:-...-$1:/o +o/$2--...::-:/::/:-......-::::::-/-...-$1:/o +/+:$2--..-/:/:::--:::..:::--::////-..--$1:+/ +-o:$2--...----::/:::/--/:::::-----...--$1:o- + /+:$2--....://:::.:/--/:.::://:....--$1:+/ + `++:$2--...-:::.--.:..:.--.:/:-...--$1:++` + /+:$2---....----:-..-:----....---$1:+/ + .++:$2---..................---$1:++. + -/+/:$2----..........----$1:/+/- + `:/+//$2::--------:::$1/+/:` `.-://++++++//:-.` \ No newline at end of file diff --git a/src/logo/ascii/cutefishos.txt b/src/logo/ascii/cutefishos.txt index a4086fc883..08b9920071 100644 --- a/src/logo/ascii/cutefishos.txt +++ b/src/logo/ascii/cutefishos.txt @@ -3,7 +3,7 @@ _ _wwMMM@M^^^^MMMMww_ M0w_ _wMMM~~ ~~MMm_ ~MMy _ww0M~ ~MMy ~MMMM~ o "MM -${c3} jw0M~~MMMw_ _wMM' +$3 jw0M~~MMMw_ _wMM' wMM~ ~~MMmw__ __w0M~ ~ ~~MM0MmwwwwwwwwwMMM~ ~~~~^^~~~ \ No newline at end of file diff --git a/src/logo/ascii/cuteos.txt b/src/logo/ascii/cuteos.txt index 3b0c40f191..1829a7bf70 100644 --- a/src/logo/ascii/cuteos.txt +++ b/src/logo/ascii/cuteos.txt @@ -1,14 +1,14 @@ - ${c3}1ua${c2} - ${c3}MMM1ua${c2} - ${c1}MM${c2}EE ${c3} MMMMM1uazE${c2} -${c1}MM ${c2}EEEE ${c3}M1MM1uazzEn ${c2}EEEE MME - EEEEE ${c3}MMM uazEno ${c2}EEEE - EEEEE${c1}MMMMMMEno~; ${c2}EE E${c2} - EE ${c1}MMMMMMMM~;;E ${c2}MMMMM M ${c2} - E ${c1}MMMMMMMMM ${c2} E E ${c2} - ${c1}MMMMMMMMMMM - ${c1}MMMMMMMMM ${c2}EE ${c1} - MM1MMMM ${c2}EEE ${c1} + $31ua$2 + $3MMM1ua$2 + $1MM$2EE $3 MMMMM1uazE$2 +$1MM $2EEEE $3M1MM1uazzEn $2EEEE MME + EEEEE $3MMM uazEno $2EEEE + EEEEE$1MMMMMMEno~; $2EE E$2 + EE $1MMMMMMMM~;;E $2MMMMM M $2 + E $1MMMMMMMMM $2 E E $2 + $1MMMMMMMMMMM + $1MMMMMMMMM $2EE $1 + MM1MMMM $2EEE $1 MMMMM MMM M \ No newline at end of file diff --git a/src/logo/ascii/cyberos.txt b/src/logo/ascii/cyberos.txt index 09dc7d643c..3a5fd10659 100644 --- a/src/logo/ascii/cyberos.txt +++ b/src/logo/ascii/cyberos.txt @@ -1,14 +1,14 @@ -${c3} !M$EEEEEEEEEEEP +$3 !M$EEEEEEEEEEEP .MMMMM000000Nr. - ${c3}&MMMMMM${c2}MMMMMMMMMMMMM9 - ${c3}~MMM${c1}MMMM${c2}MMMMMMMMMMMMC - ${c1}" ${c3}M${c1}MMMMMMM${c2}MMMMMMMMMMs - ${c1}iM${c2}MMM&&${c1}MMMMMMMM${c2}MMMMMMMMs - ${c1}BMMM${c2}MMMMM${c1}MMMMMMM${c2}MMMMMM${c3}" -${c1}9MMMMM${c2}MMMMMMM${c1}MMMM${c2}MMMM${c3}MMMf- - ${c2}sMMMMMMMM${c1}MM${c2}M${c3}MMMMMMMMM3_ - ${c2}+ffffffff${c1}P${c3}MMMMMMMMMMMM0 - ${c2}CMMMMMMMMMMM + $3&MMMMMM$2MMMMMMMMMMMMM9 + $3~MMM$1MMMM$2MMMMMMMMMMMMC + $1" $3M$1MMMMMMM$2MMMMMMMMMMs + $1iM$2MMM&&$1MMMMMMMM$2MMMMMMMMs + $1BMMM$2MMMMM$1MMMMMMM$2MMMMMM$3" +$19MMMMM$2MMMMMMM$1MMMM$2MMMM$3MMMf- + $2sMMMMMMMM$1MM$2M$3MMMMMMMMM3_ + $2+ffffffff$1P$3MMMMMMMMMMMM0 + $2CMMMMMMMMMMM }MMMMMMMMM ~MMMMMMM "RMMMM diff --git a/src/logo/ascii/darkos.txt b/src/logo/ascii/darkos.txt index 12ac108972..aaf1546f70 100644 --- a/src/logo/ascii/darkos.txt +++ b/src/logo/ascii/darkos.txt @@ -1,20 +1,20 @@ -${c3}⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⠋⡆⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c5}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡆⢀⣤⢛⠛⣠⣿⠀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c6}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⣿⠟⣡⠊⣠⣾⣿⠃⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c2}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣯⣿⠀⠊⣤⣿⣿⣿⠃⣴⣧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡟⣠⣶⣿⣿⣿⢋⣤⠿⠛⠉⢁⣭⣽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c4} ⠀⠀⠀⠀⠀⠀ ⠀⣠⠖⡭⢉⣿⣯⣿⣯⣿⣿⣿⣟⣧⠛⢉⣤⣶⣾⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c5}⠀⠀⠀⠀⠀⠀⠀⠀⣴⣫⠓⢱⣯⣿⢿⠋⠛⢛⠟⠯⠶⢟⣿⣯⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c2}⠀⠀⠀⠀⠀⠀⢀⡮⢁⣴⣿⣿⣿⠖⣠⠐⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠛⠛⠛⢿⣶⣄⠀⠀⠀⠀⠀⠀⠀ -${c3}⠀⠀⠀⠀⢀⣤⣷⣿⣿⠿⢛⣭⠒⠉⠀⠀⠀⣀⣀⣄⣤⣤⣴⣶⣶⣶⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀ -${c1}⠀⢀⣶⠏⠟⠝⠉⢀⣤⣿⣿⣶⣾⣿⣿⣿⣿⣿⣿⣟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c6}⢴⣯⣤⣶⣿⣿⣿⣿⣿⡿⣿⣯⠉⠉⠉⠉⠀⠀⠀⠈⣿⡀⣟⣿⣿⢿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c5}⠀⠀⠀⠉⠛⣿⣧⠀⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠃⣿⣿⣯⣿⣦⡀⠀⠉⠻⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c3}⠀⠀⠀⠀⠀⠀⠉⢿⣮⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⣯⠉⠉⠛⢿⣿⣷⣄⠀⠈⢻⣆⠀⠀⠀⠀⠀⠀⠀⠀ -${c2}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠢⠀⠀⠀⠀⠀⠀⠀⢀⢡⠃⣾⣿⣿⣦⠀⠀⠀⠙⢿⣿⣤⠀⠙⣄⠀⠀⠀⠀⠀⠀⠀ -${c6}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢋⡟⢠⣿⣿⣿⠋⢿⣄⠀⠀⠀⠈⡄⠙⣶⣈⡄⠀⠀⠀⠀⠀⠀ -${c1}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠚⢲⣿⠀⣾⣿⣿⠁⠀⠀⠉⢷⡀⠀⠀⣇⠀⠀⠈⠻⡀⠀⠀⠀⠀⠀ -${c4}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⣀⣿⡏⠀⣿⡿⠀⠀⠀⠀⠀⠀⠙⣦⠀⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c3}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠿⣧⣾⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣮⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -${c5}⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠀⠀⠀⠀⠀⠀ \ No newline at end of file +$3⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$1⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⠋⡆⢹⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$5⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡆⢀⣤⢛⠛⣠⣿⠀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$6⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣶⣿⠟⣡⠊⣠⣾⣿⠃⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$2⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣯⣿⠀⠊⣤⣿⣿⣿⠃⣴⣧⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$1⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡟⣠⣶⣿⣿⣿⢋⣤⠿⠛⠉⢁⣭⣽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$4 ⠀⠀⠀⠀⠀⠀ ⠀⣠⠖⡭⢉⣿⣯⣿⣯⣿⣿⣿⣟⣧⠛⢉⣤⣶⣾⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$5⠀⠀⠀⠀⠀⠀⠀⠀⣴⣫⠓⢱⣯⣿⢿⠋⠛⢛⠟⠯⠶⢟⣿⣯⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$2⠀⠀⠀⠀⠀⠀⢀⡮⢁⣴⣿⣿⣿⠖⣠⠐⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠛⠛⠛⢿⣶⣄⠀⠀⠀⠀⠀⠀⠀ +$3⠀⠀⠀⠀⢀⣤⣷⣿⣿⠿⢛⣭⠒⠉⠀⠀⠀⣀⣀⣄⣤⣤⣴⣶⣶⣶⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀ +$1⠀⢀⣶⠏⠟⠝⠉⢀⣤⣿⣿⣶⣾⣿⣿⣿⣿⣿⣿⣟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$6⢴⣯⣤⣶⣿⣿⣿⣿⣿⡿⣿⣯⠉⠉⠉⠉⠀⠀⠀⠈⣿⡀⣟⣿⣿⢿⣿⣿⣿⣿⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$5⠀⠀⠀⠉⠛⣿⣧⠀⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠃⣿⣿⣯⣿⣦⡀⠀⠉⠻⣿⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$3⠀⠀⠀⠀⠀⠀⠉⢿⣮⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⣯⠉⠉⠛⢿⣿⣷⣄⠀⠈⢻⣆⠀⠀⠀⠀⠀⠀⠀⠀ +$2⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠢⠀⠀⠀⠀⠀⠀⠀⢀⢡⠃⣾⣿⣿⣦⠀⠀⠀⠙⢿⣿⣤⠀⠙⣄⠀⠀⠀⠀⠀⠀⠀ +$6⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢋⡟⢠⣿⣿⣿⠋⢿⣄⠀⠀⠀⠈⡄⠙⣶⣈⡄⠀⠀⠀⠀⠀⠀ +$1⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⠚⢲⣿⠀⣾⣿⣿⠁⠀⠀⠉⢷⡀⠀⠀⣇⠀⠀⠈⠻⡀⠀⠀⠀⠀⠀ +$4⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⣀⣿⡏⠀⣿⡿⠀⠀⠀⠀⠀⠀⠙⣦⠀⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$3⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠿⣧⣾⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣮⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +$5⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠀⠀⠀⠀⠀⠀ \ No newline at end of file diff --git a/src/logo/ascii/dietpi.txt b/src/logo/ascii/dietpi.txt index d859c175d4..505c7dca51 100644 --- a/src/logo/ascii/dietpi.txt +++ b/src/logo/ascii/dietpi.txt @@ -1,18 +1,18 @@ :=+******+- -+******+=: =#-::-::::-=#:-#=-::::-::-#= :%-::--==-::-%%-::-==--::-%: - +#-:::::=+++${c2}@@${c1}+++=-::::-#= - :#+-::::=%${c2}@@@@@${c1}=::::-+#: - =@%##%${c2}@@@@@@@@${c1}%##%@= -${c2} .#@@@@@@@@@@@@@@@@@@@@#. + +#-:::::=+++$2@@$1+++=-::::-#= + :#+-::::=%$2@@@@@$1=::::-+#: + =@%##%$2@@@@@@@@$1%##%@= +$2 .#@@@@@@@@@@@@@@@@@@@@#. %@@@@@@@@@@@@@@@@@@@@@@% -@@@@@@@@@@@@@@@@@@@@@@@@: .#@@@@@@@@@@%%%%%@@@@@@@@@@@#. -#@@@${c1}+-=*#%${c2}%%%%%%%%%${c1}%%#+--#${c2}@@@# -%@@%${c1}*. .:${c2}=*%%%%*${c1}=: .#${c2}@@@% -:%@@@${c1}#+=-:${c2}:-*%%%%+::${c1}:-=+%${c2}@@@%: - :@@@@%@%%%%@${c1}#${c2}#${c1}#${c2}%@%%%%@%@@@@. - +@@@@@@@@@${c1}%${c2}=*+${c1}%${c2}@%@@@@@@@@+ +#@@@$1+-=*#%$2%%%%%%%%%$1%%#+--#$2@@@# +%@@%$1*. .:$2=*%%%%*$1=: .#$2@@@% +:%@@@$1#+=-:$2:-*%%%%+::$1:-=+%$2@@@%: + :@@@@%@%%%%@$1#$2#$1#$2%@%%%%@%@@@@. + +@@@@@@@@@$1%$2=*+$1%$2@%@@@@@@@@+ #@@@@@@@@@@@@@@@@@@@@@@# -#@@@@@@@@@@@@@@@@@@#- -*%@@@@@@@@@@%*- diff --git a/src/logo/ascii/dragonfly.txt b/src/logo/ascii/dragonfly.txt index 86397be287..185ea87cc8 100644 --- a/src/logo/ascii/dragonfly.txt +++ b/src/logo/ascii/dragonfly.txt @@ -1,12 +1,12 @@ -${c2},--, ${c1}| ${c2},--, -${c2}| `-, ${c1},^, ${c2},-' | -${c2} `, `-, ${c3}(/ \) ${c2},-' ,' -${c2} `-, `-,${c1}/ \${c2},-' ,-' -${c2} `------${c1}( )${c2}------' -${c2} ,----------${c1}( )${c2}----------, -${c2} | _,-${c1}( )${c2}-,_ | -${c2} `-,__,-' ${c1}\ /${c2} `-,__,-' -${c1} | | +$2,--, $1| $2,--, +$2| `-, $1,^, $2,-' | +$2 `, `-, $3(/ \) $2,-' ,' +$2 `-, `-,$1/ \$2,-' ,-' +$2 `------$1( )$2------' +$2 ,----------$1( )$2----------, +$2 | _,-$1( )$2-,_ | +$2 `-,__,-' $1\ /$2 `-,__,-' +$1 | | | | | | | | diff --git a/src/logo/ascii/dragonfly_old.txt b/src/logo/ascii/dragonfly_old.txt index 5814c6f46c..81dacd2bf4 100644 --- a/src/logo/ascii/dragonfly_old.txt +++ b/src/logo/ascii/dragonfly_old.txt @@ -1,17 +1,17 @@ .-. - ${c3} ()${c1}I${c3}() - ${c1} "==.__:-:__.==" + $3 ()$1I$3() + $1 "==.__:-:__.==" "==.__/~|~\__.==" "==._( Y )_.==" - ${c2}.-'~~""~=--...,__${c1}\/|\/${c2}__,...--=~""~~'-. -( ..=${c1}\=${c1}/${c2}=.. ) - `'-. ,.-"`;${c1}/=\${c2};"-.,_ .-'` - `~"-=-~` .-~` ${c1}|=|${c2} `~-. `~-=-"~` - .-~` /${c1}|=|${c2}\ `~-. - .~` / ${c1}|=|${c2} \ `~. - .-~` .' ${c1}|=|${c2} `. `~-. - (` _,.-="` ${c1} |=|${c2} `"=-.,_ `) - `~"~"` ${c1} |=|${c2} `"~"~` - ${c1} /=\ + $2.-'~~""~=--...,__$1\/|\/$2__,...--=~""~~'-. +( ..=$1\=$1/$2=.. ) + `'-. ,.-"`;$1/=\$2;"-.,_ .-'` + `~"-=-~` .-~` $1|=|$2 `~-. `~-=-"~` + .-~` /$1|=|$2\ `~-. + .~` / $1|=|$2 \ `~. + .-~` .' $1|=|$2 `. `~-. + (` _,.-="` $1 |=|$2 `"=-.,_ `) + `~"~"` $1 |=|$2 `"~"~` + $1 /=\ \=/ ^ \ No newline at end of file diff --git a/src/logo/ascii/dragonfly_small.txt b/src/logo/ascii/dragonfly_small.txt index eb5a52c0ab..6612742fd2 100644 --- a/src/logo/ascii/dragonfly_small.txt +++ b/src/logo/ascii/dragonfly_small.txt @@ -1,7 +1,7 @@ -${c2} ,${c1}_${c2}, -('-_${c1}|${c2}_-') - >--${c1}|${c2}--< -(_-'${c1}|${c2}'-_) - ${c1}| +$2 ,$1_$2, +('-_$1|$2_-') + >--$1|$2--< +(_-'$1|$2'-_) + $1| | | \ No newline at end of file diff --git a/src/logo/ascii/droidian.txt b/src/logo/ascii/droidian.txt index d60b676e62..adf17066cc 100644 --- a/src/logo/ascii/droidian.txt +++ b/src/logo/ascii/droidian.txt @@ -1,14 +1,14 @@ -${c2} _,met$$$$$$$$$$gg. +$2 _,met$$$$$$$$$$gg. ,g$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$P. ,$$$$P' `$$$$$$. ',$$$$P ,ggs. `$$$$b: -`d$$$$' ,$$P"' ${c1}.${c2} $$$$$$ - $$$$P d$$' ${c1},${c2} $$$$P - $$$$: $$$$. ${c1}-${c2} ,d$$$$' +`d$$$$' ,$$P"' $1.$2 $$$$$$ + $$$$P d$$' $1,$2 $$$$P + $$$$: $$$$. $1-$2 ,d$$$$' $$$$; Y$$b._ _,d$$P' - Y$$$$. ${c1}`.${c2}`"Y$$$$$$$$P"' -${c2} `$$$$b ${c1}"-.__ -${c2} `Y$$$$ + Y$$$$. $1`.$2`"Y$$$$$$$$P"' +$2 `$$$$b $1"-.__ +$2 `Y$$$$ `Y$$$$. `$$$$b. `Y$$$$b. diff --git a/src/logo/ascii/elive.txt b/src/logo/ascii/elive.txt index 67abf6cbce..e9ce45752d 100644 --- a/src/logo/ascii/elive.txt +++ b/src/logo/ascii/elive.txt @@ -1,17 +1,17 @@ - *@${c2},,&(%%%..%*. - ${c1}(@${c2}&%/##############((/${c1}*, - ${c2}@${c1}@&${c2}#########${c1}*..../${c2}########%${c1}*.. - ${c2}@${c1}&${c2}#%%%%%. ${c3},.${c1},${c2}%%%%%%. - /%${c2}(%%%%. ${c1}(${c2}%%%%#. - /${c1}*${c2}%%##,. .,%%###, - ,####. ,${c1}*${c2}#%${c1}#${c3}/,(/ ${c2}/${c1}#${c2}###, -((###/ ,,##########${c1}(${c3}/(# ${c2}%####, -%#(((${c1}. .${c1}./${c2}((((((((((((((${c1}(${c2}#/${c3}*.. ${c3}*.${c2}(((${c1}/ -${c2}%#///${c1}. ${c3}***${c2}.*///////////// -${c3}#${c2}#////* ${c3}***${c2}.*/////. - ${c3}(${c2}(***** ${c3}*** - ${c2},*****.. - ..${c1}*${c2}*****.. *${c1}%${c2}/****. - .,,*******,${c3},,../##(${c2}%&${c1}&${c2}#******${c1},${c2}. - ,*${c1},${c2},,,,,,,,,,,,,,,,,,,${c1},${c2}.. - *//${c1}/,,${c2},,,,,,,${c1},..${c2} \ No newline at end of file + *@$2,,&(%%%..%*. + $1(@$2&%/##############((/$1*, + $2@$1@&$2#########$1*..../$2########%$1*.. + $2@$1&$2#%%%%%. $3,.$1,$2%%%%%%. + /%$2(%%%%. $1($2%%%%#. + /$1*$2%%##,. .,%%###, + ,####. ,$1*$2#%$1#$3/,(/ $2/$1#$2###, +((###/ ,,##########$1($3/(# $2%####, +%#((($1. .$1./$2(((((((((((((($1($2#/$3*.. $3*.$2((($1/ +$2%#///$1. $3***$2.*///////////// +$3#$2#////* $3***$2.*/////. + $3($2(***** $3*** + $2,*****.. + ..$1*$2*****.. *$1%$2/****. + .,,*******,$3,,../##($2%&$1&$2#******$1,$2. + ,*$1,$2,,,,,,,,,,,,,,,,,,,$1,$2.. + *//$1/,,$2,,,,,,,$1,..$2 \ No newline at end of file diff --git a/src/logo/ascii/endeavouros_small.txt b/src/logo/ascii/endeavouros_small.txt index 763a1bc38b..dbe011a371 100644 --- a/src/logo/ascii/endeavouros_small.txt +++ b/src/logo/ascii/endeavouros_small.txt @@ -1,7 +1,7 @@ - /${c2}o${c3}. -${c1} /${c2}sssso${c3}- -${c1} /${c2}ossssssso${c3}: -${c1} /${c2}ssssssssssso${c3}+ -${c1} /${c2}ssssssssssssssso${c3}+ -${c1}//${c2}osssssssssssssso${c3}+- + /$2o$3. +$1 /$2sssso$3- +$1 /$2ossssssso$3: +$1 /$2ssssssssssso$3+ +$1 /$2ssssssssssssssso$3+ +$1//$2osssssssssssssso$3+- `+++++++++++++++-` \ No newline at end of file diff --git a/src/logo/ascii/eurolinux.txt b/src/logo/ascii/eurolinux.txt index a676122dd1..18c808db4c 100644 --- a/src/logo/ascii/eurolinux.txt +++ b/src/logo/ascii/eurolinux.txt @@ -3,15 +3,15 @@ -WWWWWWWWWWWWWWWWWWw- \WWWWWWWWWWWWWWWWWWW- _Ww `WWWWWWWWWWWWWWWWWWWw - -W${c2}E${c1}Www -WWWWWWWWW- -_WW${c2}U${c1}WWWW- _WWWWWWWW -_WW${c2}R${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW- -wWW${c2}O${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW -WWW${c2}L${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWw -WWW${c2}I${c1}WWWWWWWWWWWWWWWWWWWWWWWWWWWWww- -wWW${c2}N${c1}WWWWw - WW${c2}U${c1}WWWWWWw - wW${c2}X${c1}WWWWWWWWww + -W$2E$1Www -WWWWWWWWW- +_WW$2U$1WWWW- _WWWWWWWW +_WW$2R$1WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW- +wWW$2O$1WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW +WWW$2L$1WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWw +WWW$2I$1WWWWWWWWWWWWWWWWWWWWWWWWWWWWww- +wWW$2N$1WWWWw + WW$2U$1WWWWWWw + wW$2X$1WWWWWWWWww wWWWWWWWWWWWWWWWw wWWWWWWWWWWWWWWWw WWWWWWWWWWWWWw diff --git a/src/logo/ascii/eweos.txt b/src/logo/ascii/eweos.txt index 0723acbc31..6a5b6bdda0 100644 --- a/src/logo/ascii/eweos.txt +++ b/src/logo/ascii/eweos.txt @@ -1,9 +1,9 @@ -${c2} #####%%% -${c2} ##%%${c3}////${c2}%%%%%${c3}/// -${c2} #%%%%${c3}////((((////${c2}% -${c1} *@@@@@@@${c3}/${c5},,,${c3}/////${c5},,,${c2}%${c1}@@@@@@@ - .@@@@@@@@@@@${c3}////////${c2}%%%${c1}@@@@@@@@@@@@ -@@@${c4}...${c1}@@@@@@${c3}////${c2}%%${c3}////${c1}@@@@@@@@@@@@@@@@ +$2 #####%%% +$2 ##%%$3////$2%%%%%$3/// +$2 #%%%%$3////((((////$2% +$1 *@@@@@@@$3/$5,,,$3/////$5,,,$2%$1@@@@@@@ + .@@@@@@@@@@@$3////////$2%%%$1@@@@@@@@@@@@ +@@@$4...$1@@@@@@$3////$2%%$3////$1@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/logo/ascii/fedora_coreos.txt b/src/logo/ascii/fedora_coreos.txt index d066b2ec87..0eae5969e1 100644 --- a/src/logo/ascii/fedora_coreos.txt +++ b/src/logo/ascii/fedora_coreos.txt @@ -1,17 +1,17 @@ ..... .';:cccccccc:;'. - ':ccccclc${c3}lllllllll${c1}cc:. - .;cccccccc${c3}lllllllllllllll${c1}c, - ;clllccccc${c3}llllllllllllllllll${c1}c, - .cllclccccc${c3}lllll${c2}lll${c3}llllllllllll${c1}c: - ccclclcccc${c3}cllll${c2}kWMMNKk${c3}llllllllll${c1}c: - :ccclclcccc${c3}llll${c2}oWMMMMMMWO${c3}lllllllll${c1}c, -.ccllllllccc${c3}clll${c2}OMMMMMMMMM0${c3}lllllllll${c1}c -.lllllclcccc${c3}llll${c2}KMMMMMMMMMMo${c3}llllllll${c1}c. -.lllllllcccc${c3}clll${c2}KMMMMMMMMN0${c3}lllllllll${c1}c. -.cclllllcccc${c3}lllld${c2}xkkxxdo${c3}llllllllllc${c1}lc - :cccllllllcccc${c3}lllccllllcclccc${c1}cccccc; - .ccclllllllcccccccc${c3}lll${c1}ccccclccccccc + ':ccccclc$3lllllllll$1cc:. + .;cccccccc$3lllllllllllllll$1c, + ;clllccccc$3llllllllllllllllll$1c, + .cllclccccc$3lllll$2lll$3llllllllllll$1c: + ccclclcccc$3cllll$2kWMMNKk$3llllllllll$1c: + :ccclclcccc$3llll$2oWMMMMMMWO$3lllllllll$1c, +.ccllllllccc$3clll$2OMMMMMMMMM0$3lllllllll$1c +.lllllclcccc$3llll$2KMMMMMMMMMMo$3llllllll$1c. +.lllllllcccc$3clll$2KMMMMMMMMN0$3lllllllll$1c. +.cclllllcccc$3lllld$2xkkxxdo$3llllllllllc$1lc + :cccllllllcccc$3lllccllllcclccc$1cccccc; + .ccclllllllcccccccc$3lll$1ccccclccccccc .cllllllllllclcccclccclccllllcllc :cllllllllccclcllllllllllllcc; .cccccccccccccclcccccccccc:. diff --git a/src/logo/ascii/finnix.txt b/src/logo/ascii/finnix.txt index c1f7729b05..5673c6e60e 100644 --- a/src/logo/ascii/finnix.txt +++ b/src/logo/ascii/finnix.txt @@ -6,7 +6,7 @@ +############################; :#############.**,#############, *###########+ +###########+ - ?########## ${c3}Finnix${c1} ##########* + ?########## $3Finnix$1 ##########* *###########, ,###########+ :#############%..%#############, *############################+ diff --git a/src/logo/ascii/frugalware.txt b/src/logo/ascii/frugalware.txt index 7d4b2c2cbb..91c55e5c9d 100644 --- a/src/logo/ascii/frugalware.txt +++ b/src/logo/ascii/frugalware.txt @@ -6,13 +6,13 @@ ++osoooooooooooosssssssssssssyyo+++++++o: -o+ssoooooooooooosssssssssssssyyo+++++++s` o++ssoooooo++++++++++++++sssyyyyo++++++o: - :o++ssoooooo${c2}/-------------${c1}+syyyyyo+++++oo - `o+++ssoooooo${c2}/-----${c1}+++++ooosyyyyyyo++++os: - /o+++ssoooooo${c2}/-----${c1}ooooooosyyyyyyyo+oooss - .o++++ssooooos${c2}/------------${c1}syyyyyyhsosssy- - ++++++ssooooss${c2}/-----${c1}+++++ooyyhhhhhdssssso - -s+++++syssssss${c2}/-----${c1}yyhhhhhhhhhhhddssssy. - sooooooyhyyyyyh${c2}/-----${c1}hhhhhhhhhhhddddyssy+ + :o++ssoooooo$2/-------------$1+syyyyyo+++++oo + `o+++ssoooooo$2/-----$1+++++ooosyyyyyyo++++os: + /o+++ssoooooo$2/-----$1ooooooosyyyyyyyo+oooss + .o++++ssooooos$2/------------$1syyyyyyhsosssy- + ++++++ssooooss$2/-----$1+++++ooyyhhhhhdssssso + -s+++++syssssss$2/-----$1yyhhhhhhhhhhhddssssy. + sooooooyhyyyyyh$2/-----$1hhhhhhhhhhhddddyssy+ :yooooooyhyyyhhhyyyyyyhhhhhhhhhhdddddyssy` yoooooooyhyyhhhhhhhhhhhhhhhhhhhddddddysy/ -ysooooooydhhhhhhhhhhhddddddddddddddddssy diff --git a/src/logo/ascii/galliumos.txt b/src/logo/ascii/galliumos.txt index 1dbed7f48e..527344c4c0 100644 --- a/src/logo/ascii/galliumos.txt +++ b/src/logo/ascii/galliumos.txt @@ -4,13 +4,13 @@ yyysoooooooooooooooooooooooooooo+/:::::: yyyyyoooooooooooooooooooooooo+/::::::::: yyyyyysoooooooooooooooooo++/:::::::::::: yyyyyyysoooooooooooooo++/::::::::::::::: -yyyyyyyyysoooooo${c2}sydddys${c1}+/::::::::::::::: -yyyyyyyyyysooo${c2}smMMMMMMMNd${c1}+:::::::::::::: -yyyyyyyyyyyyo${c2}sMMMMMMMMMMMN${c1}/::::::::::::: -yyyyyyyyyyyyy${c2}dMMMMMMMMMMMM${c1}o//::::::::::: -yyyyyyyyyyyyy${c2}hMMMMMMMMMMMm${c1}--//:::::::::: -yyyyyyyyyyyyyy${c2}hmMMMMMMMNy${c1}:..-://:::::::: -yyyyyyyyyyyyyyy${c2}yyhhyys+:${c1}......://::::::: +yyyyyyyyysoooooo$2sydddys$1+/::::::::::::::: +yyyyyyyyyysooo$2smMMMMMMMNd$1+:::::::::::::: +yyyyyyyyyyyyo$2sMMMMMMMMMMMN$1/::::::::::::: +yyyyyyyyyyyyy$2dMMMMMMMMMMMM$1o//::::::::::: +yyyyyyyyyyyyy$2hMMMMMMMMMMMm$1--//:::::::::: +yyyyyyyyyyyyyy$2hmMMMMMMMNy$1:..-://:::::::: +yyyyyyyyyyyyyyy$2yyhhyys+:$1......://::::::: yyyyyyyyyyyyyyys+:--...........-///::::: yyyyyyyyyyyys+:--................://:::: yyyyyyyyyo+:-.....................-//::: diff --git a/src/logo/ascii/grombyang.txt b/src/logo/ascii/grombyang.txt index 7940c13a86..9cb1451193 100644 --- a/src/logo/ascii/grombyang.txt +++ b/src/logo/ascii/grombyang.txt @@ -1,18 +1,18 @@ eeeeeeeeeeee eeeeeeeeeeeeeeeee eeeeeeeeeeeeeeeeeeeeeee - eeeee ${c2}.o+ ${c1}eeee - eeee ${c2}`ooo/ ${c1}eeee - eeee ${c2}`+oooo: ${c1}eeee -eee ${c2}`+oooooo: ${c1}eee -eee ${c2}-+oooooo+: ${c1}eee -ee ${c2}`/:oooooooo+: ${c1}ee -ee ${c2}`/+ +++ +: ${c1}ee -ee ${c2}+o+\ ${c1}ee -eee ${c2}+o+\ ${c1}eee -eee ${c2}// \ooo/ \\ ${c1}eee - eee ${c2}//++++oooo++++\\ ${c1}eee - eeee ${c2}::::++oooo+::::: ${c1}eeee - eeeee ${c3}Grombyang OS ${c1} eeee + eeeee $2.o+ $1eeee + eeee $2`ooo/ $1eeee + eeee $2`+oooo: $1eeee +eee $2`+oooooo: $1eee +eee $2-+oooooo+: $1eee +ee $2`/:oooooooo+: $1ee +ee $2`/+ +++ +: $1ee +ee $2+o+\ $1ee +eee $2+o+\ $1eee +eee $2// \ooo/ \\ $1eee + eee $2//++++oooo++++\\ $1eee + eeee $2::::++oooo+::::: $1eeee + eeeee $3Grombyang OS $1 eeee eeeeeeeeeeeeeeeeeeeeeee eeeeeeeeeeeeeeeee \ No newline at end of file diff --git a/src/logo/ascii/haiku2.txt b/src/logo/ascii/haiku2.txt index 56a7feb4b7..f09f5960fd 100644 --- a/src/logo/ascii/haiku2.txt +++ b/src/logo/ascii/haiku2.txt @@ -1,17 +1,17 @@ -${c2} :dc' - 'l:;'${c1},${c2}'ck. .;dc:. - co ${c1}..${c2}k. .;; ':o. - co ${c1}..${c2}k. ol ${c1}.${c2}0. - co ${c1}..${c2}k. oc ${c1}..${c2}0. - co ${c1}..${c2}k. oc ${c1}..${c2}0. -.Ol,. co ${c1}...''${c2}Oc;kkodxOdddOoc,. - ';lxxlxOdxkxk0kd${c1}oooll${c2}dl${c1}ccc:${c2}clxd; - ..${c1}oOolllllccccccc:::::${c2}od; - cx:ooc${c1}:::::::;${c2}cooolcX. - cd${c1}.${c2}''cloxdoollc' ${c1}...${c2}0. - cd${c1}......${c2}k;${c1}.${c2}xl${c1}.... .${c2}0. - .::c${c1};..${c2}cx;${c1}.${c2}xo${c1}..... .${c2}0. - '::c'${c1}...${c2}do${c1}..... .${c2}K, - cd,.${c1}....:${c2}O,${c1} - ':clod:'${c1} - ${c1} +$2 :dc' + 'l:;'$1,$2'ck. .;dc:. + co $1..$2k. .;; ':o. + co $1..$2k. ol $1.$20. + co $1..$2k. oc $1..$20. + co $1..$2k. oc $1..$20. +.Ol,. co $1...''$2Oc;kkodxOdddOoc,. + ';lxxlxOdxkxk0kd$1oooll$2dl$1ccc:$2clxd; + ..$1oOolllllccccccc:::::$2od; + cx:ooc$1:::::::;$2cooolcX. + cd$1.$2''cloxdoollc' $1...$20. + cd$1......$2k;$1.$2xl$1.... .$20. + .::c$1;..$2cx;$1.$2xo$1..... .$20. + '::c'$1...$2do$1..... .$2K, + cd,.$1....:$2O,$1 + ':clod:'$1 + $1 diff --git a/src/logo/ascii/hamonikr.txt b/src/logo/ascii/hamonikr.txt index bbb6345329..ff8cd918d3 100644 --- a/src/logo/ascii/hamonikr.txt +++ b/src/logo/ascii/hamonikr.txt @@ -7,12 +7,12 @@ .oddddddddddddddc. ,dddddddddddddddo. ,ccoooooooocoddooo: - ,cooooooooooooooooop ${c3} c000x. -${c1}.cooooooooooooooopcllll${c3} .cddddddo. -${c1}coooooooooooooop' .qlll.${c3} .ddoooooooo; -${c1}cooooooooooc; ${c3}'qlllp. .ddoooooooooo; -${c1}.cooooooc; ${c3}'lllbc...coooooooooooo; -${c1} .cooc' ${c3}.llllcoooooooooooooo. + ,cooooooooooooooooop $3 c000x. +$1.cooooooooooooooopcllll$3 .cddddddo. +$1coooooooooooooop' .qlll.$3 .ddoooooooo; +$1cooooooooooc; $3'qlllp. .ddoooooooooo; +$1.cooooooc; $3'lllbc...coooooooooooo; +$1 .cooc' $3.llllcoooooooooooooo. .coooooooooooooop: .coooooooooooooop' .cooooooooooooop. diff --git a/src/logo/ascii/hardclanz.txt b/src/logo/ascii/hardclanz.txt index c7931c3da6..7c289dfe09 100644 --- a/src/logo/ascii/hardclanz.txt +++ b/src/logo/ascii/hardclanz.txt @@ -1,19 +1,19 @@ -${c1} ........::::.... +$1 ........::::.... ::################::.. :########################:. :######**###################: - :###${c2}&&&&^${c1}############ ${c2}&${c1}#######: - :#${c2}&&&&&${c1}.:##############:${c2}^&o${c1}`:###: - :#${c2}&&&&${c1}.:#################:.${c2}&&&${c1}`###: - :##${c2}&^${c1}:######################:${c2}^&&${c1}::##: - :#############################:${c2}&${c1}:##:: - :##########${c2}@@${c1}###########${c2}@@${c1}#####:.###: -:#########${c2}@@${c3}o${c2}@@${c1}#########${c2}@@${c3}o${c2}@@${c1}########: -:#######:${c2}@@${c3}o${c5}0${c3}o${c2}@@@@${c1}###${c2}@@@@${c3}o${c5}0${c3}o${c2}@@${c1}######: : - :######:${c2}@@@${c3}o${c2}@@@@@@${c1}V${c2}@@@@@@${c3}o${c2}@@@${c1}######: - :#####:${c2}@@@@@@@@@@@@@@@@@@@${c1}:####; - :####:.${c2}@@@@@@@@@@@@@@@@${c1}:#####: - `:####:.${c2}@@@@@@@@@@@@@@${c1}:#####: - ``:##:.${c2}@@@@@@@@@@@@${c1}^## # : - : ## ${c2}\@@@;@@@/ ${c1}:: # : - ${c2} VVV \ No newline at end of file + :###$2&&&&^$1############ $2&$1#######: + :#$2&&&&&$1.:##############:$2^&o$1`:###: + :#$2&&&&$1.:#################:.$2&&&$1`###: + :##$2&^$1:######################:$2^&&$1::##: + :#############################:$2&$1:##:: + :##########$2@@$1###########$2@@$1#####:.###: +:#########$2@@$3o$2@@$1#########$2@@$3o$2@@$1########: +:#######:$2@@$3o$50$3o$2@@@@$1###$2@@@@$3o$50$3o$2@@$1######: : + :######:$2@@@$3o$2@@@@@@$1V$2@@@@@@$3o$2@@@$1######: + :#####:$2@@@@@@@@@@@@@@@@@@@$1:####; + :####:.$2@@@@@@@@@@@@@@@@$1:#####: + `:####:.$2@@@@@@@@@@@@@@$1:#####: + ``:##:.$2@@@@@@@@@@@@$1^## # : + : ## $2\@@@;@@@/ $1:: # : + $2 VVV \ No newline at end of file diff --git a/src/logo/ascii/huayra.txt b/src/logo/ascii/huayra.txt index 2f4e90166f..90a774c8cc 100644 --- a/src/logo/ascii/huayra.txt +++ b/src/logo/ascii/huayra.txt @@ -1,4 +1,4 @@ -${c2} ` +$2 ` . . ` `` - . . `.` -` `. - `` .` @@ -7,8 +7,8 @@ ${c2} ` -+/so::h:.d-`./:`.` :hNhyMomy:os-...-. ```` .dhsshNmNhoo+:-``.``` - ${c1}`ohy:-${c2}NMds+::-.`` - ````${c1}.hNN+`${c2}mMNho/:-....```` + $1`ohy:-$2NMds+::-.`` + ````$1.hNN+`$2mMNho/:-....```` ````` `../dmNhoo+/:..`` ```` .dh++o/:....` .+s/` `/s-.-.:.`` ```` diff --git a/src/logo/ascii/hybrid.txt b/src/logo/ascii/hybrid.txt index 1d5eb004cb..ddfc3ba864 100644 --- a/src/logo/ascii/hybrid.txt +++ b/src/logo/ascii/hybrid.txt @@ -1,16 +1,16 @@ -${c1} / ${c2}# -${c1}////& ${c2}##### -${c1}///// ${c2}###### -${c1}///// ////////// ${c2}###### -${c1}///// //////////////////// ${c2}###### -${c1}////////////////////////// ${c2}###### -${c1}///////// /// ${c2}###### -${c1}/////// / ${c2}###### -${c1}////// ${c2}###### -${c1}///// ${c2}###### -${c1}///// ${c2}###### -${c1}///// ${c2}###### -${c1}///// ${c2}###### -${c1}///// ${c2}###### -${c1}///// ${c2}######### -${c1}////& ${c2}######## \ No newline at end of file +$1 / $2# +$1////& $2##### +$1///// $2###### +$1///// ////////// $2###### +$1///// //////////////////// $2###### +$1////////////////////////// $2###### +$1///////// /// $2###### +$1/////// / $2###### +$1////// $2###### +$1///// $2###### +$1///// $2###### +$1///// $2###### +$1///// $2###### +$1///// $2###### +$1///// $2######### +$1////& $2######## \ No newline at end of file diff --git a/src/logo/ascii/interix.txt b/src/logo/ascii/interix.txt index d46aa2403f..056359f601 100644 --- a/src/logo/ascii/interix.txt +++ b/src/logo/ascii/interix.txt @@ -1,17 +1,17 @@ - .${c3}. -${c1} 75${c3}G! -${c1} ^?PG${c3}&&J. -${c1} :!5GPP${c3}&&&B! -${c1} :YPPPPP${c3}&&&&&Y: -${c1} !5PPPPPP${c3}&&&&&&B! -${c1} :?PPPPPPPP${c3}&&&&&&&&Y~ -${c1} !5PPPPPPPPP${c3}###&&&&&&B7 -${c1} :?PPPP5555555${c3}B####&&&&&&5: -${c1} ~5PPPP555YJ${c5}7!~7?${c3}5B###&&&&&B?. -${c1} .:JPPPP5555Y${c5}?^....:^?${c3}G####&&&&&5: -${c1} 75PPP555555Y${c5}7:....:^!${c3}5#####&&&&&B7. -${c1} :JPPPP${c2}555555YY?${c5}~::::^~${c2}7YPGBB###${c3}&&&&&5^ -${c1}75${c2}GGPPPPPP555555YJ?77??YYYYYY55PPGGB#${c3}&B? -${c2}~!!7JY5PGGBBBBBBBBGGGGGGGBGGGGGP5YJ?7~~~ + .$3. +$1 75$3G! +$1 ^?PG$3&&J. +$1 :!5GPP$3&&&B! +$1 :YPPPPP$3&&&&&Y: +$1 !5PPPPPP$3&&&&&&B! +$1 :?PPPPPPPP$3&&&&&&&&Y~ +$1 !5PPPPPPPPP$3###&&&&&&B7 +$1 :?PPPP5555555$3B####&&&&&&5: +$1 ~5PPPP555YJ$57!~7?$35B###&&&&&B?. +$1 .:JPPPP5555Y$5?^....:^?$3G####&&&&&5: +$1 75PPP555555Y$57:....:^!$35#####&&&&&B7. +$1 :JPPPP$2555555YY?$5~::::^~$27YPGBB###$3&&&&&5^ +$175$2GGPPPPPP555555YJ?77??YYYYYY55PPGGB#$3&B? +$2~!!7JY5PGGBBBBBBBBGGGGGGGBGGGGGP5YJ?7~~~ .::^~7?JYPGBB#BGPYJ?7!7^:. ..:^... \ No newline at end of file diff --git a/src/logo/ascii/itc.txt b/src/logo/ascii/itc.txt index 2ec3fdb3d7..4bd2826689 100644 --- a/src/logo/ascii/itc.txt +++ b/src/logo/ascii/itc.txt @@ -1,10 +1,10 @@ -${c1}....................-==============+... -${c1}....................-==============:... -${c1}...:===========-....-==============:... -${c1}...-===========:....-==============-... -${c1}....*==========+........-::********-... -${c1}....*===========+.:*====**==*+-.-...... -${c1}....:============*+-..--:+**====*---... -${c1}......::--........................::... -${c1}..+-:+-.+::*:+::+:-++::++-.:-.*.:++:++. -${c1}..:-:-++++:-::--:+::-::.:++-++:++--:-:. \ No newline at end of file +$1....................-==============+... +$1....................-==============:... +$1...:===========-....-==============:... +$1...-===========:....-==============-... +$1....*==========+........-::********-... +$1....*===========+.:*====**==*+-.-...... +$1....:============*+-..--:+**====*---... +$1......::--........................::... +$1..+-:+-.+::*:+::+:-++::++-.:-.*.:++:++. +$1..:-:-++++:-::--:+::-::.:++-++:++--:-:. \ No newline at end of file diff --git a/src/logo/ascii/januslinux.txt b/src/logo/ascii/januslinux.txt index 04b6075e3f..e4708b68ef 100644 --- a/src/logo/ascii/januslinux.txt +++ b/src/logo/ascii/januslinux.txt @@ -9,10 +9,10 @@ :loooocooo cloo loooo loooo :ooooool loooo looo cooooo cooooo -looooooooooooo ;loooooo ${c2}looooooc -${c1}looooooooo loo cloooooool ${c2}looooc -${c1} cooo cooooooooooo ${c2}looolooooool -${c1} cooo: ${c2}coooooooooooooooooool +looooooooooooo ;loooooo $2looooooc +$1looooooooo loo cloooooool $2looooc +$1 cooo cooooooooooo $2looolooooool +$1 cooo: $2coooooooooooooooooool loooooooooooolc: loooc; cooo: loooooooooooc ;oool looooooo: diff --git a/src/logo/ascii/kali.txt b/src/logo/ascii/kali.txt index 246c9addfa..6cc6c00f16 100644 --- a/src/logo/ascii/kali.txt +++ b/src/logo/ascii/kali.txt @@ -5,7 +5,7 @@ .';;;:::;,,.x, ..'''. 0Xxoc:,. ... .... ,ONkc;,;cokOdc',. - . OMo ':${c2}dd${c1}o. + . OMo ':$2dd$1o. dMc :OO; 0M. .:o. ;Wd diff --git a/src/logo/ascii/kernelos.txt b/src/logo/ascii/kernelos.txt index 68523eb433..f76fc2639d 100644 --- a/src/logo/ascii/kernelos.txt +++ b/src/logo/ascii/kernelos.txt @@ -7,13 +7,13 @@ .'. .,,,,' .,,,,,. .'. '.. .,,,,'',,,,;. .'' .'. .,,,,,,,;;. ..' -.'. .,,,,;;;;;${c2}, ${c1}..'. - '.. .,;;;,${c2}';;;;;, ${c1}..' - .'. .;;${c2};;' .;;:::: ${c1}.,. - '.. ${c2}.;;;;' .::::::. ${c1}.,' - '.. ${c2}.;;;;' .::::::. ${c1}.,${c2}'${c1} - .'.. ${c2}.',. - ${c1}',.. ${c2}.',' - ${c1}.,,... ${c2}..',,. +.'. .,,,,;;;;;$2, $1..'. + '.. .,;;;,$2';;;;;, $1..' + .'. .;;$2;;' .;;:::: $1.,. + '.. $2.;;;;' .::::::. $1.,' + '.. $2.;;;;' .::::::. $1.,$2'$1 + .'.. $2.',. + $1',.. $2.',' + $1.,,... $2..',,. ..,,''........',,,. ...... \ No newline at end of file diff --git a/src/logo/ascii/kibojoe.txt b/src/logo/ascii/kibojoe.txt index 4ee1721614..3afc7ebed0 100644 --- a/src/logo/ascii/kibojoe.txt +++ b/src/logo/ascii/kibojoe.txt @@ -1,13 +1,13 @@ -${c3} ./+oooooo+/. +$3 ./+oooooo+/. -/+ooooo+/:.` - ${c1}`${c3}yyyo${c2}+++/++${c3}osss${c1}. - ${c1}+NMN${c3}yssssssssssss${c1}. - ${c1}.dMMMMN${c3}sssssssssssy${c1}Ns` - +MMMMMMMm${c3}sssssssssssh${c1}MNo` - `hMMMMMNNNMd${c3}sssssssssssd${c1}MMN/ - .${c3}syyyssssssy${c1}NNmmmmd${c3}sssss${c1}hMMMMd: - -NMmh${c3}yssssssssyhhhhyssyh${c1}mMMMMMMMy` - -NMMMMMNN${c3}mdhyyyyyyyhdm${c1}NMMMMMMMMMMMN+ + $1`$3yyyo$2+++/++$3osss$1. + $1+NMN$3yssssssssssss$1. + $1.dMMMMN$3sssssssssssy$1Ns` + +MMMMMMMm$3sssssssssssh$1MNo` + `hMMMMMNNNMd$3sssssssssssd$1MMN/ + .$3syyyssssssy$1NNmmmmd$3sssss$1hMMMMd: + -NMmh$3yssssssssyhhhhyssyh$1mMMMMMMMy` + -NMMMMMNN$3mdhyyyyyyyhdm$1NMMMMMMMMMMMN+ `NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd. ods+/:-----://+oyydmNMMMMMMMMMMMMMMMMMN- ` .-:+osyhhdmmNNNmdo \ No newline at end of file diff --git a/src/logo/ascii/korora.txt b/src/logo/ascii/korora.txt index 658fef0e34..26135c9ce0 100644 --- a/src/logo/ascii/korora.txt +++ b/src/logo/ascii/korora.txt @@ -1,16 +1,16 @@ -${c2} ____________ - _add55555555554${c1}: - _w?'${c1}``````````'${c2})k${c1}: - _Z'${c1}`${c2} ]k${c1}: - m(${c1}`${c2} )k${c1}: - _.ss${c1}`${c2}m[${c1}`${c2}, ]e${c1}: - .uY"^`${c1}`${c2}Xc${c1}`${c2}?Ss. d(${c1}` - jF'${c1}`${c2} `@. ${c1}`${c2}Sc .jr${c1}` - jr${c1}`${c2} `?n_ ${c1}`${c2}$; _a2"${c1}` -.m${c1}:${c2} `~M${c1}`${c2}1k${c1}`${c2}5?!`${c1}` -:#${c1}:${c2} ${c1}`${c2})e${c1}``` -:m${c1}:${c2} ,#'${c1}` -:#${c1}:${c2} .s2'${c1}` -:m,________.aa7^${c1}` -:#baaaaaaas!J'${c1}` +$2 ____________ + _add55555555554$1: + _w?'$1``````````'$2)k$1: + _Z'$1`$2 ]k$1: + m($1`$2 )k$1: + _.ss$1`$2m[$1`$2, ]e$1: + .uY"^`$1`$2Xc$1`$2?Ss. d($1` + jF'$1`$2 `@. $1`$2Sc .jr$1` + jr$1`$2 `?n_ $1`$2$; _a2"$1` +.m$1:$2 `~M$1`$21k$1`$25?!`$1` +:#$1:$2 $1`$2)e$1``` +:m$1:$2 ,#'$1` +:#$1:$2 .s2'$1` +:m,________.aa7^$1` +:#baaaaaaas!J'$1` ``````````` \ No newline at end of file diff --git a/src/logo/ascii/krassos.txt b/src/logo/ascii/krassos.txt index 124a360411..bfc3deac31 100644 --- a/src/logo/ascii/krassos.txt +++ b/src/logo/ascii/krassos.txt @@ -1,19 +1,19 @@ - ${c2}**@@@@@@@@@@@* - ${c2},@@@@%${c1}(((((((((((((${c2}%@@@@, - ${c2}#@@&${c1}(((((((((((((((((((((((${c2}&@@% - ${c2}@@&${c1}(((((((((((((((((((((((((((((${c2}@@@ - ${c2}@@&${c1}(((((((((((((((((((((((((((((((((${c2}&@@ - ${c2}.@@${c1}(((((((((((((((((((((((((((((((((((((${c2}@@. - ${c2}@@${c1}(((((((((((((((((((((((((((((((((((((((${c2}@@ - ${c2}@@#${c1}(((((((((((((((((((((((((((((${c2}%@@@@@@@#${c1}(#${c2}@@ - ${c2}.@@${c1}((((((((((((((((${c2}#%@@@@@@@@@&%#${c1}((((${c2}%@&${c1}((((${c2}@@. - ${c2}.@@${c1}(((((((/(${c2}&@@@@@@%${c1}(/((((((((((((((${c2}@@/${c1}(((((${c2}@@. - ${c2}.@@${c1}(///////////////////////////////${c2}@${c1}(///////${c2}@@ - ${c2}%@#${c1}/////////////////////////////(${c2}#${c1}////////${c2}%@% - ${c2} @@${c1}(///////////////////////////${c2}%${c1}/////////(${c2}@@ - ${c2}@@#${c1}***********************************${c2}%@@ - ${c2}*@@${c1}********************************${c2}/@@/ - ${c2},@@#${c1}***************************${c2}%@@* - ${c2}@@@&${c1}********************${c2}/@@@@ - ${c2}&@@@@&${c1}(//***//(${c2}&@@@@& - ${c2}**@@@@@@@@@@@* \ No newline at end of file + $2**@@@@@@@@@@@* + $2,@@@@%$1((((((((((((($2%@@@@, + $2#@@&$1((((((((((((((((((((((($2&@@% + $2@@&$1((((((((((((((((((((((((((((($2@@@ + $2@@&$1((((((((((((((((((((((((((((((((($2&@@ + $2.@@$1((((((((((((((((((((((((((((((((((((($2@@. + $2@@$1((((((((((((((((((((((((((((((((((((((($2@@ + $2@@#$1((((((((((((((((((((((((((((($2%@@@@@@@#$1(#$2@@ + $2.@@$1(((((((((((((((($2#%@@@@@@@@@&%#$1(((($2%@&$1(((($2@@. + $2.@@$1(((((((/($2&@@@@@@%$1(/(((((((((((((($2@@/$1((((($2@@. + $2.@@$1(///////////////////////////////$2@$1(///////$2@@ + $2%@#$1/////////////////////////////($2#$1////////$2%@% + $2 @@$1(///////////////////////////$2%$1/////////($2@@ + $2@@#$1***********************************$2%@@ + $2*@@$1********************************$2/@@/ + $2,@@#$1***************************$2%@@* + $2@@@&$1********************$2/@@@@ + $2&@@@@&$1(//***//($2&@@@@& + $2**@@@@@@@@@@@* \ No newline at end of file diff --git a/src/logo/ascii/kslinux.txt b/src/logo/ascii/kslinux.txt index b795c5f4ba..38444905b4 100644 --- a/src/logo/ascii/kslinux.txt +++ b/src/logo/ascii/kslinux.txt @@ -4,7 +4,7 @@ KKK U U RRRR o o K K U U R R o o K K UUU R R ooo -${c2} SSS AAA W W AAA +$2 SSS AAA W W AAA S A A W W A A SSS AAAAA W W W AAAAA S A A WW WW A A diff --git a/src/logo/ascii/lainos.txt b/src/logo/ascii/lainos.txt index 0338e0c960..7b4b31c576 100644 --- a/src/logo/ascii/lainos.txt +++ b/src/logo/ascii/lainos.txt @@ -1,20 +1,20 @@ -${c2} /==\ +$2 /==\ \==/ -${c1} · · · · · · · +$1 · · · · · · · · · · · · · · · · · - · · · ${c2}.-======-.${c1}· · · · -${c2} .::.${c1} ·${c2}.-============-.${c1}· ${c2}.::. - .:==:${c1}· ${c2}.:===:'${c1}. ·· .${c2}':===:.${c1} ·${c2}:==:. - .:===:${c1} · ${c2}:===.${c1} · ${c3}.--.${c1} · ${c2}.===:${c1} · ${c2}:===:. - :===:${c1}· · ${c2}:===.${c1} · ${c3}.:====:.${c1} · ${c2}.===:${c1} · ·${c2}:===: -(===:${c1}· · ${c2}:===-${c1} · ${c3}:======:${c1} · ${c2}-===:${c1} · ·${c2}:===) - :===:${c1}· · ${c2}:===.${c1} · ${c3}':====:'${c1} · ${c2}.===:${c1} · ·${c2}:===: - ':===:${c1} · ${c2}:===.${c1} · ${c3}'--'${c1} · ${c2}.===:${c1} · ${c2}:===:' - ':==:${c1}· ${c2}':===:.${c1}' ·· '${c2}.:===:'${c1} ·${c2}:==:' - '::'${c1} · ${c2}'===-. .-==='${c1} · ${c2}'::' - ${c2}/==\${c1} · · · ${c2}:=== ===:${c1} · · · ${c2}/==\ - \==/${c1} · · ·${c2}:===${c1} ·${c2}===:${c1}· · · ${c2}\==/${c2} - .-. ${c1}· ${c2}:===${c1}· ${c2}===:${c1} ·${c2} ${c2}.-. + · · · $2.-======-.$1· · · · +$2 .::.$1 ·$2.-============-.$1· $2.::. + .:==:$1· $2.:===:'$1. ·· .$2':===:.$1 ·$2:==:. + .:===:$1 · $2:===.$1 · $3.--.$1 · $2.===:$1 · $2:===:. + :===:$1· · $2:===.$1 · $3.:====:.$1 · $2.===:$1 · ·$2:===: +(===:$1· · $2:===-$1 · $3:======:$1 · $2-===:$1 · ·$2:===) + :===:$1· · $2:===.$1 · $3':====:'$1 · $2.===:$1 · ·$2:===: + ':===:$1 · $2:===.$1 · $3'--'$1 · $2.===:$1 · $2:===:' + ':==:$1· $2':===:.$1' ·· '$2.:===:'$1 ·$2:==:' + '::'$1 · $2'===-. .-==='$1 · $2'::' + $2/==\$1 · · · $2:=== ===:$1 · · · $2/==\ + \==/$1 · · ·$2:===$1 ·$2===:$1· · · $2\==/$2 + .-. $1· $2:===$1· $2===:$1 ·$2 $2.-. .===. .=== ===. .===. .======== ========. ''''' ''''' \ No newline at end of file diff --git a/src/logo/ascii/libreelec.txt b/src/logo/ascii/libreelec.txt index 41fe43ac2f..13278c6d03 100644 --- a/src/logo/ascii/libreelec.txt +++ b/src/logo/ascii/libreelec.txt @@ -1,20 +1,20 @@ -${c1} :+ooo/. ${c2}./ooo+: -${c1} :+ooooooo/. ${c2}./ooooooo+: -${c1} :+ooooooooooo:${c2}:ooooooooooo+: -${c1} :+ooooooooooo+- ${c2}-+ooooooooooo+: -${c1} :+ooooooooooo+- ${c3}-- ${c2}-+ooooooooooo+: -${c1}.+ooooooooooo+- ${c3}:+oo+: ${c2}-+ooooooooooo+- -${c1}-+ooooooooo+- ${c3}:+oooooo+: ${c2}-+oooooooooo- -${c1} :+ooooo+- ${c3}:+oooooooooo+: ${c2}-+oooooo: -${c1} :+o+- ${c3}:+oooooooooooooo+: ${c2}-+oo: -${c4} ./ ${c3}:oooooooooooooooooo: ${c5}/. -${c4} ./oo+: ${c3}-+oooooooooooooo+- ${c5}:+oo/. -${c4} ./oooooo+: ${c3}-+oooooooooo+- ${c5}:+oooooo/. -${c4}-oooooooooo+: ${c3}-+oooooo+- ${c5}:+oooooooooo- -${c4}.+ooooooooooo+: ${c3}-+oo+- ${c5}:+ooooooooooo+. -${c4} -+ooooooooooo+: ${c3}.. ${c5}:+ooooooooooo+- -${c4} -+ooooooooooo+: ${c5}:+ooooooooooo+- -${c4} -+oooooooooo+:${c5}:+oooooooooo+- -${c4} -+oooooo+: ${c5}:+oooooo+- -${c4} -+oo+: ${c5}:+oo+- -${c4} .. ${c5}.. \ No newline at end of file +$1 :+ooo/. $2./ooo+: +$1 :+ooooooo/. $2./ooooooo+: +$1 :+ooooooooooo:$2:ooooooooooo+: +$1 :+ooooooooooo+- $2-+ooooooooooo+: +$1 :+ooooooooooo+- $3-- $2-+ooooooooooo+: +$1.+ooooooooooo+- $3:+oo+: $2-+ooooooooooo+- +$1-+ooooooooo+- $3:+oooooo+: $2-+oooooooooo- +$1 :+ooooo+- $3:+oooooooooo+: $2-+oooooo: +$1 :+o+- $3:+oooooooooooooo+: $2-+oo: +$4 ./ $3:oooooooooooooooooo: $5/. +$4 ./oo+: $3-+oooooooooooooo+- $5:+oo/. +$4 ./oooooo+: $3-+oooooooooo+- $5:+oooooo/. +$4-oooooooooo+: $3-+oooooo+- $5:+oooooooooo- +$4.+ooooooooooo+: $3-+oo+- $5:+ooooooooooo+. +$4 -+ooooooooooo+: $3.. $5:+ooooooooooo+- +$4 -+ooooooooooo+: $5:+ooooooooooo+- +$4 -+oooooooooo+:$5:+oooooooooo+- +$4 -+oooooo+: $5:+oooooo+- +$4 -+oo+: $5:+oo+- +$4 .. $5.. \ No newline at end of file diff --git a/src/logo/ascii/linspire.txt b/src/logo/ascii/linspire.txt index ef3de677fc..48b2c8e568 100644 --- a/src/logo/ascii/linspire.txt +++ b/src/logo/ascii/linspire.txt @@ -1,12 +1,12 @@ -${c2} __^ -${c2} __/ \ -${c2} MMy dMy __/ \ -${c2} dMMy MMy ${c1}MM${c2} \ -${c2} MMMy ,, ${c1}dMMMMn ${c2}\ -${c2} dMMy dMM dMMMMMMy ${c1}dMM MM dMMMMMy dMM MM.nMMM dMMMMMM -${c1}MMM ${c2}MMy MMy MMy ${c1}dMM MMy MMy MMy MMy dy dMy -${c1}MMM ${c2}dMM dMM MMy ${c1}dMMMMy dMM dMM dMM dMM dMMMMMMM -${c2} dMMy MMy MMy MMy ${c1}dMMy MM MMy MMy MMy dMM -${c2}dMMy dMM dMM dMM ${c1}dMM MMy dMMMMMy dMM dMM MMy MM -${c2}MMMMMMMMMM MMy MMy MMy ${c1}dMMMyyy MMy MMy MMy dMMMMMMy -${c2} ${c1}dy \ No newline at end of file +$2 __^ +$2 __/ \ +$2 MMy dMy __/ \ +$2 dMMy MMy $1MM$2 \ +$2 MMMy ,, $1dMMMMn $2\ +$2 dMMy dMM dMMMMMMy $1dMM MM dMMMMMy dMM MM.nMMM dMMMMMM +$1MMM $2MMy MMy MMy $1dMM MMy MMy MMy MMy dy dMy +$1MMM $2dMM dMM MMy $1dMMMMy dMM dMM dMM dMM dMMMMMMM +$2 dMMy MMy MMy MMy $1dMMy MM MMy MMy MMy dMM +$2dMMy dMM dMM dMM $1dMM MMy dMMMMMy dMM dMM MMy MM +$2MMMMMMMMMM MMy MMy MMy $1dMMMyyy MMy MMy MMy dMMMMMMy +$2 $1dy \ No newline at end of file diff --git a/src/logo/ascii/linuxlite_small.txt b/src/logo/ascii/linuxlite_small.txt index 1aedb12aa2..2e0fc1f943 100644 --- a/src/logo/ascii/linuxlite_small.txt +++ b/src/logo/ascii/linuxlite_small.txt @@ -1,7 +1,7 @@ /\ / \ - / ${c2}/ ${c1}/ -/ ${c2}/ ${c1}/ -\ ${c2}\ ${c1}\ - \_${c2}\${c1}_\ -${c2} \ \ No newline at end of file + / $2/ $1/ +/ $2/ $1/ +\ $2\ $1\ + \_$2\$1_\ +$2 \ \ No newline at end of file diff --git a/src/logo/ascii/lubuntu.txt b/src/logo/ascii/lubuntu.txt index 2843553b97..49acd83164 100644 --- a/src/logo/ascii/lubuntu.txt +++ b/src/logo/ascii/lubuntu.txt @@ -2,19 +2,19 @@ `.:yyyyyyyyyyyyyyyyyy:.` .:yyyyyyyyyyyyyyyyyyyyyyyy:. .:yyyyyyyyyyyyyyyyyyyyyyyyyyyy:. - -yyyyyyyyyyyyyy${c2}+hNMMMNh+${c1}yyyyyyyyy- - :yy${c2}mNy+${c1}yyyyyyyy${c2}+Nmso++smMdhyysoo+${c1}yy: - -yy${c2}+MMMmmy${c1}yyyyyy${c2}hh${c1}yyyyyyyyyyyyyyyyyyy- -.yyyy${c2}NMN${c1}yy${c2}shhs${c1}yyy${c2}+o${c1}yyyyyyyyyyyyyyyyyyyy. -:yyyy${c2}oNM+${c1}yyyy${c2}+sso${c1}yyyyyyy${c2}ss${c1}yyyyyyyyyyyyy: -:yyyyy${c2}+dNs${c1}yyyyyyy${c2}++${c1}yyyyy${c2}oN+${c1}yyyyyyyyyyyy: -:yyyyy${c2}oMMmhysso${c1}yyyyyyyyyy${c2}mN+${c1}yyyyyyyyyyy: -:yyyyyy${c2}hMm${c1}yyyyy${c2}+++${c1}yyyyyyy${c2}+MN${c1}yyyyyyyyyyy: -.yyyyyyy${c2}ohmy+${c1}yyyyyyyyyyyyy${c2}NMh${c1}yyyyyyyyyy. - -yyyyyyyyyy${c2}++${c1}yyyyyyyyyyyy${c2}MMh${c1}yyyyyyyyy- - :yyyyyyyyyyyyyyyyyyyyy${c2}+mMN+${c1}yyyyyyyy: - -yyyyyyyyyyyyyyyyy${c2}+sdMMd+${c1}yyyyyyyy- - .:yyyyyyyyy${c2}hmdmmNMNdy+${c1}yyyyyyyy:. - .:yyyyyyy${c2}my${c1}yyyyyyyyyyyyyyy:. - `.:yyyy${c2}s${c1}yyyyyyyyyyyyy:.` + -yyyyyyyyyyyyyy$2+hNMMMNh+$1yyyyyyyyy- + :yy$2mNy+$1yyyyyyyy$2+Nmso++smMdhyysoo+$1yy: + -yy$2+MMMmmy$1yyyyyy$2hh$1yyyyyyyyyyyyyyyyyyy- +.yyyy$2NMN$1yy$2shhs$1yyy$2+o$1yyyyyyyyyyyyyyyyyyyy. +:yyyy$2oNM+$1yyyy$2+sso$1yyyyyyy$2ss$1yyyyyyyyyyyyy: +:yyyyy$2+dNs$1yyyyyyy$2++$1yyyyy$2oN+$1yyyyyyyyyyyy: +:yyyyy$2oMMmhysso$1yyyyyyyyyy$2mN+$1yyyyyyyyyyy: +:yyyyyy$2hMm$1yyyyy$2+++$1yyyyyyy$2+MN$1yyyyyyyyyyy: +.yyyyyyy$2ohmy+$1yyyyyyyyyyyyy$2NMh$1yyyyyyyyyy. + -yyyyyyyyyy$2++$1yyyyyyyyyyyy$2MMh$1yyyyyyyyy- + :yyyyyyyyyyyyyyyyyyyyy$2+mMN+$1yyyyyyyy: + -yyyyyyyyyyyyyyyyy$2+sdMMd+$1yyyyyyyy- + .:yyyyyyyyy$2hmdmmNMNdy+$1yyyyyyyy:. + .:yyyyyyy$2my$1yyyyyyyyyyyyyyy:. + `.:yyyy$2s$1yyyyyyyyyyyyy:.` `.:/oosyyyysso/:.` diff --git a/src/logo/ascii/lunar.txt b/src/logo/ascii/lunar.txt index 8024785316..de98565a16 100644 --- a/src/logo/ascii/lunar.txt +++ b/src/logo/ascii/lunar.txt @@ -1,13 +1,13 @@ `-. `-. -ohys/-` `:+shy/` -omNNdyo/` :+shmNNy/` - ${c3} - + $3 - /mMmo hMMMN` .NMMs - ${c1} -:+oooo+//: ${c3}/MN${c1}. -///oooo+/-` - /:.` ${c3}/${c1} `.:/` -${c3} __ + $1 -:+oooo+//: $3/MN$1. -///oooo+/-` + /:.` $3/$1 `.:/` +$3 __ | | _ _ ___ ___ ___ | |__| | | | .'| _| |_____|___|_|_|__,|_| \ No newline at end of file diff --git a/src/logo/ascii/macos3.txt b/src/logo/ascii/macos3.txt index 4abb278922..32f60ae131 100644 --- a/src/logo/ascii/macos3.txt +++ b/src/logo/ascii/macos3.txt @@ -1,16 +1,16 @@ -${c1} -:+:. -${c1} :++++. -${c1} /+++/. -${c1} .:-::- .+/:-\`\`.::- -${c1} .:/++++++/::::/++++++/::` -${c2} .:///////////////////////::` -${c2} /////////////////////////` -${c3}+++++++++++++++++++++++++` -${c3}++++++++++++++++++++++++ -${c4}ssssssssssssssssssssssss. -${c4}:ssssssssssssssssssssssss- -${c5} osssssssssssssssssssssssss` -${c5} `syyyyyyyyyyyyyyyyyyyyyyyyys` -${c6} `ossssssssssssssssssssssss -${c6} :ooooooooooooooooooo+. -${c6} `:++oo+/:- -:/+o+/- \ No newline at end of file +$1 -:+:. +$1 :++++. +$1 /+++/. +$1 .:-::- .+/:-\`\`.::- +$1 .:/++++++/::::/++++++/::` +$2 .:///////////////////////::` +$2 /////////////////////////` +$3+++++++++++++++++++++++++` +$3++++++++++++++++++++++++ +$4ssssssssssssssssssssssss. +$4:ssssssssssssssssssssssss- +$5 osssssssssssssssssssssssss` +$5 `syyyyyyyyyyyyyyyyyyyyyyyyys` +$6 `ossssssssssssssssssssssss +$6 :ooooooooooooooooooo+. +$6 `:++oo+/:- -:/+o+/- \ No newline at end of file diff --git a/src/logo/ascii/mageia.txt b/src/logo/ascii/mageia.txt index 9ccbc8b271..cf4050cf9f 100644 --- a/src/logo/ascii/mageia.txt +++ b/src/logo/ascii/mageia.txt @@ -4,7 +4,7 @@ . . °°° .°°°. .°°°. '___' -${c2} .${c1}'___' ${c2} . +$2 .$1'___' $2 . :dkxc;'. ..,cxkd; .dkk. kkkkkkkkkk .kkd. .dkk. ';cloolc;. .kkd diff --git a/src/logo/ascii/mageia_small.txt b/src/logo/ascii/mageia_small.txt index 632f368147..5bfffbba9b 100644 --- a/src/logo/ascii/mageia_small.txt +++ b/src/logo/ascii/mageia_small.txt @@ -1,7 +1,7 @@ * * ** -${c2} /\__/\ +$2 /\__/\ / \ \ / \____/ \ No newline at end of file diff --git a/src/logo/ascii/magix.txt b/src/logo/ascii/magix.txt index 0ceb350a83..3f19aa11d7 100644 --- a/src/logo/ascii/magix.txt +++ b/src/logo/ascii/magix.txt @@ -1,17 +1,17 @@ - ${c2}@ + $2@ @@--=====@@ @@--==@@ @@====+@ @-@@ @==@ @=@ - @=@${c1} @=@ @-==== @=@${c2} - @=@${c1} @-===@==++@===+@${c2} - @=@${c1} @--====@@=====+@${c2} --=@${c1} @--==========++@${c2} -==${c1} @--==========++@${c2} @=@ -@==${c1} @--=======@==++@${c2} @=+@ - @==${c1} @-==========++${c2} @=@ - @==${c1} @-=======@=%${c2} @=@ - @==${c1} @@@@@@${c2} @=@ + @=@$1 @=@ @-==== @=@$2 + @=@$1 @-===@==++@===+@$2 + @=@$1 @--====@@=====+@$2 +-=@$1 @--==========++@$2 +==$1 @--==========++@$2 @=@ +@==$1 @--=======@==++@$2 @=+@ + @==$1 @-==========++$2 @=@ + @==$1 @-=======@=%$2 @=@ + @==$1 @@@@@@$2 @=@ @====@@@ @@===+% @@=====@@==++++@@ =#@=@ diff --git a/src/logo/ascii/magpieos.txt b/src/logo/ascii/magpieos.txt index ce2010cff1..018597d58a 100644 --- a/src/logo/ascii/magpieos.txt +++ b/src/logo/ascii/magpieos.txt @@ -1,20 +1,20 @@ ;00000 :000Ol .x00kk00: O0kk00k; l00: :00. o0k :O0k. - .k0k. x${c2}d$dddd${c1}k' .d00; - k0k. ${c2}.dddddl ${c1}o00, - o00. ${c2}':cc:. ${c1}d0O + .k0k. x$2d$dddd$1k' .d00; + k0k. $2.dddddl $1o00, + o00. $2':cc:. $1d0O .00l ,00. l00. d0x k0O .:k0o O0k ;dO0000d. -k0O .O0O${c2}xxxxk${c1}00: -o00. k0O${c2}dddddd${c1}occ -'00l x0O${c2}dddddo${c3};..${c1} - x00. .x00${c2}kxxd${c3}:..${c1} - .O0x .:oxxx${c4}Okl.${c1} - .x0d ${c4},xx,${c1} - .:o. ${c4}.xd ckd${c1} - .. ${c4}dxl .xx; +k0O .O0O$2xxxxk$100: +o00. k0O$2dddddd$1occ +'00l x0O$2dddddo$3;..$1 + x00. .x00$2kxxd$3:..$1 + .O0x .:oxxx$4Okl.$1 + .x0d $4,xx,$1 + .:o. $4.xd ckd$1 + .. $4dxl .xx; :xxolldxd' ;oxdl. \ No newline at end of file diff --git a/src/logo/ascii/meowix.txt b/src/logo/ascii/meowix.txt index 8fc66b08d4..80022daaa9 100644 --- a/src/logo/ascii/meowix.txt +++ b/src/logo/ascii/meowix.txt @@ -1,10 +1,10 @@ -${c1} #${c2}% ${c3}&${c4}* -${c1} ##${c2}%% ${c3}&&${c4}** -${c1} ## ${c2}%% ${c3}&& ${c4}** -${c1} ## ${c2}%% ${c3}&& ${c4}** -${c1} ## ${c2}%% ${c3}&& ${c4}** -${c1} ## ${c2}%% ${c3}&& ${c4}** -${c1} ## ${c2}%%${c3}&& ${c4}** -${c1} ## ${c2}%% ${c4}** -${c1} ## ${c4}** -${c1}## ${c4}** \ No newline at end of file +$1 #$2% $3&$4* +$1 ##$2%% $3&&$4** +$1 ## $2%% $3&& $4** +$1 ## $2%% $3&& $4** +$1 ## $2%% $3&& $4** +$1 ## $2%% $3&& $4** +$1 ## $2%%$3&& $4** +$1 ## $2%% $4** +$1 ## $4** +$1## $4** \ No newline at end of file diff --git a/src/logo/ascii/nekos.txt b/src/logo/ascii/nekos.txt index fcfa05bfa2..4ddaf1c5d7 100644 --- a/src/logo/ascii/nekos.txt +++ b/src/logo/ascii/nekos.txt @@ -5,13 +5,13 @@ @@@@@@@@@@@@@ . @@@@@@@@@@@@@@@@@ , @@@@@@@@@@@@@@@@@@@ - @@@@@${c2}///${c1}@@@@@@@${c2}///${c1}@@@ - @@@@${c2}/***${c1}@@@@@@@${c2}**//${c1}@@@@ + @@@@@$2///$1@@@@@@@$2///$1@@@ + @@@@$2/***$1@@@@@@@$2**//$1@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@ @@@/ /@@@@@@@@@/ /@@@ - @@@@@@ @@@${c3}██${c1}@@@@ @@@@@@ - @@@@@@/ /@${c2}██${c3}██${c2}██${c1}@@/ /@@@@@@ + @@@@@@ @@@$3██$1@@@@ @@@@@@ + @@@@@@/ /@$2██$3██$2██$1@@/ /@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@ ##########%%%% ##########%% %% diff --git a/src/logo/ascii/omnios.txt b/src/logo/ascii/omnios.txt index a0636a5fca..a1512dc573 100644 --- a/src/logo/ascii/omnios.txt +++ b/src/logo/ascii/omnios.txt @@ -1,8 +1,8 @@ ____ __ __ _ _ _ / __ \ | \/ || \ | || | | | | || || \| || | -| |__| || |\/| || , `${c2}_${c1}||${c2}_${c1}| ${c2}____${c1} - \____/ |_| |_||_|\${c2}/ __ \ / ___| +| |__| || |\/| || , `$2_$1||$2_$1| $2____$1 + \____/ |_| |_||_|\$2/ __ \ / ___| | | | ||(__ - ${c3}community${c2} | |__| | ___)| - ${c3}edition${c2} \____/ |____/ \ No newline at end of file + $3community$2 | |__| | ___)| + $3edition$2 \____/ |____/ \ No newline at end of file diff --git a/src/logo/ascii/openeuler.txt b/src/logo/ascii/openeuler.txt index a2fc627295..344d432b4c 100644 --- a/src/logo/ascii/openeuler.txt +++ b/src/logo/ascii/openeuler.txt @@ -3,19 +3,19 @@ `.cccccccccccccccc.` ``.cccccccccccccccccccccc.`` `..cccccccccccccccccccccccccccc..` -`.ccccccccccccccc${c2}/++/${c1}ccccccccccccccccc.` -.ccccccccccccccc${c2}mNMMNdo+oso+${c1}ccccccccccc. -.cccccccccc${c2}/++odms+//+mMMMMm/:+syso/${c1}cccc -.ccccccccc${c2}yNNMMMs:::/::+o+/:${c1}c${c2}dMMMMMm${c1}cccc -.ccccccc${c2}:+NmdyyhNNmNNNd:${c1}ccccc${c1}${c2}:oyyyo:${c1}cccc -.ccc${c2}:ohdmMs:${c1}cccc${c2}+mNMNmy${c1}ccccccccccccccccc -.cc${c2}/NMMMMMo////:${c1}c${c2}:///:${c1}cccccccccccccccccc -.cc${c2}:syysyNMNNNMNy${c1}ccccccccccccccccccccccc -.cccccccc${c2}+MMMMMNy${c1}c${c2}:/+++/${c1}cccccccccccccccc -.ccccccccc${c2}ohhhs/${c1}c${c2}omMMMMNh${c1}ccccccccccccccc -.ccccccccccccccc${c2}:MMMMMMMM/${c1}cccccccccccccc -.cccccccccccccccc${c2}sNNNNNd+${c1}cccccccccccccc. -`..cccccccccccccccc${c2}/+/:${c1}cccccccccccccc..` +`.ccccccccccccccc$2/++/$1ccccccccccccccccc.` +.ccccccccccccccc$2mNMMNdo+oso+$1ccccccccccc. +.cccccccccc$2/++odms+//+mMMMMm/:+syso/$1cccc +.ccccccccc$2yNNMMMs:::/::+o+/:$1c$2dMMMMMm$1cccc +.ccccccc$2:+NmdyyhNNmNNNd:$1ccccc$1$2:oyyyo:$1cccc +.ccc$2:ohdmMs:$1cccc$2+mNMNmy$1ccccccccccccccccc +.cc$2/NMMMMMo////:$1c$2:///:$1cccccccccccccccccc +.cc$2:syysyNMNNNMNy$1ccccccccccccccccccccccc +.cccccccc$2+MMMMMNy$1c$2:/+++/$1cccccccccccccccc +.ccccccccc$2ohhhs/$1c$2omMMMMNh$1ccccccccccccccc +.ccccccccccccccc$2:MMMMMMMM/$1cccccccccccccc +.cccccccccccccccc$2sNNNNNd+$1cccccccccccccc. +`..cccccccccccccccc$2/+/:$1cccccccccccccc..` ``.cccccccccccccccccccccccccccc.`` `.cccccccccccccccccccccc.` ``.cccccccccccccc.`` diff --git a/src/logo/ascii/openindiana.txt b/src/logo/ascii/openindiana.txt index 3ac73148b5..d9b7e56091 100644 --- a/src/logo/ascii/openindiana.txt +++ b/src/logo/ascii/openindiana.txt @@ -1,15 +1,15 @@ -${c2} .sy/ +$2 .sy/ .yh+ - ${c1}-+syyyo+- ${c2} /+. - ${c1}+ddo/---/sdh/ ${c2} ym- - ${c1}`hm+ `sms${c2} ym-```````.-. - ${c1}sm+ sm/ ${c2} ym- +s - ${c1}hm. /mo ${c2} ym- /h - ${c1}omo ym: ${c2} ym- `os` - ${c1}smo` .ym+ ${c2} ym- .os- - `` ${c1}:ymy+///oyms- ${c2} ym- .+s+. - ..` ${c1}`:+oo+/-` ${c2} -//oyo- + $1-+syyyo+- $2 /+. + $1+ddo/---/sdh/ $2 ym- + $1`hm+ `sms$2 ym-```````.-. + $1sm+ sm/ $2 ym- +s + $1hm. /mo $2 ym- /h + $1omo ym: $2 ym- `os` + $1smo` .ym+ $2 ym- .os- + `` $1:ymy+///oyms- $2 ym- .+s+. + ..` $1`:+oo+/-` $2 -//oyo- -:` .:oys/. +- `./oyys/. h+` `.-:+oyyyo/-` diff --git a/src/logo/ascii/openmamba.txt b/src/logo/ascii/openmamba.txt index 94318fedb6..8730bbed7a 100644 --- a/src/logo/ascii/openmamba.txt +++ b/src/logo/ascii/openmamba.txt @@ -3,9 +3,9 @@ ./ooooooooooooooooooo+:. -+oooooooooooooooooooooooo+- .+ooooooooo+/:---::/+ooooooooo+. - :oooooooo/-` `-/oo${c2}s´${c1}oooo.${c2}s´${c1} - :ooooooo/` `${c2}sNds${c1}ooo${c2}sNds${c1} - -ooooooo- ${c2}:dmy${c1}ooo${c2}:dmy${c1} + :oooooooo/-` `-/oo$2s´$1oooo.$2s´$1 + :ooooooo/` `$2sNds$1ooo$2sNds$1 + -ooooooo- $2:dmy$1ooo$2:dmy$1 +oooooo: :oooooo- .ooooooo .://:` :oooooo+ ./+o+:` diff --git a/src/logo/ascii/opnsense.txt b/src/logo/ascii/opnsense.txt index 1ae5b205b2..618d717e1d 100644 --- a/src/logo/ascii/opnsense.txt +++ b/src/logo/ascii/opnsense.txt @@ -6,11 +6,11 @@ .,cll:' ':llc,. ,;;:okxdxd: :dxdxko:;;, .xxxx0XNNK0O. .O0KNNX0xxxx. - ,${c2}cc:${c1},. .,${c2}:cc${c1}, - ........;${c2}ccc:${c1};. .;${c2}:ccc${c1};........ - ${c2}ccccccccccccccc ccccccccccccccc${c1} - ........;${c2}ccc:${c1};. .;${c2}:ccc${c1};........ - ,${c2}cc:${c1},. .,${c2}:cc${c1}, + ,$2cc:$1,. .,$2:cc$1, + ........;$2ccc:$1;. .;$2:ccc$1;........ + $2ccccccccccccccc ccccccccccccccc$1 + ........;$2ccc:$1;. .;$2:ccc$1;........ + ,$2cc:$1,. .,$2:cc$1, .xxxx0XNNK0O. .O0KNNX0xxxx. ,;;:okxdxd: :dxdxko:;;, .,cll:' ':llc,. diff --git a/src/logo/ascii/orchid.txt b/src/logo/ascii/orchid.txt index 17362a1cba..bf084f8d1f 100644 --- a/src/logo/ascii/orchid.txt +++ b/src/logo/ascii/orchid.txt @@ -1,20 +1,20 @@ -${c2} .==. - .-${c3}#${c1}@@${c3}#${c2}-. - .-${c3}##${c1}@@@@${c3}##${c2}-. - .-${c3}##${c1}@@@@@@@@${c3}##${c2}-. - :*${c1}@@@@@${c3}####${c1}@@@@@${c2}*: - ..:*${c1}@@@@${c2}==--==${c1}@@@@${c2}*:.. - .-*${c1}%%${c3}#${c2}==${c3}#${c1}@@${c3}#${c2}====${c3}#${c1}@@${c3}#${c2}==${c3}#${c1}%%${c2}*-. - .-${c3}#${c1}@@@@@${c3}##${c2}==${c3}#${c1}@@${c2}++${c1}@@${c3}##${c2}==${c3}#${c1}@@@@@${c3}#${c2}-. - .-${c3}#${c1}@@@@@${c2}#${c1}@@@${c3}#${c2}++#====${c3}#${c2}++#${c1}@@@${c2}#${c1}@@@@@${c3}#${c2}-. -.-${c3}#${c1}@@@@@${c3}#${c2}-==**${c3}###${c2}+:--:+${c3}###${c2}**==-${c3}#${c1}@@@@@${c3}#${c2}-. -.-${c3}#${c1}@@@@@${c3}#${c2}-==**${c3}###${c2}+:--:+${c3}###${c2}**==-${c3}#${c1}@@@@@${c3}#${c2}-. - .-${c3}#${c1}@@@@@${c2}#${c1}@@@${c3}#${c2}++#====${c3}#${c2}++#${c1}@@@${c2}#${c1}@@@@@${c3}#${c2}-. - .-${c3}#${c1}@@@@@${c3}##${c2}==${c3}#${c1}@@${c2}++${c1}@@${c3}##${c2}==${c3}#${c1}@@@@@${c3}#${c2}-. - .-*${c1}%%${c3}#${c2}==${c3}#${c1}@@${c3}#${c2}====${c3}#${c1}@@${c3}#${c2}==${c3}#${c1}%%${c2}*-. - ..:*${c1}@@@@${c2}==--==${c1}@@@@${c2}*:.. - :*${c1}@@@@@${c3}####${c1}@@@@@${c2}*: - .-${c3}##${c1}@@@@@@@@${c3}##${c2}-. - .-${c3}##${c1}@@@@${c3}##${c2}-. - .-${c3}#${c1}@@${c3}#${c2}-. +$2 .==. + .-$3#$1@@$3#$2-. + .-$3##$1@@@@$3##$2-. + .-$3##$1@@@@@@@@$3##$2-. + :*$1@@@@@$3####$1@@@@@$2*: + ..:*$1@@@@$2==--==$1@@@@$2*:.. + .-*$1%%$3#$2==$3#$1@@$3#$2====$3#$1@@$3#$2==$3#$1%%$2*-. + .-$3#$1@@@@@$3##$2==$3#$1@@$2++$1@@$3##$2==$3#$1@@@@@$3#$2-. + .-$3#$1@@@@@$2#$1@@@$3#$2++#====$3#$2++#$1@@@$2#$1@@@@@$3#$2-. +.-$3#$1@@@@@$3#$2-==**$3###$2+:--:+$3###$2**==-$3#$1@@@@@$3#$2-. +.-$3#$1@@@@@$3#$2-==**$3###$2+:--:+$3###$2**==-$3#$1@@@@@$3#$2-. + .-$3#$1@@@@@$2#$1@@@$3#$2++#====$3#$2++#$1@@@$2#$1@@@@@$3#$2-. + .-$3#$1@@@@@$3##$2==$3#$1@@$2++$1@@$3##$2==$3#$1@@@@@$3#$2-. + .-*$1%%$3#$2==$3#$1@@$3#$2====$3#$1@@$3#$2==$3#$1%%$2*-. + ..:*$1@@@@$2==--==$1@@@@$2*:.. + :*$1@@@@@$3####$1@@@@@$2*: + .-$3##$1@@@@@@@@$3##$2-. + .-$3##$1@@@@$3##$2-. + .-$3#$1@@$3#$2-. .==. \ No newline at end of file diff --git a/src/logo/ascii/orchid_small.txt b/src/logo/ascii/orchid_small.txt index 22fe0ca16b..6af179fcbb 100644 --- a/src/logo/ascii/orchid_small.txt +++ b/src/logo/ascii/orchid_small.txt @@ -1,13 +1,13 @@ - ${c2}:##: - -#${c1}@@@@${c2}#- - #${c1}@@${c2}=..=${c1}@@${c2}# - +${c1}@@${c2}- -${c1}@@${c2}+ - -#${c1}@@${c2}*..*${c1}@${c2}..${c1}@${c2}*..*${c1}@@${c2}#- - :#${c1}@@${c2}*+%${c1}@${c2}= . . =${c1}@${c2}%+*${c1}@@${c2}#: -+${c1}@@@${c2}: :-. .-: :${c1}@@@${c2}+ - :#${c1}@@${c2}*+%${c1}@${c2}= . . =${c1}@${c2}%+*${c1}@@${c2}#: - -#${c1}@@${c2}*..*${c1}@${c2}..${c1}@${c2}*..*${c1}@@${c2}#- - +${c1}@@${c2}- -${c1}@@${c2}+ - #${c1}@@${c2}=..=${c1}@@${c2}# - -#${c1}@@@@${c2}#- + $2:##: + -#$1@@@@$2#- + #$1@@$2=..=$1@@$2# + +$1@@$2- -$1@@$2+ + -#$1@@$2*..*$1@$2..$1@$2*..*$1@@$2#- + :#$1@@$2*+%$1@$2= . . =$1@$2%+*$1@@$2#: ++$1@@@$2: :-. .-: :$1@@@$2+ + :#$1@@$2*+%$1@$2= . . =$1@$2%+*$1@@$2#: + -#$1@@$2*..*$1@$2..$1@$2*..*$1@@$2#- + +$1@@$2- -$1@@$2+ + #$1@@$2=..=$1@@$2# + -#$1@@@@$2#- :##: \ No newline at end of file diff --git a/src/logo/ascii/panwah.txt b/src/logo/ascii/panwah.txt index 36fc73e408..8d3dd89620 100644 --- a/src/logo/ascii/panwah.txt +++ b/src/logo/ascii/panwah.txt @@ -3,19 +3,19 @@ HAAAAH HAAAH HAAAAAAH HAAAAH HAAAAAAH HAAAAAH - HAAAAAAAAH${c2}WWWWWWWWWWWWWWWW ${c1}HAAAAAH - HAAAAAAAAH${c2}WWWWWWWWWWWWWWWWWWWW${c1} HAAAAAH - HAA${c2}WWWWWWWWWWWWWWWWWWWWWWWWWWWWW${c1}AAAAAH${c2} - WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW${c1}WAH${c2} + HAAAAAAAAH$2WWWWWWWWWWWWWWWW $1HAAAAAH + HAAAAAAAAH$2WWWWWWWWWWWWWWWWWWWW$1 HAAAAAH + HAA$2WWWWWWWWWWWWWWWWWWWWWWWWWWWWW$1AAAAAH$2 + WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW$1WAH$2 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW -WWWWWWW${c1}AAA${c2}WWWW WWWWWWWWWWWWWWWWWWWWWWWWWWW - WWWW${c1}AAA${c2}WWWWW WWWWWWW WWWWWWWWWWWWWWW - WW${c1}AAA${c2}WWWWWWWWWWWWWWWWW WWWWW${c1}AAA${c2}WWWWWWWW - ${c1}AAA${c2}WWWWW${c1}OOOOOOOOOOO${c2}WWWWWWWWWWW${c1}AAA${c2}WWWWWW - ${c1}OOOO${c3}GGGGGGG${c1}OOOO${c2}WWWWWWWWWW${c1}AAA${c2}WWWW - ${c1}OOO${c3}GGGGGGG${c1}OOO${c2}WWWWWWWWWWWW${c1}AAA${c2}W - ${c1}OOOOOOOOO \ No newline at end of file +WWWWWWW$1AAA$2WWWW WWWWWWWWWWWWWWWWWWWWWWWWWWW + WWWW$1AAA$2WWWWW WWWWWWW WWWWWWWWWWWWWWW + WW$1AAA$2WWWWWWWWWWWWWWWWW WWWWW$1AAA$2WWWWWWWW + $1AAA$2WWWWW$1OOOOOOOOOOO$2WWWWWWWWWWW$1AAA$2WWWWWW + $1OOOO$3GGGGGGG$1OOOO$2WWWWWWWWWW$1AAA$2WWWW + $1OOO$3GGGGGGG$1OOO$2WWWWWWWWWWWW$1AAA$2W + $1OOOOOOOOO \ No newline at end of file diff --git a/src/logo/ascii/parsix.txt b/src/logo/ascii/parsix.txt index 43a9c53c74..ddbf9124aa 100644 --- a/src/logo/ascii/parsix.txt +++ b/src/logo/ascii/parsix.txt @@ -1,21 +1,21 @@ - ${c2}-/+/:. - ${c2}.syssssys. - ${c1}.--. ${c2}ssssssssso${c1} ..--. - :++++++: ${c2}+ssssssss+${c1} ./++/+++: - /+++++++++.${c2}.yssooooy`${c1}-+///////o- - /++++++++++.${c2}+soooos:${c1}:+////////+- - :+++++////o-${c2}oooooo-${c1}+/////////- - `-/++//++-${c4}.-----.-${c1}:+/////:- - ${c3}-://::--${c1}-:/:${c4}.--.````.--.${c1}:::-${c3}--::::::. -${c3}-/:::::::://:${c4}.:-` `-:${c3}`:/:::::::--/- -${c3}/::::::::::/-${c4}--. .-.${c3}-/://///::::/ -${c3}-/:::::::::/:${c4}`:-. .-:${c3}`:///////////- - `${c3}-::::--${c1}.-://.${c4}---....---${c1}`:+/:-${c3}--::::-` - ${c1}-/+///+o/-${c4}.----.${c1}.:oo+++o+. - ${c1}-+/////+++o:${c2}syyyyy.${c1}o+++++++++: - ${c1}.+////+++++-${c2}+sssssy+${c1}.++++++++++\ - ${c1}.+:/++++++.${c2}.yssssssy-${c1}`+++++++++: - ${c1}:/+++++- ${c2}+sssssssss ${c1}-++++++- - ${c1}`--` ${c2}+sssssssso ${c1}`--` - ${c2}+sssssy+` - ${c2}`.::-` \ No newline at end of file + $2-/+/:. + $2.syssssys. + $1.--. $2ssssssssso$1 ..--. + :++++++: $2+ssssssss+$1 ./++/+++: + /+++++++++.$2.yssooooy`$1-+///////o- + /++++++++++.$2+soooos:$1:+////////+- + :+++++////o-$2oooooo-$1+/////////- + `-/++//++-$4.-----.-$1:+/////:- + $3-://::--$1-:/:$4.--.````.--.$1:::-$3--::::::. +$3-/:::::::://:$4.:-` `-:$3`:/:::::::--/- +$3/::::::::::/-$4--. .-.$3-/://///::::/ +$3-/:::::::::/:$4`:-. .-:$3`:///////////- + `$3-::::--$1.-://.$4---....---$1`:+/:-$3--::::-` + $1-/+///+o/-$4.----.$1.:oo+++o+. + $1-+/////+++o:$2syyyyy.$1o+++++++++: + $1.+////+++++-$2+sssssy+$1.++++++++++\ + $1.+:/++++++.$2.yssssssy-$1`+++++++++: + $1:/+++++- $2+sssssssss $1-++++++- + $1`--` $2+sssssssso $1`--` + $2+sssssy+` + $2`.::-` \ No newline at end of file diff --git a/src/logo/ascii/pclinuxos.txt b/src/logo/ascii/pclinuxos.txt index dd76e3d6aa..9e1cfa7458 100644 --- a/src/logo/ascii/pclinuxos.txt +++ b/src/logo/ascii/pclinuxos.txt @@ -4,13 +4,13 @@ Nsshhy+. `/shhysm dohhy/ -shhsy dohhs` /hhys -N+hho ${c2}+ssssss+- .+syhys+ ${c1}/hhsy -ohhh` ${c2}ymmo++hmm+`smmy/::+y` ${c1}shh+ -+hho ${c2}ymm- /mmy+mms ${c1}:hhod -/hh+ ${c2}ymmhhdmmh.smm/ ${c1}.hhsh -+hhs ${c2}ymm+::-` /mmy` ` ${c1}/hh+m -yyhh- ${c2}ymm- /dmdyosyd` ${c1}`yhh+ - ohhy` ${c2}://` -/+++/- ${c1}ohhom +N+hho $2+ssssss+- .+syhys+ $1/hhsy +ohhh` $2ymmo++hmm+`smmy/::+y` $1shh+ ++hho $2ymm- /mmy+mms $1:hhod +/hh+ $2ymmhhdmmh.smm/ $1.hhsh ++hhs $2ymm+::-` /mmy` ` $1/hh+m +yyhh- $2ymm- /dmdyosyd` $1`yhh+ + ohhy` $2://` -/+++/- $1ohhom N+hhy- `shhoh sshho. `+hhyom dsyhhs/. `:ohhhoy diff --git a/src/logo/ascii/pengwin.txt b/src/logo/ascii/pengwin.txt index 4e3007a549..7bec1886e4 100644 --- a/src/logo/ascii/pengwin.txt +++ b/src/logo/ascii/pengwin.txt @@ -1,15 +1,15 @@ -${c3} ...` -${c3} `-///:-` -${c3} .+${c2}ssys${c3}/ -${c3} +${c2}yyyyy${c3}o ${c2} -${c2} -yyyyyy: -${c2} `.:/+ooo+/:` -yyyyyy+ -${c2} `:oyyyyyys+:-.`syyyyyy: -${c2} .syyyyyyo-` .oyyyyyyo -${c2}`syyyyyy `-+yyyyyyy/` -${c2}/yyyyyy+ -/osyyyyyyo/. -${c2}+yyyyyy- `.-:::-.` -${c2}.yyyyyy- -${c3} :${c2}yyyyy${c3}o -${c3} .+${c2}ooo${c3}+ -${c3} `.::/:. \ No newline at end of file +$3 ...` +$3 `-///:-` +$3 .+$2ssys$3/ +$3 +$2yyyyy$3o $2 +$2 -yyyyyy: +$2 `.:/+ooo+/:` -yyyyyy+ +$2 `:oyyyyyys+:-.`syyyyyy: +$2 .syyyyyyo-` .oyyyyyyo +$2`syyyyyy `-+yyyyyyy/` +$2/yyyyyy+ -/osyyyyyyo/. +$2+yyyyyy- `.-:::-.` +$2.yyyyyy- +$3 :$2yyyyy$3o +$3 .+$2ooo$3+ +$3 `.::/:. \ No newline at end of file diff --git a/src/logo/ascii/pentoo.txt b/src/logo/ascii/pentoo.txt index 3f50f42db0..4d8a2bdccb 100644 --- a/src/logo/ascii/pentoo.txt +++ b/src/logo/ascii/pentoo.txt @@ -1,4 +1,4 @@ -${c2} `:oydNNMMMMNNdyo:` +$2 `:oydNNMMMMNNdyo:` :yNMMMMMMMMMMMMMMMMNy: :dMMMMMMMMMMMMMMMMMMMMMMd: oMMMMMMMho/-....-/ohMMMMMMMo @@ -6,15 +6,15 @@ ${c2} `:oydNNMMMMNNdyo:` .MMMMMMo oMMMMMM. +MMMMMm mMMMMM+ oMMMMMh hMMMMMo - //hMMMMMm//${c1}`${c2} ${c1}`${c2}////mMMMMMh// -MMMMMMMMMMM${c1}/${c2} ${c1}/o/`${c2} ${c1}.${c2}smMMMMMMMMMMM -MMMMMMMMMMm ${c1}`NMN:${c2} ${c1}.${c2}yMMMMMMMMMM -MMMMMMMMMMMh${c1}:.${c2} dMMMMMMMMM -MMMMMMMMMMMMMy${c1}.${c2} ${c1}-${c2}NMMMMMMMMM -MMMMMMMMMMMd:${c1}`${c2} ${c1}-${c2}yNMMMMMMMMMM -MMMMMMMMMMh${c1}`${c2} ${c1}./${c2}hNMMMMMMMMMMMM -MMMMMMMMMM${c1}s${c2} ${c1}.:${c2}ymMMMMMMMMMMMMMMM -MMMMMMMMMMN${c1}s:..-/${c2}ohNMMMMMMMMMMMMMMMMMM + //hMMMMMm//$1`$2 $1`$2////mMMMMMh// +MMMMMMMMMMM$1/$2 $1/o/`$2 $1.$2smMMMMMMMMMMM +MMMMMMMMMMm $1`NMN:$2 $1.$2yMMMMMMMMMM +MMMMMMMMMMMh$1:.$2 dMMMMMMMMM +MMMMMMMMMMMMMy$1.$2 $1-$2NMMMMMMMMM +MMMMMMMMMMMd:$1`$2 $1-$2yNMMMMMMMMMM +MMMMMMMMMMh$1`$2 $1./$2hNMMMMMMMMMMMM +MMMMMMMMMM$1s$2 $1.:$2ymMMMMMMMMMMMMMMM +MMMMMMMMMMN$1s:..-/$2ohNMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM \ No newline at end of file diff --git a/src/logo/ascii/peppermint.txt b/src/logo/ascii/peppermint.txt index 4f83cece21..a579575efc 100644 --- a/src/logo/ascii/peppermint.txt +++ b/src/logo/ascii/peppermint.txt @@ -1,21 +1,21 @@ -${c1} PPPPPPPPPPPPPP -${c1} PPPP${c2}MMMMMMM${c1}PPPPPPPPPPP -${c1} PPPP${c2}MMMMMMMMMM${c1}PPPPPPPP${c2}MM${c1}PP -${c1} PPPPPPPP${c2}MMMMMMM${c1}PPPPPPPP${c2}MMMMM${c1}PP -${c1} PPPPPPPPPPPP${c2}MMMMMM${c1}PPPPPPP${c2}MMMMMMM${c1}PP -${c1} PPPPPPPPPPPP${c2}MMMMMMM${c1}PPPP${c2}M${c1}P${c2}MMMMMMMMM${c1}PP -${c1} PP${c2}MMMM${c1}PPPPPPPPPP${c2}MMM${c1}PPPPP${c2}MMMMMMM${c1}P${c2}MM${c1}PPPP -${c1} P${c2}MMMMMMMMMM${c1}PPPPPP${c2}MM${c1}PPPPP${c2}MMMMMM${c1}PPPPPPPP -${c1}P${c2}MMMMMMMMMMMM${c1}PPPPP${c2}MM${c1}PP${c2}M${c1}P${c2}MM${c1}P${c2}MM${c1}PPPPPPPPPPP -${c1}P${c2}MMMMMMMMMMMMMMMM${c1}PP${c2}M${c1}P${c2}MMM${c1}PPPPPPPPPPPPPPPP -${c1}P${c2}MMM${c1}PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP${c2}MMMMM${c1}P -${c1}PPPPPPPPPPPPPPPP${c2}MMM${c1}P${c2}M${c1}P${c2}MMMMMMMMMMMMMMMM${c1}PP -${c1}PPPPPPPPPPP${c2}MM${c1}P${c2}MM${c1}PPPP${c2}MM${c1}PPPPP${c2}MMMMMMMMMMM${c1}PP -${c1} PPPPPPPP${c2}MMMMMM${c1}PPPPP${c2}MM${c1}PPPPPP${c2}MMMMMMMMM${c1}PP -${c1} PPPP${c2}MM${c1}P${c2}MMMMMMM${c1}PPPPPP${c2}MM${c1}PPPPPPPPPP${c2}MMMM${c1}PP -${c1} PP${c2}MMMMMMMMM${c1}P${c2}M${c1}PPPP${c2}MMMMMM${c1}PPPPPPPPPPPPP -${c1} PP${c2}MMMMMMM${c1}PPPPPPP${c2}MMMMMM${c1}PPPPPPPPPPPP -${c1} PP${c2}MMMM${c1}PPPPPPPPP${c2}MMMMMMM${c1}PPPPPPPP -${c1} PP${c2}MM${c1}PPPPPPPP${c2}MMMMMMMMMM${c1}PPPP -${c1} PPPPPPPPPP${c2}MMMMMMMM${c1}PPPP -${c1} PPPPPPPPPPPPPP \ No newline at end of file +$1 PPPPPPPPPPPPPP +$1 PPPP$2MMMMMMM$1PPPPPPPPPPP +$1 PPPP$2MMMMMMMMMM$1PPPPPPPP$2MM$1PP +$1 PPPPPPPP$2MMMMMMM$1PPPPPPPP$2MMMMM$1PP +$1 PPPPPPPPPPPP$2MMMMMM$1PPPPPPP$2MMMMMMM$1PP +$1 PPPPPPPPPPPP$2MMMMMMM$1PPPP$2M$1P$2MMMMMMMMM$1PP +$1 PP$2MMMM$1PPPPPPPPPP$2MMM$1PPPPP$2MMMMMMM$1P$2MM$1PPPP +$1 P$2MMMMMMMMMM$1PPPPPP$2MM$1PPPPP$2MMMMMM$1PPPPPPPP +$1P$2MMMMMMMMMMMM$1PPPPP$2MM$1PP$2M$1P$2MM$1P$2MM$1PPPPPPPPPPP +$1P$2MMMMMMMMMMMMMMMM$1PP$2M$1P$2MMM$1PPPPPPPPPPPPPPPP +$1P$2MMM$1PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP$2MMMMM$1P +$1PPPPPPPPPPPPPPPP$2MMM$1P$2M$1P$2MMMMMMMMMMMMMMMM$1PP +$1PPPPPPPPPPP$2MM$1P$2MM$1PPPP$2MM$1PPPPP$2MMMMMMMMMMM$1PP +$1 PPPPPPPP$2MMMMMM$1PPPPP$2MM$1PPPPPP$2MMMMMMMMM$1PP +$1 PPPP$2MM$1P$2MMMMMMM$1PPPPPP$2MM$1PPPPPPPPPP$2MMMM$1PP +$1 PP$2MMMMMMMMM$1P$2M$1PPPP$2MMMMMM$1PPPPPPPPPPPPP +$1 PP$2MMMMMMM$1PPPPPPP$2MMMMMM$1PPPPPPPPPPPP +$1 PP$2MMMM$1PPPPPPPPP$2MMMMMMM$1PPPPPPPP +$1 PP$2MM$1PPPPPPPP$2MMMMMMMMMM$1PPPP +$1 PPPPPPPPPP$2MMMMMMMM$1PPPP +$1 PPPPPPPPPPPPPP \ No newline at end of file diff --git a/src/logo/ascii/pisi.txt b/src/logo/ascii/pisi.txt index dc32d7a5d5..16958be0cc 100644 --- a/src/logo/ascii/pisi.txt +++ b/src/logo/ascii/pisi.txt @@ -1,19 +1,19 @@ \Fv/!- `:?lzC -${c1} Q!::=zFx! ${c2}`;v6WBCicl;` ${c1},vCC\!::#. -${c1} ,%:::,'` ${c2}+#%@@FQ@@. ,cF%i${c1}``-',::a? -${c1} +m:,'```${c2}}3,/@@Q\@@ "af-${c1} `-'"7f - =o'.` ${c2}/m' :Q@:Qg ,kl${c1} `.|o - :k` '${c2}$+ 'Narm >d,${c1} ii - #`${c2}!p. `C , 'd+${c1} %' -${c2} !0m `6Kv +$1 Q!::=zFx! $2`;v6WBCicl;` $1,vCC\!::#. +$1 ,%:::,'` $2+#%@@FQ@@. ,cF%i$1``-',::a? +$1 +m:,'```$2}3,/@@Q\@@ "af-$1 `-'"7f + =o'.` $2/m' :Q@:Qg ,kl$1 `.|o + :k` '$2$+ 'Narm >d,$1 ii + #`$2!p. `C , 'd+$1 %' +$2 !0m `6Kv =a m+ !A !\L|: :|L\! $: .8` Q''%Q#' '#Q%''Q `0- :6 E|.6QQu uQQ6.|E p: i{ \jts9? ?9stj\ u\ |a` -''. `e> - ,m+ ${c1}'^ !`${c2}s@@@@a${c1}'"`+`${c2} >e' - !3|${c1}`|=>>r- ${c2}'U%:${c1} '>>>=:`\3! - 'xopE| ${c2}`'${c1} `ledoz- - `;=>>+`${c2}`^llci/|==|/iclc;`${c1}'>>>>: - `^`+~ ${c2}````${c1} !!-^ \ No newline at end of file + ,m+ $1'^ !`$2s@@@@a$1'"`+`$2 >e' + !3|$1`|=>>r- $2'U%:$1 '>>>=:`\3! + 'xopE| $2`'$1 `ledoz- + `;=>>+`$2`^llci/|==|/iclc;`$1'>>>>: + `^`+~ $2````$1 !!-^ \ No newline at end of file diff --git a/src/logo/ascii/pnm_linux.txt b/src/logo/ascii/pnm_linux.txt index 1666762452..5152320982 100644 --- a/src/logo/ascii/pnm_linux.txt +++ b/src/logo/ascii/pnm_linux.txt @@ -1,19 +1,19 @@ ``.---..` `--` - ``.---........-:.${c2}-::`${c1} - ${c2}./::-${c1}........${c2}--::.````${c1} - ${c2}.:://:::${c1}----${c2}::::-..${c1} - ..${c2}--:::::--::::++-${c1}.` - ${c2}`-:-`${c1} .-ohy+::${c2}-:::${c1}/sdmdd:.${c2} `-:- - .-:::${c1}...${c3}sNNmds$y${c1}o/+${c3}sy+NN$m${c1}d+.`${c2}-:::-. - `.-:-${c1}./${c3}dN${c1}()${c3}yyooosd${c1}()${c3}$m${c1}dy${c2}-.::-.`${c1} - ${c2}`.${c1}-...-${c3}+hNdyyyyyydmy${c1}:......${c2}`${c1} - ``..--.....-${c3}yNNm${c4}hssssh${c3}mmdo${c1}.........``` -`-:://:.....${c3}hNNNNN${c4}mddm${c3}NNNmds${c1}.....//::--` - ```.:-...${c3}oNNNNNNNNNNNNNNmd/${c1}...:-.``` - .....${c3}hNNNNNNNNNNNNNNmds${c1}....` - --...${c3}hNNNNNNNNNNNNNNmdo${c1}..... - .:...${c3}/NNNNNNNNNNNNNNdd${c1}:....` - `-...${c3}+mNNNNNNNNNNNmh${c1}:...-. - ${c4}.:+o+/:-${c1}:+oo+///++o+/:-${c4}:/+ooo/:. - ${c4}+oo/:o- +oooooso.` - ${c4}.` ` `/ .-//- \ No newline at end of file + ``.---........-:.$2-::`$1 + $2./::-$1........$2--::.````$1 + $2.:://:::$1----$2::::-..$1 + ..$2--:::::--::::++-$1.` + $2`-:-`$1 .-ohy+::$2-:::$1/sdmdd:.$2 `-:- + .-:::$1...$3sNNmds$y$1o/+$3sy+NN$m$1d+.`$2-:::-. + `.-:-$1./$3dN$1()$3yyooosd$1()$3$m$1dy$2-.::-.`$1 + $2`.$1-...-$3+hNdyyyyyydmy$1:......$2`$1 + ``..--.....-$3yNNm$4hssssh$3mmdo$1.........``` +`-:://:.....$3hNNNNN$4mddm$3NNNmds$1.....//::--` + ```.:-...$3oNNNNNNNNNNNNNNmd/$1...:-.``` + .....$3hNNNNNNNNNNNNNNmds$1....` + --...$3hNNNNNNNNNNNNNNmdo$1..... + .:...$3/NNNNNNNNNNNNNNdd$1:....` + `-...$3+mNNNNNNNNNNNmh$1:...-. + $4.:+o+/:-$1:+oo+///++o+/:-$4:/+ooo/:. + $4+oo/:o- +oooooso.` + $4.` ` `/ .-//- \ No newline at end of file diff --git a/src/logo/ascii/proxmox.txt b/src/logo/ascii/proxmox.txt index e2b725440d..fda7bf16ac 100644 --- a/src/logo/ascii/proxmox.txt +++ b/src/logo/ascii/proxmox.txt @@ -1,20 +1,20 @@ -${c1} .://:` `://:. +$1 .://:` `://:. `hMMMMMMd/ /dMMMMMMh` `sMMMMMMMd: :mMMMMMMMs` -${c2}`-/+oo+/:${c1}`.yMMMMMMMh- -hMMMMMMMy.`${c2}:/+oo+/-` -`:oooooooo/${c1}`-hMMMMMMMyyMMMMMMMh-`${c2}/oooooooo:` - `/oooooooo:${c1}`:mMMMMMMMMMMMMm:`${c2}:oooooooo/` - ./ooooooo+-${c1} +NMMMMMMMMN+ ${c2}-+ooooooo/. - .+ooooooo+-${c1}`oNMMMMNo`${c2}-+ooooooo+. - -+ooooooo/.${c1}`sMMs`${c2}./ooooooo+- - :oooooooo/${c1}`..`${c2}/oooooooo: - :oooooooo/`${c1}..${c2}`/oooooooo: - -+ooooooo/.`${c1}sMMs${c2}`./ooooooo+- - .+ooooooo+-`${c1}oNMMMMNo${c2}`-+ooooooo+. - ./ooooooo+-${c1} +NMMMMMMMMN+ ${c2}-+ooooooo/. - `/oooooooo:`${c1}:mMMMMMMMMMMMMm:${c2}`:oooooooo/` -`:oooooooo/`${c1}-hMMMMMMMyyMMMMMMMh-${c2}`/oooooooo:` -`-/+oo+/:`${c1}.yMMMMMMMh- -hMMMMMMMy.${c2}`:/+oo+/-` -${c1} `sMMMMMMMm: :dMMMMMMMs` +$2`-/+oo+/:$1`.yMMMMMMMh- -hMMMMMMMy.`$2:/+oo+/-` +`:oooooooo/$1`-hMMMMMMMyyMMMMMMMh-`$2/oooooooo:` + `/oooooooo:$1`:mMMMMMMMMMMMMm:`$2:oooooooo/` + ./ooooooo+-$1 +NMMMMMMMMN+ $2-+ooooooo/. + .+ooooooo+-$1`oNMMMMNo`$2-+ooooooo+. + -+ooooooo/.$1`sMMs`$2./ooooooo+- + :oooooooo/$1`..`$2/oooooooo: + :oooooooo/`$1..$2`/oooooooo: + -+ooooooo/.`$1sMMs$2`./ooooooo+- + .+ooooooo+-`$1oNMMMMNo$2`-+ooooooo+. + ./ooooooo+-$1 +NMMMMMMMMN+ $2-+ooooooo/. + `/oooooooo:`$1:mMMMMMMMMMMMMm:$2`:oooooooo/` +`:oooooooo/`$1-hMMMMMMMyyMMMMMMMh-$2`/oooooooo:` +`-/+oo+/:`$1.yMMMMMMMh- -hMMMMMMMy.$2`:/+oo+/-` +$1 `sMMMMMMMm: :dMMMMMMMs` `hMMMMMMd/ /dMMMMMMh` `://:` `://:` \ No newline at end of file diff --git a/src/logo/ascii/q4os.txt b/src/logo/ascii/q4os.txt index cf002ed2b1..01e178c824 100644 --- a/src/logo/ascii/q4os.txt +++ b/src/logo/ascii/q4os.txt @@ -8,12 +8,12 @@ .*************: .=============. *************. .============: -${c1}:############. ${c2}:==: -${c1}:##############. ${c2}:======: - ${c1}:################ ${c2}.==========: - ${c1}:############### ${c2}.===========: - ${c1}:############## ${c2}.===========: - ${c1}:############# ${c2}.=========: - ${c1}:########### ${c2}.=====: - ${c1}.######### ${c2}.=: - ${c1}.##### \ No newline at end of file +$1:############. $2:==: +$1:##############. $2:======: + $1:################ $2.==========: + $1:############### $2.===========: + $1:############## $2.===========: + $1:############# $2.=========: + $1:########### $2.=====: + $1.######### $2.=: + $1.##### \ No newline at end of file diff --git a/src/logo/ascii/qubyt.txt b/src/logo/ascii/qubyt.txt index c7e0849a3e..f3101062bb 100644 --- a/src/logo/ascii/qubyt.txt +++ b/src/logo/ascii/qubyt.txt @@ -1,15 +1,15 @@ -${c1} ########################${c2}(${c3}ooo -${c1} ########################${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}###${c2}(${c3}ooo -${c1}###${c2}(${c3}ooo ${c1}##${c3}o ${c2}((((${c3}ooo -${c1}###${c2}(${c3}ooo o${c2}((${c1}### ${c3}oooooo -${c1}###${c2}(${c3}ooo oo${c2}((${c1}###${c3}o -${c1}###${c2}(${c3}ooo ooo${c2}((${c1}### -${c1}################${c2}(${c3}oo oo${c2}((((${c3}o -${c2}(((((((((((((((((${c3}ooo ooooo +$1 ########################$2($3ooo +$1 ########################$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1###$2($3ooo +$1###$2($3ooo $1##$3o $2(((($3ooo +$1###$2($3ooo o$2(($1### $3oooooo +$1###$2($3ooo oo$2(($1###$3o +$1###$2($3ooo ooo$2(($1### +$1################$2($3oo oo$2(((($3o +$2((((((((((((((((($3ooo ooooo oooooooooooooooooo o \ No newline at end of file diff --git a/src/logo/ascii/quibian.txt b/src/logo/ascii/quibian.txt index 8592ddfd20..647fb8f0d3 100644 --- a/src/logo/ascii/quibian.txt +++ b/src/logo/ascii/quibian.txt @@ -1,9 +1,9 @@ `.--::::::::--.` `.-:::-..`` ``..-::-.` - .::::-` .${c2}+${c1}:`` `.-::.` + .::::-` .$2+$1:`` `.-::.` .::::.` -::::::-` `.::. `-:::-` -:::::::::--..`` .::` - `::::- .${c2}oy${c1}:::::::---.```.: `::` + `::::- .$2oy$1:::::::---.```.: `::` -:::: `.-:::::::::::-.``` `:: .::::.`-:::::::::::::. `:. -::::.::::::::::::::: -: diff --git a/src/logo/ascii/radix.txt b/src/logo/ascii/radix.txt index 5007d484b6..4a3aa6f5b1 100644 --- a/src/logo/ascii/radix.txt +++ b/src/logo/ascii/radix.txt @@ -2,7 +2,7 @@ `/yhyoosdms` -o+/ohmmho- ..`.:/:-` - `.--:::-.``${c2} + `.--:::-.``$2 .+ydNMMMMMMNmhs:` `omMMMMMMMMMMMMMMNh- oNMMMNmddhhyyhhhddmy. diff --git a/src/logo/ascii/regata.txt b/src/logo/ascii/regata.txt index 163faa9d64..4f30382a48 100644 --- a/src/logo/ascii/regata.txt +++ b/src/logo/ascii/regata.txt @@ -1,20 +1,20 @@ ddhso+++++osydd - dho/.`hh${c2}.:/+/:.${c1}hhh`:+yd - do-hhhhhh${c2}/sssssss+`${c1}hhhhh./yd - h/`hhhhhhh${c2}-sssssssss:${c1}hhhhhhhh-yd - do`hhhhhhhhh${c2}`ossssssso.${c1}hhhhhhhhhh/d - d/hhhhhhhhhhhh${c2}`/ossso/.${c1}hhhhhhhhhhhh.h - /hhhhhhhhhhhh${c3}`-/osyso/-`${c1}hhhhhhhhhhhh.h -shh${c4}-/ooo+-${c1}hhh${c3}:syyso+osyys/`${c1}hhh${c5}`+oo`${c1}hhh/ -h${c4}`ohhhhhhho`${c3}+yyo.${c1}hhhhh${c3}.+yyo`${c5}.sssssss.${c1}h`h -s${c4}:hhhhhhhhho${c3}yys`${c1}hhhhhhh${c3}.oyy/${c5}ossssssso-${c1}hs -s${c4}.yhhhhhhhy/${c3}yys`${c1}hhhhhhh${c3}.oyy/${c5}ossssssso-${c1}hs -hh${c4}./syyys+.${c1} ${c3}+yy+.${c1}hhhhh${c3}.+yyo`${c5}.ossssso/${c1}h`h -shhh${c4}``.`${c1}hhh${c3}`/syyso++oyys/`${c1}hhh${c5}`+++-`${c1}hh:h -d/hhhhhhhhhhhh${c3}`-/osyso+-`${c1}hhhhhhhhhhhh.h - d/hhhhhhhhhhhh${c6}`/ossso/.${c1}hhhhhhhhhhhh.h - do`hhhhhhhhh${c6}`ossssssso.${c1}hhhhhhhhhh:h - h/`hhhhhhh${c6}-sssssssss:${c1}hhhhhhhh-yd - h+.hhhhhh${c6}+sssssss+${c1}hhhhhh`/yd - dho:.hhh${c6}.:+++/.${c1}hhh`-+yd + dho/.`hh$2.:/+/:.$1hhh`:+yd + do-hhhhhh$2/sssssss+`$1hhhhh./yd + h/`hhhhhhh$2-sssssssss:$1hhhhhhhh-yd + do`hhhhhhhhh$2`ossssssso.$1hhhhhhhhhh/d + d/hhhhhhhhhhhh$2`/ossso/.$1hhhhhhhhhhhh.h + /hhhhhhhhhhhh$3`-/osyso/-`$1hhhhhhhhhhhh.h +shh$4-/ooo+-$1hhh$3:syyso+osyys/`$1hhh$5`+oo`$1hhh/ +h$4`ohhhhhhho`$3+yyo.$1hhhhh$3.+yyo`$5.sssssss.$1h`h +s$4:hhhhhhhhho$3yys`$1hhhhhhh$3.oyy/$5ossssssso-$1hs +s$4.yhhhhhhhy/$3yys`$1hhhhhhh$3.oyy/$5ossssssso-$1hs +hh$4./syyys+.$1 $3+yy+.$1hhhhh$3.+yyo`$5.ossssso/$1h`h +shhh$4``.`$1hhh$3`/syyso++oyys/`$1hhh$5`+++-`$1hh:h +d/hhhhhhhhhhhh$3`-/osyso+-`$1hhhhhhhhhhhh.h + d/hhhhhhhhhhhh$6`/ossso/.$1hhhhhhhhhhhh.h + do`hhhhhhhhh$6`ossssssso.$1hhhhhhhhhh:h + h/`hhhhhhh$6-sssssssss:$1hhhhhhhh-yd + h+.hhhhhh$6+sssssss+$1hhhhhh`/yd + dho:.hhh$6.:+++/.$1hhh`-+yd ddhso+++++osyhd \ No newline at end of file diff --git a/src/logo/ascii/rhel_old.txt b/src/logo/ascii/rhel_old.txt index bb757c926f..99b86517fc 100644 --- a/src/logo/ascii/rhel_old.txt +++ b/src/logo/ascii/rhel_old.txt @@ -7,8 +7,8 @@ `://////:-.` :///////::///:` .-/////////:---/////////////: .-://////////////////////. -${c2} yMN+`.-${c1}::///////////////-` -${c2} .-`:NMMNMs` `..-------..` +$2 yMN+`.-$1::///////////////-` +$2 .-`:NMMNMs` `..-------..` MN+/mMMMMMhoooyysshsss MMM MMMMMMMMMMMMMMyyddMMM+ MMMM MMMMMMMMMMMMMNdyNMMh` hyhMMM diff --git a/src/logo/ascii/rhino.txt b/src/logo/ascii/rhino.txt index 8d4012f269..7bab3c37e9 100644 --- a/src/logo/ascii/rhino.txt +++ b/src/logo/ascii/rhino.txt @@ -1,12 +1,12 @@ -${c1} .;:;,. .: -${c1} 'coooooooo:oo.';. -${c1} ,oooooooooooooooo ; -${c1} clllcccllloooooooo;c:'o -${c1}.${c4};${c3}';:::::::::${c1}cclooooooo' -${c4}''',${c3}::::::::::::::${c1}ccclc. -${c4}.'''${c3};::::::::::${c2}l${c3}::::::: -${c4} ''''${c3},:::::::::${c2}kd${c3}. -${c4} .'''''${c3},;::${c2}ck:${c2}oW${c3}; -${c4} ''''''''${c2}kXOM. -${c4} .,,:${c2}dXMK -${c4} ${c2}:k +$1 .;:;,. .: +$1 'coooooooo:oo.';. +$1 ,oooooooooooooooo ; +$1 clllcccllloooooooo;c:'o +$1.$4;$3';:::::::::$1cclooooooo' +$4''',$3::::::::::::::$1ccclc. +$4.'''$3;::::::::::$2l$3::::::: +$4 ''''$3,:::::::::$2kd$3. +$4 .'''''$3,;::$2ck:$2oW$3; +$4 ''''''''$2kXOM. +$4 .,,:$2dXMK +$4 $2:k diff --git a/src/logo/ascii/rosa.txt b/src/logo/ascii/rosa.txt index 70c2d88846..e6caa5f6b2 100644 --- a/src/logo/ascii/rosa.txt +++ b/src/logo/ascii/rosa.txt @@ -1,15 +1,15 @@ -${c2} ⢀⣀⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣄ -${c2} ⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ -${c1} ⢀⣤⣄ ${c2}⣿⣿⣿⡇ -${c1} ⢀⣴⣿⣿⣿⠗ ${c2}⣿⣿⣿⡇ -${c1} ⢠⣾⣿⣿⡿⠁ ${c2}⣿⣿⣿⡇ -${c1} ⢠⣿⣿⣿⡟ ${c2}⣿⣿⣿⡇ -${c1}⢀⣿⣿⣿⡿ ${c2}⣿⣿⣿⡇ -${c1}⢸⣿⣿⣿⠃ ${c2}⣿⣿⣿⡇ -${c1}⢸⣿⣿⣿ ${c2}⣿⣿⣿⡇ -${c1}⢸⣿⣿⣿ ${c2}⣿⣿⣿⡇ -${c1}⢸⣿⣿⣿⡄ ${c2}⠙⢿⡿ -${c1}⠘⣿⣿⣿⣷ +$2 ⢀⣀⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣄ +$2 ⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇ +$1 ⢀⣤⣄ $2⣿⣿⣿⡇ +$1 ⢀⣴⣿⣿⣿⠗ $2⣿⣿⣿⡇ +$1 ⢠⣾⣿⣿⡿⠁ $2⣿⣿⣿⡇ +$1 ⢠⣿⣿⣿⡟ $2⣿⣿⣿⡇ +$1⢀⣿⣿⣿⡿ $2⣿⣿⣿⡇ +$1⢸⣿⣿⣿⠃ $2⣿⣿⣿⡇ +$1⢸⣿⣿⣿ $2⣿⣿⣿⡇ +$1⢸⣿⣿⣿ $2⣿⣿⣿⡇ +$1⢸⣿⣿⣿⡄ $2⠙⢿⡿ +$1⠘⣿⣿⣿⣷ ⠘⣿⣿⣿⣦ ⠙⣿⣿⣿⣷⡀ ⢀⡀ ⠘⢿⣿⣿⣿⣦⣄ ⣠⣴⣿⣿⡦ diff --git a/src/logo/ascii/sabayon.txt b/src/logo/ascii/sabayon.txt index cb0ceb8c4f..355610e254 100644 --- a/src/logo/ascii/sabayon.txt +++ b/src/logo/ascii/sabayon.txt @@ -1,18 +1,18 @@ ........... .. .. .. .. - .. ${c2}o ${c1}.. - .. ${c2}:W' ${c1}.. - .. ${c2}.d. ${c1}.. -:. ${c2}.KNO ${c1}.: -:. ${c2}cNNN. ${c1}.: -: ${c2}dXXX, ${c1}: -: ${c2}. dXXX, .cd, ${c1}: -: ${c2}'kc .. dKKK. ,ll;:' ${c1}: -: ${c2}.xkkxc;..dkkkc',cxkkl ${c1}: -:. ${c2}.,cdddddddddddddo:. ${c1}.: - .. ${c2}:lllllll: ${c1}.. - .. ${c2}',,,,, ${c1}.. + .. $2o $1.. + .. $2:W' $1.. + .. $2.d. $1.. +:. $2.KNO $1.: +:. $2cNNN. $1.: +: $2dXXX, $1: +: $2. dXXX, .cd, $1: +: $2'kc .. dKKK. ,ll;:' $1: +: $2.xkkxc;..dkkkc',cxkkl $1: +:. $2.,cdddddddddddddo:. $1.: + .. $2:lllllll: $1.. + .. $2',,,,, $1.. .. .. .. .. ............... \ No newline at end of file diff --git a/src/logo/ascii/salentos.txt b/src/logo/ascii/salentos.txt index 2824405b57..08d3eb29d8 100644 --- a/src/logo/ascii/salentos.txt +++ b/src/logo/ascii/salentos.txt @@ -1,20 +1,20 @@ ``..`` .-:+oshdNMMMMMMNdhyo+:-.` -oydmMMMMMMMMMMMMMMMMMMMMMMMMMMNdhs/ -${c4} +hdddm${c1}NMMMMMMMMMMMMMMMMMMMMMMMMN${c4}mdddh+` -${c2}`MMMMMN${c4}mdddddm${c1}MMMMMMMMMMMM${c4}mdddddm${c3}NMMMMM- -${c2} mMMMMMMMMMMMN${c4}ddddhyyhhddd${c3}NMMMMMMMMMMMM` -${c2} dMMMMMMMMMMMMMMMMM${c4}oo${c3}MMMMMMMMMMMMMMMMMN` -${c2} yMMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMd -${c2} +MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMy -${c2} :MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMMo -${c2} .MMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMM/ -${c2} `NMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMM- -${c2} mMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMN` -${c2} hMMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMm -${c2} /MMMMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMMMMy -${c2} .+hMMMMMMMMMMMMM${c4}hh${c3}MMMMMMMMMMMMMms: -${c2} `:smMMMMMMMMM${c4}hh${c3}MMMMMMMMMNh+. -${c2} .+hMMMMMM${c4}hh${c3}MMMMMMdo: -${c2} `:smMM${c4}yy${c3}MMNy/` - ${c2}.- ${c4}`${c3}:. \ No newline at end of file +$4 +hdddm$1NMMMMMMMMMMMMMMMMMMMMMMMMN$4mdddh+` +$2`MMMMMN$4mdddddm$1MMMMMMMMMMMM$4mdddddm$3NMMMMM- +$2 mMMMMMMMMMMMN$4ddddhyyhhddd$3NMMMMMMMMMMMM` +$2 dMMMMMMMMMMMMMMMMM$4oo$3MMMMMMMMMMMMMMMMMN` +$2 yMMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMMd +$2 +MMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMMy +$2 :MMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMMo +$2 .MMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMM/ +$2 `NMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMM- +$2 mMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMN` +$2 hMMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMm +$2 /MMMMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMMMMy +$2 .+hMMMMMMMMMMMMM$4hh$3MMMMMMMMMMMMMms: +$2 `:smMMMMMMMMM$4hh$3MMMMMMMMMNh+. +$2 .+hMMMMMM$4hh$3MMMMMMdo: +$2 `:smMM$4yy$3MMNy/` + $2.- $4`$3:. \ No newline at end of file diff --git a/src/logo/ascii/scientific.txt b/src/logo/ascii/scientific.txt index a433abb61a..eab2e4500a 100644 --- a/src/logo/ascii/scientific.txt +++ b/src/logo/ascii/scientific.txt @@ -7,8 +7,8 @@ M- ,=;;;#:, ,:#;;:=, ,@ :# :#.=/++++/=.$= #= ,#; #/:+/;,,/++:+/ ;+. ,+/. ,;@+, ,#H;, ,/+, - ;+;;/= @. ${c3}.H${c2}#${c3}#X ${c1}-X :///+; - ;+=;;;.@, ${c2}.X${c3}M${c2}@$. ${c1}=X.//;=#/. + ;+;;/= @. $3.H$2#$3#X $1-X :///+; + ;+=;;;.@, $2.X$3M$2@$. $1=X.//;=#/. ,;: :@#= =$H: .+#- ,#= #;-///==///-// =#, ;+ :#-;;;:;;;;-X- +: diff --git a/src/logo/ascii/semc.txt b/src/logo/ascii/semc.txt index 4167ec4b95..8c5a7d13a9 100644 --- a/src/logo/ascii/semc.txt +++ b/src/logo/ascii/semc.txt @@ -1,9 +1,9 @@ /\ ______/ \ - / |()| ${c2}E M C -${c1} | (-- | | + / |()| $2E M C +$1 | (-- | | \ \ | | .----) | |__| -|_______/ / ${c3}"${c1} \ - ${c3}" +|_______/ / $3"$1 \ + $3" " \ No newline at end of file diff --git a/src/logo/ascii/septor.txt b/src/logo/ascii/septor.txt index 7a3a1a7172..1a1a51366a 100644 --- a/src/logo/ascii/septor.txt +++ b/src/logo/ascii/septor.txt @@ -2,17 +2,17 @@ ssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssss ssssssssssssssssssssssssssssssssssssssss -ssssssssss${c2};okOOOOOOOOOOOOOOko;${c1}ssssssssss -sssssssss${c2}oNWWWWWWWWWWWWWWWWWWNo${c1}sssssssss -ssssssss${c2}:WWWWWWWWWWWWWWWWWWWWWW:${c1}ssssssss -ssssssss${c2}lWWWWWk${c1}ssssssssss${c2}lddddd:${c1}ssssssss -ssssssss${c2}cWWWWWNKKKKKKKKKKKKOx:${c1}ssssssssss -${c3}yy${c1}sssssss${c2}OWWWWWWWWWWWWWWWWWWWWx${c1}sssssss${c3}yy -yyyyyyyyyy${c2}:kKNNNNNNNNNNNNWWWWWW:${c3}yyyyyyyy -yyyyyyyy${c2}sccccc;${c3}yyyyyyyyyy${c2}kWWWWW:${c3}yyyyyyyy -yyyyyyyy${c2}:WWWWWWNNNNNNNNNNWWWWWW;${c3}yyyyyyyy -yyyyyyyy${c2}.dWWWWWWWWWWWWWWWWWWWNd${c3}yyyyyyyyy -yyyyyyyyyy${c2}sdO0KKKKKKKKKKKK0Od;${c3}yyyyyyyyyy +ssssssssss$2;okOOOOOOOOOOOOOOko;$1ssssssssss +sssssssss$2oNWWWWWWWWWWWWWWWWWWNo$1sssssssss +ssssssss$2:WWWWWWWWWWWWWWWWWWWWWW:$1ssssssss +ssssssss$2lWWWWWk$1ssssssssss$2lddddd:$1ssssssss +ssssssss$2cWWWWWNKKKKKKKKKKKKOx:$1ssssssssss +$3yy$1sssssss$2OWWWWWWWWWWWWWWWWWWWWx$1sssssss$3yy +yyyyyyyyyy$2:kKNNNNNNNNNNNNWWWWWW:$3yyyyyyyy +yyyyyyyy$2sccccc;$3yyyyyyyyyy$2kWWWWW:$3yyyyyyyy +yyyyyyyy$2:WWWWWWNNNNNNNNNNWWWWWW;$3yyyyyyyy +yyyyyyyy$2.dWWWWWWWWWWWWWWWWWWWNd$3yyyyyyyyy +yyyyyyyyyy$2sdO0KKKKKKKKKKKK0Od;$3yyyyyyyyyy yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy diff --git a/src/logo/ascii/skiffos.txt b/src/logo/ascii/skiffos.txt index 3897d74b4b..e98a64723a 100644 --- a/src/logo/ascii/skiffos.txt +++ b/src/logo/ascii/skiffos.txt @@ -1,9 +1,9 @@ -${c2} ,@@@@@@@@@@@w,_ - ${c2}====~~~,,.${c2}A@@@@@@@@@@@@@@@@@W,_ - ${c1}`||||||||||||||L{${c2}"@$@@@@@@@@B" - ${c1}`|||||||||||||||||||||L{${c2}"$D - ${c2}@@@@@@@@@@@@@@@@@@@@@${c1}_||||}==, - ${c2}*@@@@@@@@@@@@@@@@@@@@@@@@@p${c1}||||==, - ${c1}`'||LLL{{""${c2}@$B@@@@@@@@@@@@@@@p${c1}|| - ${c1}`~=|||||||||||L"${c2}$@@@@@@@@@@@ - ${c1}````'"""""""${c2}'"""""""" \ No newline at end of file +$2 ,@@@@@@@@@@@w,_ + $2====~~~,,.$2A@@@@@@@@@@@@@@@@@W,_ + $1`||||||||||||||L{$2"@$@@@@@@@@B" + $1`|||||||||||||||||||||L{$2"$D + $2@@@@@@@@@@@@@@@@@@@@@$1_||||}==, + $2*@@@@@@@@@@@@@@@@@@@@@@@@@p$1||||==, + $1`'||LLL{{""$2@$B@@@@@@@@@@@@@@@p$1|| + $1`~=|||||||||||L"$2$@@@@@@@@@@@ + $1````'"""""""$2'"""""""" \ No newline at end of file diff --git a/src/logo/ascii/soda.txt b/src/logo/ascii/soda.txt index 3d778fd9ee..c947682cef 100644 --- a/src/logo/ascii/soda.txt +++ b/src/logo/ascii/soda.txt @@ -1,15 +1,15 @@ - ${c2}@&&&&${c1} *'*, - ${c2}@@@@@@@&&&${c1} ** '*, - ${c2}@@@@@@@@@@@&&&& + $2@&&&&$1 *'*, + $2@@@@@@@&&&$1 ** '*, + $2@@@@@@@@@@@&&&& @&@@@@@@@@@@@@@@@&&& - ${c1}******${c2}@@@@@@@@@@@@@@@&&&& - ${c1}************${c2}@@@@@@@@@@@@@@ - ${c1}*****************${c2}@@@@@@@@@ - ${c1}**********************${c2}@@@ - @@@@@${c1}******************** - ${c2}@@@@@@@@@${c1}*************** -${c2}@@@@@@@@@@@@@@@${c1}********* -${c2}@@@@@@@@@@@@@@@@@@${c1}**** - ${c2}@@@@@@@@@@@@@@@@@@ + $1******$2@@@@@@@@@@@@@@@&&&& + $1************$2@@@@@@@@@@@@@@ + $1*****************$2@@@@@@@@@ + $1**********************$2@@@ + @@@@@$1******************** + $2@@@@@@@@@$1*************** +$2@@@@@@@@@@@@@@@$1********* +$2@@@@@@@@@@@@@@@@@@$1**** + $2@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@ \ No newline at end of file diff --git a/src/logo/ascii/swagarch.txt b/src/logo/ascii/swagarch.txt index 8df60b8db6..ad8d20996a 100644 --- a/src/logo/ascii/swagarch.txt +++ b/src/logo/ascii/swagarch.txt @@ -1,15 +1,15 @@ -${c2} .;ldkOKXXNNNNXXK0Oxoc,. +$2 .;ldkOKXXNNNNXXK0Oxoc,. ,lkXMMNK0OkkxkkOKWMMMMMMMMMM; 'K0xo ..,;:c:. `'lKMMMMM0 .lONMMMMMM' `lNMk' -${c2} ;WMMMMMMMMMO. ${c1}....::... -${c2} OMMMMMMMMMMMMKl. ${c1}.,;;;;;ccccccc, -${c2} `0MMMMMMMMMMMMMM0: ${c1}.. .ccccccc. -${c2} 'kWMMMMMMMMMMMMMNo. ${c1}.,:' .ccccccc. -${c2} `c0MMMMMMMMMMMMMN,${c1},:c; :cccccc: -${c2} ckl. `lXMMMMMMMMMX${c1}occcc:.. ;ccccccc. -${c2}dMMMMXd, `OMMMMMMWk${c1}ccc;:''` ,ccccccc: -${c2}XMMMMMMMWKkxxOWMMMMMNo${c1}ccc; .cccccccc. -${c2} `':ldxO0KXXXXXK0Okdo${c1}cccc. :cccccccc. +$2 ;WMMMMMMMMMO. $1....::... +$2 OMMMMMMMMMMMMKl. $1.,;;;;;ccccccc, +$2 `0MMMMMMMMMMMMMM0: $1.. .ccccccc. +$2 'kWMMMMMMMMMMMMMNo. $1.,:' .ccccccc. +$2 `c0MMMMMMMMMMMMMN,$1,:c; :cccccc: +$2 ckl. `lXMMMMMMMMMX$1occcc:.. ;ccccccc. +$2dMMMMXd, `OMMMMMMWk$1ccc;:''` ,ccccccc: +$2XMMMMMMMWKkxxOWMMMMMNo$1ccc; .cccccccc. +$2 `':ldxO0KXXXXXK0Okdo$1cccc. :cccccccc. :ccc:' `cccccccc:, '' \ No newline at end of file diff --git a/src/logo/ascii/t2_small.txt b/src/logo/ascii/t2_small.txt index 5ab9870cf8..83981dc572 100644 --- a/src/logo/ascii/t2_small.txt +++ b/src/logo/ascii/t2_small.txt @@ -1,6 +1,6 @@ -${c2}TTTTTTTTTT - tt ${c1}222${c2} - tt ${c1}2 2${c2} - tt ${c1}2${c2} - tt ${c1}2${c2} - tt ${c1}22222${c2} \ No newline at end of file +$2TTTTTTTTTT + tt $1222$2 + tt $12 2$2 + tt $12$2 + tt $12$2 + tt $122222$2 \ No newline at end of file diff --git a/src/logo/ascii/tileos.txt b/src/logo/ascii/tileos.txt index fb7e2842f2..42f3d59a2f 100644 --- a/src/logo/ascii/tileos.txt +++ b/src/logo/ascii/tileos.txt @@ -1,20 +1,20 @@ -${c2} ,. -${c2} ########## -${c2} ###################. -${c2} ############################ -${c2} #################################### -${c2} ###################################### -${c1},(/${c2} *############################( ${c3}.%${c1} -${c1}(((((((${c2} (#################### ${c3}%%####${c1} -${c1}(((((((((((/${c2} ############ ${c3}%#########${c1} -${c1}((((((((((((((((${c2} ##/ ${c3}(##############${c1} -${c1}((((((((((((((((((((${c2} ${c3}###################${c1} -${c1}(((((((((((((((((((((${c2} ${c3}####################${c1} -${c1}(((((((((((((((((((((${c2} ${c3}####################${c1} -${c1}(((((((((((((((((((((${c2} ${c3}####################${c1} -${c1}(((((((((((((((((((((${c2} ${c3}####################${c1} -${c1} ((((((((((((((((((((${c2} ${c3}###################%${c1} -${c1} ((((((((((((((((${c2} ${c3}################/${c1} -${c1} ((((((((((((${c2} ${c3}###########%${c1} -${c1} (((((((${c2} ${c3}#######*${c1} -${c1} (((${c2} ${c3}##%*${c1} \ No newline at end of file +$2 ,. +$2 ########## +$2 ###################. +$2 ############################ +$2 #################################### +$2 ###################################### +$1,(/$2 *############################( $3.%$1 +$1((((((($2 (#################### $3%%####$1 +$1(((((((((((/$2 ############ $3%#########$1 +$1(((((((((((((((($2 ##/ $3(##############$1 +$1(((((((((((((((((((($2 $3###################$1 +$1((((((((((((((((((((($2 $3####################$1 +$1((((((((((((((((((((($2 $3####################$1 +$1((((((((((((((((((((($2 $3####################$1 +$1((((((((((((((((((((($2 $3####################$1 +$1 (((((((((((((((((((($2 $3###################%$1 +$1 (((((((((((((((($2 $3################/$1 +$1 (((((((((((($2 $3###########%$1 +$1 ((((((($2 $3#######*$1 +$1 ((($2 $3##%*$1 \ No newline at end of file diff --git a/src/logo/ascii/torizoncore.txt b/src/logo/ascii/torizoncore.txt index 3e19c93fd0..541705aad9 100644 --- a/src/logo/ascii/torizoncore.txt +++ b/src/logo/ascii/torizoncore.txt @@ -1,28 +1,28 @@ -${c2} `.::-. +$2 `.::-. `-://////:-. `:////////////:. `.-.` `-:///////-. ` `.://///:.` `-::-. `-://:.` .:///////////:. `-:////////:.` `.://///////:-` .:////////////:` - `.-/:-` `.:///:-` ${c3}`-+o/.${c2} `.://////-. `.` - `.:///////:-` `.` ${c3}`-+sssssso/.${c2} `.--. `-:///:-` --/////////////: ${c3}`+sssssssssssso-${c2} `-://///////:-` - .-///////:.` `` ${c3}-/sssssssso/.${c2} ` .:///////////-. - .-::.` `-://:-. ${c3}-/sso/.${c2} `.:/:-. `.://///-. - `-:////////:-. ${c3}`${c2} `.:////////-. `.-. -${c1}o-${c2} -:///////////:` .:////////////:` ${c1}-o${c2} -${c1}hdho-${c2} `-://///:.` `..` `-://////:.` ${c1}-ohdh${c2} -${c1}/ydddho-${c2} `--.` `.:////:.` `-::.` ${c1}-ohdddy/${c2} - ${c1}./ydddho:`${c2} `.://////////:. ${c1}`:ohdddy/.${c2} -` ${c1}`/shddho:`${c2} `.://////////:. ${c1}`:ohddds/`${c2} ` -::-` ${c1}`/shddhs:`${c2} `.:////:.` ${c1}`:shddhs/`${c2} `-:: -:///:-` ${c1}`:shddhs/`${c2} `..` ${c1}`/shddhs:`${c2} `-:///- - `.:///:-` ${c1}`:ohddhs/`${c2} ${c1}`/shddho:`${c2} `-:///:.` - `.:///:-. ${c1}-ohdddy/.${c2} ${c1}./ydddho-${c2} .-:///-.` - `.:///:-. ${c1}-+hdddy+//+ydddh+-${c2} .-://:-. - `.-///:-. ${c1}-+yddddddy+-${c2} .-://:-. - .-://:-. ${c1}./++/.${c2} .-///:-. + `.-/:-` `.:///:-` $3`-+o/.$2 `.://////-. `.` + `.:///////:-` `.` $3`-+sssssso/.$2 `.--. `-:///:-` +-/////////////: $3`+sssssssssssso-$2 `-://///////:-` + .-///////:.` `` $3-/sssssssso/.$2 ` .:///////////-. + .-::.` `-://:-. $3-/sso/.$2 `.:/:-. `.://///-. + `-:////////:-. $3`$2 `.:////////-. `.-. +$1o-$2 -:///////////:` .:////////////:` $1-o$2 +$1hdho-$2 `-://///:.` `..` `-://////:.` $1-ohdh$2 +$1/ydddho-$2 `--.` `.:////:.` `-::.` $1-ohdddy/$2 + $1./ydddho:`$2 `.://////////:. $1`:ohdddy/.$2 +` $1`/shddho:`$2 `.://////////:. $1`:ohddds/`$2 ` +::-` $1`/shddhs:`$2 `.:////:.` $1`:shddhs/`$2 `-:: +:///:-` $1`:shddhs/`$2 `..` $1`/shddhs:`$2 `-:///- + `.:///:-` $1`:ohddhs/`$2 $1`/shddho:`$2 `-:///:.` + `.:///:-. $1-ohdddy/.$2 $1./ydddho-$2 .-:///-.` + `.:///:-. $1-+hdddy+//+ydddh+-$2 .-://:-. + `.-///:-. $1-+yddddddy+-$2 .-://:-. + .-://:-. $1./++/.$2 .-///:-. .-:///:.` `.:///:-` `-:///:.````.:///:-` `-:////////:-` diff --git a/src/logo/ascii/trisquel.txt b/src/logo/ascii/trisquel.txt index 013050ff2e..203345efcd 100644 --- a/src/logo/ascii/trisquel.txt +++ b/src/logo/ascii/trisquel.txt @@ -5,9 +5,9 @@ ,$$$$"' "Y$$$$$$$$o. 'b. ,b d$$$$$$ $$$$' .d$$$$$$$$b '$$$$$$$$o 'Y$$$$$$Y d$$$$$$' $$$$' q' 'b '$$$$$$$$$$o._ _.o$$$$$$$$' -.$$$$,_ _,d$$ ,$$$$$$$$$$$$$$$$$$$$$$$$${c2}$$$$$$$$Y' -${c1} '$$$$$$$$aaa$$$$$$' .$$$$$$$$$$$$${c2}$$$$$$$$$$$$$$$$' -${c1} """" ${c2}d$$$$$$$$"' +.$$$$,_ _,d$$ ,$$$$$$$$$$$$$$$$$$$$$$$$$2$$$$$$$$Y' +$1 '$$$$$$$$aaa$$$$$$' .$$$$$$$$$$$$$2$$$$$$$$$$$$$$$$' +$1 """" $2d$$$$$$$$"' d$$$$$$' .d$$$$b. $$$$$$$$ .$$" 'a$$. $$$$$$$$ $$b $$$$. diff --git a/src/logo/ascii/twister.txt b/src/logo/ascii/twister.txt index 6e7e8c3386..30ec36df89 100644 --- a/src/logo/ascii/twister.txt +++ b/src/logo/ascii/twister.txt @@ -1,23 +1,23 @@ -${c3}.......................${c4}.......${c5}.,:ccllllcc:.${c4}... -${c3}.......................${c5}.,;cldxkO0KXNNNWNNNX0x: -${c3}.................${c5}.,:ldkOOKK0OkkkkkOKWMMMMMMMNo -${c3}.............${c5},;coxO0Oxo::'${c4}.........${c5},oXMMMMMM0' -${c3}.........${c5},:ldkOOkc;'${c3}...${c4}.............${c5};OMMMMW0:${c4}. -${c3}.......${c5};ldkOxol:'${c3}......${c4}............${c5},dNMMX0''${c4}.. -${c3}....${c5};:oxkxl:'${c3}..........${c4}..........${c5},lOWWXx:.,'${c4}.. -${c3}..${c5},ldxkkd:'${c3}............${c5}.:c${c4}....${c5}':lkNMNOc,cdl'${c4}.. -${c3}.${c5};oxxkkkc'${c3}.........${c5}.:clc;'.';lkKNNKk;;ck00l${c4}... -${c5}.lxxxkkkxoooooddxkOOko'..cok0KOd':::o0NXd;'${c4}... -${c3}.${c5}:odxxkkOOOOOOOkdoi'..:ddxdoc:::od0NWW0c'${c4}..... -${c3}...${c5}':;gggggg;::''.......::::x0XWMMMNO.::'${c4}..... -${c3}..............${c5};......,;od0KNWMWNK0O:::do'${c4}..... -${c3}...............${c5}'cclgggggggxdll":::'XKoo,${c4}...... -${c3}.................${c5}',,,,,,,::::;ooNWMWOc'${c4}....... -${c3}..................${c5},:loxxxO0KXNNXK0ko:'${c4}........ -${c3}..................${c5}';::;oTcoggcoF":::'${c4}......... -${c3}..................${c5}':o,.:::::::::,p'${c4}........... -${c3}..................${c5};'ccdxkOOOdxlf'${c4}............. -${c3}.................${c5},l;;XgggggXP:'${c4}............... -${c3}................${c5};lco;::::::'${c4}.................. -${c3}..............${c5}.';ggggol'`${c4}..................... -${c3}.............${c5}':oo:''${c3}...${c4}....................... \ No newline at end of file +$3.......................$4.......$5.,:ccllllcc:.$4... +$3.......................$5.,;cldxkO0KXNNNWNNNX0x: +$3.................$5.,:ldkOOKK0OkkkkkOKWMMMMMMMNo +$3.............$5,;coxO0Oxo::'$4.........$5,oXMMMMMM0' +$3.........$5,:ldkOOkc;'$3...$4.............$5;OMMMMW0:$4. +$3.......$5;ldkOxol:'$3......$4............$5,dNMMX0''$4.. +$3....$5;:oxkxl:'$3..........$4..........$5,lOWWXx:.,'$4.. +$3..$5,ldxkkd:'$3............$5.:c$4....$5':lkNMNOc,cdl'$4.. +$3.$5;oxxkkkc'$3.........$5.:clc;'.';lkKNNKk;;ck00l$4... +$5.lxxxkkkxoooooddxkOOko'..cok0KOd':::o0NXd;'$4... +$3.$5:odxxkkOOOOOOOkdoi'..:ddxdoc:::od0NWW0c'$4..... +$3...$5':;gggggg;::''.......::::x0XWMMMNO.::'$4..... +$3..............$5;......,;od0KNWMWNK0O:::do'$4..... +$3...............$5'cclgggggggxdll":::'XKoo,$4...... +$3.................$5',,,,,,,::::;ooNWMWOc'$4....... +$3..................$5,:loxxxO0KXNNXK0ko:'$4........ +$3..................$5';::;oTcoggcoF":::'$4......... +$3..................$5':o,.:::::::::,p'$4........... +$3..................$5;'ccdxkOOOdxlf'$4............. +$3.................$5,l;;XgggggXP:'$4............... +$3................$5;lco;::::::'$4.................. +$3..............$5.';ggggol'`$4..................... +$3.............$5':oo:''$3...$4....................... \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_cinnamon.txt b/src/logo/ascii/ubuntu_cinnamon.txt index 512d25a6f8..5ed66900fa 100644 --- a/src/logo/ascii/ubuntu_cinnamon.txt +++ b/src/logo/ascii/ubuntu_cinnamon.txt @@ -1,20 +1,20 @@ .-/+oooooooo+/-. `:+oooooooooooooooooo+:` -+oooooooooooooooooooooooo+- - .ooooooooooooooooooo${c2}:ohNd${c1}oooooo. - /oooooooooooo${c2}:/+oo++:/ohNd${c1}ooooooo/ - +oooooooooo${c2}:osNdhyyhdNNh+:+${c1}oooooooo+ - /ooooooooo${c2}/dN/${c1}ooooooooo${c2}/sNNo${c1}ooooooooo/ -.ooooooooo${c2}oMd:${c1}oooooooooooo${c2}:yMy${c1}ooooooooo. -+ooooo${c2}:+o/Md${c1}oooooo${c2}:sm/${c1}oo/ooo${c2}yMo${c1}oooooooo+ -ooo${c2}:sdMdosMo${c1}ooooo${c2}oNMd${c1}//${c2}dMd+${c1}o${c2}:so${c1}ooooooooo -oooo${c2}+ymdosMo${c1}ooo${c2}+mMm${c1}+/${c2}hMMMMMh+hs${c1}ooooooooo -+oooooo${c2}:${c1}:${c2}/Nm:${c1}/${c2}hMNo${c1}:y${c2}MMMMMMMMMM+${c1}oooooooo+ -.ooooooooo${c2}/NNMNy${c1}:o${c2}NMMMMMMMMMMo${c1}ooooooooo. -/oooooooooo${c2}:yh:${c1}+m${c2}MMMMMMMMMMd/${c1}ooooooooo/ - +oooooooooo${c2}+${c1}/h${c2}mMMMMMMNds//o${c1}oooooooo+ - /oooooooooooo${c2}+:////:o/ymMd${c1}ooooooo/ - .oooooooooooooooooooo${c2}/sdh${c1}oooooo. + .ooooooooooooooooooo$2:ohNd$1oooooo. + /oooooooooooo$2:/+oo++:/ohNd$1ooooooo/ + +oooooooooo$2:osNdhyyhdNNh+:+$1oooooooo+ + /ooooooooo$2/dN/$1ooooooooo$2/sNNo$1ooooooooo/ +.ooooooooo$2oMd:$1oooooooooooo$2:yMy$1ooooooooo. ++ooooo$2:+o/Md$1oooooo$2:sm/$1oo/ooo$2yMo$1oooooooo+ +ooo$2:sdMdosMo$1ooooo$2oNMd$1//$2dMd+$1o$2:so$1ooooooooo +oooo$2+ymdosMo$1ooo$2+mMm$1+/$2hMMMMMh+hs$1ooooooooo ++oooooo$2:$1:$2/Nm:$1/$2hMNo$1:y$2MMMMMMMMMM+$1oooooooo+ +.ooooooooo$2/NNMNy$1:o$2NMMMMMMMMMMo$1ooooooooo. +/oooooooooo$2:yh:$1+m$2MMMMMMMMMMd/$1ooooooooo/ + +oooooooooo$2+$1/h$2mMMMMMMNds//o$1oooooooo+ + /oooooooooooo$2+:////:o/ymMd$1ooooooo/ + .oooooooooooooooooooo$2/sdh$1oooooo. -+oooooooooooooooooooooooo+- `:+oooooooooooooooooo+:` .-/+oooooooo+/-. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_gnome.txt b/src/logo/ascii/ubuntu_gnome.txt index 7314165a22..41c2633d96 100644 --- a/src/logo/ascii/ubuntu_gnome.txt +++ b/src/logo/ascii/ubuntu_gnome.txt @@ -1,16 +1,16 @@ -${c3} ./o. +$3 ./o. .oooooooo .oooo```soooo .oooo` `soooo - .ooo` ${c4}.o.${c3} `\/ooo. - :ooo ${c4}:oooo.${c3} `\/ooo. - sooo ${c4}`ooooo${c3} \/oooo - \/ooo ${c4}`soooo${c3} `ooooo - `soooo ${c4}`\/ooo${c3} `soooo -${c4}./oo ${c3}`\/ooo ${c4}`/oooo.${c3} `/ooo -${c4}`\/ooo. ${c3}`/oooo. ${c4}`/oooo.${c3} `` -${c4} `\/ooo. ${c3}/oooo ${c4}/ooo` -${c4} `ooooo ${c3}`` ${c4}.oooo -${c4} `soooo. .oooo` + .ooo` $4.o.$3 `\/ooo. + :ooo $4:oooo.$3 `\/ooo. + sooo $4`ooooo$3 \/oooo + \/ooo $4`soooo$3 `ooooo + `soooo $4`\/ooo$3 `soooo +$4./oo $3`\/ooo $4`/oooo.$3 `/ooo +$4`\/ooo. $3`/oooo. $4`/oooo.$3 `` +$4 `\/ooo. $3/oooo $4/ooo` +$4 `ooooo $3`` $4.oooo +$4 `soooo. .oooo` `\/oooooooooo` ``\/oo`` \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_old2.txt b/src/logo/ascii/ubuntu_old2.txt index 94fa72222c..b78f810844 100644 --- a/src/logo/ascii/ubuntu_old2.txt +++ b/src/logo/ascii/ubuntu_old2.txt @@ -1,18 +1,18 @@ ./+o+- -${c2} yyyyy- ${c1}-yyyyyy+ -${c2} ${c2}://+//////${c1}-yyyyyyo -${c3} .++ ${c2}.:/++++++/-${c1}.+sss/` -${c3} .:++o: ${c2}/++++++++/:--:/- -${c3} o:+o+:++.${c2}`..```.-/oo+++++/ -${c3} .:+o:+o/.${c2} `+sssoo+/ -${c2} .++/+:${c3}+oo+o:`${c2} /sssooo. -${c2}/+++//+:${c3}`oo+o${c2} /::--:. -${c2}+/+o+++${c3}`o++o${c1} ++////. -${c2} .++.o+${c3}++oo+:`${c1} /dddhhh. -${c3} .+.o+oo:.${c1} `oddhhhh+ -${c3} +.++o+o`${c1}`-````.:ohdhhhhh+ -${c3} `:o+++ ${c1}`ohhhhhhhhyo++os: -${c3} .o:${c1}`.syhhhhhhh/${c3}.oo++o` -${c1} /osyyyyyyo${c3}++ooo+++/ -${c1} ````` ${c3}+oo+++o: -${c3} `oo++. \ No newline at end of file +$2 yyyyy- $1-yyyyyy+ +$2 $2://+//////$1-yyyyyyo +$3 .++ $2.:/++++++/-$1.+sss/` +$3 .:++o: $2/++++++++/:--:/- +$3 o:+o+:++.$2`..```.-/oo+++++/ +$3 .:+o:+o/.$2 `+sssoo+/ +$2 .++/+:$3+oo+o:`$2 /sssooo. +$2/+++//+:$3`oo+o$2 /::--:. +$2+/+o+++$3`o++o$1 ++////. +$2 .++.o+$3++oo+:`$1 /dddhhh. +$3 .+.o+oo:.$1 `oddhhhh+ +$3 +.++o+o`$1`-````.:ohdhhhhh+ +$3 `:o+++ $1`ohhhhhhhhyo++os: +$3 .o:$1`.syhhhhhhh/$3.oo++o` +$1 /osyyyyyyo$3++ooo+++/ +$1 ````` $3+oo+++o: +$3 `oo++. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_studio.txt b/src/logo/ascii/ubuntu_studio.txt index 1d216d76f1..129869b5d6 100644 --- a/src/logo/ascii/ubuntu_studio.txt +++ b/src/logo/ascii/ubuntu_studio.txt @@ -1,20 +1,20 @@ ..-::::::-.` - `.:+++++++++++${c2}ooo${c1}++:.` - ./+++++++++++++${c2}sMMMNdyo${c1}+/. - .++++++++++++++++${c2}oyhmMMMMms${c1}++. - `/+++++++++${c2}osyhddddhys${c1}+${c2}osdMMMh${c1}++/` - `+++++++++${c2}ydMMMMNNNMMMMNds${c1}+${c2}oyyo${c1}++++` - +++++++++${c2}dMMNhso${c1}++++${c2}oydNMMmo${c1}++++++++` - :+${c2}odmy${c1}+++${c2}ooysoohmNMMNmyoohMMNs${c1}+++++++: - ++${c2}dMMm${c1}+${c2}oNMd${c1}++${c2}yMMMmhhmMMNs+yMMNo${c1}+++++++ -`++${c2}NMMy${c1}+${c2}hMMd${c1}+${c2}oMMMs${c1}++++${c2}sMMN${c1}++${c2}NMMs${c1}+++++++. -`++${c2}NMMy${c1}+${c2}hMMd${c1}+${c2}oMMMo${c1}++++${c2}sMMN${c1}++${c2}mMMs${c1}+++++++. - ++${c2}dMMd${c1}+${c2}oNMm${c1}++${c2}yMMNdhhdMMMs${c1}+y${c2}MMNo${c1}+++++++ - :+${c2}odmy${c1}++${c2}oo${c1}+${c2}ss${c1}+${c2}ohNMMMMmho${c1}+${c2}yMMMs${c1}+++++++: - +++++++++${c2}hMMmhs+ooo+oshNMMms${c1}++++++++ - `++++++++${c2}oymMMMMNmmNMMMMmy+oys${c1}+++++` - `/+++++++++${c2}oyhdmmmmdhso+sdMMMs${c1}++/ - ./+++++++++++++++${c2}oyhdNMMMms${c1}++. - ./+++++++++++++${c2}hMMMNdyo${c1}+/. - `.:+++++++++++${c2}sso${c1}++:. + `.:+++++++++++$2ooo$1++:.` + ./+++++++++++++$2sMMMNdyo$1+/. + .++++++++++++++++$2oyhmMMMMms$1++. + `/+++++++++$2osyhddddhys$1+$2osdMMMh$1++/` + `+++++++++$2ydMMMMNNNMMMMNds$1+$2oyyo$1++++` + +++++++++$2dMMNhso$1++++$2oydNMMmo$1++++++++` + :+$2odmy$1+++$2ooysoohmNMMNmyoohMMNs$1+++++++: + ++$2dMMm$1+$2oNMd$1++$2yMMMmhhmMMNs+yMMNo$1+++++++ +`++$2NMMy$1+$2hMMd$1+$2oMMMs$1++++$2sMMN$1++$2NMMs$1+++++++. +`++$2NMMy$1+$2hMMd$1+$2oMMMo$1++++$2sMMN$1++$2mMMs$1+++++++. + ++$2dMMd$1+$2oNMm$1++$2yMMNdhhdMMMs$1+y$2MMNo$1+++++++ + :+$2odmy$1++$2oo$1+$2ss$1+$2ohNMMMMmho$1+$2yMMMs$1+++++++: + +++++++++$2hMMmhs+ooo+oshNMMms$1++++++++ + `++++++++$2oymMMMMNmmNMMMMmy+oys$1+++++` + `/+++++++++$2oyhdmmmmdhso+sdMMMs$1++/ + ./+++++++++++++++$2oyhdNMMMms$1++. + ./+++++++++++++$2hMMMNdyo$1+/. + `.:+++++++++++$2sso$1++:. ..-::::::-.. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_sway.txt b/src/logo/ascii/ubuntu_sway.txt index e4a6da6385..deb53ad2ca 100644 --- a/src/logo/ascii/ubuntu_sway.txt +++ b/src/logo/ascii/ubuntu_sway.txt @@ -1,20 +1,20 @@ .-/+oossssoo+\-. ´:+ssssssssssssssssss+:` - -+ssssssssssssssssss${c2}yy${c1}ssss+- - .ossssssssssssssssss${c2}dMMMNyy${c1}ssso. - /sssssssssss${c2}hdmmNNmmyNMMMMh${c1}ssssss\ - +sssssssss${c2}hm${c1}ydMMMMMMMNdd${c2}ddy${c1}ssssssss+ - /ssssssss${c2}hN${c1}MM${c2}M${c1}yh${c2}hyyyyhmNM${c1}MM${c2}Nh${c1}ssssssss\ -.ssssssss${c2}dM${c1}MM${c2}Nh${c1}ssssssssss${c2}hN${c1}MM${c2}Md${c1}ssssssss. -+sss${c2}yyyyyN${c1}MM${c2}Ny${c1}ssssssssssss${c2}yN${c1}MM${c2}My${c1}sssssss+ -ossy${c2}NMMMNy${c1}MM${c2}h${c1}ssssssssssssss${c2}hm${c1}mm${c2}h${c1}ssssssso -ossy${c2}NMMMNy${c1}MM${c2}h${c1}sssssssssssssshmmmh${c1}ssssssso -+sss${c2}yyyyyN${c1}MM${c2}Ny${c1}ssssssssssss${c2}yN${c1}MM${c2}My${c1}sssssss+ -.ssssssss${c2}dM${c1}MM${c2}Nh${c1}ssssssssss${c2}hN${c1}MM${c2}Md${c1}ssssssss. - \ssssssss${c2}hN${c1}MM${c2}M${c1}yh${c2}hyyyyhdNM${c1}M${c2}MNh${c1}ssssssss/ - +sssssssss${c2}dm${c1}ydMMMMMMMMdd${c2}ddy${c1}ssssssss+ - \sssssssssss${c2}hdmNNNNmyNMMMMh${c1}ssssss/ - .ossssssssssssssssss${c2}dMMMNyy${c1}ssso. - -+sssssssssssssssss${c2}yy${c1}sss+- + -+ssssssssssssssssss$2yy$1ssss+- + .ossssssssssssssssss$2dMMMNyy$1ssso. + /sssssssssss$2hdmmNNmmyNMMMMh$1ssssss\ + +sssssssss$2hm$1ydMMMMMMMNdd$2ddy$1ssssssss+ + /ssssssss$2hN$1MM$2M$1yh$2hyyyyhmNM$1MM$2Nh$1ssssssss\ +.ssssssss$2dM$1MM$2Nh$1ssssssssss$2hN$1MM$2Md$1ssssssss. ++sss$2yyyyyN$1MM$2Ny$1ssssssssssss$2yN$1MM$2My$1sssssss+ +ossy$2NMMMNy$1MM$2h$1ssssssssssssss$2hm$1mm$2h$1ssssssso +ossy$2NMMMNy$1MM$2h$1sssssssssssssshmmmh$1ssssssso ++sss$2yyyyyN$1MM$2Ny$1ssssssssssss$2yN$1MM$2My$1sssssss+ +.ssssssss$2dM$1MM$2Nh$1ssssssssss$2hN$1MM$2Md$1ssssssss. + \ssssssss$2hN$1MM$2M$1yh$2hyyyyhdNM$1M$2MNh$1ssssssss/ + +sssssssss$2dm$1ydMMMMMMMMdd$2ddy$1ssssssss+ + \sssssssssss$2hdmNNNNmyNMMMMh$1ssssss/ + .ossssssssssssssssss$2dMMMNyy$1ssso. + -+sssssssssssssssss$2yy$1sss+- `:+ssssssssssssssssss+:` .-\+oossssoo+/-. \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_touch.txt b/src/logo/ascii/ubuntu_touch.txt index 72d19abbf3..50d5808727 100644 --- a/src/logo/ascii/ubuntu_touch.txt +++ b/src/logo/ascii/ubuntu_touch.txt @@ -1,7 +1,7 @@ ############### ## ## -## ${c2}##${c1} ${c2}##${c1} ## -## ${c2}##${c1} ${c2}#${c1} ${c2}#${c1} ${c2}##${c1} ## -## ${c2}###${c1} ## +## $2##$1 $2##$1 ## +## $2##$1 $2#$1 $2#$1 $2##$1 ## +## $2###$1 ## ## ## ############### \ No newline at end of file diff --git a/src/logo/ascii/ubuntu_unity.txt b/src/logo/ascii/ubuntu_unity.txt index bfbeceddde..b288ef8cb3 100644 --- a/src/logo/ascii/ubuntu_unity.txt +++ b/src/logo/ascii/ubuntu_unity.txt @@ -1,25 +1,25 @@ .-/+ooosssssssooo+\-. ,:+sssssssssssssssssssss+:. - -+ssssssssssssssssssss${c2}.....${c1}ssss+- - .ssssss${c2},${c1}ss${c2}:cloooooo:${c1}ss${c2}.:loooo.${c1}ssssss. - .ssssssss${c2}loo${c1}ss${c2}oooooooc${c1}ss${c2}.ooooooooo${c1}ssssss. - .ssssss${c2}.;looooool:,''.${c1}ss${c2}:ooooooooooc${c1}ssssss. - +ssssss${c2};loooool;.${c1}ssssssssss${c2}ooooooooo${c1}ssssssss+ - /ssssss${c2};clool'${c1}sssssssssssssss${c2}ooooooc${c1}ssss${c2},,${c1}sssss. -.sssssssssssssssssssssssssssssssssssss${c2}.:oo,${c1}sssss. -.sssss${c2}.;clol:,.${c1}ssssssssssssssssssssss${c2}.loooo'${c1}ssss. -+ssss${c2}:ooooooooo,${c1}ssssssssssssssssssssss${c2}'ooool${c1}ssss+ -osss${c2}'ooooooooooo.${c1}ssssssssssssssssssssss${c2}loooo.${c1}ssso -osss${c2}'ooooooooool${c1}sssssssssssssssssssssss${c2}co${c1}ssssssso -ossss${c2},looooooc.${c1}sssssssssssssssssssssss${c2}.loooo.${c1}ssso -+ssssss${c2}.,;;;'.${c1}ssssssssssssssssssssssss${c2};ooooc${c1}ssss+ -.ssssssssssssssssssssssssssssssssssss${c2},ooool.${c1}ssss. -.sssssss${c2}.cooooc.${c1}sssssssssssss${c2}.,,,,.${c1}ss${c2}.cooo.${c1}sssss. - `sssssss${c2}ooooo:.${c1}ssssssssssss${c2}oooooooc.${c1}ss${c2}:l.${c1}sssss' - +ssssss${c2}.coooooc,..${c1}sssssss${c2}cooooooooo.${c1}ssssssss+ - `sssssss${c2}.:oo${c1}s${c2}ooooolc:.${c1}s${c2}.ooooooooooo'${c1}ssssss' - .sssssss${c2}.o${c1}ss${c2}`:loooo;${c1}sss${c2},ooooooooc${c1}sssssss. - `sssssssss${c2};oooo';:c'${c1}ssss${c2}`:ooo:'${c1}sssssss' + -+ssssssssssssssssssss$2.....$1ssss+- + .ssssss$2,$1ss$2:cloooooo:$1ss$2.:loooo.$1ssssss. + .ssssssss$2loo$1ss$2oooooooc$1ss$2.ooooooooo$1ssssss. + .ssssss$2.;looooool:,''.$1ss$2:ooooooooooc$1ssssss. + +ssssss$2;loooool;.$1ssssssssss$2ooooooooo$1ssssssss+ + /ssssss$2;clool'$1sssssssssssssss$2ooooooc$1ssss$2,,$1sssss. +.sssssssssssssssssssssssssssssssssssss$2.:oo,$1sssss. +.sssss$2.;clol:,.$1ssssssssssssssssssssss$2.loooo'$1ssss. ++ssss$2:ooooooooo,$1ssssssssssssssssssssss$2'ooool$1ssss+ +osss$2'ooooooooooo.$1ssssssssssssssssssssss$2loooo.$1ssso +osss$2'ooooooooool$1sssssssssssssssssssssss$2co$1ssssssso +ossss$2,looooooc.$1sssssssssssssssssssssss$2.loooo.$1ssso ++ssssss$2.,;;;'.$1ssssssssssssssssssssssss$2;ooooc$1ssss+ +.ssssssssssssssssssssssssssssssssssss$2,ooool.$1ssss. +.sssssss$2.cooooc.$1sssssssssssss$2.,,,,.$1ss$2.cooo.$1sssss. + `sssssss$2ooooo:.$1ssssssssssss$2oooooooc.$1ss$2:l.$1sssss' + +ssssss$2.coooooc,..$1sssssss$2cooooooooo.$1ssssssss+ + `sssssss$2.:oo$1s$2ooooolc:.$1s$2.ooooooooooo'$1ssssss' + .sssssss$2.o$1ss$2`:loooo;$1sss$2,ooooooooc$1sssssss. + `sssssssss$2;oooo';:c'$1ssss$2`:ooo:'$1sssssss' -+sssssssssssssssssssssssssssssss+- `:+sssssssssssssssssssssss+:' `-\+ooosssssssooo+/-' \ No newline at end of file diff --git a/src/logo/ascii/ultramarine.txt b/src/logo/ascii/ultramarine.txt index cfbc01d03c..4021d0573e 100644 --- a/src/logo/ascii/ultramarine.txt +++ b/src/logo/ascii/ultramarine.txt @@ -6,15 +6,15 @@ .0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0. .0NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0. dNNNNNNNNNNNNWWWWWWWWNNNNNNNNNNNNNNNNNNd -NNNNNNNNNNNNNW${c2}MMMMMMMM${c1}WWNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNW${c2}MMMMMMMMM${c1}WWNNNNNNNNNNNNNN -NNNNNNNNNNNNNNW${c2}MMMMMMMMMMMM${c1}WNNNNNNNNNNNN -NNNNNNNNNNWWW${c2}MMMMMMMMMMMMMMMM${c1}WWWNNNNNNNX -oNWWWW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WWWNNo - OW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WO - .OW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WO. - lNW${c2}MMMMMMMMMMMMMMMMMMMMMMMMMMMM${c1}WNl - .dNW${c2}MMMMMMMMMMMMMMMMMMMMMMMM${c1}WNd. - .cKW${c2}MMMMMMMMMMMMMMMMMMMM${c1}WKc. - 'oOXWWW${c2}MMMMMMMM${c1}WWWXOl. +NNNNNNNNNNNNNW$2MMMMMMMM$1WWNNNNNNNNNNNNNNNN +NNNNNNNNNNNNNNW$2MMMMMMMMM$1WWNNNNNNNNNNNNNN +NNNNNNNNNNNNNNW$2MMMMMMMMMMMM$1WNNNNNNNNNNNN +NNNNNNNNNNWWW$2MMMMMMMMMMMMMMMM$1WWWNNNNNNNX +oNWWWW$2MMMMMMMMMMMMMMMMMMMMMMMMMMMM$1WWWNNo + OW$2MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM$1WO + .OW$2MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM$1WO. + lNW$2MMMMMMMMMMMMMMMMMMMMMMMMMMMM$1WNl + .dNW$2MMMMMMMMMMMMMMMMMMMMMMMM$1WNd. + .cKW$2MMMMMMMMMMMMMMMMMMMM$1WKc. + 'oOXWWW$2MMMMMMMM$1WWWXOl. ;lkXNNNNNNXkl' \ No newline at end of file diff --git a/src/logo/ascii/univention.txt b/src/logo/ascii/univention.txt index 503f0a94c7..ceafbae918 100644 --- a/src/logo/ascii/univention.txt +++ b/src/logo/ascii/univention.txt @@ -1,20 +1,20 @@ ./osssssssssssssssssssssso+- `ohhhhhhhhhhhhhhhhhhhhhhhhhhhhy: shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh- - `-//${c2}sssss${c1}/hhhhhhhhhhhhhh+${c2}s${c1}.hhhhhhhhh+ - .ohhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sss${c1}+hhhhhhh+ -.yhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}ssss${c1}:hhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}sssss${c1}.hhhhhhhhhhhhhh.${c2}sssss${c1}yhhhhh+ -+hhhhhy${c2}ssssss${c1}+yhhhhhhhhhhy/${c2}ssssss${c1}yhhhhh+ -+hhhhhh:${c2}sssssss${c1}:hhhhhhh+${c2}.ssssssss${c1}yhhhhy. -+hhhhhhh+`${c2}ssssssssssssssss${c1}hh${c2}sssss${c1}yhhho` -+hhhhhhhhhs+${c2}ssssssssssss${c1}+hh+${c2}sssss${c1}/:-` + `-//$2sssss$1/hhhhhhhhhhhhhh+$2s$1.hhhhhhhhh+ + .ohhhy$2sssss$1.hhhhhhhhhhhhhh.$2sss$1+hhhhhhh+ +.yhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2ssss$1:hhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2sssss$1.hhhhhhhhhhhhhh.$2sssss$1yhhhhh+ ++hhhhhy$2ssssss$1+yhhhhhhhhhhy/$2ssssss$1yhhhhh+ ++hhhhhh:$2sssssss$1:hhhhhhh+$2.ssssssss$1yhhhhy. ++hhhhhhh+`$2ssssssssssssssss$1hh$2sssss$1yhhho` ++hhhhhhhhhs+$2ssssssssssss$1+hh+$2sssss$1/:-` -hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhho :yhhhhhhhhhhhhhhhhhhhhhhhhhhhh+` -+ossssssssssssssssssssss+:` \ No newline at end of file diff --git a/src/logo/ascii/urukos.txt b/src/logo/ascii/urukos.txt index 3de7d1e10c..004df179f5 100644 --- a/src/logo/ascii/urukos.txt +++ b/src/logo/ascii/urukos.txt @@ -1,20 +1,20 @@ - ${c3}:${c4}:::::::::::::: ${c5}. - ${c3}=#${c4}*============. ${c5}:#: - ${c3}=##%${c4}+----------. ${c5}.###: - ${c3}=####. ${c5}.####: - ${c3}=####. ${c5}.####: - ${c3}=###*. .=${c4}--------. ${c5}####: - ${c3}=####. .*#+${c4}======- ${c5}####: - ${c3}=###*. .*###+${c4}====- ${c5}####: - ${c3}=###*. .*#####+${c4}==- ${c5}####: -${c3}=###*. .*#######+${c4}: ${c5}####: -${c3}=###*. .*#######+${c4}: ${c5}####: - ${c3}=###*. .*#####+${c4}==- ${c5}####: - ${c3}=###*. .*###+${c4}====- ${c5}####: - ${c3}=####. .*#+${c4}======- ${c5}####: - ${c3}=###*. .=${c4}--------. ${c5}.####: - ${c3}=####. ${c5}.####: - ${c3}=####. ${c5}.####: - ${c3}=###+${c4}--------------${c5}####: - ${c3}=#+${c4}=================-${c5}: - ${c3}:${c4}::::::::::::::::::. \ No newline at end of file + $3:$4:::::::::::::: $5. + $3=#$4*============. $5:#: + $3=##%$4+----------. $5.###: + $3=####. $5.####: + $3=####. $5.####: + $3=###*. .=$4--------. $5####: + $3=####. .*#+$4======- $5####: + $3=###*. .*###+$4====- $5####: + $3=###*. .*#####+$4==- $5####: +$3=###*. .*#######+$4: $5####: +$3=###*. .*#######+$4: $5####: + $3=###*. .*#####+$4==- $5####: + $3=###*. .*###+$4====- $5####: + $3=####. .*#+$4======- $5####: + $3=###*. .=$4--------. $5.####: + $3=####. $5.####: + $3=####. $5.####: + $3=###+$4--------------$5####: + $3=#+$4=================-$5: + $3:$4::::::::::::::::::. \ No newline at end of file diff --git a/src/logo/ascii/uwuntu.txt b/src/logo/ascii/uwuntu.txt index 60fa3d30ac..e77f14dac0 100644 --- a/src/logo/ascii/uwuntu.txt +++ b/src/logo/ascii/uwuntu.txt @@ -2,19 +2,19 @@ &&&&&&&& , *&&&&&& &&&&&&&&( &%%%%&&&& &&&&&&&&&&&& ,&&&&& - %%${c2}%%%%&&${c1}&&& ,&&&&&&&&&&&&&, %&&&$&&&%%$%%%. - &%%%${c2}%&&&&&${c1}&&# &, &&&&&&${c2}&&&&&&&%%%${c1}%% - &%%&&${c2}&&&&${c1}&&&( &&&${c2}&&&&&&%${c1}%%% - &&&&&${c2}&&&${c1}&% *&&${c2}&&&&&${c1}&&% - &&&/ &&&&${c3}\${c1}& ,${c3}/${c1}*.** - %&&&&&&&& &&&${c3}⟩${c1}., *.${c3}⟨${c1} - %&&&&&&&& &&${c3}/${c1}.. ${c3}/ \${c1} ..${c3}\${c1}(&&&&&& - #&&&#%%%%.%%%( ${c3}\_/\_/${c1} (%%%.%%%%/ + %%$2%%%%&&$1&&& ,&&&&&&&&&&&&&, %&&&$&&&%%$%%%. + &%%%$2%&&&&&$1&&# &, &&&&&&$2&&&&&&&%%%$1%% + &%%&&$2&&&&$1&&&( &&&$2&&&&&&%$1%%% + &&&&&$2&&&$1&% *&&$2&&&&&$1&&% + &&&/ &&&&$3\$1& ,$3/$1*.** + %&&&&&&&& &&&$3⟩$1., *.$3⟨$1 + %&&&&&&&& &&$3/$1.. $3/ \$1 ..$3\$1(&&&&&& + #&&&#%%%%.%%%( $3\_/\_/$1 (%%%.%%%%/ /%%%%%%%&&* ,&&&%%%%%%& &&&&&&&& &&&&&&&&&&& (&&&&& &&&&&&&&&&& - ${c2}%%${c1} & &&&&&&&&&&&& &&&&&&& - ${c2}%%%${c1} #&&&&&&# &&&&&&&&& - ${c2}%%%%% %%${c1} #&&&&&( -${c2}&%. %%%${c1} - ${c2}%%%%%%% \ No newline at end of file + $2%%$1 & &&&&&&&&&&&& &&&&&&& + $2%%%$1 #&&&&&&# &&&&&&&&& + $2%%%%% %%$1 #&&&&&( +$2&%. %%%$1 + $2%%%%%%% \ No newline at end of file diff --git a/src/logo/ascii/vnux.txt b/src/logo/ascii/vnux.txt index 84b5c4e35e..a9641a0a98 100644 --- a/src/logo/ascii/vnux.txt +++ b/src/logo/ascii/vnux.txt @@ -2,19 +2,19 @@ ^[XOx~. ^_nwdbbkp0ti' -${c2} _j>!vC1,, - ${c4},${c2} ,CY${c3}O${c2}t${c3}O${c2}1(l;" -`${c4}~-{r(1I${c2} ^${c1}/zmwJuc:${c2}I^ -'${c4}?)|${c1}U${c4}/}-${c2} ^${c3}f${c1}OCLLOw${c3}_${c2},; - ,${c4}i,``. ${c2}",${c3}k%ooW@$d"${c2}I,' - ' ;^${c3}u$$$$$$$$$$$$$$$$^<${c2}:^ - ` .>>${c3}($$$$${c5}$@@@@$$$$${c3}$nl${c2}[:: - `!}?${c3}B$$${c5}%&WMMW&%$$${c3}$1}-${c2}}": - ^?j${c3}Z$$${c5}WMMWWWWMMW$$${c3}ofc${c2};;` - <~x&${c3}$$${c5}&MWWWWWWWWp${c3}-${c5}l>[< -${c1} 'ljmwn${c2}~tk8${c5}MWWWWM8O${c2}X${c1}r${c2}+]nC${c1}[ -!JZqwwdX${c2}:^C8${c5}#MMMM@${c2}X${c1}Odpdpq0< -!vC1,, + $4,$2 ,CY$3O$2t$3O$21(l;" +`$4~-{r(1I$2 ^$1/zmwJuc:$2I^ +'$4?)|$1U$4/}-$2 ^$3f$1OCLLOw$3_$2,; + ,$4i,``. $2",$3k%ooW@$d"$2I,' + ' ;^$3u$$$$$$$$$$$$$$$$^<$2:^ + ` .>>$3($$$$$5$@@@@$$$$$3$nl$2[:: + `!}?$3B$$$5%&WMMW&%$$$3$1}-$2}": + ^?j$3Z$$$5WMMWWWWMMW$$$3ofc$2;;` + <~x&$3$$$5&MWWWWWWWWp$3-$5l>[< +$1 'ljmwn$2~tk8$5MWWWWM8O$2X$1r$2+]nC$1[ +!JZqwwdX$2:^C8$5#MMMM@$2X$1Odpdpq0< + ^x00J(" ^" \ No newline at end of file diff --git a/src/logo/ascii/vzlinux.txt b/src/logo/ascii/vzlinux.txt index cbb7004f13..36ecd2cea6 100644 --- a/src/logo/ascii/vzlinux.txt +++ b/src/logo/ascii/vzlinux.txt @@ -1,11 +1,11 @@ - ${c1}.::::::::.${c2} -`/////` ${c1}:zzzzzzzz${c2} ://///- - VVVVVu` ${c1}-zzz`${c2} /VVVVV. - `dVVVVV ${c1}.zzz`${c2} :VVVVV: - `VVVVVo ${c1}zzz${c2} -VVVVV/ - .VVVVV\ ${c1}zzz/${c2} .VVVVV+ - -VVVVV: ${c1}zzzzzzzzz${c2} .dVVVVs - \VVVVV- ${c1}`````````${c2} VVVVVV + $1.::::::::.$2 +`/////` $1:zzzzzzzz$2 ://///- + VVVVVu` $1-zzz`$2 /VVVVV. + `dVVVVV $1.zzz`$2 :VVVVV: + `VVVVVo $1zzz$2 -VVVVV/ + .VVVVV\ $1zzz/$2 .VVVVV+ + -VVVVV: $1zzzzzzzzz$2 .dVVVVs + \VVVVV- $1`````````$2 VVVVVV +VVVVV. sVVVVu` oVVVVd` +VVVVd` VVVVVV /VVVVV. diff --git a/src/logo/ascii/xcp_ng.txt b/src/logo/ascii/xcp_ng.txt index 4d33560b81..a957e441b4 100644 --- a/src/logo/ascii/xcp_ng.txt +++ b/src/logo/ascii/xcp_ng.txt @@ -1,15 +1,15 @@ - ${c3}%${c4}# - ${c1}((((${c3}%%%%%${c4}&& - ${c1}#((((((((((${c4}&&&& - ${c1}(((((((((((${c2}#####${c4}&& - ${c1}(((((${c5}%.....${c2}%####### - ${c1}(((( ((((((${c5}%.......${c2}%####, - ${c1}%((((((& ((((((((${c5}%.....${c2}%#### - ${c1}((((((((((((((${c2}########### - ${c1}(((( (((((((${c2}########### - ${c1}( /((((${c2}########### - ${c6},,*..${c2}########## - ${c6},,,******${c2}## ###### - ${c6},,,*,,,, ${c2}## ###### -${c6}. .,,,, ${c2}### ## - ${c6}... \ No newline at end of file + $3%$4# + $1(((($3%%%%%$4&& + $1#(((((((((($4&&&& + $1((((((((((($2#####$4&& + $1((((($5%.....$2%####### + $1(((( (((((($5%.......$2%####, + $1%((((((& (((((((($5%.....$2%#### + $1(((((((((((((($2########### + $1(((( ((((((($2########### + $1( /(((($2########### + $6,,*..$2########## + $6,,,******$2## ###### + $6,,,*,,,, $2## ###### +$6. .,,,, $2### ## + $6... \ No newline at end of file diff --git a/src/logo/ascii/xenia.txt b/src/logo/ascii/xenia.txt index c6ae8ddb2e..6ddf64b181 100644 --- a/src/logo/ascii/xenia.txt +++ b/src/logo/ascii/xenia.txt @@ -1,21 +1,21 @@ -${c2} ,c. .c; -${c2} .${c1}KMMMk${c2}.... ....${c1}kMMMK${c2}. -${c2} .${c1}WMMMMMX${c2}..... .....${c1}KMMMMMW. -${c1} XMMMMMMM0${c2}..... ....${c1}OMMMMMMMN -${c1} dMMMMMMMMM;${c2}.... ..... ....,${c1}MMMMMMMMMd -${c1} WMMMMMMMMMl;${c3}okKKKKKKKKKOo${c1};cMMMMMMMMMM -${c1} 'MMMMMMMNX${c2}K0${c3}KKKKKKKKKKKKKKK${c2}0K${c1}XNMMMMMMM; -${c1} oMMMMMMM${c2}Oxo${c3}KKKKKKKKKKKKKKKKK${c2}oxO${c1}MMMMMMMd -${c1} dMMMMMMM${c2}dxxx${c3}KKKKKKKKKKKKKKK${c2}xxxd${c1}NMMMMMMk -${c1} :MMMMX0${c2}xxxxxx${c3}0KKKKKKKK0KK0${c2}xxxxxx0${c1}XMMMMc -${c1} MMMO${c2}xxxxxxxxdx${c3}kdd${c2}0x0${c3}ddk${c2}xdxxxxxxxx${c1}OMMM -${c1} ;${c2}xxkxddxxxxdodxxxxdxdxxxxdodxxxxddxkxx${c1}; -${c1}dxd${c2}KMMMWXo${c1}'.....'${c2}cdxxxdc${c1}'.....'${c2}lXWMMMX${c1}dxd -${c1}cxd${c2}XMMMN${c1},..........${c2}dxd${c1}'.........'${c2}XMMMN${c1}dxl -${c1} .xx${c2}WMMl${c1}...''....'.;k:.'....''...${c2}lMMW${c1}xx. -${c1}..:kXMMx..'....''..kMk..''....'..xMMXkc.. -${c1} dMMMMMMd.....'...xMMMx...''....dMMMMMMx -${c1} kMMMMWOoc:coOkolllokOoc:coOWMMMMO -${c1} .MMMMMMMMl${c2}...${c1}lNMMMMMMM. -${c1} KMMMMMMX${c2}l${c1}KMMMMMMX -${c1} .MMMMMMMMM. \ No newline at end of file +$2 ,c. .c; +$2 .$1KMMMk$2.... ....$1kMMMK$2. +$2 .$1WMMMMMX$2..... .....$1KMMMMMW. +$1 XMMMMMMM0$2..... ....$1OMMMMMMMN +$1 dMMMMMMMMM;$2.... ..... ....,$1MMMMMMMMMd +$1 WMMMMMMMMMl;$3okKKKKKKKKKOo$1;cMMMMMMMMMM +$1 'MMMMMMMNX$2K0$3KKKKKKKKKKKKKKK$20K$1XNMMMMMMM; +$1 oMMMMMMM$2Oxo$3KKKKKKKKKKKKKKKKK$2oxO$1MMMMMMMd +$1 dMMMMMMM$2dxxx$3KKKKKKKKKKKKKKK$2xxxd$1NMMMMMMk +$1 :MMMMX0$2xxxxxx$30KKKKKKKK0KK0$2xxxxxx0$1XMMMMc +$1 MMMO$2xxxxxxxxdx$3kdd$20x0$3ddk$2xdxxxxxxxx$1OMMM +$1 ;$2xxkxddxxxxdodxxxxdxdxxxxdodxxxxddxkxx$1; +$1dxd$2KMMMWXo$1'.....'$2cdxxxdc$1'.....'$2lXWMMMX$1dxd +$1cxd$2XMMMN$1,..........$2dxd$1'.........'$2XMMMN$1dxl +$1 .xx$2WMMl$1...''....'.;k:.'....''...$2lMMW$1xx. +$1..:kXMMx..'....''..kMk..''....'..xMMXkc.. +$1 dMMMMMMd.....'...xMMMx...''....dMMMMMMx +$1 kMMMMWOoc:coOkolllokOoc:coOWMMMMO +$1 .MMMMMMMMl$2...$1lNMMMMMMM. +$1 KMMMMMMX$2l$1KMMMMMMX +$1 .MMMMMMMMM. \ No newline at end of file diff --git a/src/logo/ascii/xeroarch.txt b/src/logo/ascii/xeroarch.txt index 890c2b2783..c30a2a2ad0 100644 --- a/src/logo/ascii/xeroarch.txt +++ b/src/logo/ascii/xeroarch.txt @@ -1,19 +1,19 @@ -${c5} ████ -${c5} ███${c2}▓▓${c5}███ -${c5} ███${c2}▓▓▓▓${c5}███ -${c5} ███${c2}▓▓▓▓▓▓${c5}███ -${c5} ███${c2}▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c2}▓▓▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c2}▓▓▓▓▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c2}▓▓▓▓▓▓${c5}██${c2}▓▓▓▓▓▓${c5}▓██ -${c5} ███${c2}▓▓▓▓▓▓${c5}████${c2}▓▓▓▓▓▓${c5}▓██ -${c5} ██▓${c2}▓▓▓▓▓▓${c5}█▓${c3}▓▓${c5}▓█${c2}▓▓▓▓▓▓${c5}▓██ -${c5} █████▓▒▒▒██${c3}▓${c4}▒▒${c3}▓${c5}██▒▒▒▓█████ -${c5} ███${c6}▓▓▓▓▓${c5}████${c3}▓${c4}▒▒▒▒${c3}▓${c5}▓███${c6}▓▓▓▓▓${c5}███ -${c5} ███${c6}▓▓▓▓▓▓▓▓▓${c5}███▓▓███${c6}▓▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c6}▓▓▓▓▓▓▓${c2}▓▓${c6}▓▓▓▓▓${c5}█${c6}▓▓▓▓▓▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c6}▓▓▓▓▓▓${c2}▓▓${c5}▒▒${c6}${c2}▓▓${c6}▓▓▓${c5}▓${c6}▓▓▓▓${c4}()${c6}▓▓▓▓▓▓▓▓${c5}███ -${c5} ███${c6}▓▓▓▓▓${c2}▓▓${c5}▒▒▒▒▒▒${c6}${c2}▓▓${c6}▓${c5}▓${c6}▓▓${c3}()${c6}▓▓${c3}()${c6}▓▓▓▓▓▓▓${c5}███ -${c5}███${c6}▓▓▓▓▓▓▓▓${c2}▓▓${c5}▒▒${c6}${c2}▓▓${c6}▓▓▓${c5}▓${c6}▓▓▓▓${c4}()${c6}▓▓▓▓▓▓▓▓▓▓${c5}███ -${c5}██${c6}▓▓▓▓▓▓▓▓▓▓▓${c2}▓▓${c6}▓▓▓▓▓${c5}▓${c6}▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓${c5}██ -${c5}████████████████████████████████████████ \ No newline at end of file +$5 ████ +$5 ███$2▓▓$5███ +$5 ███$2▓▓▓▓$5███ +$5 ███$2▓▓▓▓▓▓$5███ +$5 ███$2▓▓▓▓▓▓▓▓$5███ +$5 ███$2▓▓▓▓▓▓▓▓▓▓$5███ +$5 ███$2▓▓▓▓▓▓▓▓▓▓▓▓$5███ +$5 ███$2▓▓▓▓▓▓$5██$2▓▓▓▓▓▓$5▓██ +$5 ███$2▓▓▓▓▓▓$5████$2▓▓▓▓▓▓$5▓██ +$5 ██▓$2▓▓▓▓▓▓$5█▓$3▓▓$5▓█$2▓▓▓▓▓▓$5▓██ +$5 █████▓▒▒▒██$3▓$4▒▒$3▓$5██▒▒▒▓█████ +$5 ███$6▓▓▓▓▓$5████$3▓$4▒▒▒▒$3▓$5▓███$6▓▓▓▓▓$5███ +$5 ███$6▓▓▓▓▓▓▓▓▓$5███▓▓███$6▓▓▓▓▓▓▓▓▓$5███ +$5 ███$6▓▓▓▓▓▓▓$2▓▓$6▓▓▓▓▓$5█$6▓▓▓▓▓▓▓▓▓▓▓▓▓$5███ +$5 ███$6▓▓▓▓▓▓$2▓▓$5▒▒$6$2▓▓$6▓▓▓$5▓$6▓▓▓▓$4()$6▓▓▓▓▓▓▓▓$5███ +$5 ███$6▓▓▓▓▓$2▓▓$5▒▒▒▒▒▒$6$2▓▓$6▓$5▓$6▓▓$3()$6▓▓$3()$6▓▓▓▓▓▓▓$5███ +$5███$6▓▓▓▓▓▓▓▓$2▓▓$5▒▒$6$2▓▓$6▓▓▓$5▓$6▓▓▓▓$4()$6▓▓▓▓▓▓▓▓▓▓$5███ +$5██$6▓▓▓▓▓▓▓▓▓▓▓$2▓▓$6▓▓▓▓▓$5▓$6▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓$5██ +$5████████████████████████████████████████ \ No newline at end of file diff --git a/src/logo/ascii/yiffos.txt b/src/logo/ascii/yiffos.txt index b1cab612e0..09432849a1 100644 --- a/src/logo/ascii/yiffos.txt +++ b/src/logo/ascii/yiffos.txt @@ -7,12 +7,12 @@ N0dllllllllllllllodxOKNW WKxlllllllllllllllllllooxOKN WKdllllllllllllllooooooooooooo - Nxllllllllllllllloooooooooo${c2}oooo -${c1} XXNOolllllllllllloooooooooo${c2}oooooo -${c1} WX0xolllllllllllooooooooooo${c2}oooooooo -${c1}XWN0xolllllllllloooooooo${c2}ooooooooooooo -${c1} Kkdolllllllooooddddd${c2}doooooooooooddo -${c1} K00XNW${c2} WX0xdooooooddddddd + Nxllllllllllllllloooooooooo$2oooo +$1 XXNOolllllllllllloooooooooo$2oooooo +$1 WX0xolllllllllllooooooooooo$2oooooooo +$1XWN0xolllllllllloooooooo$2ooooooooooooo +$1 Kkdolllllllooooddddd$2doooooooooooddo +$1 K00XNW$2 WX0xdooooooddddddd WXOxdoooooodddd WXOxdddddddd NX0ddd From 0c3059008896fb94727a74f4c4da8955dc79f163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 7 May 2025 10:45:16 +0800 Subject: [PATCH 15/41] Builtin (Logo): new AthenaOS logo Fix #1741 --- src/logo/ascii/athenaos.txt | 29 +++++++++++++++++++ .../ascii/{athena.txt => athenaos_old.txt} | 2 +- src/logo/builtin.c | 18 ++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/logo/ascii/athenaos.txt rename src/logo/ascii/{athena.txt => athenaos_old.txt} (97%) diff --git a/src/logo/ascii/athenaos.txt b/src/logo/ascii/athenaos.txt new file mode 100644 index 0000000000..383b5ab8d9 --- /dev/null +++ b/src/logo/ascii/athenaos.txt @@ -0,0 +1,29 @@ + u. + ..:Y + .Y..1 + ..::i::.. .br7S. + .::::...::::. 5dDr: + ..:::.. .:i::.. Y7: + ..:::::.. ..::::. + ...:i:i:i:.. $2... $1:.:..:i:::... + ::i:. $2.USL Yr $1..i::. +.:::. $2:K :u. $1.::. +:... $2jB. .:vUi: 77 KB: $1..:: +...: $2iBR vP::5X5PgSKXvLjS. iBB $1.::. +:i:: $2BBQr jgDIuj1UuJjXbbi 2BBP $1:::; +'i:: $2sQBg: i2S55121XSSU. YBQZ: $1.::: + r::: $2r:JgBMu. Q :BqEqZEB: Q :qBBK7i: $1:i:i + .rir. $2IBqPDgQBDr P rB :q 1QBRgEqgB $1.::i. + :i:i $2:JsXPDDRQQPBL P qQXBQRDDPIYY $1rir: + :iii $25qvLUDDMgMgBB5 :DBQZRgMDdJ7Ygi $1iir: + iri: $2MBRgdZZggQgRBMIBQQRRggdZdMBBr $1riri + irii $2IBQgdZbDDRRRgQgQQMZDdZdgBB. $1iiri + i7rr $2.BBQZZbEEMQQDBQMEZdDDBBP $1.rir: + :7ir. $27BBQMDMQSbB5ZBggQBBQ. $1ivr7. + :r7r. $27BBBB:rBbQ.1BBBM. $1:r7vi + ::rLrr. $2.b:rBQ7QB uU. $1:7vLi. + .BB .iLYv: $1idL B1 $1:r77r. + LBB :vrvvr rvu7r: + ZB. ':7v177Lsvurr:' + .d2 ''::r:'' + :' \ No newline at end of file diff --git a/src/logo/ascii/athena.txt b/src/logo/ascii/athenaos_old.txt similarity index 97% rename from src/logo/ascii/athena.txt rename to src/logo/ascii/athenaos_old.txt index bc9626706a..d26fa04473 100644 --- a/src/logo/ascii/athena.txt +++ b/src/logo/ascii/athenaos_old.txt @@ -1,4 +1,4 @@ -$1 . .. + . .. $1 :####: ####. $1 .################ $1 :################## diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 9cae63359c..b1358c157d 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -652,10 +652,22 @@ static const FFlogo A[] = { .colorKeys = FF_COLOR_FG_BLUE, .colorTitle = FF_COLOR_FG_MAGENTA, }, - // Athena + // AthenaOS { - .names = {"Athena"}, - .lines = FASTFETCH_DATATEXT_LOGO_ATHENA, + .names = {"AthenaOS"}, + .lines = FASTFETCH_DATATEXT_LOGO_ATHENAOS, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_LIGHT_BLUE, + }, + .colorKeys = FF_COLOR_FG_BLUE, + .colorTitle = FF_COLOR_FG_LIGHT_BLUE, + }, + // AthenaOS_old + { + .names = {"AthenaOS_old"}, + .lines = FASTFETCH_DATATEXT_LOGO_ATHENAOS_OLD, + .type = FF_LOGO_LINE_TYPE_ALTER_BIT, .colors = { FF_COLOR_FG_WHITE, FF_COLOR_FG_YELLOW, From 5d3fb98072e7c487b7e4978b6fdccf674ee7e2fd Mon Sep 17 00:00:00 2001 From: Joe_ <126924661+me-joe@users.noreply.github.com> Date: Wed, 7 May 2025 15:02:36 +0700 Subject: [PATCH 16/41] Logo (Builtin): add Hydra Framework logo (#1740) * Added: Hydra Framework logo * Remove extra line: hydra.txt --- src/logo/ascii/hydra.txt | 11 +++++++++++ src/logo/builtin.c | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/logo/ascii/hydra.txt diff --git a/src/logo/ascii/hydra.txt b/src/logo/ascii/hydra.txt new file mode 100644 index 0000000000..d4b67c96d3 --- /dev/null +++ b/src/logo/ascii/hydra.txt @@ -0,0 +1,11 @@ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⣶⣶⣦⣤⣄⡀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣦⣤⣌⣙⠻⢶⣄⠀ +⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠊⣤⣶⣶⣶⣦⣤⣼⡧⢤⡈⠙⠳⣦⡙⢷⣄⠀ +⠀⠀⣠⣴⣶⣿⣿⣿⣿⣿⣿⣶⣦⣀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡿⢾⡷⣢⢄⣠⣬⣭⣝⣿⣿⣄⠈⠓⢄⠈⠳⡄⠙⢷ +⢀⣾⣿⡿⠛⠉⠀⠀⠀⠀⠉⠛⠿⣿⣷⣦⡀⠀⠀⠀⡖⠉⣠⠶⢛⣼⣡⡍⢉⠍⠉⠙⠻⣿⣿⣧⠀⠀⠁⠀⠀⠀⠀⠳⡀ +⢸⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⢿⣿⣦⣄⠀⠀⠈⠁⡠⠟⣫⣵⡇⠀⠀⠀⠀⠀⢈⣿⣿ +⢸⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣷⣄⠀⠚⠀⠞⠋⠀⠀⠀⠀⠀⠀⢀⣼⣿⡟ +⠸⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠙⢿⣿⣷⣤⡀⠀⠀⠀⠀⠀⠀⢀⣠⣿⣿⠏ +⠀⠹⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⣀⣴⡞⠁⠀⠀⠀⠀⠈⠛⠿⣿⣿⣶⣶⣶⣶⣾⡿⠟⠋ +⠀⠀⠙⠿⣿⣷⣶⣦⣴⣶⣾⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠁ +⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index b1358c157d..5132c12c1d 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -2267,6 +2267,15 @@ static const FFlogo H[] = { .colorKeys = FF_COLOR_FG_LIGHT_BLACK, .colorTitle = FF_COLOR_FG_WHITE, }, + // Hydra Framework + { + .names = {"Hydra"}, + .lines = FASTFETCH_DATATEXT_LOGO_HYDRA, + .colors = { + FF_COLOR_FG_RED, + FF_COLOR_FG_WHITE, + }, + }, // LAST {}, }; From 484e05eae30312e3672e1abc50139f2bdd350916 Mon Sep 17 00:00:00 2001 From: Samuli Thomasson Date: Wed, 7 May 2025 16:06:47 +0200 Subject: [PATCH 17/41] GPU: optionally hide unknown GPUs (#1742) The current default behavior of not hiding any GPUs is retained. The new feature of hiding unknown or unrecognized GPUs can be enabled with hide-type = "unknown". --- doc/json_schema.json | 1 + src/data/help.json | 3 ++- src/modules/gpu/gpu.c | 14 +++++++++++--- src/modules/gpu/option.h | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/doc/json_schema.json b/doc/json_schema.json index b6ad80b0a4..6b63916a62 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -2053,6 +2053,7 @@ "enum": [ "integrated", "discrete", + "unknown", "none" ], "default": "none" diff --git a/src/data/help.json b/src/data/help.json index 10955e3dae..a66e43d40b 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -1139,12 +1139,13 @@ }, { "long": "gpu-hide-type", - "desc": "Specify which types of GPUs should not be displayed", + "desc": "Specify which types of GPUs should not be displayed (default: all GPUs are shown, regardless of recognition)", "arg": { "type": "enum", "enum": { "integrated": "Hide integrated GPUs", "discrete": "Hide discrete GPUs", + "unknown": "Hide unknown (unrecognized) GPUs", "none": "Do not hide any GPUs" }, "default": "none" diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 9049e7afb6..6754deed51 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -173,6 +173,9 @@ void ffPrintGPU(FFGPUOptions* options) FF_LIST_FOR_EACH(FFGPUResult, gpu, gpus) { + if(gpu->type == FF_GPU_TYPE_UNKNOWN && options->hideType == FF_GPU_TYPE_UNKNOWN) + continue; + if(gpu->type == FF_GPU_TYPE_INTEGRATED && options->hideType == FF_GPU_TYPE_INTEGRATED) continue; @@ -230,7 +233,8 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char if (ffStrEqualsIgnCase(subKey, "hide-type")) { options->hideType = (FFGPUType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) { - { "none", FF_GPU_TYPE_UNKNOWN }, + { "none", FF_GPU_TYPE_NONE }, + { "unknown", FF_GPU_TYPE_UNKNOWN }, { "integrated", FF_GPU_TYPE_INTEGRATED }, { "discrete", FF_GPU_TYPE_DISCRETE }, {}, @@ -288,7 +292,8 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module) { int value; const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) { - { "none", FF_GPU_TYPE_UNKNOWN }, + { "none", FF_GPU_TYPE_NONE }, + { "unknown", FF_GPU_TYPE_UNKNOWN }, { "integrated", FF_GPU_TYPE_INTEGRATED }, { "discrete", FF_GPU_TYPE_DISCRETE }, {}, @@ -345,9 +350,12 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_ { switch (options->hideType) { - case FF_GPU_TYPE_UNKNOWN: + case FF_GPU_TYPE_NONE: yyjson_mut_obj_add_str(doc, module, "hideType", "none"); break; + case FF_GPU_TYPE_UNKNOWN: + yyjson_mut_obj_add_str(doc, module, "hideType", "unknown"); + break; case FF_GPU_TYPE_INTEGRATED: yyjson_mut_obj_add_str(doc, module, "hideType", "integrated"); break; diff --git a/src/modules/gpu/option.h b/src/modules/gpu/option.h index 98362940b2..f88343770a 100644 --- a/src/modules/gpu/option.h +++ b/src/modules/gpu/option.h @@ -7,7 +7,8 @@ typedef enum __attribute__((__packed__)) FFGPUType { - FF_GPU_TYPE_UNKNOWN, + FF_GPU_TYPE_NONE, // Indicates no specific GPU type. Useful as a hide filter only. + FF_GPU_TYPE_UNKNOWN, // Indicates an unknown or unrecognized GPU type. FF_GPU_TYPE_INTEGRATED, FF_GPU_TYPE_DISCRETE, } FFGPUType; From 6e1ab12399dd2c953dc53968754d8a81b69a70f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 8 May 2025 23:17:22 +0800 Subject: [PATCH 18/41] Memory / Swap: always initialize local variables --- src/modules/memory/memory.c | 2 +- src/modules/swap/swap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 8d395a0e8e..845a28b188 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -116,7 +116,7 @@ void ffGenerateMemoryJsonConfig(FFMemoryOptions* options, yyjson_mut_doc* doc, y void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { - FFMemoryResult storage; + FFMemoryResult storage = {}; const char* error = ffDetectMemory(&storage); if(error) diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 04995afa8e..e6cfa8c0c7 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -125,7 +125,7 @@ void ffGenerateSwapJsonConfig(FFSwapOptions* options, yyjson_mut_doc* doc, yyjso void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { - FFSwapResult storage; + FFSwapResult storage = {}; const char* error = ffDetectSwap(&storage); if(error) From fe66eb3df01968e2d62e1f80b76662d2630e540c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 8 May 2025 23:20:53 +0800 Subject: [PATCH 19/41] GPU (Windows): fix incorrect used shared memory size --- src/detection/gpu/gpu_amd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 5ebbeb2ba9..6f752974f8 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -204,7 +204,10 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu if (status == ADL_OK) { uint64_t totalUsage = (uint64_t) vramUsage * 1024 * 1024; - result.sharedMemory->used = totalUsage - result.memory->used; + result.sharedMemory->used = totalUsage; + // If we have dedicated VRAM usage, subtract it from the total + if (result.memory->used != FF_GPU_VMEM_SIZE_UNSET) + result.sharedMemory->used -= result.memory->used; FF_DEBUG("Total VRAM usage: %llu bytes, Shared VRAM usage: %llu bytes (%llu MB)", totalUsage, result.sharedMemory->used, result.sharedMemory->used / (1024 * 1024)); } else { From 06427ee62be39f751cb65a383cf92ea010f446b4 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 3 May 2025 07:44:06 +0800 Subject: [PATCH 20/41] Media (Linux): fix duplicated playback status --- src/detection/media/media_linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index aabf2da3ec..16ba329a08 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -142,6 +142,7 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul ffStrbufClear(&result->artist); ffStrbufClear(&result->album); ffStrbufClear(&result->url); + ffStrbufClear(&result->status); return false; } } From 2f706ed494181c4b994ca4bddfdd690900624c8c Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 9 May 2025 21:55:31 +0800 Subject: [PATCH 21/41] Smbios: discard usless values --- src/util/smbiosHelper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 62fed285d7..31047580b0 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -32,6 +32,7 @@ bool ffIsSmbiosValueSet(FFstrbuf* value) !ffStrbufIgnCaseEqualS(value, "All Series") && !ffStrbufIgnCaseEqualS(value, "N/A") && !ffStrbufIgnCaseEqualS(value, "Unknown") && + !ffStrbufIgnCaseEqualS(value, "Standard") && !ffStrbufIgnCaseEqualS(value, "0x0000") ; } From ff3028c6563be25bcdc830ff95dc18a0fadcad20 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 9 May 2025 21:58:41 +0800 Subject: [PATCH 22/41] GPU: don't hide unknown type of GPUs by default Fix #1742 --- src/modules/gpu/gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/gpu/gpu.c b/src/modules/gpu/gpu.c index 6754deed51..f7f4c90bc1 100644 --- a/src/modules/gpu/gpu.c +++ b/src/modules/gpu/gpu.c @@ -505,7 +505,7 @@ void ffInitGPUOptions(FFGPUOptions* options) #endif ; options->temp = false; - options->hideType = FF_GPU_TYPE_UNKNOWN; + options->hideType = FF_GPU_TYPE_NONE; options->tempConfig = (FFColorRangeConfig) { 60, 80 }; options->percent = (FFPercentageModuleConfig) { 50, 80, 0 }; } From 9dfb404a0d95ddb137c16a8b7c1acac1c0b9766a Mon Sep 17 00:00:00 2001 From: Carter Li Date: Fri, 9 May 2025 22:01:29 +0800 Subject: [PATCH 23/41] GPU (AMD): more verbose logs --- src/detection/gpu/gpu_amd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 6f752974f8..052a9ff85c 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -208,8 +208,8 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu // If we have dedicated VRAM usage, subtract it from the total if (result.memory->used != FF_GPU_VMEM_SIZE_UNSET) result.sharedMemory->used -= result.memory->used; - FF_DEBUG("Total VRAM usage: %llu bytes, Shared VRAM usage: %llu bytes (%llu MB)", - totalUsage, result.sharedMemory->used, result.sharedMemory->used / (1024 * 1024)); + FF_DEBUG("Total VRAM usage: %llu bytes (%llu MB), Shared VRAM usage: %llu bytes (%llu MB)", + totalUsage, totalUsage / (1024 * 1024), result.sharedMemory->used, result.sharedMemory->used / (1024 * 1024)); } else { FF_DEBUG("Failed to get total VRAM usage"); } From 23b43244c5c0f612851628d06dd44371b5725e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 9 May 2025 22:45:01 +0800 Subject: [PATCH 24/41] GPU (AMD): seems `ADL2_Adapter_VRAMUsage_Get` reports system mem usage only, not full memory usage Because VRAMUsage reports a value which is smaller than DedicatedVRAMUsage --- src/detection/gpu/gpu_amd.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 052a9ff85c..0537b6d78e 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -188,31 +188,26 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu FF_DEBUG("ADL2_Adapter_DedicatedVRAMUsage_Get returned %s (%d), usage: %d MB", ffAdlStatusToString(status), status, vramUsage); - if (status == ADL_OK) { + if (status == ADL_OK && vramUsage >= 0) { result.memory->used = (uint64_t) vramUsage * 1024 * 1024; FF_DEBUG("Dedicated VRAM usage: %llu bytes (%d MB)", result.memory->used, vramUsage); } else { FF_DEBUG("Failed to get dedicated VRAM usage"); } + } - if (result.sharedMemory) - { - vramUsage = 0; - status = adlData.ffADL2_Adapter_VRAMUsage_Get(adlData.apiHandle, device->iAdapterIndex, &vramUsage); - FF_DEBUG("ADL2_Adapter_VRAMUsage_Get returned %s (%d), usage: %d MB", - ffAdlStatusToString(status), status, vramUsage); - - if (status == ADL_OK) { - uint64_t totalUsage = (uint64_t) vramUsage * 1024 * 1024; - result.sharedMemory->used = totalUsage; - // If we have dedicated VRAM usage, subtract it from the total - if (result.memory->used != FF_GPU_VMEM_SIZE_UNSET) - result.sharedMemory->used -= result.memory->used; - FF_DEBUG("Total VRAM usage: %llu bytes (%llu MB), Shared VRAM usage: %llu bytes (%llu MB)", - totalUsage, totalUsage / (1024 * 1024), result.sharedMemory->used, result.sharedMemory->used / (1024 * 1024)); - } else { - FF_DEBUG("Failed to get total VRAM usage"); - } + if (result.sharedMemory) + { + int vramUsage = 0; + int status = adlData.ffADL2_Adapter_VRAMUsage_Get(adlData.apiHandle, device->iAdapterIndex, &vramUsage); + FF_DEBUG("ADL2_Adapter_VRAMUsage_Get returned %s (%d), usage: %d MB", + ffAdlStatusToString(status), status, vramUsage); + + if (status == ADL_OK && vramUsage >= 0) { + result.sharedMemory->used = (uint64_t) vramUsage * 1024 * 1024; + FF_DEBUG("Shared VRAM usage: %llu bytes (%d MB)", result.sharedMemory->used, vramUsage); + } else { + FF_DEBUG("Failed to get total VRAM usage"); } } From a96a9fc31d68fbb1207babafb233bcd87908a5e0 Mon Sep 17 00:00:00 2001 From: Marvin Friedrich Date: Sat, 10 May 2025 04:49:22 +0200 Subject: [PATCH 25/41] Smbios: fix transitive include for `loff_t` (#1746) --- src/util/smbiosHelper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/smbiosHelper.c b/src/util/smbiosHelper.c index 31047580b0..c0db8dc49f 100644 --- a/src/util/smbiosHelper.c +++ b/src/util/smbiosHelper.c @@ -55,6 +55,7 @@ const FFSmbiosHeader* ffSmbiosNextEntry(const FFSmbiosHeader* header) #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) || defined(__OpenBSD__) #include #include +#include #include #include From 154f9f462bfbcb8e81862f487f231cb2f1a14ed0 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 10 May 2025 20:56:59 +0800 Subject: [PATCH 26/41] GPU (Linux): detect VRAM type of AMD GPUs --- src/detection/gpu/gpu_linux.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 30528c8963..560a3abf74 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -145,6 +145,29 @@ static const char* drmDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult gpu->frequency = (uint32_t) (gpuInfo.max_engine_clk / 1000u); gpu->index = FF_GPU_INDEX_UNSET; gpu->type = gpuInfo.ids_flags & AMDGPU_IDS_FLAGS_FUSION ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; + #define FF_VRAM_CASE(x) case AMDGPU_VRAM_TYPE_ ## x: ffStrbufSetStatic(&gpu->memoryType, #x); break + switch (gpuInfo.vram_type) + { + FF_VRAM_CASE(UNKNOWN); + FF_VRAM_CASE(GDDR1); + FF_VRAM_CASE(DDR2); + FF_VRAM_CASE(GDDR3); + FF_VRAM_CASE(GDDR4); + FF_VRAM_CASE(GDDR5); + FF_VRAM_CASE(HBM); + FF_VRAM_CASE(DDR3); + FF_VRAM_CASE(DDR4); + FF_VRAM_CASE(GDDR6); + FF_VRAM_CASE(DDR5); + FF_VRAM_CASE(LPDDR4); + FF_VRAM_CASE(LPDDR5); + #ifdef AMDGPU_VRAM_TYPE_GDDR7 + FF_VRAM_CASE(GDDR7); + #endif + default: + ffStrbufAppendF(&gpu->memoryType, "Unknown (%u)", gpuInfo.vram_type); + break; + } struct amdgpu_heap_info heapInfo; if (ffamdgpu_query_heap_info(handle, AMDGPU_GEM_DOMAIN_VRAM, 0, &heapInfo) >= 0) From 115108b3f10248b699eaeae874b5c98008b8ea20 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 10 May 2025 20:57:31 +0800 Subject: [PATCH 27/41] GPU (Linux): detect core usage when libamdgpu is not available --- src/detection/gpu/gpu_linux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 560a3abf74..42dd186212 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -253,6 +253,11 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu, gpu->shared.used = value; } } + + ffStrbufSubstrBefore(pciDir, pciDirLen); + ffStrbufAppendS(pciDir, "/gpu_busy_percent"); + if (ffReadFileBuffer(pciDir->chars, buffer) && (value = ffStrbufToUInt(buffer, 0))) + gpu->coreUsage = (double) value; } } From 7626ef6eaab4eb4c2d65d710b9c681d3577dc7b4 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 10 May 2025 21:38:26 +0800 Subject: [PATCH 28/41] GPU (Linux): fix CI errors F**k Ubuntu --- src/detection/gpu/gpu_linux.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 42dd186212..e09865ac16 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -145,25 +145,22 @@ static const char* drmDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult gpu->frequency = (uint32_t) (gpuInfo.max_engine_clk / 1000u); gpu->index = FF_GPU_INDEX_UNSET; gpu->type = gpuInfo.ids_flags & AMDGPU_IDS_FLAGS_FUSION ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; - #define FF_VRAM_CASE(x) case AMDGPU_VRAM_TYPE_ ## x: ffStrbufSetStatic(&gpu->memoryType, #x); break + #define FF_VRAM_CASE(name, value) case value /* AMDGPU_VRAM_TYPE_ ## name */: ffStrbufSetStatic(&gpu->memoryType, #name); break switch (gpuInfo.vram_type) { - FF_VRAM_CASE(UNKNOWN); - FF_VRAM_CASE(GDDR1); - FF_VRAM_CASE(DDR2); - FF_VRAM_CASE(GDDR3); - FF_VRAM_CASE(GDDR4); - FF_VRAM_CASE(GDDR5); - FF_VRAM_CASE(HBM); - FF_VRAM_CASE(DDR3); - FF_VRAM_CASE(DDR4); - FF_VRAM_CASE(GDDR6); - FF_VRAM_CASE(DDR5); - FF_VRAM_CASE(LPDDR4); - FF_VRAM_CASE(LPDDR5); - #ifdef AMDGPU_VRAM_TYPE_GDDR7 - FF_VRAM_CASE(GDDR7); - #endif + FF_VRAM_CASE(UNKNOWN, 0); + FF_VRAM_CASE(GDDR1, 1); + FF_VRAM_CASE(DDR2, 2); + FF_VRAM_CASE(GDDR3, 3); + FF_VRAM_CASE(GDDR4, 4); + FF_VRAM_CASE(GDDR5, 5); + FF_VRAM_CASE(HBM, 6); + FF_VRAM_CASE(DDR3, 7); + FF_VRAM_CASE(DDR4, 8); + FF_VRAM_CASE(GDDR6, 9); + FF_VRAM_CASE(DDR5, 10); + FF_VRAM_CASE(LPDDR4, 11); + FF_VRAM_CASE(LPDDR5, 12); default: ffStrbufAppendF(&gpu->memoryType, "Unknown (%u)", gpuInfo.vram_type); break; From 36b0fdbcda0008c547f36048c5574b439ea80a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 09:29:21 +0800 Subject: [PATCH 29/41] Vulkan: use `VK_API_VERSION_*` instead of deprecated `VK_VERSION_*` --- src/detection/vulkan/vulkan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 43747d2410..2b0918d1b5 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -13,9 +13,9 @@ static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion) { - ffVersion->major = VK_VERSION_MAJOR(vulkanVersion); - ffVersion->minor = VK_VERSION_MINOR(vulkanVersion); - ffVersion->patch = VK_VERSION_PATCH(vulkanVersion); + ffVersion->major = VK_API_VERSION_MAJOR(vulkanVersion); + ffVersion->minor = VK_API_VERSION_MINOR(vulkanVersion); + ffVersion->patch = VK_API_VERSION_PATCH(vulkanVersion); } static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFstrbuf* result) From 4672b7848165b754e1da6102c4ec5f6cee88bd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 09:30:30 +0800 Subject: [PATCH 30/41] Sound: don't show 255 in custom format Fix #1750 --- src/modules/sound/sound.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 93edf3e46c..4dec032acd 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -46,11 +46,14 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui else { FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate(); - if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - ffPercentAppendNum(&percentageNum, device->volume, options->percent, false, &options->moduleArgs); FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate(); - if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) - ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs); + if(device->volume != FF_SOUND_VOLUME_UNKNOWN) + { + if (percentType & FF_PERCENTAGE_TYPE_NUM_BIT) + ffPercentAppendNum(&percentageNum, device->volume, options->percent, false, &options->moduleArgs); + if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT) + ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs); + } FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) { FF_FORMAT_ARG(device->main, "is-main"), From bd61d08afe78311a29159d52784c7a974f7d809e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 09:35:13 +0800 Subject: [PATCH 31/41] Sound (macOS): report the volume of muted device as 0% --- src/detection/sound/sound_apple.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index 1c9c3f630f..88881adc57 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -94,7 +94,9 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) }, 0, NULL, &dataSize, &active) == kAudioHardwareNoError) device->active = !!active; - if (!muted) + if (muted) + device->volume = 0; + else { float volume; dataSize = sizeof(volume); From 576a9cc6fe3d094c19197a507946bf0590840b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 10:02:38 +0800 Subject: [PATCH 32/41] Revert "Vulkan: use `VK_API_VERSION_*` instead of deprecated `VK_VERSION_*`" Breaks building with old vulkan-headers This reverts commit 36b0fdbcda0008c547f36048c5574b439ea80a63. --- src/detection/vulkan/vulkan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 2b0918d1b5..43747d2410 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -13,9 +13,9 @@ static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion) { - ffVersion->major = VK_API_VERSION_MAJOR(vulkanVersion); - ffVersion->minor = VK_API_VERSION_MINOR(vulkanVersion); - ffVersion->patch = VK_API_VERSION_PATCH(vulkanVersion); + ffVersion->major = VK_VERSION_MAJOR(vulkanVersion); + ffVersion->minor = VK_VERSION_MINOR(vulkanVersion); + ffVersion->patch = VK_VERSION_PATCH(vulkanVersion); } static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFstrbuf* result) From 9de5d9008b8f284474313eb575e8bb4b41d5c727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 10:37:52 +0800 Subject: [PATCH 33/41] Release: v2.43.0 --- CHANGELOG.md | 18 ++++++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad30b328b2..a65f9022c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# 2.43.0 + +Features: +* Support physical core count and package count detection on Solaris (CPU, SunOS) +* Improve physical core count detection on FreeBSD (CPU, FreeBSD) +* Add option to hide unknown GPUs (GPU) +* Detect VRAM type of AMD GPUs on Linux (GPU, Linux) + +Bugfixes: +* Fix disk usage detection on 32-bit Linux (#1734, Disk, Linux) +* Fix compiling on Asahi Linux (GPU, Linux) +* Fix duplicated playback status (Media, Linux) +* Don't show 255 in custom format when muted on macOS (#1750, Sound, macOS) + +Logos: +* new AthenaOS +* add Hydra Framework + # 2.42.0 Changes: diff --git a/CMakeLists.txt b/CMakeLists.txt index de4860b78c..ad48f4292a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.42.0 + VERSION 2.43.0 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" From 41d0f61ee0a1ee97941fa3413bbb527ba004d1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 13:39:42 +0800 Subject: [PATCH 34/41] GPU (AMD): remove usage of `ADL2_Adapter_VRAMUsage_Get` It reports dedicated GPU memory usage too. Ref: https://github.com/GPUOpen-LibrariesAndSDKs/display-library/issues/48 --- src/detection/gpu/adl.h | 3 --- src/detection/gpu/gpu_amd.c | 17 ----------------- 2 files changed, 20 deletions(-) diff --git a/src/detection/gpu/adl.h b/src/detection/gpu/adl.h index 8b80572d04..ddf948ec65 100644 --- a/src/detection/gpu/adl.h +++ b/src/detection/gpu/adl.h @@ -20,9 +20,6 @@ extern int ADL2_Adapter_Graphic_Core_Info_Get(ADL_CONTEXT_HANDLE context, int iA // Function to retrieve memory information from the adapter. Version 2 extern int ADL2_Adapter_MemoryInfo2_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, ADLMemoryInfo2* lpMemoryInfo2); -// This function retrieves the VRAM usage of given adapter. -extern int ADL2_Adapter_VRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVRAMUsageInMB); - // This function retrieves the Dedicated VRAM usage of given adapter. extern int ADL2_Adapter_DedicatedVRAMUsage_Get(ADL_CONTEXT_HANDLE context, int iAdapterIndex, int* iVRAMUsageInMB); diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 0537b6d78e..11edf9fa23 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -49,7 +49,6 @@ struct FFAdlData { FF_LIBRARY_SYMBOL(ADL2_Adapter_Graphic_Core_Info_Get) FF_LIBRARY_SYMBOL(ADL2_Adapter_MemoryInfo2_Get) FF_LIBRARY_SYMBOL(ADL2_Adapter_DedicatedVRAMUsage_Get) - FF_LIBRARY_SYMBOL(ADL2_Adapter_VRAMUsage_Get) FF_LIBRARY_SYMBOL(ADL2_Adapter_ASICFamilyType_Get) FF_LIBRARY_SYMBOL(ADL2_Overdrive_Caps) FF_LIBRARY_SYMBOL(ADL2_OverdriveN_CapabilitiesX2_Get) @@ -91,7 +90,6 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_Graphic_Core_Info_Get) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_MemoryInfo2_Get) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_DedicatedVRAMUsage_Get) - FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_VRAMUsage_Get) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Adapter_ASICFamilyType_Get) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_Overdrive_Caps) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(atiadl, adlData, ADL2_OverdriveN_CapabilitiesX2_Get) @@ -196,21 +194,6 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu } } - if (result.sharedMemory) - { - int vramUsage = 0; - int status = adlData.ffADL2_Adapter_VRAMUsage_Get(adlData.apiHandle, device->iAdapterIndex, &vramUsage); - FF_DEBUG("ADL2_Adapter_VRAMUsage_Get returned %s (%d), usage: %d MB", - ffAdlStatusToString(status), status, vramUsage); - - if (status == ADL_OK && vramUsage >= 0) { - result.sharedMemory->used = (uint64_t) vramUsage * 1024 * 1024; - FF_DEBUG("Shared VRAM usage: %llu bytes (%d MB)", result.sharedMemory->used, vramUsage); - } else { - FF_DEBUG("Failed to get total VRAM usage"); - } - } - if (result.memoryType) { ADLMemoryInfo2 memoryInfo; From 1b1b0521f4897f296cb4942ee754610ecfc24787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 13:49:54 +0800 Subject: [PATCH 35/41] Doc: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a65f9022c1..6bdf3aba59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Bugfixes: * Fix compiling on Asahi Linux (GPU, Linux) * Fix duplicated playback status (Media, Linux) * Don't show 255 in custom format when muted on macOS (#1750, Sound, macOS) +* Remove shared memory detection for AMD GPUs, which doesn't work as expected (GPU, Windows) Logos: * new AthenaOS From 9ac635e2e6b130bed3a2f679f5261ba5bd1f258b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 15:46:33 +0800 Subject: [PATCH 36/41] Media (Windows): detect player name (UMP apps only) --- src/detection/media/media_windows.c | 13 +++++++++---- src/detection/media/media_windows.dll.cpp | 7 +++++++ src/detection/media/media_windows.dll.h | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/detection/media/media_windows.c b/src/detection/media/media_windows.c index cf040f983b..54175aa3f9 100644 --- a/src/detection/media/media_windows.c +++ b/src/detection/media/media_windows.c @@ -19,11 +19,16 @@ static const char* getMedia(FFMediaResult* media) } ffStrbufSetWS(&media->playerId, result.playerId); - ffStrbufSet(&media->player, &media->playerId); - if (ffStrbufEndsWithIgnCaseS(&media->player, ".exe")) - ffStrbufSubstrBefore(&media->player, media->player.length - 4); + if (result.playerName[0]) + { + ffStrbufSetWS(&media->player, result.playerName); + } else - ffStrbufSubstrAfterFirstC(&media->player, '!'); // UWP ID + { + ffStrbufSet(&media->player, &media->playerId); + if (ffStrbufEndsWithIgnCaseS(&media->player, ".exe")) + ffStrbufSubstrBefore(&media->player, media->player.length - 4); + } ffStrbufSetWS(&media->song, result.song); ffStrbufSetWS(&media->artist, result.artist); ffStrbufSetWS(&media->album, result.album); diff --git a/src/detection/media/media_windows.dll.cpp b/src/detection/media/media_windows.dll.cpp index ff197cf5b4..34f46219be 100644 --- a/src/detection/media/media_windows.dll.cpp +++ b/src/detection/media/media_windows.dll.cpp @@ -1,5 +1,6 @@ #include #include +#include #include extern "C" @@ -11,6 +12,7 @@ const char* ffWinrtDetectMedia(FFWinrtMediaResult* result) // C++/WinRT requires Windows 8.1+ and C++ runtime (std::string, exceptions and other stuff) // Make it a separate dll in order not to break Windows 7 support using namespace winrt::Windows::Media::Control; + using namespace winrt::Windows::ApplicationModel; try { @@ -48,6 +50,11 @@ const char* ffWinrtDetectMedia(FFWinrtMediaResult* result) ::wcsncpy(result->song, mediaProps.Title().data(), FF_MEDIA_WIN_RESULT_BUFLEN); ::wcsncpy(result->artist, mediaProps.Artist().data(), FF_MEDIA_WIN_RESULT_BUFLEN); ::wcsncpy(result->album, mediaProps.AlbumTitle().data(), FF_MEDIA_WIN_RESULT_BUFLEN); + try + { + // Only works for UWP apps + ::wcsncpy(result->playerName, AppInfo::GetFromAppUserModelId(session.SourceAppUserModelId()).DisplayInfo().DisplayName().data(), FF_MEDIA_WIN_RESULT_BUFLEN); + } catch (...) { } return NULL; } diff --git a/src/detection/media/media_windows.dll.h b/src/detection/media/media_windows.dll.h index 045976c2e4..aae081e88a 100644 --- a/src/detection/media/media_windows.dll.h +++ b/src/detection/media/media_windows.dll.h @@ -5,6 +5,7 @@ typedef struct FFWinrtMediaResult { wchar_t playerId[FF_MEDIA_WIN_RESULT_BUFLEN]; + wchar_t playerName[FF_MEDIA_WIN_RESULT_BUFLEN]; wchar_t song[FF_MEDIA_WIN_RESULT_BUFLEN]; wchar_t artist[FF_MEDIA_WIN_RESULT_BUFLEN]; wchar_t album[FF_MEDIA_WIN_RESULT_BUFLEN]; From e629126d73f5198c7ec6ecc964c425cfd1611053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 May 2025 15:52:11 +0800 Subject: [PATCH 37/41] Doc: update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdf3aba59..3b96cae9a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Features: * Improve physical core count detection on FreeBSD (CPU, FreeBSD) * Add option to hide unknown GPUs (GPU) * Detect VRAM type of AMD GPUs on Linux (GPU, Linux) +* Support playing media detection on macOS 15.4 (#1737, Media, macOS) + * Whether it works on newer versions is unknown +* Detect player name for Windows UMP apps (Media, Windows) Bugfixes: * Fix disk usage detection on 32-bit Linux (#1734, Disk, Linux) From f22d73d473dd3af6e620fa7265aaf22096269546 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 13 May 2025 18:29:46 +0800 Subject: [PATCH 38/41] PhysicalDisk: trim white spaces of serial --- src/detection/physicaldisk/physicaldisk_bsd.c | 1 + src/detection/physicaldisk/physicaldisk_linux.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/detection/physicaldisk/physicaldisk_bsd.c b/src/detection/physicaldisk/physicaldisk_bsd.c index 42918ff95a..562fbb3cfd 100644 --- a/src/detection/physicaldisk/physicaldisk_bsd.c +++ b/src/detection/physicaldisk/physicaldisk_bsd.c @@ -65,6 +65,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) FFPhysicalDiskResult* device = (FFPhysicalDiskResult*) ffListAdd(result); ffStrbufInitF(&device->devPath, "/dev/%s", provider->lg_name); ffStrbufInitMove(&device->serial, &identifier); + ffStrbufTrim(&device->serial, ' '); ffStrbufInit(&device->revision); ffStrbufInit(&device->interconnect); switch (snapIter->device_type & DEVSTAT_TYPE_IF_MASK) diff --git a/src/detection/physicaldisk/physicaldisk_linux.c b/src/detection/physicaldisk/physicaldisk_linux.c index 245ad639ca..11923f4d4f 100644 --- a/src/detection/physicaldisk/physicaldisk_linux.c +++ b/src/detection/physicaldisk/physicaldisk_linux.c @@ -153,7 +153,7 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption { ffStrbufInit(&device->serial); if (ffReadFileBufferRelative(devfd, "serial", &device->serial)) - ffStrbufTrimRightSpace(&device->serial); + ffStrbufTrim(&device->serial, ' '); } { From 7a2cbc060f8c5cf6d9cf7116f03e76f6d70adf8e Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 14 May 2025 08:52:06 +0800 Subject: [PATCH 39/41] 3rdparty (yyjson): upgrade to 0.11.1 --- src/3rdparty/yyjson/repo.json | 2 +- src/3rdparty/yyjson/yyjson.c | 19 ++++++++++++++----- src/3rdparty/yyjson/yyjson.h | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/3rdparty/yyjson/repo.json b/src/3rdparty/yyjson/repo.json index b459f526a5..bb2256ef01 100644 --- a/src/3rdparty/yyjson/repo.json +++ b/src/3rdparty/yyjson/repo.json @@ -1,6 +1,6 @@ { "home": "https://github.com/ibireme/yyjson", "license": "MIT ( embed in source )", - "version": "0.11.0", + "version": "0.11.1", "author": "ibireme" } diff --git a/src/3rdparty/yyjson/yyjson.c b/src/3rdparty/yyjson/yyjson.c index 1d55473c8b..20c3050aee 100644 --- a/src/3rdparty/yyjson/yyjson.c +++ b/src/3rdparty/yyjson/yyjson.c @@ -566,6 +566,8 @@ typedef union v64_uni { v64 v; u64 u; } v64_uni; *============================================================================*/ #define byte_move_idx(x) ((char *)dst)[x] = ((const char *)src)[x]; +#define byte_move_src(x) ((char *)tmp)[x] = ((const char *)src)[x]; +#define byte_move_dst(x) ((char *)dst)[x] = ((const char *)tmp)[x]; static_inline void byte_copy_2(void *dst, const void *src) { #if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS @@ -605,7 +607,9 @@ static_inline void byte_move_2(void *dst, const void *src) { memcpy(&tmp, src, 2); memcpy(dst, &tmp, 2); #else - repeat2_incr(byte_move_idx) + char tmp[2]; + repeat2_incr(byte_move_src) + repeat2_incr(byte_move_dst) #endif } @@ -615,7 +619,9 @@ static_inline void byte_move_4(void *dst, const void *src) { memcpy(&tmp, src, 4); memcpy(dst, &tmp, 4); #else - repeat4_incr(byte_move_idx) + char tmp[4]; + repeat4_incr(byte_move_src) + repeat4_incr(byte_move_dst) #endif } @@ -625,7 +631,9 @@ static_inline void byte_move_8(void *dst, const void *src) { memcpy(&tmp, src, 8); memcpy(dst, &tmp, 8); #else - repeat8_incr(byte_move_idx) + char tmp[8]; + repeat8_incr(byte_move_src) + repeat8_incr(byte_move_dst) #endif } @@ -639,7 +647,9 @@ static_inline void byte_move_16(void *dst, const void *src) { memcpy(pdst, &tmp1, 8); memcpy(pdst + 8, &tmp2, 8); #else - repeat16_incr(byte_move_idx) + char tmp[16]; + repeat16_incr(byte_move_src) + repeat16_incr(byte_move_dst) #endif } @@ -700,7 +710,6 @@ static_inline u32 byte_load_4(const void *src) { #if !YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS memcpy(&uni, src, 4); #else - v32_uni uni; uni.v.c[0] = ((const char *)src)[0]; uni.v.c[1] = ((const char *)src)[1]; uni.v.c[2] = ((const char *)src)[2]; diff --git a/src/3rdparty/yyjson/yyjson.h b/src/3rdparty/yyjson/yyjson.h index d26dc49b7d..824026059a 100644 --- a/src/3rdparty/yyjson/yyjson.h +++ b/src/3rdparty/yyjson/yyjson.h @@ -502,13 +502,13 @@ extern "C" { #define YYJSON_VERSION_MINOR 11 /** The patch version of yyjson. */ -#define YYJSON_VERSION_PATCH 0 +#define YYJSON_VERSION_PATCH 1 /** The version of yyjson in hex: `(major << 16) | (minor << 8) | (patch)`. */ -#define YYJSON_VERSION_HEX 0x000B00 +#define YYJSON_VERSION_HEX 0x000B01 /** The version string of yyjson. */ -#define YYJSON_VERSION_STRING "0.11.0" +#define YYJSON_VERSION_STRING "0.11.1" /** The version of yyjson in hex, same as `YYJSON_VERSION_HEX`. */ yyjson_api uint32_t yyjson_version(void); From 87e13543daa55d4cf4cbfe9c867697ae2d5ad274 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 14 May 2025 08:59:53 +0800 Subject: [PATCH 40/41] GPU (Linux): embed asahi_drm.h --- src/detection/gpu/asahi_drm.h | 1194 +++++++++++++++++++++++++++++++++ src/detection/gpu/gpu_linux.c | 11 +- 2 files changed, 1200 insertions(+), 5 deletions(-) create mode 100644 src/detection/gpu/asahi_drm.h diff --git a/src/detection/gpu/asahi_drm.h b/src/detection/gpu/asahi_drm.h new file mode 100644 index 0000000000..01a5ed2a34 --- /dev/null +++ b/src/detection/gpu/asahi_drm.h @@ -0,0 +1,1194 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (C) The Asahi Linux Contributors + * Copyright (C) 2018-2023 Collabora Ltd. + * Copyright (C) 2014-2018 Broadcom + */ +#ifndef _ASAHI_DRM_H_ +#define _ASAHI_DRM_H_ + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * DOC: Introduction to the Asahi UAPI + * + * This documentation describes the Asahi IOCTLs. + * + * Just a few generic rules about the data passed to the Asahi IOCTLs (cribbed + * from Panthor): + * + * - Structures must be aligned on 64-bit/8-byte. If the object is not + * naturally aligned, a padding field must be added. + * - Fields must be explicitly aligned to their natural type alignment with + * pad[0..N] fields. + * - All padding fields will be checked by the driver to make sure they are + * zeroed. + * - Flags can be added, but not removed/replaced. + * - New fields can be added to the main structures (the structures + * directly passed to the ioctl). Those fields can be added at the end of + * the structure, or replace existing padding fields. Any new field being + * added must preserve the behavior that existed before those fields were + * added when a value of zero is passed. + * - New fields can be added to indirect objects (objects pointed by the + * main structure), iff those objects are passed a size to reflect the + * size known by the userspace driver (see + * drm_asahi_cmd_header::size). + * - If the kernel driver is too old to know some fields, those will be + * ignored if zero, and otherwise rejected (and so will be zero on output). + * - If userspace is too old to know some fields, those will be zeroed + * (input) before the structure is parsed by the kernel driver. + * - Each new flag/field addition must come with a driver version update so + * the userspace driver doesn't have to guess which flags are supported. + * - Structures should not contain unions, as this would defeat the + * extensibility of such structures. + * - IOCTLs can't be removed or replaced. New IOCTL IDs should be placed + * at the end of the drm_asahi_ioctl_id enum. + */ + +/** + * enum drm_asahi_ioctl_id - IOCTL IDs + * + * Place new ioctls at the end, don't re-order, don't replace or remove entries. + * + * These IDs are not meant to be used directly. Use the DRM_IOCTL_ASAHI_xxx + * definitions instead. + */ +enum drm_asahi_ioctl_id { + /** @DRM_ASAHI_GET_PARAMS: Query device properties. */ + DRM_ASAHI_GET_PARAMS = 0, + + /** @DRM_ASAHI_GET_TIME: Query device time. */ + DRM_ASAHI_GET_TIME, + + /** @DRM_ASAHI_VM_CREATE: Create a GPU VM address space. */ + DRM_ASAHI_VM_CREATE, + + /** @DRM_ASAHI_VM_DESTROY: Destroy a VM. */ + DRM_ASAHI_VM_DESTROY, + + /** @DRM_ASAHI_VM_BIND: Bind/unbind memory to a VM. */ + DRM_ASAHI_VM_BIND, + + /** @DRM_ASAHI_GEM_CREATE: Create a buffer object. */ + DRM_ASAHI_GEM_CREATE, + + /** + * @DRM_ASAHI_GEM_MMAP_OFFSET: Get offset to pass to mmap() to map a + * given GEM handle. + */ + DRM_ASAHI_GEM_MMAP_OFFSET, + + /** @DRM_ASAHI_GEM_BIND_OBJECT: Bind memory as a special object */ + DRM_ASAHI_GEM_BIND_OBJECT, + + /** @DRM_ASAHI_QUEUE_CREATE: Create a scheduling queue. */ + DRM_ASAHI_QUEUE_CREATE, + + /** @DRM_ASAHI_QUEUE_DESTROY: Destroy a scheduling queue. */ + DRM_ASAHI_QUEUE_DESTROY, + + /** @DRM_ASAHI_SUBMIT: Submit commands to a queue. */ + DRM_ASAHI_SUBMIT, +}; + +#define DRM_ASAHI_MAX_CLUSTERS 64 + +/** + * struct drm_asahi_params_global - Global parameters. + * + * This struct may be queried by drm_asahi_get_params. + */ +struct drm_asahi_params_global { + /** @features: Feature bits from drm_asahi_feature */ + __u64 features; + + /** @gpu_generation: GPU generation, e.g. 13 for G13G */ + __u32 gpu_generation; + + /** @gpu_variant: GPU variant as a character, e.g. 'C' for G13C */ + __u32 gpu_variant; + + /** + * @gpu_revision: GPU revision in BCD, e.g. 0x00 for 'A0' or + * 0x21 for 'C1' + */ + __u32 gpu_revision; + + /** @chip_id: Chip ID in BCD, e.g. 0x8103 for T8103 */ + __u32 chip_id; + + /** @num_dies: Number of dies in the SoC */ + __u32 num_dies; + + /** @num_clusters_total: Number of GPU clusters (across all dies) */ + __u32 num_clusters_total; + + /** + * @num_cores_per_cluster: Number of logical cores per cluster + * (including inactive/nonexistent) + */ + __u32 num_cores_per_cluster; + + /** @max_frequency_khz: Maximum GPU core clock frequency */ + __u32 max_frequency_khz; + + /** @core_masks: Bitmask of present/enabled cores per cluster */ + __u64 core_masks[DRM_ASAHI_MAX_CLUSTERS]; + + /** + * @vm_start: VM range start VMA. Together with @vm_end, this defines + * the window of valid GPU VAs. Userspace is expected to subdivide VAs + * out of this window. + * + * This window contains all virtual addresses that userspace needs to + * know about. There may be kernel-internal GPU VAs outside this range, + * but that detail is not relevant here. + */ + __u64 vm_start; + + /** @vm_end: VM range end VMA */ + __u64 vm_end; + + /** + * @vm_kernel_min_size: Minimum kernel VMA window size. + * + * When creating a VM, userspace is required to carve out a section of + * virtual addresses (within the range given by @vm_start and + * @vm_end). The kernel will allocate various internal structures + * within the specified VA range. + * + * Allowing userspace to choose the VA range for the kernel, rather than + * the kernel reserving VAs and requiring userspace to cope, can assist + * in implementing SVM. + */ + __u64 vm_kernel_min_size; + + /** + * @max_commands_per_submission: Maximum number of supported commands + * per submission. This mirrors firmware limits. Userspace must split up + * larger command buffers, which may require inserting additional + * synchronization. + */ + __u32 max_commands_per_submission; + + /** + * @max_attachments: Maximum number of drm_asahi_attachment's per + * command + */ + __u32 max_attachments; + + /** + * @command_timestamp_frequency_hz: Timebase frequency for timestamps + * written during command exeuction, specified via drm_asahi_timestamp + * structures. As this rate is controlled by the firmware, it is a + * queryable parameter. + * + * Userspace must divide by this frequency to convert timestamps to + * seconds, rather than hardcoding a particular firmware's rate. + */ + __u64 command_timestamp_frequency_hz; +}; + +/** + * enum drm_asahi_feature - Feature bits + * + * This covers only features that userspace cannot infer from the architecture + * version. Most features don't need to be here. + */ +enum drm_asahi_feature { + /** + * @DRM_ASAHI_FEATURE_SOFT_FAULTS: GPU has "soft fault" enabled. Shader + * loads of unmapped memory will return zero. Shader stores to unmapped + * memory will be silently discarded. Note that only shader load/store + * is affected. Other hardware units are not affected, notably including + * texture sampling. + * + * Soft fault is set when initializing the GPU and cannot be runtime + * toggled. Therefore, it is exposed as a feature bit and not a + * userspace-settable flag on the VM. When soft fault is enabled, + * userspace can speculate memory accesses more aggressively. + */ + DRM_ASAHI_FEATURE_SOFT_FAULTS = (1UL) << 0, +}; + +/** + * struct drm_asahi_get_params - Arguments passed to DRM_IOCTL_ASAHI_GET_PARAMS + */ +struct drm_asahi_get_params { + /** @param_group: Parameter group to fetch (MBZ) */ + __u32 param_group; + + /** @pad: MBZ */ + __u32 pad; + + /** @pointer: User pointer to write parameter struct */ + __u64 pointer; + + /** + * @size: Size of the user buffer. In case of older userspace, this may + * be less than sizeof(struct drm_asahi_params_global). The kernel will + * not write past the length specified here, allowing extensibility. + */ + __u64 size; +}; + +/** + * struct drm_asahi_vm_create - Arguments passed to DRM_IOCTL_ASAHI_VM_CREATE + */ +struct drm_asahi_vm_create { + /** + * @kernel_start: Start of the kernel-reserved address range. See + * drm_asahi_params_global::vm_kernel_min_size. + * + * Both @kernel_start and @kernel_end must be within the range of + * valid VAs given by drm_asahi_params_global::vm_start and + * drm_asahi_params_global::vm_end. The size of the kernel range + * (@kernel_end - @kernel_start) must be at least + * drm_asahi_params_global::vm_kernel_min_size. + * + * Userspace must not bind any memory on this VM into this reserved + * range, it is for kernel use only. + */ + __u64 kernel_start; + + /** + * @kernel_end: End of the kernel-reserved address range. See + * @kernel_start. + */ + __u64 kernel_end; + + /** @vm_id: Returned VM ID */ + __u32 vm_id; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * struct drm_asahi_vm_destroy - Arguments passed to DRM_IOCTL_ASAHI_VM_DESTROY + */ +struct drm_asahi_vm_destroy { + /** @vm_id: VM ID to be destroyed */ + __u32 vm_id; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * enum drm_asahi_gem_flags - Flags for GEM creation + */ +enum drm_asahi_gem_flags { + /** + * @DRM_ASAHI_GEM_WRITEBACK: BO should be CPU-mapped as writeback. + * + * Map as writeback instead of write-combine. This optimizes for CPU + * reads. + */ + DRM_ASAHI_GEM_WRITEBACK = (1L << 0), + + /** + * @DRM_ASAHI_GEM_VM_PRIVATE: BO is private to this GPU VM (no exports). + */ + DRM_ASAHI_GEM_VM_PRIVATE = (1L << 1), +}; + +/** + * struct drm_asahi_gem_create - Arguments passed to DRM_IOCTL_ASAHI_GEM_CREATE + */ +struct drm_asahi_gem_create { + /** @size: Size of the BO */ + __u64 size; + + /** @flags: Combination of drm_asahi_gem_flags flags. */ + __u32 flags; + + /** + * @vm_id: VM ID to assign to the BO, if DRM_ASAHI_GEM_VM_PRIVATE is set + */ + __u32 vm_id; + + /** @handle: Returned GEM handle for the BO */ + __u32 handle; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * struct drm_asahi_gem_mmap_offset - Arguments passed to + * DRM_IOCTL_ASAHI_GEM_MMAP_OFFSET + */ +struct drm_asahi_gem_mmap_offset { + /** @handle: Handle for the object being mapped. */ + __u32 handle; + + /** @flags: Must be zero */ + __u32 flags; + + /** @offset: The fake offset to use for subsequent mmap call */ + __u64 offset; +}; + +/** + * enum drm_asahi_bind_flags - Flags for GEM binding + */ +enum drm_asahi_bind_flags { + /** + * @DRM_ASAHI_BIND_UNBIND: Instead of binding a GEM object to the range, + * simply unbind the GPU VMA range. + */ + DRM_ASAHI_BIND_UNBIND = (1L << 0), + + /** @DRM_ASAHI_BIND_READ: Map BO with GPU read permission */ + DRM_ASAHI_BIND_READ = (1L << 1), + + /** @DRM_ASAHI_BIND_WRITE: Map BO with GPU write permission */ + DRM_ASAHI_BIND_WRITE = (1L << 2), + + /** + * @DRM_ASAHI_BIND_SINGLE_PAGE: Map a single page of the BO repeatedly + * across the VA range. + * + * This is useful to fill a VA range with scratch pages or zero pages. + * It is intended as a mechanism to accelerate sparse. + */ + DRM_ASAHI_BIND_SINGLE_PAGE = (1L << 3), +}; + +/** + * struct drm_asahi_gem_bind_op - Description of a single GEM bind operation. + */ +struct drm_asahi_gem_bind_op { + /** @flags: Combination of drm_asahi_bind_flags flags. */ + __u32 flags; + + /** @handle: GEM object to bind (except for UNBIND) */ + __u32 handle; + + /** + * @offset: Offset into the object (except for UNBIND). + * + * For a regular bind, this is the beginning of the region of the GEM + * object to bind. + * + * For a single-page bind, this is the offset to the single page that + * will be repeatedly bound. + * + * Must be page-size aligned. + */ + __u64 offset; + + /** + * @range: Number of bytes to bind/unbind to @addr. + * + * Must be page-size aligned. + */ + __u64 range; + + /** + * @addr: Address to bind to. + * + * Must be page-size aligned. + */ + __u64 addr; +}; + +/** + * struct drm_asahi_vm_bind - Arguments passed to + * DRM_IOCTL_ASAHI_VM_BIND + */ +struct drm_asahi_vm_bind { + /** @vm_id: The ID of the VM to bind to */ + __u32 vm_id; + + /** @num_binds: number of binds in this IOCTL. */ + __u32 num_binds; + + /** + * @stride: Stride in bytes between consecutive binds. This allows + * extensibility of drm_asahi_gem_bind_op. + */ + __u32 stride; + + /** @pad: MBZ */ + __u32 pad; + + /** + * @userptr: User pointer to an array of @num_binds structures of type + * @drm_asahi_gem_bind_op and size @stride bytes. + */ + __u64 userptr; +}; + +/** + * enum drm_asahi_bind_object_op - Special object bind operation + */ +enum drm_asahi_bind_object_op { + /** @DRM_ASAHI_BIND_OBJECT_OP_BIND: Bind a BO as a special GPU object */ + DRM_ASAHI_BIND_OBJECT_OP_BIND = 0, + + /** @DRM_ASAHI_BIND_OBJECT_OP_UNBIND: Unbind a special GPU object */ + DRM_ASAHI_BIND_OBJECT_OP_UNBIND = 1, +}; + +/** + * enum drm_asahi_bind_object_flags - Special object bind flags + */ +enum drm_asahi_bind_object_flags { + /** + * @DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS: Map a BO as a timestamp + * buffer. + */ + DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS = (1L << 0), +}; + +/** + * struct drm_asahi_gem_bind_object - Arguments passed to + * DRM_IOCTL_ASAHI_GEM_BIND_OBJECT + */ +struct drm_asahi_gem_bind_object { + /** @op: Bind operation (enum drm_asahi_bind_object_op) */ + __u32 op; + + /** @flags: Combination of drm_asahi_bind_object_flags flags. */ + __u32 flags; + + /** @handle: GEM object to bind/unbind (BIND) */ + __u32 handle; + + /** @vm_id: The ID of the VM to operate on (MBZ currently) */ + __u32 vm_id; + + /** @offset: Offset into the object (BIND only) */ + __u64 offset; + + /** @range: Number of bytes to bind/unbind (BIND only) */ + __u64 range; + + /** @object_handle: Object handle (out for BIND, in for UNBIND) */ + __u32 object_handle; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * enum drm_asahi_cmd_type - Command type + */ +enum drm_asahi_cmd_type { + /** + * @DRM_ASAHI_CMD_RENDER: Render command, executing on the render + * subqueue. Combined vertex and fragment operation. + * + * Followed by a @drm_asahi_cmd_render payload. + */ + DRM_ASAHI_CMD_RENDER = 0, + + /** + * @DRM_ASAHI_CMD_COMPUTE: Compute command on the compute subqueue. + * + * Followed by a @drm_asahi_cmd_compute payload. + */ + DRM_ASAHI_CMD_COMPUTE = 1, + + /** + * @DRM_ASAHI_SET_VERTEX_ATTACHMENTS: Software command to set + * attachments for subsequent vertex shaders in the same submit. + * + * Followed by (possibly multiple) @drm_asahi_attachment payloads. + */ + DRM_ASAHI_SET_VERTEX_ATTACHMENTS = 2, + + /** + * @DRM_ASAHI_SET_FRAGMENT_ATTACHMENTS: Software command to set + * attachments for subsequent fragment shaders in the same submit. + * + * Followed by (possibly multiple) @drm_asahi_attachment payloads. + */ + DRM_ASAHI_SET_FRAGMENT_ATTACHMENTS = 3, + + /** + * @DRM_ASAHI_SET_COMPUTE_ATTACHMENTS: Software command to set + * attachments for subsequent compute shaders in the same submit. + * + * Followed by (possibly multiple) @drm_asahi_attachment payloads. + */ + DRM_ASAHI_SET_COMPUTE_ATTACHMENTS = 4, +}; + +/** + * enum drm_asahi_priority - Scheduling queue priority. + * + * These priorities are forwarded to the firmware to influence firmware + * scheduling. The exact policy is ultimately decided by firmware, but + * these enums allow userspace to communicate the intentions. + */ +enum drm_asahi_priority { + /** @DRM_ASAHI_PRIORITY_LOW: Low priority queue. */ + DRM_ASAHI_PRIORITY_LOW = 0, + + /** @DRM_ASAHI_PRIORITY_MEDIUM: Medium priority queue. */ + DRM_ASAHI_PRIORITY_MEDIUM = 1, + + /** + * @DRM_ASAHI_PRIORITY_HIGH: High priority queue. + * + * Reserved for future extension. + */ + DRM_ASAHI_PRIORITY_HIGH = 2, + + /** + * @DRM_ASAHI_PRIORITY_REALTIME: Real-time priority queue. + * + * Reserved for future extension. + */ + DRM_ASAHI_PRIORITY_REALTIME = 3, +}; + +/** + * struct drm_asahi_queue_create - Arguments passed to + * DRM_IOCTL_ASAHI_QUEUE_CREATE + */ +struct drm_asahi_queue_create { + /** @flags: MBZ */ + __u32 flags; + + /** @vm_id: The ID of the VM this queue is bound to */ + __u32 vm_id; + + /** @priority: One of drm_asahi_priority */ + __u32 priority; + + /** @queue_id: The returned queue ID */ + __u32 queue_id; + + /** + * @usc_exec_base: GPU base address for all USC binaries (shaders) on + * this queue. USC addresses are 32-bit relative to this 64-bit base. + * + * This sets the following registers on all queue commands: + * + * USC_EXEC_BASE_TA (vertex) + * USC_EXEC_BASE_ISP (fragment) + * USC_EXEC_BASE_CP (compute) + * + * While the hardware lets us configure these independently per command, + * we do not have a use case for this. Instead, we expect userspace to + * fix a 4GiB VA carveout for USC memory and pass its base address here. + */ + __u64 usc_exec_base; +}; + +/** + * struct drm_asahi_queue_destroy - Arguments passed to + * DRM_IOCTL_ASAHI_QUEUE_DESTROY + */ +struct drm_asahi_queue_destroy { + /** @queue_id: The queue ID to be destroyed */ + __u32 queue_id; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * enum drm_asahi_sync_type - Sync item type + */ +enum drm_asahi_sync_type { + /** @DRM_ASAHI_SYNC_SYNCOBJ: Binary sync object */ + DRM_ASAHI_SYNC_SYNCOBJ = 0, + + /** @DRM_ASAHI_SYNC_TIMELINE_SYNCOBJ: Timeline sync object */ + DRM_ASAHI_SYNC_TIMELINE_SYNCOBJ = 1, +}; + +/** + * struct drm_asahi_sync - Sync item + */ +struct drm_asahi_sync { + /** @sync_type: One of drm_asahi_sync_type */ + __u32 sync_type; + + /** @handle: The sync object handle */ + __u32 handle; + + /** @timeline_value: Timeline value for timeline sync objects */ + __u64 timeline_value; +}; + +/** + * define DRM_ASAHI_BARRIER_NONE - Command index for no barrier + * + * This special value may be passed in to drm_asahi_command::vdm_barrier or + * drm_asahi_command::cdm_barrier to indicate that the respective subqueue + * should not wait on any previous work. + */ +#define DRM_ASAHI_BARRIER_NONE (0xFFFFu) + +/** + * struct drm_asahi_cmd_header - Top level command structure + * + * This struct is core to the command buffer definition and therefore is not + * extensible. + */ +struct drm_asahi_cmd_header { + /** @cmd_type: One of drm_asahi_cmd_type */ + __u16 cmd_type; + + /** + * @size: Size of this command, not including this header. + * + * For hardware commands, this enables extensibility of commands without + * requiring extra command types. Passing a command that is shorter + * than expected is explicitly allowed for backwards-compatibility. + * Truncated fields will be zeroed. + * + * For the synthetic attachment setting commands, this implicitly + * encodes the number of attachments. These commands take multiple + * fixed-size @drm_asahi_attachment structures as their payload, so size + * equals number of attachments * sizeof(struct drm_asahi_attachment). + */ + __u16 size; + + /** + * @vdm_barrier: VDM (render) command index to wait on. + * + * Barriers are indices relative to the beginning of a given submit. A + * barrier of 0 waits on commands submitted to the respective subqueue + * in previous submit ioctls. A barrier of N waits on N previous + * commands on the subqueue within the current submit ioctl. As a + * special case, passing @DRM_ASAHI_BARRIER_NONE avoids waiting on any + * commands in the subqueue. + * + * Examples: + * + * 0: This waits on all previous work. + * + * NONE: This does not wait for anything on this subqueue. + * + * 1: This waits on the first render command in the submit. + * This is valid only if there are multiple render commands in the + * same submit. + * + * Barriers are valid only for hardware commands. Synthetic software + * commands to set attachments must pass NONE here. + */ + __u16 vdm_barrier; + + /** + * @cdm_barrier: CDM (compute) command index to wait on. + * + * See @vdm_barrier, and replace VDM/render with CDM/compute. + */ + __u16 cdm_barrier; +}; + +/** + * struct drm_asahi_submit - Arguments passed to DRM_IOCTL_ASAHI_SUBMIT + */ +struct drm_asahi_submit { + /** + * @syncs: An optional pointer to an array of drm_asahi_sync. The first + * @in_sync_count elements are in-syncs, then the remaining + * @out_sync_count elements are out-syncs. Using a single array with + * explicit partitioning simplifies handling. + */ + __u64 syncs; + + /** + * @cmdbuf: Pointer to the command buffer to submit. + * + * This is a flat command buffer. By design, it contains no CPU + * pointers, which makes it suitable for a virtgpu wire protocol without + * requiring any serializing/deserializing step. + * + * It consists of a series of commands. Each command begins with a + * fixed-size @drm_asahi_cmd_header header and is followed by a + * variable-length payload according to the type and size in the header. + * + * The combined count of "real" hardware commands must be nonzero and at + * most drm_asahi_params_global::max_commands_per_submission. + */ + __u64 cmdbuf; + + /** @flags: Flags for command submission (MBZ) */ + __u32 flags; + + /** @queue_id: The queue ID to be submitted to */ + __u32 queue_id; + + /** + * @in_sync_count: Number of sync objects to wait on before starting + * this job. + */ + __u32 in_sync_count; + + /** + * @out_sync_count: Number of sync objects to signal upon completion of + * this job. + */ + __u32 out_sync_count; + + /** @cmdbuf_size: Command buffer size in bytes */ + __u32 cmdbuf_size; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * struct drm_asahi_attachment - Describe an "attachment". + * + * Attachments are any memory written by shaders, notably including render + * target attachments written by the end-of-tile program. This is purely a hint + * about the accessed memory regions. It is optional to specify, which is + * fortunate as it cannot be specified precisely with bindless access anyway. + * But where possible, it's probably a good idea for userspace to include these + * hints, forwarded to the firmware. + * + * This struct is implicitly sized and therefore is not extensible. + */ +struct drm_asahi_attachment { + /** @pointer: Base address of the attachment */ + __u64 pointer; + + /** @size: Size of the attachment in bytes */ + __u64 size; + + /** @pad: MBZ */ + __u32 pad; + + /** @flags: MBZ */ + __u32 flags; +}; + +enum drm_asahi_render_flags { + /** + * @DRM_ASAHI_RENDER_VERTEX_SCRATCH: A vertex stage shader uses scratch + * memory. + */ + DRM_ASAHI_RENDER_VERTEX_SCRATCH = (1U << 0), + + /** + * @DRM_ASAHI_RENDER_PROCESS_EMPTY_TILES: Process even empty tiles. + * This must be set when clearing render targets. + */ + DRM_ASAHI_RENDER_PROCESS_EMPTY_TILES = (1U << 1), + + /** + * @DRM_ASAHI_RENDER_NO_VERTEX_CLUSTERING: Run vertex stage on a single + * cluster (on multi-cluster GPUs) + * + * This harms performance but can workaround certain sync/coherency + * bugs, and therefore is useful for debugging. + */ + DRM_ASAHI_RENDER_NO_VERTEX_CLUSTERING = (1U << 2), + + /** + * @DRM_ASAHI_RENDER_DBIAS_IS_INT: Use integer depth bias formula. + * + * Graphics specifications contain two alternate formulas for depth + * bias, a float formula used with floating-point depth buffers and an + * integer formula using with unorm depth buffers. This flag specifies + * that the integer formula should be used. If omitted, the float + * formula is used instead. + * + * This corresponds to bit 18 of the relevant hardware control register, + * so we match that here for efficiency. + */ + DRM_ASAHI_RENDER_DBIAS_IS_INT = (1U << 18), +}; + +/** + * struct drm_asahi_zls_buffer - Describe a depth or stencil buffer. + * + * These fields correspond to hardware registers in the ZLS (Z Load/Store) unit. + * There are three hardware registers for each field respectively for loads, + * stores, and partial renders. In practice, it makes sense to set all to the + * same values, except in exceptional cases not yet implemented in userspace, so + * we do not duplicate here for simplicity/efficiency. + * + * This struct is embedded in other structs and therefore is not extensible. + */ +struct drm_asahi_zls_buffer { + /** @base: Base address of the buffer */ + __u64 base; + + /** + * @comp_base: If the load buffer is compressed, address of the + * compression metadata section. + */ + __u64 comp_base; + + /** + * @stride: If layered rendering is enabled, the number of bytes + * between each layer of the buffer. + */ + __u32 stride; + + /** + * @comp_stride: If layered rendering is enabled, the number of bytes + * between each layer of the compression metadata. + */ + __u32 comp_stride; +}; + +/** + * struct drm_asahi_timestamp - Describe a timestamp write. + * + * The firmware can optionally write the GPU timestamp at render pass + * granularities, but it needs to be mapped specially via + * DRM_IOCTL_ASAHI_GEM_BIND_OBJECT. This structure therefore describes where to + * write as a handle-offset pair, rather than a GPU address like normal. + * + * This struct is embedded in other structs and therefore is not extensible. + */ +struct drm_asahi_timestamp { + /** + * @handle: Handle of the timestamp buffer, or 0 to skip this + * timestamp. If nonzero, this must equal the value returned in + * drm_asahi_gem_bind_object::object_handle. + */ + __u32 handle; + + /** @offset: Offset to write into the timestamp buffer */ + __u32 offset; +}; + +/** + * struct drm_asahi_timestamps - Describe timestamp writes. + * + * Each operation that can be timestamped, can be timestamped at the start and + * end. Therefore, drm_asahi_timestamp structs always come in pairs, bundled + * together into drm_asahi_timestamps. + * + * This struct is embedded in other structs and therefore is not extensible. + */ +struct drm_asahi_timestamps { + /** @start: Timestamp recorded at the start of the operation */ + struct drm_asahi_timestamp start; + + /** @end: Timestamp recorded at the end of the operation */ + struct drm_asahi_timestamp end; +}; + +/** + * struct drm_asahi_helper_program - Describe helper program configuration. + * + * The helper program is a compute-like kernel required for various hardware + * functionality. Its most important role is dynamically allocating + * scratch/stack memory for individual subgroups, by partitioning a static + * allocation shared for the whole device. It is supplied by userspace via + * drm_asahi_helper_program and internally dispatched by the hardware as needed. + * + * This struct is embedded in other structs and therefore is not extensible. + */ +struct drm_asahi_helper_program { + /** + * @binary: USC address to the helper program binary. This is a tagged + * pointer with configuration in the bottom bits. + */ + __u32 binary; + + /** @cfg: Additional configuration bits for the helper program. */ + __u32 cfg; + + /** + * @data: Data passed to the helper program. This value is not + * interpreted by the kernel, firmware, or hardware in any way. It is + * simply a sideband for userspace, set with the submit ioctl and read + * via special registers inside the helper program. + * + * In practice, userspace will pass a 64-bit GPU VA here pointing to the + * actual arguments, which presumably don't fit in 64-bits. + */ + __u64 data; +}; + +/** + * struct drm_asahi_bg_eot - Describe a background or end-of-tile program. + * + * The background and end-of-tile programs are dispatched by the hardware at the + * beginning and end of rendering. As the hardware "tilebuffer" is simply local + * memory, these programs are necessary to implement API-level render targets. + * The fragment-like background program is responsible for loading either the + * clear colour or the existing render target contents, while the compute-like + * end-of-tile program stores the tilebuffer contents to memory. + * + * This struct is embedded in other structs and therefore is not extensible. + */ +struct drm_asahi_bg_eot { + /** + * @usc: USC address of the hardware USC words binding resources + * (including images and uniforms) and the program itself. Note this is + * an additional layer of indirection compared to the helper program, + * avoiding the need for a sideband for data. This is a tagged pointer + * with additional configuration in the bottom bits. + */ + __u32 usc; + + /** + * @rsrc_spec: Resource specifier for the program. This is a packed + * hardware data structure describing the required number of registers, + * uniforms, bound textures, and bound samplers. + */ + __u32 rsrc_spec; +}; + +/** + * struct drm_asahi_cmd_render - Command to submit 3D + * + * This command submits a single render pass. The hardware control stream may + * include many draws and subpasses, but within the command, the framebuffer + * dimensions and attachments are fixed. + * + * The hardware requires the firmware to set a large number of Control Registers + * setting up state at render pass granularity before each command rendering 3D. + * The firmware bundles this state into data structures. Unfortunately, we + * cannot expose either any of that directly to userspace, because the + * kernel-firmware ABI is not stable. Although we can guarantee the firmware + * updates in tandem with the kernel, we cannot break old userspace when + * upgrading the firmware and kernel. Therefore, we need to abstract well the + * data structures to avoid tying our hands with future firmwares. + * + * The bulk of drm_asahi_cmd_render therefore consists of values of hardware + * control registers, marshalled via the firmware interface. + * + * The framebuffer/tilebuffer dimensions are also specified here. In addition to + * being passed to the firmware/hardware, the kernel requires these dimensions + * to calculate various essential tiling-related data structures. It is + * unfortunate that our submits are heavier than on vendors with saner + * hardware-software interfaces. The upshot is all of this information is + * readily available to userspace with all current APIs. + * + * It looks odd - but it's not overly burdensome and it ensures we can remain + * compatible with old userspace. + */ +struct drm_asahi_cmd_render { + /** @flags: Combination of drm_asahi_render_flags flags. */ + __u32 flags; + + /** + * @isp_zls_pixels: ISP_ZLS_PIXELS register value. This contains the + * depth/stencil width/height, which may differ from the framebuffer + * width/height. + */ + __u32 isp_zls_pixels; + + /** + * @vdm_ctrl_stream_base: VDM_CTRL_STREAM_BASE register value. GPU + * address to the beginning of the VDM control stream. + */ + __u64 vdm_ctrl_stream_base; + + /** @vertex_helper: Helper program used for the vertex shader */ + struct drm_asahi_helper_program vertex_helper; + + /** @fragment_helper: Helper program used for the fragment shader */ + struct drm_asahi_helper_program fragment_helper; + + /** + * @isp_scissor_base: ISP_SCISSOR_BASE register value. GPU address of an + * array of scissor descriptors indexed in the render pass. + */ + __u64 isp_scissor_base; + + /** + * @isp_dbias_base: ISP_DBIAS_BASE register value. GPU address of an + * array of depth bias values indexed in the render pass. + */ + __u64 isp_dbias_base; + + /** + * @isp_oclqry_base: ISP_OCLQRY_BASE register value. GPU address of an + * array of occlusion query results written by the render pass. + */ + __u64 isp_oclqry_base; + + /** @depth: Depth buffer */ + struct drm_asahi_zls_buffer depth; + + /** @stencil: Stencil buffer */ + struct drm_asahi_zls_buffer stencil; + + /** @zls_ctrl: ZLS_CTRL register value */ + __u64 zls_ctrl; + + /** @ppp_multisamplectl: PPP_MULTISAMPLECTL register value */ + __u64 ppp_multisamplectl; + + /** + * @sampler_heap: Base address of the sampler heap. This heap is used + * for both vertex shaders and fragment shaders. The registers are + * per-stage, but there is no known use case for separate heaps. + */ + __u64 sampler_heap; + + /** @ppp_ctrl: PPP_CTRL register value */ + __u32 ppp_ctrl; + + /** @width_px: Framebuffer width in pixels */ + __u16 width_px; + + /** @height_px: Framebuffer height in pixels */ + __u16 height_px; + + /** @layers: Number of layers in the framebuffer */ + __u16 layers; + + /** @sampler_count: Number of samplers in the sampler heap. */ + __u16 sampler_count; + + /** @utile_width_px: Width of a logical tilebuffer tile in pixels */ + __u8 utile_width_px; + + /** @utile_height_px: Height of a logical tilebuffer tile in pixels */ + __u8 utile_height_px; + + /** @samples: # of samples in the framebuffer. Must be 1, 2, or 4. */ + __u8 samples; + + /** @sample_size_B: # of bytes in the tilebuffer required per sample. */ + __u8 sample_size_B; + + /** + * @isp_merge_upper_x: 32-bit float used in the hardware triangle + * merging. Calculate as: tan(60 deg) * width. + * + * Making these values UAPI avoids requiring floating-point calculations + * in the kernel in the hot path. + */ + __u32 isp_merge_upper_x; + + /** + * @isp_merge_upper_y: 32-bit float. Calculate as: tan(60 deg) * height. + * See @isp_merge_upper_x. + */ + __u32 isp_merge_upper_y; + + /** @bg: Background program run for each tile at the start */ + struct drm_asahi_bg_eot bg; + + /** @eot: End-of-tile program ran for each tile at the end */ + struct drm_asahi_bg_eot eot; + + /** + * @partial_bg: Background program ran at the start of each tile when + * resuming the render pass during a partial render. + */ + struct drm_asahi_bg_eot partial_bg; + + /** + * @partial_eot: End-of-tile program ran at the end of each tile when + * pausing the render pass during a partial render. + */ + struct drm_asahi_bg_eot partial_eot; + + /** + * @isp_bgobjdepth: ISP_BGOBJDEPTH register value. This is the depth + * buffer clear value, encoded in the depth buffer's format: either a + * 32-bit float or a 16-bit unorm (with upper bits zeroed). + */ + __u32 isp_bgobjdepth; + + /** + * @isp_bgobjvals: ISP_BGOBJVALS register value. The bottom 8-bits + * contain the stencil buffer clear value. + */ + __u32 isp_bgobjvals; + + /** @ts_vtx: Timestamps for the vertex portion of the render */ + struct drm_asahi_timestamps ts_vtx; + + /** @ts_frag: Timestamps for the fragment portion of the render */ + struct drm_asahi_timestamps ts_frag; +}; + +/** + * struct drm_asahi_cmd_compute - Command to submit compute + * + * This command submits a control stream consisting of compute dispatches. There + * is essentially no limit on how many compute dispatches may be included in a + * single compute command, although timestamps are at command granularity. + */ +struct drm_asahi_cmd_compute { + /** @flags: MBZ */ + __u32 flags; + + /** @sampler_count: Number of samplers in the sampler heap. */ + __u32 sampler_count; + + /** + * @cdm_ctrl_stream_base: CDM_CTRL_STREAM_BASE register value. GPU + * address to the beginning of the CDM control stream. + */ + __u64 cdm_ctrl_stream_base; + + /** + * @cdm_ctrl_stream_end: GPU base address to the end of the hardware + * control stream. Note this only considers the first contiguous segment + * of the control stream, as the stream might jump elsewhere. + */ + __u64 cdm_ctrl_stream_end; + + /** @sampler_heap: Base address of the sampler heap. */ + __u64 sampler_heap; + + /** @helper: Helper program used for this compute command */ + struct drm_asahi_helper_program helper; + + /** @ts: Timestamps for the compute command */ + struct drm_asahi_timestamps ts; +}; + +/** + * struct drm_asahi_get_time - Arguments passed to DRM_IOCTL_ASAHI_GET_TIME + */ +struct drm_asahi_get_time { + /** @flags: MBZ. */ + __u64 flags; + + /** @gpu_timestamp: On return, the GPU timestamp in nanoseconds. */ + __u64 gpu_timestamp; +}; + +/** + * DRM_IOCTL_ASAHI() - Build an Asahi IOCTL number + * @__access: Access type. Must be R, W or RW. + * @__id: One of the DRM_ASAHI_xxx id. + * @__type: Suffix of the type being passed to the IOCTL. + * + * Don't use this macro directly, use the DRM_IOCTL_ASAHI_xxx + * values instead. + * + * Return: An IOCTL number to be passed to ioctl() from userspace. + */ +#define DRM_IOCTL_ASAHI(__access, __id, __type) \ + DRM_IO ## __access(DRM_COMMAND_BASE + DRM_ASAHI_ ## __id, \ + struct drm_asahi_ ## __type) + +/* Note: this is an enum so that it can be resolved by Rust bindgen. */ +enum { + DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOCTL_ASAHI(W, GET_PARAMS, get_params), + DRM_IOCTL_ASAHI_GET_TIME = DRM_IOCTL_ASAHI(WR, GET_TIME, get_time), + DRM_IOCTL_ASAHI_VM_CREATE = DRM_IOCTL_ASAHI(WR, VM_CREATE, vm_create), + DRM_IOCTL_ASAHI_VM_DESTROY = DRM_IOCTL_ASAHI(W, VM_DESTROY, vm_destroy), + DRM_IOCTL_ASAHI_VM_BIND = DRM_IOCTL_ASAHI(W, VM_BIND, vm_bind), + DRM_IOCTL_ASAHI_GEM_CREATE = DRM_IOCTL_ASAHI(WR, GEM_CREATE, gem_create), + DRM_IOCTL_ASAHI_GEM_MMAP_OFFSET = DRM_IOCTL_ASAHI(WR, GEM_MMAP_OFFSET, gem_mmap_offset), + DRM_IOCTL_ASAHI_GEM_BIND_OBJECT = DRM_IOCTL_ASAHI(WR, GEM_BIND_OBJECT, gem_bind_object), + DRM_IOCTL_ASAHI_QUEUE_CREATE = DRM_IOCTL_ASAHI(WR, QUEUE_CREATE, queue_create), + DRM_IOCTL_ASAHI_QUEUE_DESTROY = DRM_IOCTL_ASAHI(W, QUEUE_DESTROY, queue_destroy), + DRM_IOCTL_ASAHI_SUBMIT = DRM_IOCTL_ASAHI(W, SUBMIT, submit), +}; + +#if defined(__cplusplus) +} +#endif + +#endif /* _ASAHI_DRM_H_ */ diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index e09865ac16..ad2f0d4a22 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -21,16 +21,17 @@ #include #endif -#if defined(FF_HAVE_DRM) && __has_include() +#if defined(FF_HAVE_DRM) && defined(__aarch64__) // https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h // Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64 - #include + #if __has_include() + #include + #else + #include "asahi_drm.h" + #endif #define FF_HAVE_DRM_ASAHI 1 #endif -#define FF_STR_INDIR(x) #x -#define FF_STR(x) FF_STR_INDIR(x) - static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey) { uint32_t pciDirLength = pciDir->length; From 7e04305d1cde9933c088776468edc50322cd7eb4 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 14 May 2025 09:18:48 +0800 Subject: [PATCH 41/41] CI: silence spell check errors --- .codespellrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codespellrc b/.codespellrc index ec3c029c29..48fa44238a 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,5 @@ [codespell] check-filenames = builtin = clear,rare,usage,informal -skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii +skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii,./src/detection/gpu/asahi_drm.h ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,slave,sur,doas,conexant,ags,bu