mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-07 17:32:45 -04:00
Main: include/kernaux/printf.h: Remove Easter egg
This commit is contained in:
parent
28e0cf6a54
commit
aadd863025
6 changed files with 1 additions and 92 deletions
|
@ -1,6 +1,7 @@
|
|||
2022-06-06 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* include/kernaux/libc.h: Add more functions
|
||||
* include/kernaux/print.h: Remove Easter egg
|
||||
|
||||
2022-06-04 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
|
|
|
@ -119,7 +119,6 @@ stable options.
|
|||
|
||||
#### Features
|
||||
|
||||
* `--(enable|disable)-bloat` - heavy binary data
|
||||
* `--(enable|disable)-float` - floating-point arithmetic
|
||||
* `--(enable|disable)-werror` - fail on warning (`CFLAGS+='-Werror'`)
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ AC_CANONICAL_HOST
|
|||
###############
|
||||
|
||||
dnl Features (enabled by default)
|
||||
AC_ARG_ENABLE([bloat], AS_HELP_STRING([--disable-bloat], [disable unnecessary heavy binary data]))
|
||||
AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic]))
|
||||
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
|
||||
|
||||
|
@ -106,7 +105,6 @@ AS_IF([test "$with_libc_all" = yes], do_with_libc_all)
|
|||
##################
|
||||
|
||||
dnl Features (enabled by default)
|
||||
AS_IF([test "$enable_bloat" = no ], [enable_bloat=no], [enable_bloat=yes])
|
||||
AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes])
|
||||
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
|
||||
|
||||
|
@ -167,7 +165,6 @@ AM_CONDITIONAL([ASM_RISCV64], [test "$host_cpu" = riscv64])
|
|||
AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64])
|
||||
|
||||
dnl Features (enabled by default)
|
||||
AM_CONDITIONAL([ENABLE_BLOAT], [test "$enable_bloat" = yes])
|
||||
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes])
|
||||
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
|
||||
|
||||
|
@ -210,7 +207,6 @@ AS_IF([test "$host_cpu" = riscv64], [AC_DEFINE([ASM_RISCV64], [1]
|
|||
AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1], [architecture is x86_64])])
|
||||
|
||||
dnl Features (enabled by default)
|
||||
AS_IF([test "$enable_bloat" = yes], [AC_DEFINE([ENABLE_BLOAT], [1], [enabled unnecessary heavy binary data])])
|
||||
AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])])
|
||||
AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])])
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ extern "C" {
|
|||
#define KERNAUX_PRINTF_FMT_FLAGS_LONG_LONG (1u << 9u)
|
||||
#define KERNAUX_PRINTF_FMT_FLAGS_PRECISION (1u << 10u)
|
||||
#define KERNAUX_PRINTF_FMT_FLAGS_ADAPT_EXP (1u << 11u)
|
||||
#define KERNAUX_PRINTF_FMT_FLAGS_CUSTOM (1u << 12u)
|
||||
|
||||
enum KernAux_PrintfFmt_Type {
|
||||
KERNAUX_PRINTF_FMT_TYPE_NONE,
|
||||
|
@ -29,7 +28,6 @@ enum KernAux_PrintfFmt_Type {
|
|||
KERNAUX_PRINTF_FMT_TYPE_EXP,
|
||||
KERNAUX_PRINTF_FMT_TYPE_CHAR,
|
||||
KERNAUX_PRINTF_FMT_TYPE_STR,
|
||||
KERNAUX_PRINTF_FMT_TYPE_CUSTOM,
|
||||
KERNAUX_PRINTF_FMT_TYPE_PTR,
|
||||
KERNAUX_PRINTF_FMT_TYPE_PERCENT,
|
||||
};
|
||||
|
|
66
src/printf.c
66
src/printf.c
|
@ -56,10 +56,6 @@ static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t ma
|
|||
static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags);
|
||||
static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags);
|
||||
|
||||
#ifdef ENABLE_BLOAT
|
||||
static char _custom(unsigned int flags, size_t *index);
|
||||
#endif // ENABLE_BLOAT
|
||||
|
||||
#ifdef ENABLE_FLOAT
|
||||
static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags);
|
||||
static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags);
|
||||
|
@ -244,18 +240,6 @@ int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const char*
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BLOAT
|
||||
case KERNAUX_PRINTF_FMT_TYPE_CUSTOM:
|
||||
{
|
||||
size_t index = 0;
|
||||
char c;
|
||||
while ((c = _custom(spec.flags, &index))) {
|
||||
out(c, buffer, idx++, maxlen);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif // ENABLE_BLOAT
|
||||
|
||||
case KERNAUX_PRINTF_FMT_TYPE_PTR:
|
||||
{
|
||||
const bool is_ll = sizeof(uintptr_t) == sizeof(long long);
|
||||
|
@ -435,56 +419,6 @@ size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen
|
|||
return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BLOAT
|
||||
/**
|
||||
* Idea: superleaf1995
|
||||
* Implementation: smwmaster
|
||||
*/
|
||||
static const size_t map_size = 630;
|
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||||
"\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF7\x92\x97\x97\x97\x97\x97\x97\x97\x97"
|
||||
"\x97\x97\x97\x97\x97\x97\x97\x97\xA1\xF7\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xF9\xBA\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97"
|
||||
"\x97\x97\x97\x97\x97\xE9\xF7\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\x96\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97"
|
||||
"\x97\x97\x92\xF7\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xFE\x81"
|
||||
"\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x81"
|
||||
"\xFE\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xB5\x97\x97\x97\x97"
|
||||
"\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\x97\xF5\xF9\xF9"
|
||||
"\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF7\x96\x97\x97\x97\xA1\xF5\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xFE\x96\x97\x97\x97\x97\x97\x97\xE3\xF9\xF9\xD3\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xF9\xF7\xF5\x81\x97\x97\x92\xF7\xF9\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\xFE\x81\x97\x97\x97\x97\x97\xBA\xF9\xF9\xD3\xF9\xF9\xF7\xE2\xBA"
|
||||
"\xBA\xBA\xF5\xB2\x97\x97\x97\x97\xE3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF5"
|
||||
"\x81\x97\x97\x97\x97\x97\xE3\xF9\xF9\xD3\xF9\xF9\xFE\xE9\x81\x97\x97\x97"
|
||||
"\x97\x97\x81\x92\xB2\xF7\xF9\xF9\xF9\xF9\xF9\xF7\xF7\xF7\xB6\x97\x97\x97"
|
||||
"\x97\x97\x97\xE2\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xF9\xF7\xFE\xB2\x92\x81\x81\x97\x97\x97\x97\x97\x97\xE9"
|
||||
"\xF7\xF9\xF9\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xF5\xB2\x96\xE9\xE9\x96\xA1\xBD\xF5\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xD3\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9"
|
||||
"\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xF9\xD3\xD3\xD9";
|
||||
|
||||
char _custom(const unsigned int flags, size_t *const index)
|
||||
{
|
||||
if (*index >= map_size) return '\0';
|
||||
return map[(*index)++] ^ (73 + ((flags >> 8) | 128));
|
||||
}
|
||||
#endif // ENABLE_BLOAT
|
||||
|
||||
#ifdef ENABLE_FLOAT
|
||||
// internal ftoa for fixed decimal floating point
|
||||
size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags)
|
||||
|
|
|
@ -145,16 +145,6 @@ void KernAux_PrintfFmt_Spec_parse_length(struct KernAux_PrintfFmt_Spec *const sp
|
|||
spec->flags |= (sizeof(size_t) == sizeof(long) ? KERNAUX_PRINTF_FMT_FLAGS_LONG : KERNAUX_PRINTF_FMT_FLAGS_LONG_LONG);
|
||||
++(*format);
|
||||
break;
|
||||
#ifdef ENABLE_BLOAT
|
||||
case 'S':
|
||||
if (*(++(*format)) == 'U') {
|
||||
spec->flags |= KERNAUX_PRINTF_FMT_FLAGS_CUSTOM;
|
||||
++(*format);
|
||||
} else {
|
||||
--(*format);
|
||||
}
|
||||
break;
|
||||
#endif // ENABLE_BLOAT
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -238,15 +228,6 @@ void KernAux_PrintfFmt_Spec_parse_type(struct KernAux_PrintfFmt_Spec *const spec
|
|||
++(*format);
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_BLOAT
|
||||
case 'S':
|
||||
if (spec->flags & KERNAUX_PRINTF_FMT_FLAGS_CUSTOM) {
|
||||
spec->type = KERNAUX_PRINTF_FMT_TYPE_CUSTOM;
|
||||
++(*format);
|
||||
}
|
||||
break;
|
||||
#endif // ENABLE_BLOAT
|
||||
|
||||
case 'p':
|
||||
spec->width = sizeof(void*) * 2u;
|
||||
spec->flags |= KERNAUX_PRINTF_FMT_FLAGS_ZEROPAD | KERNAUX_PRINTF_FMT_FLAGS_UPPERCASE;
|
||||
|
|
Loading…
Add table
Reference in a new issue