wuffs gen -version=0.3.0-alpha.5

This commit is contained in:
Nigel Tao committed 2020-07-01 12:22:17 +10:00
1 parent c94ccef400
commit 991e1b2667
1 file changed
+1653 -801
+1653 -801
View File
@@ -65,15 +65,15 @@ extern "C" {
// each major.minor branch, the commit count should increase monotonically.
//
// WUFFS_VERSION was overridden by "wuffs gen -version" based on revision
// d377dcaea826f12b47492cced1b75450a440f6c1 committed on 2020-06-17.
// c94ccef400cd94a23bef9e2a3d824358147ea121 committed on 2020-07-01.
#define WUFFS_VERSION 0x000030000
#define WUFFS_VERSION_MAJOR 0
#define WUFFS_VERSION_MINOR 3
#define WUFFS_VERSION_PATCH 0
#define WUFFS_VERSION_PRE_RELEASE_LABEL "alpha.4"
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 2514
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20200617
#define WUFFS_VERSION_STRING "0.3.0-alpha.4+2514.20200617"
#define WUFFS_VERSION_PRE_RELEASE_LABEL "alpha.5"
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 2523
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20200701
#define WUFFS_VERSION_STRING "0.3.0-alpha.5+2523.20200701"
// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have
// static storage. The motivation is discussed in the "ALLOW STATIC
@@ -111,7 +111,9 @@ extern "C" {
#define WUFFS_BASE__WARN_UNUSED_RESULT
#endif
// Flags for wuffs_foo__bar__initialize functions.
// --------
// Options (bitwise or'ed together) for wuffs_foo__bar__initialize functions.
#define WUFFS_INITIALIZE__DEFAULT_OPTIONS ((uint32_t)0x00000000)
@@ -193,36 +195,36 @@ typedef struct {
} wuffs_base__status;
extern const char* wuffs_base__note__i_o_redirect;
extern const char* wuffs_base__note__end_of_data;
extern const char* wuffs_base__note__metadata_reported;
extern const char* wuffs_base__suspension__even_more_information;
extern const char* wuffs_base__suspension__mispositioned_read;
extern const char* wuffs_base__suspension__mispositioned_write;
extern const char* wuffs_base__suspension__short_read;
extern const char* wuffs_base__suspension__short_write;
extern const char* wuffs_base__error__bad_i_o_position;
extern const char* wuffs_base__error__bad_argument_length_too_short;
extern const char* wuffs_base__error__bad_argument;
extern const char* wuffs_base__error__bad_call_sequence;
extern const char* wuffs_base__error__bad_receiver;
extern const char* wuffs_base__error__bad_restart;
extern const char* wuffs_base__error__bad_sizeof_receiver;
extern const char* wuffs_base__error__bad_vtable;
extern const char* wuffs_base__error__bad_workbuf_length;
extern const char* wuffs_base__error__bad_wuffs_version;
extern const char* wuffs_base__error__cannot_return_a_suspension;
extern const char* wuffs_base__error__disabled_by_previous_error;
extern const char* wuffs_base__error__initialize_falsely_claimed_already_zeroed;
extern const char* wuffs_base__error__initialize_not_called;
extern const char* wuffs_base__error__interleaved_coroutine_calls;
extern const char* wuffs_base__error__no_more_information;
extern const char* wuffs_base__error__not_enough_data;
extern const char* wuffs_base__error__out_of_bounds;
extern const char* wuffs_base__error__unsupported_method;
extern const char* wuffs_base__error__unsupported_option;
extern const char* wuffs_base__error__unsupported_pixel_swizzler_option;
extern const char* wuffs_base__error__too_much_data;
extern const char wuffs_base__note__i_o_redirect[];
extern const char wuffs_base__note__end_of_data[];
extern const char wuffs_base__note__metadata_reported[];
extern const char wuffs_base__suspension__even_more_information[];
extern const char wuffs_base__suspension__mispositioned_read[];
extern const char wuffs_base__suspension__mispositioned_write[];
extern const char wuffs_base__suspension__short_read[];
extern const char wuffs_base__suspension__short_write[];
extern const char wuffs_base__error__bad_i_o_position[];
extern const char wuffs_base__error__bad_argument_length_too_short[];
extern const char wuffs_base__error__bad_argument[];
extern const char wuffs_base__error__bad_call_sequence[];
extern const char wuffs_base__error__bad_receiver[];
extern const char wuffs_base__error__bad_restart[];
extern const char wuffs_base__error__bad_sizeof_receiver[];
extern const char wuffs_base__error__bad_vtable[];
extern const char wuffs_base__error__bad_workbuf_length[];
extern const char wuffs_base__error__bad_wuffs_version[];
extern const char wuffs_base__error__cannot_return_a_suspension[];
extern const char wuffs_base__error__disabled_by_previous_error[];
extern const char wuffs_base__error__initialize_falsely_claimed_already_zeroed[];
extern const char wuffs_base__error__initialize_not_called[];
extern const char wuffs_base__error__interleaved_coroutine_calls[];
extern const char wuffs_base__error__no_more_information[];
extern const char wuffs_base__error__not_enough_data[];
extern const char wuffs_base__error__out_of_bounds[];
extern const char wuffs_base__error__unsupported_method[];
extern const char wuffs_base__error__unsupported_option[];
extern const char wuffs_base__error__unsupported_pixel_swizzler_option[];
extern const char wuffs_base__error__too_much_data[];
static inline wuffs_base__status //
wuffs_base__make_status(const char* repr) {
@@ -353,6 +355,46 @@ typedef int64_t wuffs_base__flicks;
// inline attribute to guide optimizations such as inlining, to avoid the
// -Wunused-function warning, and we like to compile with -Wall -Werror.
static inline int8_t //
wuffs_base__i8__min(int8_t x, int8_t y) {
return x < y ? x : y;
}
static inline int8_t //
wuffs_base__i8__max(int8_t x, int8_t y) {
return x > y ? x : y;
}
static inline int16_t //
wuffs_base__i16__min(int16_t x, int16_t y) {
return x < y ? x : y;
}
static inline int16_t //
wuffs_base__i16__max(int16_t x, int16_t y) {
return x > y ? x : y;
}
static inline int32_t //
wuffs_base__i32__min(int32_t x, int32_t y) {
return x < y ? x : y;
}
static inline int32_t //
wuffs_base__i32__max(int32_t x, int32_t y) {
return x > y ? x : y;
}
static inline int64_t //
wuffs_base__i64__min(int64_t x, int64_t y) {
return x < y ? x : y;
}
static inline int64_t //
wuffs_base__i64__max(int64_t x, int64_t y) {
return x > y ? x : y;
}
static inline uint8_t //
wuffs_base__u8__min(uint8_t x, uint8_t y) {
return x < y ? x : y;
@@ -3865,43 +3907,49 @@ wuffs_base__pixel_swizzler::swizzle_interleaved_from_slice(
// ---------------- String Conversions
// wuffs_base__parse_number_i64 parses the ASCII integer in s. For example, if
// s contains the bytes "-123" then it will return the int64_t -123.
//
// It returns an error if s does not contain an integer or if the integer
// within would overflow an int64_t.
//
// It is similar to wuffs_base__parse_number_u64 but it returns a signed
// integer, not an unsigned integer. It also allows a leading '+' or '-'.
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64 //
wuffs_base__parse_number_i64(wuffs_base__slice_u8 s);
// Options (bitwise or'ed together) for wuffs_base__render_number_xxx
// functions. The XXX options apply to both integer and floating point. The FXX
// options apply only to floating point.
// wuffs_base__parse_number_u64 parses the ASCII integer in s. For example, if
// s contains the bytes "123" then it will return the uint64_t 123.
#define WUFFS_BASE__RENDER_NUMBER_XXX__DEFAULT_OPTIONS ((uint32_t)0x00000000)
// WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT means to render to the right side
// (higher indexes) of the destination slice, leaving any untouched bytes on
// the left side (lower indexes). The default is vice versa: rendering on the
// left with slack on the right.
#define WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT ((uint32_t)0x00000001)
// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN means to render the leading
// "+" for non-negative numbers: "+0" and "+12.3" instead of "0" and "12.3".
#define WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN ((uint32_t)0x00000002)
// WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA means to render
// one-and-a-half as "1,5" instead of "1.5".
#define WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA \
((uint32_t)0x00000100)
// WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ETC means whether to never
// (EXPONENT_ABSENT, equivalent to printf's "%f") or to always
// (EXPONENT_PRESENT, equivalent to printf's "%e") render a floating point
// number as "1.23e+05" instead of "123000".
//
// It returns an error if s does not contain an integer or if the integer
// within would overflow a uint64_t.
// Having both bits set is the same has having neither bit set, where the
// notation used depends on whether the exponent is sufficiently large: "0.5"
// is preferred over "5e-01" but "5e-09" is preferred over "0.000000005".
#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT ((uint32_t)0x00000200)
#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT ((uint32_t)0x00000400)
// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION means to render the
// smallest number of digits so that parsing the resultant string will recover
// the same double-precision floating point number.
//
// It is similar to the C standard library's strtoull function, but:
// - Errors are returned in-band (in a result type), not out-of-band (errno).
// - It takes a slice (a pointer and length), not a NUL-terminated C string.
// - It does not take an optional endptr argument. It does not allow a partial
// parse: it returns an error unless all of s is consumed.
// - It does not allow whitespace, leading or otherwise.
// - It does not allow a leading '+' or '-'.
// - It does not allow unnecessary leading zeroes ("0" is valid and its sole
// zero is necessary). All of "00", "0644" and "007" are invalid.
// - It does not take a base argument (e.g. base 10 vs base 16). Instead, it
// always accepts both decimal (e.g "1234", "0d5678") and hexadecimal (e.g.
// "0x9aBC"). The caller is responsible for prior filtering of e.g. hex
// numbers if they are unwanted. For example, Wuffs' JSON decoder will only
// produce a wuffs_base__token for decimal numbers, not hexadecimal.
// - It is not affected by i18n / l10n settings such as environment variables.
// - It does allow arbitrary underscores, except inside the optional 2-byte
// opening "0d" or "0X" that denotes base-10 or base-16. For example,
// "__0D_1_002" would successfully parse as "one thousand and two".
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64 //
wuffs_base__parse_number_u64(wuffs_base__slice_u8 s);
// For example, double-precision cannot distinguish between 0.3 and
// 0.299999999999999988897769753748434595763683319091796875, so when this bit
// is set, rendering the latter will produce "0.3" but rendering
// 0.3000000000000000444089209850062616169452667236328125 will produce
// "0.30000000000000004".
#define WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION \
((uint32_t)0x00000800)
// ---------------- IEEE 754 Floating Point
@@ -3944,6 +3992,8 @@ wuffs_base__parse_number_u64(wuffs_base__slice_u8 s);
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_f64 //
wuffs_base__parse_number_f64(wuffs_base__slice_u8 s);
// --------
// wuffs_base__ieee_754_bit_representation__etc converts between a double
// precision numerical value and its IEEE 754 64-bit representation (1 sign
// bit, 11 exponent bits, 52 explicit significand bits).
@@ -3973,6 +4023,105 @@ wuffs_base__ieee_754_bit_representation__to_f64(uint64_t u) {
return f;
}
// ---------------- Integer
// wuffs_base__parse_number_i64 parses the ASCII integer in s. For example, if
// s contains the bytes "-123" then it will return the int64_t -123.
//
// It returns an error if s does not contain an integer or if the integer
// within would overflow an int64_t.
//
// It is similar to wuffs_base__parse_number_u64 but it returns a signed
// integer, not an unsigned integer. It also allows a leading '+' or '-'.
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64 //
wuffs_base__parse_number_i64(wuffs_base__slice_u8 s);
// wuffs_base__parse_number_u64 parses the ASCII integer in s. For example, if
// s contains the bytes "123" then it will return the uint64_t 123.
//
// It returns an error if s does not contain an integer or if the integer
// within would overflow a uint64_t.
//
// It is similar to the C standard library's strtoull function, but:
// - Errors are returned in-band (in a result type), not out-of-band (errno).
// - It takes a slice (a pointer and length), not a NUL-terminated C string.
// - It does not take an optional endptr argument. It does not allow a partial
// parse: it returns an error unless all of s is consumed.
// - It does not allow whitespace, leading or otherwise.
// - It does not allow a leading '+' or '-'.
// - It does not allow unnecessary leading zeroes ("0" is valid and its sole
// zero is necessary). All of "00", "0644" and "007" are invalid.
// - It does not take a base argument (e.g. base 10 vs base 16). Instead, it
// always accepts both decimal (e.g "1234", "0d5678") and hexadecimal (e.g.
// "0x9aBC"). The caller is responsible for prior filtering of e.g. hex
// numbers if they are unwanted. For example, Wuffs' JSON decoder will only
// produce a wuffs_base__token for decimal numbers, not hexadecimal.
// - It is not affected by i18n / l10n settings such as environment variables.
// - It does allow arbitrary underscores, except inside the optional 2-byte
// opening "0d" or "0X" that denotes base-10 or base-16. For example,
// "__0D_1_002" would successfully parse as "one thousand and two".
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64 //
wuffs_base__parse_number_u64(wuffs_base__slice_u8 s);
// --------
#define WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL 20
#define WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL 21
// wuffs_base__render_number_f64 writes the decimal encoding of x to dst and
// returns the number of bytes written. If dst is shorter than the entire
// encoding, it returns 0 (and no bytes are written).
//
// For those familiar with C's printf or Go's fmt.Printf functions:
// - "%e" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT option.
// - "%f" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT option.
// - "%g" means neither or both bits are set.
//
// The precision argument controls the number of digits rendered, excluding the
// exponent (the "e+05" in "1.23e+05"):
// - for "%e" and "%f" it is the number of digits after the decimal separator,
// - for "%g" it is the number of significant digits (and trailing zeroes are
// removed).
//
// A precision of 6 gives similar output to printf's defaults.
//
// A precision greater than 4095 is equivalent to 4095.
//
// The precision argument is ignored when the
// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION option is set. This is
// similar to Go's strconv.FormatFloat with a negative (i.e. non-sensical)
// precision, but there is no corresponding feature in C's printf.
//
// Extreme values of x will be rendered as "NaN", "Inf" (or "+Inf" if the
// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN option is set) or "-Inf".
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_f64(wuffs_base__slice_u8 dst,
double x,
uint32_t precision,
uint32_t options);
// wuffs_base__render_number_i64 writes the decimal encoding of x to dst and
// returns the number of bytes written. If dst is shorter than the entire
// encoding, it returns 0 (and no bytes are written).
//
// dst will never be too short if its length is at least 20, also known as
// WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL.
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_i64(wuffs_base__slice_u8 dst,
int64_t x,
uint32_t options);
// wuffs_base__render_number_u64 writes the decimal encoding of x to dst and
// returns the number of bytes written. If dst is shorter than the entire
// encoding, it returns 0 (and no bytes are written).
//
// dst will never be too short if its length is at least 21, also known as
// WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL.
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_u64(wuffs_base__slice_u8 dst,
uint64_t x,
uint32_t options);
// ---------------- Hexadecimal
// wuffs_base__hexadecimal__decode2 converts "6A6b" to "jk", where e.g. 'j' is
@@ -4141,7 +4290,7 @@ wuffs_base__ascii__longest_valid_prefix(wuffs_base__slice_u8 s);
// --------
extern const char* wuffs_base__hasher_u32__vtable_name;
extern const char wuffs_base__hasher_u32__vtable_name[];
typedef struct {
wuffs_base__empty_struct (*set_quirk_enabled)(
@@ -4202,7 +4351,7 @@ struct wuffs_base__hasher_u32__struct {
// --------
extern const char* wuffs_base__image_decoder__vtable_name;
extern const char wuffs_base__image_decoder__vtable_name[];
typedef struct {
wuffs_base__status (*decode_frame)(
@@ -4423,7 +4572,7 @@ struct wuffs_base__image_decoder__struct {
// --------
extern const char* wuffs_base__io_transformer__vtable_name;
extern const char wuffs_base__io_transformer__vtable_name[];
typedef struct {
wuffs_base__empty_struct (*set_quirk_enabled)(
@@ -4501,7 +4650,7 @@ struct wuffs_base__io_transformer__struct {
// --------
extern const char* wuffs_base__token_decoder__vtable_name;
extern const char wuffs_base__token_decoder__vtable_name[];
typedef struct {
wuffs_base__status (*decode_tokens)(
@@ -4601,14 +4750,14 @@ typedef struct wuffs_adler32__hasher__struct wuffs_adler32__hasher;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_adler32__hasher__initialize(
wuffs_adler32__hasher* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_adler32__hasher();
@@ -4727,9 +4876,9 @@ struct wuffs_adler32__hasher__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_adler32__hasher__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__hasher_u32*
@@ -4765,8 +4914,8 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_bmp__error__bad_header;
extern const char* wuffs_bmp__error__unsupported_bmp_file;
extern const char wuffs_bmp__error__bad_header[];
extern const char wuffs_bmp__error__unsupported_bmp_file[];
// ---------------- Public Consts
@@ -4782,14 +4931,14 @@ typedef struct wuffs_bmp__decoder__struct wuffs_bmp__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_bmp__decoder__initialize(
wuffs_bmp__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_bmp__decoder();
@@ -5002,9 +5151,9 @@ struct wuffs_bmp__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_bmp__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__image_decoder*
@@ -5117,14 +5266,14 @@ typedef struct wuffs_crc32__ieee_hasher__struct wuffs_crc32__ieee_hasher;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_crc32__ieee_hasher__initialize(
wuffs_crc32__ieee_hasher* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_crc32__ieee_hasher();
@@ -5242,9 +5391,9 @@ struct wuffs_crc32__ieee_hasher__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_crc32__ieee_hasher__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__hasher_u32*
@@ -5280,19 +5429,19 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_deflate__error__bad_huffman_code_over_subscribed;
extern const char* wuffs_deflate__error__bad_huffman_code_under_subscribed;
extern const char* wuffs_deflate__error__bad_huffman_code_length_count;
extern const char* wuffs_deflate__error__bad_huffman_code_length_repetition;
extern const char* wuffs_deflate__error__bad_huffman_code;
extern const char* wuffs_deflate__error__bad_huffman_minimum_code_length;
extern const char* wuffs_deflate__error__bad_block;
extern const char* wuffs_deflate__error__bad_distance;
extern const char* wuffs_deflate__error__bad_distance_code_count;
extern const char* wuffs_deflate__error__bad_literal_length_code_count;
extern const char* wuffs_deflate__error__inconsistent_stored_block_length;
extern const char* wuffs_deflate__error__missing_end_of_block_code;
extern const char* wuffs_deflate__error__no_huffman_codes;
extern const char wuffs_deflate__error__bad_huffman_code_over_subscribed[];
extern const char wuffs_deflate__error__bad_huffman_code_under_subscribed[];
extern const char wuffs_deflate__error__bad_huffman_code_length_count[];
extern const char wuffs_deflate__error__bad_huffman_code_length_repetition[];
extern const char wuffs_deflate__error__bad_huffman_code[];
extern const char wuffs_deflate__error__bad_huffman_minimum_code_length[];
extern const char wuffs_deflate__error__bad_block[];
extern const char wuffs_deflate__error__bad_distance[];
extern const char wuffs_deflate__error__bad_distance_code_count[];
extern const char wuffs_deflate__error__bad_literal_length_code_count[];
extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
extern const char wuffs_deflate__error__missing_end_of_block_code[];
extern const char wuffs_deflate__error__no_huffman_codes[];
// ---------------- Public Consts
@@ -5308,14 +5457,14 @@ typedef struct wuffs_deflate__decoder__struct wuffs_deflate__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_deflate__decoder__initialize(
wuffs_deflate__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_deflate__decoder();
@@ -5496,9 +5645,9 @@ struct wuffs_deflate__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_deflate__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__io_transformer*
@@ -5547,7 +5696,7 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_lzw__error__bad_code;
extern const char wuffs_lzw__error__bad_code[];
// ---------------- Public Consts
@@ -5563,14 +5712,14 @@ typedef struct wuffs_lzw__decoder__struct wuffs_lzw__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_lzw__decoder__initialize(
wuffs_lzw__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_lzw__decoder();
@@ -5724,9 +5873,9 @@ struct wuffs_lzw__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_lzw__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__io_transformer*
@@ -5780,12 +5929,12 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_gif__error__bad_extension_label;
extern const char* wuffs_gif__error__bad_frame_size;
extern const char* wuffs_gif__error__bad_graphic_control;
extern const char* wuffs_gif__error__bad_header;
extern const char* wuffs_gif__error__bad_literal_width;
extern const char* wuffs_gif__error__bad_palette;
extern const char wuffs_gif__error__bad_extension_label[];
extern const char wuffs_gif__error__bad_frame_size[];
extern const char wuffs_gif__error__bad_graphic_control[];
extern const char wuffs_gif__error__bad_header[];
extern const char wuffs_gif__error__bad_literal_width[];
extern const char wuffs_gif__error__bad_palette[];
// ---------------- Public Consts
@@ -5817,14 +5966,14 @@ typedef struct wuffs_gif__decoder__struct wuffs_gif__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_gif__config_decoder__initialize(
wuffs_gif__config_decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_gif__config_decoder();
@@ -5834,7 +5983,7 @@ wuffs_gif__decoder__initialize(
wuffs_gif__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_gif__decoder();
@@ -6168,9 +6317,9 @@ struct wuffs_gif__config_decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_gif__config_decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__image_decoder*
@@ -6431,9 +6580,9 @@ struct wuffs_gif__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_gif__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__image_decoder*
@@ -6534,10 +6683,10 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_gzip__error__bad_checksum;
extern const char* wuffs_gzip__error__bad_compression_method;
extern const char* wuffs_gzip__error__bad_encoding_flags;
extern const char* wuffs_gzip__error__bad_header;
extern const char wuffs_gzip__error__bad_checksum[];
extern const char wuffs_gzip__error__bad_compression_method[];
extern const char wuffs_gzip__error__bad_encoding_flags[];
extern const char wuffs_gzip__error__bad_header[];
// ---------------- Public Consts
@@ -6553,14 +6702,14 @@ typedef struct wuffs_gzip__decoder__struct wuffs_gzip__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_gzip__decoder__initialize(
wuffs_gzip__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_gzip__decoder();
@@ -6704,9 +6853,9 @@ struct wuffs_gzip__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_gzip__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__io_transformer*
@@ -6755,12 +6904,12 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_json__error__bad_c0_control_code;
extern const char* wuffs_json__error__bad_utf_8;
extern const char* wuffs_json__error__bad_backslash_escape;
extern const char* wuffs_json__error__bad_input;
extern const char* wuffs_json__error__unsupported_number_length;
extern const char* wuffs_json__error__unsupported_recursion_depth;
extern const char wuffs_json__error__bad_c0_control_code[];
extern const char wuffs_json__error__bad_utf_8[];
extern const char wuffs_json__error__bad_backslash_escape[];
extern const char wuffs_json__error__bad_input[];
extern const char wuffs_json__error__unsupported_number_length[];
extern const char wuffs_json__error__unsupported_recursion_depth[];
// ---------------- Public Consts
@@ -6818,14 +6967,14 @@ typedef struct wuffs_json__decoder__struct wuffs_json__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_json__decoder__initialize(
wuffs_json__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_json__decoder();
@@ -6971,9 +7120,9 @@ struct wuffs_json__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_json__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__token_decoder*
@@ -7016,7 +7165,7 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_wbmp__error__bad_header;
extern const char wuffs_wbmp__error__bad_header[];
// ---------------- Public Consts
@@ -7032,14 +7181,14 @@ typedef struct wuffs_wbmp__decoder__struct wuffs_wbmp__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_wbmp__decoder__initialize(
wuffs_wbmp__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_wbmp__decoder();
@@ -7238,9 +7387,9 @@ struct wuffs_wbmp__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_wbmp__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__image_decoder*
@@ -7341,12 +7490,12 @@ extern "C" {
// ---------------- Status Codes
extern const char* wuffs_zlib__note__dictionary_required;
extern const char* wuffs_zlib__error__bad_checksum;
extern const char* wuffs_zlib__error__bad_compression_method;
extern const char* wuffs_zlib__error__bad_compression_window_size;
extern const char* wuffs_zlib__error__bad_parity_check;
extern const char* wuffs_zlib__error__incorrect_dictionary;
extern const char wuffs_zlib__note__dictionary_required[];
extern const char wuffs_zlib__error__bad_checksum[];
extern const char wuffs_zlib__error__bad_compression_method[];
extern const char wuffs_zlib__error__bad_compression_window_size[];
extern const char wuffs_zlib__error__bad_parity_check[];
extern const char wuffs_zlib__error__incorrect_dictionary[];
// ---------------- Public Consts
@@ -7362,14 +7511,14 @@ typedef struct wuffs_zlib__decoder__struct wuffs_zlib__decoder;
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
//
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for initialize_flags.
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
wuffs_zlib__decoder__initialize(
wuffs_zlib__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags);
uint32_t options);
size_t
sizeof__wuffs_zlib__decoder();
@@ -7526,9 +7675,9 @@ struct wuffs_zlib__decoder__struct {
initialize(
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags) {
uint32_t options) {
return wuffs_zlib__decoder__initialize(
this, sizeof_star_self, wuffs_version, initialize_flags);
this, sizeof_star_self, wuffs_version, options);
}
inline wuffs_base__io_transformer*
@@ -8154,548 +8303,41 @@ const uint32_t wuffs_base__pixel_format__bits_per_channel[16] = {
0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40,
};
const char* wuffs_base__note__i_o_redirect = "@base: I/O redirect";
const char* wuffs_base__note__end_of_data = "@base: end of data";
const char* wuffs_base__note__metadata_reported = "@base: metadata reported";
const char* wuffs_base__suspension__even_more_information = "$base: even more information";
const char* wuffs_base__suspension__mispositioned_read = "$base: mispositioned read";
const char* wuffs_base__suspension__mispositioned_write = "$base: mispositioned write";
const char* wuffs_base__suspension__short_read = "$base: short read";
const char* wuffs_base__suspension__short_write = "$base: short write";
const char* wuffs_base__error__bad_i_o_position = "#base: bad I/O position";
const char* wuffs_base__error__bad_argument_length_too_short = "#base: bad argument (length too short)";
const char* wuffs_base__error__bad_argument = "#base: bad argument";
const char* wuffs_base__error__bad_call_sequence = "#base: bad call sequence";
const char* wuffs_base__error__bad_receiver = "#base: bad receiver";
const char* wuffs_base__error__bad_restart = "#base: bad restart";
const char* wuffs_base__error__bad_sizeof_receiver = "#base: bad sizeof receiver";
const char* wuffs_base__error__bad_vtable = "#base: bad vtable";
const char* wuffs_base__error__bad_workbuf_length = "#base: bad workbuf length";
const char* wuffs_base__error__bad_wuffs_version = "#base: bad wuffs version";
const char* wuffs_base__error__cannot_return_a_suspension = "#base: cannot return a suspension";
const char* wuffs_base__error__disabled_by_previous_error = "#base: disabled by previous error";
const char* wuffs_base__error__initialize_falsely_claimed_already_zeroed = "#base: initialize falsely claimed already zeroed";
const char* wuffs_base__error__initialize_not_called = "#base: initialize not called";
const char* wuffs_base__error__interleaved_coroutine_calls = "#base: interleaved coroutine calls";
const char* wuffs_base__error__no_more_information = "#base: no more information";
const char* wuffs_base__error__not_enough_data = "#base: not enough data";
const char* wuffs_base__error__out_of_bounds = "#base: out of bounds";
const char* wuffs_base__error__unsupported_method = "#base: unsupported method";
const char* wuffs_base__error__unsupported_option = "#base: unsupported option";
const char* wuffs_base__error__unsupported_pixel_swizzler_option = "#base: unsupported pixel swizzler option";
const char* wuffs_base__error__too_much_data = "#base: too much data";
const char wuffs_base__note__i_o_redirect[] = "@base: I/O redirect";
const char wuffs_base__note__end_of_data[] = "@base: end of data";
const char wuffs_base__note__metadata_reported[] = "@base: metadata reported";
const char wuffs_base__suspension__even_more_information[] = "$base: even more information";
const char wuffs_base__suspension__mispositioned_read[] = "$base: mispositioned read";
const char wuffs_base__suspension__mispositioned_write[] = "$base: mispositioned write";
const char wuffs_base__suspension__short_read[] = "$base: short read";
const char wuffs_base__suspension__short_write[] = "$base: short write";
const char wuffs_base__error__bad_i_o_position[] = "#base: bad I/O position";
const char wuffs_base__error__bad_argument_length_too_short[] = "#base: bad argument (length too short)";
const char wuffs_base__error__bad_argument[] = "#base: bad argument";
const char wuffs_base__error__bad_call_sequence[] = "#base: bad call sequence";
const char wuffs_base__error__bad_receiver[] = "#base: bad receiver";
const char wuffs_base__error__bad_restart[] = "#base: bad restart";
const char wuffs_base__error__bad_sizeof_receiver[] = "#base: bad sizeof receiver";
const char wuffs_base__error__bad_vtable[] = "#base: bad vtable";
const char wuffs_base__error__bad_workbuf_length[] = "#base: bad workbuf length";
const char wuffs_base__error__bad_wuffs_version[] = "#base: bad wuffs version";
const char wuffs_base__error__cannot_return_a_suspension[] = "#base: cannot return a suspension";
const char wuffs_base__error__disabled_by_previous_error[] = "#base: disabled by previous error";
const char wuffs_base__error__initialize_falsely_claimed_already_zeroed[] = "#base: initialize falsely claimed already zeroed";
const char wuffs_base__error__initialize_not_called[] = "#base: initialize not called";
const char wuffs_base__error__interleaved_coroutine_calls[] = "#base: interleaved coroutine calls";
const char wuffs_base__error__no_more_information[] = "#base: no more information";
const char wuffs_base__error__not_enough_data[] = "#base: not enough data";
const char wuffs_base__error__out_of_bounds[] = "#base: out of bounds";
const char wuffs_base__error__unsupported_method[] = "#base: unsupported method";
const char wuffs_base__error__unsupported_option[] = "#base: unsupported option";
const char wuffs_base__error__unsupported_pixel_swizzler_option[] = "#base: unsupported pixel swizzler option";
const char wuffs_base__error__too_much_data[] = "#base: too much data";
const char* wuffs_base__hasher_u32__vtable_name = "{vtable}wuffs_base__hasher_u32";
const char* wuffs_base__image_decoder__vtable_name = "{vtable}wuffs_base__image_decoder";
const char* wuffs_base__io_transformer__vtable_name = "{vtable}wuffs_base__io_transformer";
const char* wuffs_base__token_decoder__vtable_name = "{vtable}wuffs_base__token_decoder";
// ---------------- String Conversions
// wuffs_base__parse_number__foo_digits entries are 0x00 for invalid digits,
// and (0x80 | v) for valid digits, where v is the 4 bit value.
static const uint8_t wuffs_base__parse_number__decimal_digits[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.
0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
static const uint8_t wuffs_base__parse_number__hexadecimal_digits[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.
0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.
0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x40 ..= 0x47. 'A'-'F'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x60 ..= 0x67. 'a'-'f'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
// --------
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64 //
wuffs_base__parse_number_i64(wuffs_base__slice_u8 s) {
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p < q) && (*p == '_'); p++) {
}
bool negative = false;
if (p >= q) {
goto fail_bad_argument;
} else if (*p == '-') {
p++;
negative = true;
} else if (*p == '+') {
p++;
}
do {
wuffs_base__result_u64 r = wuffs_base__parse_number_u64(
wuffs_base__make_slice_u8(p, (size_t)(q - p)));
if (r.status.repr != NULL) {
wuffs_base__result_i64 ret;
ret.status.repr = r.status.repr;
ret.value = 0;
return ret;
} else if (negative) {
if (r.value > 0x8000000000000000) {
goto fail_out_of_bounds;
}
wuffs_base__result_i64 ret;
ret.status.repr = NULL;
ret.value = -(int64_t)(r.value);
return ret;
} else if (r.value > 0x7FFFFFFFFFFFFFFF) {
goto fail_out_of_bounds;
} else {
wuffs_base__result_i64 ret;
ret.status.repr = NULL;
ret.value = +(int64_t)(r.value);
return ret;
}
} while (0);
fail_bad_argument:
do {
wuffs_base__result_i64 ret;
ret.status.repr = wuffs_base__error__bad_argument;
ret.value = 0;
return ret;
} while (0);
fail_out_of_bounds:
do {
wuffs_base__result_i64 ret;
ret.status.repr = wuffs_base__error__out_of_bounds;
ret.value = 0;
return ret;
} while (0);
}
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64 //
wuffs_base__parse_number_u64(wuffs_base__slice_u8 s) {
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p < q) && (*p == '_'); p++) {
}
if (p >= q) {
goto fail_bad_argument;
} else if (*p == '0') {
p++;
if (p >= q) {
goto ok_zero;
}
if (*p == '_') {
p++;
for (; p < q; p++) {
if (*p != '_') {
goto fail_bad_argument;
}
}
goto ok_zero;
}
if ((*p == 'x') || (*p == 'X')) {
p++;
for (; (p < q) && (*p == '_'); p++) {
}
if (p < q) {
goto hexadecimal;
}
} else if ((*p == 'd') || (*p == 'D')) {
p++;
for (; (p < q) && (*p == '_'); p++) {
}
if (p < q) {
goto decimal;
}
}
goto fail_bad_argument;
}
decimal:
do {
uint64_t v = wuffs_base__parse_number__decimal_digits[*p++];
if (v == 0) {
goto fail_bad_argument;
}
v &= 0x0F;
// UINT64_MAX is 18446744073709551615, which is ((10 * max10) + max1).
const uint64_t max10 = 1844674407370955161u;
const uint8_t max1 = 5;
for (; p < q; p++) {
if (*p == '_') {
continue;
}
uint8_t digit = wuffs_base__parse_number__decimal_digits[*p];
if (digit == 0) {
goto fail_bad_argument;
}
digit &= 0x0F;
if ((v > max10) || ((v == max10) && (digit > max1))) {
goto fail_out_of_bounds;
}
v = (10 * v) + ((uint64_t)(digit));
}
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = v;
return ret;
} while (0);
hexadecimal:
do {
uint64_t v = wuffs_base__parse_number__hexadecimal_digits[*p++];
if (v == 0) {
goto fail_bad_argument;
}
v &= 0x0F;
for (; p < q; p++) {
if (*p == '_') {
continue;
}
uint8_t digit = wuffs_base__parse_number__hexadecimal_digits[*p];
if (digit == 0) {
goto fail_bad_argument;
}
digit &= 0x0F;
if ((v >> 60) != 0) {
goto fail_out_of_bounds;
}
v = (v << 4) | ((uint64_t)(digit));
}
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = v;
return ret;
} while (0);
ok_zero:
do {
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = 0;
return ret;
} while (0);
fail_bad_argument:
do {
wuffs_base__result_u64 ret;
ret.status.repr = wuffs_base__error__bad_argument;
ret.value = 0;
return ret;
} while (0);
fail_out_of_bounds:
do {
wuffs_base__result_u64 ret;
ret.status.repr = wuffs_base__error__out_of_bounds;
ret.value = 0;
return ret;
} while (0);
}
// ---------------- Hexadecimal
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__hexadecimal__decode2(wuffs_base__slice_u8 dst,
wuffs_base__slice_u8 src) {
size_t src_len2 = src.len / 2;
size_t len = dst.len < src_len2 ? dst.len : src_len2;
uint8_t* d = dst.ptr;
uint8_t* s = src.ptr;
size_t n = len;
while (n--) {
*d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[0]] << 4) |
(wuffs_base__parse_number__hexadecimal_digits[s[1]] & 0x0F));
d += 1;
s += 2;
}
return len;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__hexadecimal__decode4(wuffs_base__slice_u8 dst,
wuffs_base__slice_u8 src) {
size_t src_len4 = src.len / 4;
size_t len = dst.len < src_len4 ? dst.len : src_len4;
uint8_t* d = dst.ptr;
uint8_t* s = src.ptr;
size_t n = len;
while (n--) {
*d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[2]] << 4) |
(wuffs_base__parse_number__hexadecimal_digits[s[3]] & 0x0F));
d += 1;
s += 4;
}
return len;
}
// ---------------- Unicode and UTF-8
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__utf_8__encode(wuffs_base__slice_u8 dst, uint32_t code_point) {
if (code_point <= 0x7F) {
if (dst.len >= 1) {
dst.ptr[0] = (uint8_t)(code_point);
return 1;
}
} else if (code_point <= 0x07FF) {
if (dst.len >= 2) {
dst.ptr[0] = (uint8_t)(0xC0 | ((code_point >> 6)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 2;
}
} else if (code_point <= 0xFFFF) {
if ((dst.len >= 3) && ((code_point < 0xD800) || (0xDFFF < code_point))) {
dst.ptr[0] = (uint8_t)(0xE0 | ((code_point >> 12)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3F));
dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 3;
}
} else if (code_point <= 0x10FFFF) {
if (dst.len >= 4) {
dst.ptr[0] = (uint8_t)(0xF0 | ((code_point >> 18)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 12) & 0x3F));
dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3F));
dst.ptr[3] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 4;
}
}
return 0;
}
// wuffs_base__utf_8__byte_length_minus_1 is the byte length (minus 1) of a
// UTF-8 encoded code point, based on the encoding's initial byte.
// - 0x00 is 1-byte UTF-8 (ASCII).
// - 0x01 is the start of 2-byte UTF-8.
// - 0x02 is the start of 3-byte UTF-8.
// - 0x03 is the start of 4-byte UTF-8.
// - 0x40 is a UTF-8 tail byte.
// - 0x80 is invalid UTF-8.
//
// RFC 3629 (UTF-8) gives this grammar for valid UTF-8:
// UTF8-1 = %x00-7F
// UTF8-2 = %xC2-DF UTF8-tail
// UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
// %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
// %xF4 %x80-8F 2( UTF8-tail )
// UTF8-tail = %x80-BF
static const uint8_t wuffs_base__utf_8__byte_length_minus_1[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x80 ..= 0x87.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x88 ..= 0x8F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x90 ..= 0x97.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x98 ..= 0x9F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA0 ..= 0xA7.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA8 ..= 0xAF.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB0 ..= 0xB7.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB8 ..= 0xBF.
0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC0 ..= 0xC7.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC8 ..= 0xCF.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD0 ..= 0xD7.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD8 ..= 0xDF.
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE0 ..= 0xE7.
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE8 ..= 0xEF.
0x03, 0x03, 0x03, 0x03, 0x03, 0x80, 0x80, 0x80, // 0xF0 ..= 0xF7.
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
WUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output //
wuffs_base__utf_8__next(wuffs_base__slice_u8 s) {
if (s.len == 0) {
return wuffs_base__make_utf_8__next__output(0, 0);
}
uint32_t c = s.ptr[0];
switch (wuffs_base__utf_8__byte_length_minus_1[c & 0xFF]) {
case 0:
return wuffs_base__make_utf_8__next__output(c, 1);
case 1:
if (s.len < 2) {
break;
}
c = wuffs_base__load_u16le__no_bounds_check(s.ptr);
if ((c & 0xC000) != 0x8000) {
break;
}
c = (0x0007C0 & (c << 6)) | (0x00003F & (c >> 8));
return wuffs_base__make_utf_8__next__output(c, 2);
case 2:
if (s.len < 3) {
break;
}
c = wuffs_base__load_u24le__no_bounds_check(s.ptr);
if ((c & 0xC0C000) != 0x808000) {
break;
}
c = (0x00F000 & (c << 12)) | (0x000FC0 & (c >> 2)) |
(0x00003F & (c >> 16));
if ((c <= 0x07FF) || ((0xD800 <= c) && (c <= 0xDFFF))) {
break;
}
return wuffs_base__make_utf_8__next__output(c, 3);
case 3:
if (s.len < 4) {
break;
}
c = wuffs_base__load_u32le__no_bounds_check(s.ptr);
if ((c & 0xC0C0C000) != 0x80808000) {
break;
}
c = (0x1C0000 & (c << 18)) | (0x03F000 & (c << 4)) |
(0x000FC0 & (c >> 10)) | (0x00003F & (c >> 24));
if ((c <= 0xFFFF) || (0x110000 <= c)) {
break;
}
return wuffs_base__make_utf_8__next__output(c, 4);
}
return wuffs_base__make_utf_8__next__output(
WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER, 1);
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__utf_8__longest_valid_prefix(wuffs_base__slice_u8 s) {
// TODO: possibly optimize the all-ASCII case (4 or 8 bytes at a time).
//
// TODO: possibly optimize this by manually inlining the
// wuffs_base__utf_8__next calls.
size_t original_len = s.len;
while (s.len > 0) {
wuffs_base__utf_8__next__output o = wuffs_base__utf_8__next(s);
if ((o.code_point > 0x7F) && (o.byte_length == 1)) {
break;
}
s.ptr += o.byte_length;
s.len -= o.byte_length;
}
return original_len - s.len;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__ascii__longest_valid_prefix(wuffs_base__slice_u8 s) {
// TODO: possibly optimize this by checking 4 or 8 bytes at a time.
uint8_t* original_ptr = s.ptr;
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p != q) && ((*p & 0x80) == 0); p++) {
}
return (size_t)(p - original_ptr);
}
const char wuffs_base__hasher_u32__vtable_name[] = "{vtable}wuffs_base__hasher_u32";
const char wuffs_base__image_decoder__vtable_name[] = "{vtable}wuffs_base__image_decoder";
const char wuffs_base__io_transformer__vtable_name[] = "{vtable}wuffs_base__io_transformer";
const char wuffs_base__token_decoder__vtable_name[] = "{vtable}wuffs_base__token_decoder";
#endif // !defined(WUFFS_CONFIG__MODULES) ||
// defined(WUFFS_CONFIG__MODULE__BASE) ||
@@ -9300,8 +8942,8 @@ wuffs_base__token_decoder__workbuf_len(
// ---------------- IEEE 754 Floating Point
#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE 1023
#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION 500
#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE 2047
#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION 800
// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL is the largest N
// such that ((10 << N) < (1 << 64)).
@@ -9311,14 +8953,14 @@ wuffs_base__token_decoder__workbuf_len(
// fixed precision floating point decimal number, augmented with ±infinity
// values, but it cannot represent NaN (Not a Number).
//
// "High precision" means that the mantissa holds 500 decimal digits. 500 is
// "High precision" means that the mantissa holds 800 decimal digits. 800 is
// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION.
//
// An HPD isn't for general purpose arithmetic, only for conversions to and
// from IEEE 754 double-precision floating point, where the largest and
// smallest positive, finite values are approximately 1.8e+308 and 4.9e-324.
// HPD exponents above +1023 mean infinity, below -1023 mean zero. The ±1023
// bounds are further away from zero than ±(324 + 500), where 500 and 1023 is
// HPD exponents above +2047 mean infinity, below -2047 mean zero. The ±2047
// bounds are further away from zero than ±(324 + 800), where 800 and 2047 is
// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION and
// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE.
//
@@ -9340,8 +8982,8 @@ wuffs_base__token_decoder__workbuf_len(
// - A decimal_point of +4 means "7890."
// - A decimal_point of +5 means "78900."
//
// As above, a decimal_point higher than +1023 means that the overall value is
// infinity, lower than -1023 means zero.
// As above, a decimal_point higher than +2047 means that the overall value is
// infinity, lower than -2047 means zero.
//
// negative is a sign bit. An HPD can distinguish positive and negative zero.
//
@@ -9373,6 +9015,48 @@ wuffs_base__private_implementation__high_prec_dec__trim(
}
}
// wuffs_base__private_implementation__high_prec_dec__assign sets h to
// represent the number x.
//
// Preconditions:
// - h is non-NULL.
static void //
wuffs_base__private_implementation__high_prec_dec__assign(
wuffs_base__private_implementation__high_prec_dec* h,
uint64_t x,
bool negative) {
uint32_t n = 0;
// Set h->digits.
if (x > 0) {
// Calculate the digits, working right-to-left. After we determine n (how
// many digits there are), copy from buf to h->digits.
//
// UINT64_MAX, 18446744073709551615, is 20 digits long. It can be faster to
// copy a constant number of bytes than a variable number (20 instead of
// n). Make buf large enough (and start writing to it from the middle) so
// that can we always copy 20 bytes: the slice buf[(20-n) .. (40-n)].
uint8_t buf[40] = {0};
uint8_t* ptr = &buf[20];
do {
uint64_t remaining = x / 10;
x -= remaining * 10;
ptr--;
*ptr = (uint8_t)x;
n++;
x = remaining;
} while (x > 0);
memcpy(h->digits, ptr, 20);
}
// Set h's other fields.
h->num_digits = n;
h->decimal_point = (int32_t)n;
h->negative = negative;
h->truncated = false;
wuffs_base__private_implementation__high_prec_dec__trim(h);
}
static wuffs_base__status //
wuffs_base__private_implementation__high_prec_dec__parse(
wuffs_base__private_implementation__high_prec_dec* h,
@@ -9748,6 +9432,11 @@ wuffs_base__private_implementation__high_prec_dec__rounded_integer(
// wuffs_base__private_implementation__high_prec_dec__rounded_integer and
// wuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits
// have the same preconditions.
//
// wuffs_base__private_implementation__high_prec_dec__lshift keeps the first
// two preconditions but not the last two. Its shift argument is signed and
// does not need to be "small": zero is a no-op, positive means left shift and
// negative means right shift.
static void //
wuffs_base__private_implementation__high_prec_dec__small_lshift(
@@ -9861,6 +9550,254 @@ wuffs_base__private_implementation__high_prec_dec__small_rshift(
wuffs_base__private_implementation__high_prec_dec__trim(h);
}
static void //
wuffs_base__private_implementation__high_prec_dec__lshift(
wuffs_base__private_implementation__high_prec_dec* h,
int32_t shift) {
if (shift > 0) {
while (shift > +WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL) {
wuffs_base__private_implementation__high_prec_dec__small_lshift(
h, WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL);
shift -= WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
}
wuffs_base__private_implementation__high_prec_dec__small_lshift(
h, ((uint32_t)(+shift)));
} else if (shift < 0) {
while (shift < -WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL) {
wuffs_base__private_implementation__high_prec_dec__small_rshift(
h, WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL);
shift += WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
}
wuffs_base__private_implementation__high_prec_dec__small_rshift(
h, ((uint32_t)(-shift)));
}
}
// --------
// wuffs_base__private_implementation__high_prec_dec__round_etc rounds h's
// number. For those functions that take an n argument, rounding produces at
// most n digits (which is not necessarily at most n decimal places). Negative
// n values are ignored, as well as any n greater than or equal to h's number
// of digits. The etc__round_just_enough function implicitly chooses an n to
// implement WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION.
//
// Preconditions:
// - h is non-NULL.
// - h->decimal_point is "not extreme".
//
// "Not extreme" means within
// ±WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE.
static void //
wuffs_base__private_implementation__high_prec_dec__round_down(
wuffs_base__private_implementation__high_prec_dec* h,
int32_t n) {
if ((n < 0) || (h->num_digits <= (uint32_t)n)) {
return;
}
h->num_digits = (uint32_t)(n);
wuffs_base__private_implementation__high_prec_dec__trim(h);
}
static void //
wuffs_base__private_implementation__high_prec_dec__round_up(
wuffs_base__private_implementation__high_prec_dec* h,
int32_t n) {
if ((n < 0) || (h->num_digits <= (uint32_t)n)) {
return;
}
for (n--; n >= 0; n--) {
if (h->digits[n] < 9) {
h->digits[n]++;
h->num_digits = (uint32_t)(n + 1);
return;
}
}
// The number is all 9s. Change to a single 1 and adjust the decimal point.
h->digits[0] = 1;
h->num_digits = 1;
h->decimal_point++;
}
static void //
wuffs_base__private_implementation__high_prec_dec__round_nearest(
wuffs_base__private_implementation__high_prec_dec* h,
int32_t n) {
if ((n < 0) || (h->num_digits <= (uint32_t)n)) {
return;
}
bool up = h->digits[n] >= 5;
if ((h->digits[n] == 5) && ((n + 1) == ((int32_t)(h->num_digits)))) {
up = h->truncated || //
((n > 0) && ((h->digits[n - 1] & 1) != 0));
}
if (up) {
wuffs_base__private_implementation__high_prec_dec__round_up(h, n);
} else {
wuffs_base__private_implementation__high_prec_dec__round_down(h, n);
}
}
static void //
wuffs_base__private_implementation__high_prec_dec__round_just_enough(
wuffs_base__private_implementation__high_prec_dec* h,
int32_t exp2,
uint64_t mantissa) {
// The magic numbers 52 and 53 in this function are because IEEE 754 double
// precision has 52 mantissa bits.
//
// Let f be the floating point number represented by exp2 and mantissa (and
// also the number in h): the number (mantissa * (2 ** (exp2 - 52))).
//
// If f is zero, we can return early.
if (mantissa == 0) {
return;
}
// The smallest normal f has an exp2 of -1022 and a mantissa of (1 << 52).
// Subnormal numbers have the same exp2 but a smaller mantissa.
static const int32_t min_incl_normal_exp2 = -1022;
static const uint64_t min_incl_normal_mantissa = 0x0010000000000000ul;
// Compute lower and upper bounds such that any number between them (possibly
// inclusive) will round to f. First, the lower bound. Our number f is:
// ((mantissa + 0) * (2 ** ( exp2 - 52)))
//
// The next lowest floating point number is:
// ((mantissa - 1) * (2 ** ( exp2 - 52)))
// unless (mantissa - 1) drops the (1 << 52) bit and exp2 is not the
// min_incl_normal_exp2. Either way, call it:
// ((l_mantissa) * (2 ** (l_exp2 - 52)))
//
// The lower bound is halfway between them (noting that 52 became 53):
// (((2 * l_mantissa) + 1) * (2 ** (l_exp2 - 53)))
int32_t l_exp2 = exp2;
uint64_t l_mantissa = mantissa - 1;
if ((exp2 > min_incl_normal_exp2) && (mantissa <= min_incl_normal_mantissa)) {
l_exp2 = exp2 - 1;
l_mantissa = (2 * mantissa) - 1;
}
wuffs_base__private_implementation__high_prec_dec lower;
wuffs_base__private_implementation__high_prec_dec__assign(
&lower, (2 * l_mantissa) + 1, false);
wuffs_base__private_implementation__high_prec_dec__lshift(&lower,
l_exp2 - 53);
// Next, the upper bound. Our number f is:
// ((mantissa + 0) * (2 ** (exp2 - 52)))
//
// The next highest floating point number is:
// ((mantissa + 1) * (2 ** (exp2 - 52)))
//
// The upper bound is halfway between them (noting that 52 became 53):
// (((2 * mantissa) + 1) * (2 ** (exp2 - 53)))
wuffs_base__private_implementation__high_prec_dec upper;
wuffs_base__private_implementation__high_prec_dec__assign(
&upper, (2 * mantissa) + 1, false);
wuffs_base__private_implementation__high_prec_dec__lshift(&upper, exp2 - 53);
// The lower and upper bounds are possible outputs only if the original
// mantissa is even, so that IEEE round-to-even would round to the original
// mantissa and not its neighbors.
bool inclusive = (mantissa & 1) == 0;
// As we walk the digits, we want to know whether rounding up would fall
// within the upper bound. This is tracked by upper_delta:
// - When -1, the digits of h and upper are the same so far.
// - When +0, we saw a difference of 1 between h and upper on a previous
// digit and subsequently only 9s for h and 0s for upper. Thus, rounding
// up may fall outside of the bound if !inclusive.
// - When +1, the difference is greater than 1 and we know that rounding up
// falls within the bound.
//
// This is a state machine with three states. The numerical value for each
// state (-1, +0 or +1) isn't important, other than their order.
int upper_delta = -1;
// We can now figure out the shortest number of digits required. Walk the
// digits until h has distinguished itself from lower or upper.
//
// The zi and zd variables are indexes and digits, for z in l (lower), h (the
// number) and u (upper).
//
// The lower, h and upper numbers may have their decimal points at different
// places. In this case, upper is the longest, so we iterate ui starting from
// 0 and iterate li and hi starting from either 0 or -1.
int32_t ui = 0;
for (;; ui++) {
// Calculate hd, the middle number's digit.
int32_t hi = ui - upper.decimal_point + h->decimal_point;
if (hi >= ((int32_t)(h->num_digits))) {
break;
}
uint8_t hd = (((uint32_t)hi) < h->num_digits) ? h->digits[hi] : 0;
// Calculate ld, the lower bound's digit.
int32_t li = ui - upper.decimal_point + lower.decimal_point;
uint8_t ld = (((uint32_t)li) < lower.num_digits) ? lower.digits[li] : 0;
// We can round down (truncate) if lower has a different digit than h or if
// lower is inclusive and is exactly the result of rounding down (i.e. we
// have reached the final digit of lower).
bool can_round_down =
(ld != hd) || //
(inclusive && ((li + 1) == ((int32_t)(lower.num_digits))));
// Calculate ud, the upper bound's digit, and update upper_delta.
uint8_t ud = (((uint32_t)ui) < upper.num_digits) ? upper.digits[ui] : 0;
if (upper_delta < 0) {
if ((hd + 1) < ud) {
// For example:
// h = 12345???
// upper = 12347???
upper_delta = +1;
} else if (hd != ud) {
// For example:
// h = 12345???
// upper = 12346???
upper_delta = +0;
}
} else if (upper_delta == 0) {
if ((hd != 9) || (ud != 0)) {
// For example:
// h = 1234598?
// upper = 1234600?
upper_delta = +1;
}
}
// We can round up if upper has a different digit than h and either upper
// is inclusive or upper is bigger than the result of rounding up.
bool can_round_up =
(upper_delta > 0) || //
((upper_delta == 0) && //
(inclusive || ((ui + 1) < ((int32_t)(upper.num_digits)))));
// If we can round either way, round to nearest. If we can round only one
// way, do it. If we can't round, continue the loop.
if (can_round_down) {
if (can_round_up) {
wuffs_base__private_implementation__high_prec_dec__round_nearest(
h, hi + 1);
return;
} else {
wuffs_base__private_implementation__high_prec_dec__round_down(h,
hi + 1);
return;
}
} else {
if (can_round_up) {
wuffs_base__private_implementation__high_prec_dec__round_up(h, hi + 1);
return;
}
}
}
}
// --------
// The wuffs_base__private_implementation__etc_powers_of_10 tables were printed
@@ -10547,10 +10484,736 @@ infinity:
} while (0);
}
// --------
static inline size_t //
wuffs_base__private_implementation__render_inf(wuffs_base__slice_u8 dst,
bool neg,
uint32_t options) {
if (neg) {
if (dst.len < 4) {
return 0;
}
wuffs_base__store_u32le__no_bounds_check(dst.ptr, 0x666E492D); // '-Inf'le.
return 4;
}
if (options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN) {
if (dst.len < 4) {
return 0;
}
wuffs_base__store_u32le__no_bounds_check(dst.ptr, 0x666E492B); // '+Inf'le.
return 4;
}
if (dst.len < 3) {
return 0;
}
wuffs_base__store_u24le__no_bounds_check(dst.ptr, 0x666E49); // 'Inf'le.
return 3;
}
static inline size_t //
wuffs_base__private_implementation__render_nan(wuffs_base__slice_u8 dst) {
if (dst.len < 3) {
return 0;
}
wuffs_base__store_u24le__no_bounds_check(dst.ptr, 0x4E614E); // 'NaN'le.
return 3;
}
static size_t //
wuffs_base__private_implementation__high_prec_dec__render_exponent_absent(
wuffs_base__slice_u8 dst,
wuffs_base__private_implementation__high_prec_dec* h,
uint32_t precision,
uint32_t options) {
size_t n = (h->negative ||
(options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN))
? 1
: 0;
if (h->decimal_point <= 0) {
n += 1;
} else {
n += (size_t)(h->decimal_point);
}
if (precision > 0) {
n += precision + 1; // +1 for the '.'.
}
// Don't modify dst if the formatted number won't fit.
if (n > dst.len) {
return 0;
}
// Align-left or align-right.
uint8_t* ptr = (options & WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT)
? &dst.ptr[dst.len - n]
: &dst.ptr[0];
// Leading "±".
if (h->negative) {
*ptr++ = '-';
} else if (options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN) {
*ptr++ = '+';
}
// Integral digits.
if (h->decimal_point <= 0) {
*ptr++ = '0';
} else {
uint32_t m =
wuffs_base__u32__min(h->num_digits, (uint32_t)(h->decimal_point));
uint32_t i = 0;
for (; i < m; i++) {
*ptr++ = (uint8_t)('0' | h->digits[i]);
}
for (; i < (uint32_t)(h->decimal_point); i++) {
*ptr++ = '0';
}
}
// Separator and then fractional digits.
if (precision > 0) {
*ptr++ =
(options & WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA)
? ','
: '.';
uint32_t i = 0;
for (; i < precision; i++) {
uint32_t j = ((uint32_t)(h->decimal_point)) + i;
*ptr++ = (uint8_t)('0' | ((j < h->num_digits) ? h->digits[j] : 0));
}
}
return n;
}
static size_t //
wuffs_base__private_implementation__high_prec_dec__render_exponent_present(
wuffs_base__slice_u8 dst,
wuffs_base__private_implementation__high_prec_dec* h,
uint32_t precision,
uint32_t options) {
int32_t exp = 0;
if (h->num_digits > 0) {
exp = h->decimal_point - 1;
}
bool negative_exp = exp < 0;
if (negative_exp) {
exp = -exp;
}
size_t n = (h->negative ||
(options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN))
? 4
: 3; // Mininum 3 bytes: first digit and then "e±".
if (precision > 0) {
n += precision + 1; // +1 for the '.'.
}
n += (exp < 100) ? 2 : 3;
// Don't modify dst if the formatted number won't fit.
if (n > dst.len) {
return 0;
}
// Align-left or align-right.
uint8_t* ptr = (options & WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT)
? &dst.ptr[dst.len - n]
: &dst.ptr[0];
// Leading "±".
if (h->negative) {
*ptr++ = '-';
} else if (options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN) {
*ptr++ = '+';
}
// Integral digit.
if (h->num_digits > 0) {
*ptr++ = (uint8_t)('0' | h->digits[0]);
} else {
*ptr++ = '0';
}
// Separator and then fractional digits.
if (precision > 0) {
*ptr++ =
(options & WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA)
? ','
: '.';
uint32_t i = 1;
uint32_t j = wuffs_base__u32__min(h->num_digits, precision + 1);
for (; i < j; i++) {
*ptr++ = (uint8_t)('0' | h->digits[i]);
}
for (; i <= precision; i++) {
*ptr++ = '0';
}
}
// Exponent: "e±" and then 2 or 3 digits.
*ptr++ = 'e';
*ptr++ = negative_exp ? '-' : '+';
if (exp < 10) {
*ptr++ = '0';
*ptr++ = (uint8_t)('0' | exp);
} else if (exp < 100) {
*ptr++ = (uint8_t)('0' | (exp / 10));
*ptr++ = (uint8_t)('0' | (exp % 10));
} else {
int32_t e = exp / 100;
exp -= e * 100;
*ptr++ = (uint8_t)('0' | e);
*ptr++ = (uint8_t)('0' | (exp / 10));
*ptr++ = (uint8_t)('0' | (exp % 10));
}
return n;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_f64(wuffs_base__slice_u8 dst,
double x,
uint32_t precision,
uint32_t options) {
// Decompose x (64 bits) into negativity (1 bit), base-2 exponent (11 bits
// with a -1023 bias) and mantissa (52 bits).
uint64_t bits = wuffs_base__ieee_754_bit_representation__from_f64(x);
bool neg = (bits >> 63) != 0;
int32_t exp2 = ((int32_t)(bits >> 52)) & 0x7FF;
uint64_t man = bits & 0x000FFFFFFFFFFFFFul;
// Apply the exponent bias and set the implicit top bit of the mantissa,
// unless x is subnormal. Also take care of Inf and NaN.
if (exp2 == 0x7FF) {
if (man != 0) {
return wuffs_base__private_implementation__render_nan(dst);
}
return wuffs_base__private_implementation__render_inf(dst, neg, options);
} else if (exp2 == 0) {
exp2 = -1022;
} else {
exp2 -= 1023;
man |= 0x0010000000000000ul;
}
// Ensure that precision isn't too large.
if (precision > 4095) {
precision = 4095;
}
// Convert from the (neg, exp2, man) tuple to an HPD.
wuffs_base__private_implementation__high_prec_dec h;
wuffs_base__private_implementation__high_prec_dec__assign(&h, man, neg);
if (h.num_digits > 0) {
wuffs_base__private_implementation__high_prec_dec__lshift(
&h, exp2 - 52); // 52 mantissa bits.
}
// Handle the "%e" and "%f" formats.
switch (options & (WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT |
WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT)) {
case WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT: // The "%"f" format.
if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {
wuffs_base__private_implementation__high_prec_dec__round_just_enough(
&h, exp2, man);
int32_t p = ((int32_t)(h.num_digits)) - h.decimal_point;
precision = ((uint32_t)(wuffs_base__i32__max(0, p)));
} else {
wuffs_base__private_implementation__high_prec_dec__round_nearest(
&h, ((int32_t)precision) + h.decimal_point);
}
return wuffs_base__private_implementation__high_prec_dec__render_exponent_absent(
dst, &h, precision, options);
case WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT: // The "%e" format.
if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {
wuffs_base__private_implementation__high_prec_dec__round_just_enough(
&h, exp2, man);
precision = (h.num_digits > 0) ? (h.num_digits - 1) : 0;
} else {
wuffs_base__private_implementation__high_prec_dec__round_nearest(
&h, ((int32_t)precision) + 1);
}
return wuffs_base__private_implementation__high_prec_dec__render_exponent_present(
dst, &h, precision, options);
}
// We have the "%g" format and so precision means the number of significant
// digits, not the number of digits after the decimal separator. Perform
// rounding and determine whether to use "%e" or "%f".
int32_t e_threshold = 0;
if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {
wuffs_base__private_implementation__high_prec_dec__round_just_enough(
&h, exp2, man);
precision = h.num_digits;
e_threshold = 6;
} else {
if (precision == 0) {
precision = 1;
}
wuffs_base__private_implementation__high_prec_dec__round_nearest(
&h, ((int32_t)precision));
e_threshold = ((int32_t)precision);
int32_t nd = ((int32_t)(h.num_digits));
if ((e_threshold > nd) && (nd >= h.decimal_point)) {
e_threshold = nd;
}
}
// Use the "%e" format if the exponent is large.
int32_t e = h.decimal_point - 1;
if ((e < -4) || (e_threshold <= e)) {
uint32_t p = wuffs_base__u32__min(precision, h.num_digits);
return wuffs_base__private_implementation__high_prec_dec__render_exponent_present(
dst, &h, (p > 0) ? (p - 1) : 0, options);
}
// Use the "%f" format otherwise.
int32_t p = ((int32_t)precision);
if (p > h.decimal_point) {
p = ((int32_t)(h.num_digits));
}
precision = ((uint32_t)(wuffs_base__i32__max(0, p - h.decimal_point)));
return wuffs_base__private_implementation__high_prec_dec__render_exponent_absent(
dst, &h, precision, options);
}
#endif // !defined(WUFFS_CONFIG__MODULES) ||
// defined(WUFFS_CONFIG__MODULE__BASE) ||
// defined(WUFFS_CONFIG__MODULE__BASE__F64CONV)
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE) || \
defined(WUFFS_CONFIG__MODULE__BASE__I64CONV)
// ---------------- Integer
// wuffs_base__parse_number__foo_digits entries are 0x00 for invalid digits,
// and (0x80 | v) for valid digits, where v is the 4 bit value.
static const uint8_t wuffs_base__parse_number__decimal_digits[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.
0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
static const uint8_t wuffs_base__parse_number__hexadecimal_digits[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.
0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.
0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x40 ..= 0x47. 'A'-'F'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x60 ..= 0x67. 'a'-'f'.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
// --------
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64 //
wuffs_base__parse_number_i64(wuffs_base__slice_u8 s) {
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p < q) && (*p == '_'); p++) {
}
bool negative = false;
if (p >= q) {
goto fail_bad_argument;
} else if (*p == '-') {
p++;
negative = true;
} else if (*p == '+') {
p++;
}
do {
wuffs_base__result_u64 r = wuffs_base__parse_number_u64(
wuffs_base__make_slice_u8(p, (size_t)(q - p)));
if (r.status.repr != NULL) {
wuffs_base__result_i64 ret;
ret.status.repr = r.status.repr;
ret.value = 0;
return ret;
} else if (negative) {
if (r.value > 0x8000000000000000) {
goto fail_out_of_bounds;
}
wuffs_base__result_i64 ret;
ret.status.repr = NULL;
ret.value = -(int64_t)(r.value);
return ret;
} else if (r.value > 0x7FFFFFFFFFFFFFFF) {
goto fail_out_of_bounds;
} else {
wuffs_base__result_i64 ret;
ret.status.repr = NULL;
ret.value = +(int64_t)(r.value);
return ret;
}
} while (0);
fail_bad_argument:
do {
wuffs_base__result_i64 ret;
ret.status.repr = wuffs_base__error__bad_argument;
ret.value = 0;
return ret;
} while (0);
fail_out_of_bounds:
do {
wuffs_base__result_i64 ret;
ret.status.repr = wuffs_base__error__out_of_bounds;
ret.value = 0;
return ret;
} while (0);
}
WUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64 //
wuffs_base__parse_number_u64(wuffs_base__slice_u8 s) {
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p < q) && (*p == '_'); p++) {
}
if (p >= q) {
goto fail_bad_argument;
} else if (*p == '0') {
p++;
if (p >= q) {
goto ok_zero;
}
if (*p == '_') {
p++;
for (; p < q; p++) {
if (*p != '_') {
goto fail_bad_argument;
}
}
goto ok_zero;
}
if ((*p == 'x') || (*p == 'X')) {
p++;
for (; (p < q) && (*p == '_'); p++) {
}
if (p < q) {
goto hexadecimal;
}
} else if ((*p == 'd') || (*p == 'D')) {
p++;
for (; (p < q) && (*p == '_'); p++) {
}
if (p < q) {
goto decimal;
}
}
goto fail_bad_argument;
}
decimal:
do {
uint64_t v = wuffs_base__parse_number__decimal_digits[*p++];
if (v == 0) {
goto fail_bad_argument;
}
v &= 0x0F;
// UINT64_MAX is 18446744073709551615, which is ((10 * max10) + max1).
const uint64_t max10 = 1844674407370955161u;
const uint8_t max1 = 5;
for (; p < q; p++) {
if (*p == '_') {
continue;
}
uint8_t digit = wuffs_base__parse_number__decimal_digits[*p];
if (digit == 0) {
goto fail_bad_argument;
}
digit &= 0x0F;
if ((v > max10) || ((v == max10) && (digit > max1))) {
goto fail_out_of_bounds;
}
v = (10 * v) + ((uint64_t)(digit));
}
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = v;
return ret;
} while (0);
hexadecimal:
do {
uint64_t v = wuffs_base__parse_number__hexadecimal_digits[*p++];
if (v == 0) {
goto fail_bad_argument;
}
v &= 0x0F;
for (; p < q; p++) {
if (*p == '_') {
continue;
}
uint8_t digit = wuffs_base__parse_number__hexadecimal_digits[*p];
if (digit == 0) {
goto fail_bad_argument;
}
digit &= 0x0F;
if ((v >> 60) != 0) {
goto fail_out_of_bounds;
}
v = (v << 4) | ((uint64_t)(digit));
}
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = v;
return ret;
} while (0);
ok_zero:
do {
wuffs_base__result_u64 ret;
ret.status.repr = NULL;
ret.value = 0;
return ret;
} while (0);
fail_bad_argument:
do {
wuffs_base__result_u64 ret;
ret.status.repr = wuffs_base__error__bad_argument;
ret.value = 0;
return ret;
} while (0);
fail_out_of_bounds:
do {
wuffs_base__result_u64 ret;
ret.status.repr = wuffs_base__error__out_of_bounds;
ret.value = 0;
return ret;
} while (0);
}
// --------
// wuffs_base__render_number__first_hundred contains the decimal encodings of
// the first one hundred numbers [0 ..= 99].
static const uint8_t wuffs_base__render_number__first_hundred[200] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', //
'0', '5', '0', '6', '0', '7', '0', '8', '0', '9', //
'1', '0', '1', '1', '1', '2', '1', '3', '1', '4', //
'1', '5', '1', '6', '1', '7', '1', '8', '1', '9', //
'2', '0', '2', '1', '2', '2', '2', '3', '2', '4', //
'2', '5', '2', '6', '2', '7', '2', '8', '2', '9', //
'3', '0', '3', '1', '3', '2', '3', '3', '3', '4', //
'3', '5', '3', '6', '3', '7', '3', '8', '3', '9', //
'4', '0', '4', '1', '4', '2', '4', '3', '4', '4', //
'4', '5', '4', '6', '4', '7', '4', '8', '4', '9', //
'5', '0', '5', '1', '5', '2', '5', '3', '5', '4', //
'5', '5', '5', '6', '5', '7', '5', '8', '5', '9', //
'6', '0', '6', '1', '6', '2', '6', '3', '6', '4', //
'6', '5', '6', '6', '6', '7', '6', '8', '6', '9', //
'7', '0', '7', '1', '7', '2', '7', '3', '7', '4', //
'7', '5', '7', '6', '7', '7', '7', '8', '7', '9', //
'8', '0', '8', '1', '8', '2', '8', '3', '8', '4', //
'8', '5', '8', '6', '8', '7', '8', '8', '8', '9', //
'9', '0', '9', '1', '9', '2', '9', '3', '9', '4', //
'9', '5', '9', '6', '9', '7', '9', '8', '9', '9', //
};
static size_t //
wuffs_base__private_implementation__render_number_u64(wuffs_base__slice_u8 dst,
uint64_t x,
uint32_t options,
bool neg) {
uint8_t buf[WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL];
uint8_t* ptr = &buf[0] + sizeof(buf);
while (x >= 100) {
size_t index = (x % 100) * 2;
x /= 100;
uint8_t s0 = wuffs_base__render_number__first_hundred[index + 0];
uint8_t s1 = wuffs_base__render_number__first_hundred[index + 1];
ptr -= 2;
ptr[0] = s0;
ptr[1] = s1;
}
if (x < 10) {
ptr -= 1;
ptr[0] = (uint8_t)('0' + x);
} else {
size_t index = x * 2;
uint8_t s0 = wuffs_base__render_number__first_hundred[index + 0];
uint8_t s1 = wuffs_base__render_number__first_hundred[index + 1];
ptr -= 2;
ptr[0] = s0;
ptr[1] = s1;
}
if (neg) {
ptr -= 1;
ptr[0] = '-';
} else if (options & WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN) {
ptr -= 1;
ptr[0] = '+';
}
size_t n = sizeof(buf) - ((size_t)(ptr - &buf[0]));
if (n > dst.len) {
return 0;
}
memcpy(dst.ptr + ((options & WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT)
? (dst.len - n)
: 0),
ptr, n);
return n;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_i64(wuffs_base__slice_u8 dst,
int64_t x,
uint32_t options) {
uint64_t u = (uint64_t)x;
bool neg = x < 0;
if (neg) {
u = 1 + ~u;
}
return wuffs_base__private_implementation__render_number_u64(dst, u, options,
neg);
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__render_number_u64(wuffs_base__slice_u8 dst,
uint64_t x,
uint32_t options) {
return wuffs_base__private_implementation__render_number_u64(dst, x, options,
false);
}
// ---------------- Hexadecimal
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__hexadecimal__decode2(wuffs_base__slice_u8 dst,
wuffs_base__slice_u8 src) {
size_t src_len2 = src.len / 2;
size_t len = dst.len < src_len2 ? dst.len : src_len2;
uint8_t* d = dst.ptr;
uint8_t* s = src.ptr;
size_t n = len;
while (n--) {
*d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[0]] << 4) |
(wuffs_base__parse_number__hexadecimal_digits[s[1]] & 0x0F));
d += 1;
s += 2;
}
return len;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__hexadecimal__decode4(wuffs_base__slice_u8 dst,
wuffs_base__slice_u8 src) {
size_t src_len4 = src.len / 4;
size_t len = dst.len < src_len4 ? dst.len : src_len4;
uint8_t* d = dst.ptr;
uint8_t* s = src.ptr;
size_t n = len;
while (n--) {
*d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[2]] << 4) |
(wuffs_base__parse_number__hexadecimal_digits[s[3]] & 0x0F));
d += 1;
s += 4;
}
return len;
}
#endif // !defined(WUFFS_CONFIG__MODULES) ||
// defined(WUFFS_CONFIG__MODULE__BASE) ||
// defined(WUFFS_CONFIG__MODULE__BASE__I64CONV)
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE) || \
defined(WUFFS_CONFIG__MODULE__BASE__PIXCONV)
@@ -12063,6 +12726,195 @@ wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(
// defined(WUFFS_CONFIG__MODULE__BASE) ||
// defined(WUFFS_CONFIG__MODULE__BASE__PIXCONV)
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE) || \
defined(WUFFS_CONFIG__MODULE__BASE__UTF8)
// ---------------- Unicode and UTF-8
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__utf_8__encode(wuffs_base__slice_u8 dst, uint32_t code_point) {
if (code_point <= 0x7F) {
if (dst.len >= 1) {
dst.ptr[0] = (uint8_t)(code_point);
return 1;
}
} else if (code_point <= 0x07FF) {
if (dst.len >= 2) {
dst.ptr[0] = (uint8_t)(0xC0 | ((code_point >> 6)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 2;
}
} else if (code_point <= 0xFFFF) {
if ((dst.len >= 3) && ((code_point < 0xD800) || (0xDFFF < code_point))) {
dst.ptr[0] = (uint8_t)(0xE0 | ((code_point >> 12)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3F));
dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 3;
}
} else if (code_point <= 0x10FFFF) {
if (dst.len >= 4) {
dst.ptr[0] = (uint8_t)(0xF0 | ((code_point >> 18)));
dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 12) & 0x3F));
dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3F));
dst.ptr[3] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));
return 4;
}
}
return 0;
}
// wuffs_base__utf_8__byte_length_minus_1 is the byte length (minus 1) of a
// UTF-8 encoded code point, based on the encoding's initial byte.
// - 0x00 is 1-byte UTF-8 (ASCII).
// - 0x01 is the start of 2-byte UTF-8.
// - 0x02 is the start of 3-byte UTF-8.
// - 0x03 is the start of 4-byte UTF-8.
// - 0x40 is a UTF-8 tail byte.
// - 0x80 is invalid UTF-8.
//
// RFC 3629 (UTF-8) gives this grammar for valid UTF-8:
// UTF8-1 = %x00-7F
// UTF8-2 = %xC2-DF UTF8-tail
// UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /
// %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )
// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
// %xF4 %x80-8F 2( UTF8-tail )
// UTF8-tail = %x80-BF
static const uint8_t wuffs_base__utf_8__byte_length_minus_1[256] = {
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x80 ..= 0x87.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x88 ..= 0x8F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x90 ..= 0x97.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x98 ..= 0x9F.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA0 ..= 0xA7.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA8 ..= 0xAF.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB0 ..= 0xB7.
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB8 ..= 0xBF.
0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC0 ..= 0xC7.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC8 ..= 0xCF.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD0 ..= 0xD7.
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD8 ..= 0xDF.
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE0 ..= 0xE7.
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE8 ..= 0xEF.
0x03, 0x03, 0x03, 0x03, 0x03, 0x80, 0x80, 0x80, // 0xF0 ..= 0xF7.
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0xF8 ..= 0xFF.
// 0 1 2 3 4 5 6 7
// 8 9 A B C D E F
};
WUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output //
wuffs_base__utf_8__next(wuffs_base__slice_u8 s) {
if (s.len == 0) {
return wuffs_base__make_utf_8__next__output(0, 0);
}
uint32_t c = s.ptr[0];
switch (wuffs_base__utf_8__byte_length_minus_1[c & 0xFF]) {
case 0:
return wuffs_base__make_utf_8__next__output(c, 1);
case 1:
if (s.len < 2) {
break;
}
c = wuffs_base__load_u16le__no_bounds_check(s.ptr);
if ((c & 0xC000) != 0x8000) {
break;
}
c = (0x0007C0 & (c << 6)) | (0x00003F & (c >> 8));
return wuffs_base__make_utf_8__next__output(c, 2);
case 2:
if (s.len < 3) {
break;
}
c = wuffs_base__load_u24le__no_bounds_check(s.ptr);
if ((c & 0xC0C000) != 0x808000) {
break;
}
c = (0x00F000 & (c << 12)) | (0x000FC0 & (c >> 2)) |
(0x00003F & (c >> 16));
if ((c <= 0x07FF) || ((0xD800 <= c) && (c <= 0xDFFF))) {
break;
}
return wuffs_base__make_utf_8__next__output(c, 3);
case 3:
if (s.len < 4) {
break;
}
c = wuffs_base__load_u32le__no_bounds_check(s.ptr);
if ((c & 0xC0C0C000) != 0x80808000) {
break;
}
c = (0x1C0000 & (c << 18)) | (0x03F000 & (c << 4)) |
(0x000FC0 & (c >> 10)) | (0x00003F & (c >> 24));
if ((c <= 0xFFFF) || (0x110000 <= c)) {
break;
}
return wuffs_base__make_utf_8__next__output(c, 4);
}
return wuffs_base__make_utf_8__next__output(
WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER, 1);
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__utf_8__longest_valid_prefix(wuffs_base__slice_u8 s) {
// TODO: possibly optimize the all-ASCII case (4 or 8 bytes at a time).
//
// TODO: possibly optimize this by manually inlining the
// wuffs_base__utf_8__next calls.
size_t original_len = s.len;
while (s.len > 0) {
wuffs_base__utf_8__next__output o = wuffs_base__utf_8__next(s);
if ((o.code_point > 0x7F) && (o.byte_length == 1)) {
break;
}
s.ptr += o.byte_length;
s.len -= o.byte_length;
}
return original_len - s.len;
}
WUFFS_BASE__MAYBE_STATIC size_t //
wuffs_base__ascii__longest_valid_prefix(wuffs_base__slice_u8 s) {
// TODO: possibly optimize this by checking 4 or 8 bytes at a time.
uint8_t* original_ptr = s.ptr;
uint8_t* p = s.ptr;
uint8_t* q = s.ptr + s.len;
for (; (p != q) && ((*p & 0x80) == 0); p++) {
}
return (size_t)(p - original_ptr);
}
#endif // !defined(WUFFS_CONFIG__MODULES) ||
// defined(WUFFS_CONFIG__MODULE__BASE) ||
// defined(WUFFS_CONFIG__MODULE__BASE__UTF8)
#ifdef __cplusplus
} // extern "C"
#endif
@@ -12095,7 +12947,7 @@ wuffs_adler32__hasher__initialize(
wuffs_adler32__hasher* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -12107,7 +12959,7 @@ wuffs_adler32__hasher__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -12121,9 +12973,9 @@ wuffs_adler32__hasher__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -12252,9 +13104,9 @@ wuffs_adler32__hasher__update_u32(
// ---------------- Status Codes Implementations
const char* wuffs_bmp__error__bad_header = "#bmp: bad header";
const char* wuffs_bmp__error__unsupported_bmp_file = "#bmp: unsupported BMP file";
const char* wuffs_bmp__note__internal_note_short_read = "@bmp: internal note: short read";
const char wuffs_bmp__error__bad_header[] = "#bmp: bad header";
const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file";
const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read";
// ---------------- Private Consts
@@ -12316,7 +13168,7 @@ wuffs_bmp__decoder__initialize(
wuffs_bmp__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -12328,7 +13180,7 @@ wuffs_bmp__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -12342,9 +13194,9 @@ wuffs_bmp__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -14114,7 +14966,7 @@ wuffs_crc32__ieee_hasher__initialize(
wuffs_crc32__ieee_hasher* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -14126,7 +14978,7 @@ wuffs_crc32__ieee_hasher__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -14140,9 +14992,9 @@ wuffs_crc32__ieee_hasher__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -14296,23 +15148,23 @@ wuffs_crc32__ieee_hasher__update_u32(
// ---------------- Status Codes Implementations
const char* wuffs_deflate__error__bad_huffman_code_over_subscribed = "#deflate: bad Huffman code (over-subscribed)";
const char* wuffs_deflate__error__bad_huffman_code_under_subscribed = "#deflate: bad Huffman code (under-subscribed)";
const char* wuffs_deflate__error__bad_huffman_code_length_count = "#deflate: bad Huffman code length count";
const char* wuffs_deflate__error__bad_huffman_code_length_repetition = "#deflate: bad Huffman code length repetition";
const char* wuffs_deflate__error__bad_huffman_code = "#deflate: bad Huffman code";
const char* wuffs_deflate__error__bad_huffman_minimum_code_length = "#deflate: bad Huffman minimum code length";
const char* wuffs_deflate__error__bad_block = "#deflate: bad block";
const char* wuffs_deflate__error__bad_distance = "#deflate: bad distance";
const char* wuffs_deflate__error__bad_distance_code_count = "#deflate: bad distance code count";
const char* wuffs_deflate__error__bad_literal_length_code_count = "#deflate: bad literal/length code count";
const char* wuffs_deflate__error__inconsistent_stored_block_length = "#deflate: inconsistent stored block length";
const char* wuffs_deflate__error__missing_end_of_block_code = "#deflate: missing end-of-block code";
const char* wuffs_deflate__error__no_huffman_codes = "#deflate: no Huffman codes";
const char* wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state = "#deflate: internal error: inconsistent Huffman decoder state";
const char* wuffs_deflate__error__internal_error_inconsistent_i_o = "#deflate: internal error: inconsistent I/O";
const char* wuffs_deflate__error__internal_error_inconsistent_distance = "#deflate: internal error: inconsistent distance";
const char* wuffs_deflate__error__internal_error_inconsistent_n_bits = "#deflate: internal error: inconsistent n_bits";
const char wuffs_deflate__error__bad_huffman_code_over_subscribed[] = "#deflate: bad Huffman code (over-subscribed)";
const char wuffs_deflate__error__bad_huffman_code_under_subscribed[] = "#deflate: bad Huffman code (under-subscribed)";
const char wuffs_deflate__error__bad_huffman_code_length_count[] = "#deflate: bad Huffman code length count";
const char wuffs_deflate__error__bad_huffman_code_length_repetition[] = "#deflate: bad Huffman code length repetition";
const char wuffs_deflate__error__bad_huffman_code[] = "#deflate: bad Huffman code";
const char wuffs_deflate__error__bad_huffman_minimum_code_length[] = "#deflate: bad Huffman minimum code length";
const char wuffs_deflate__error__bad_block[] = "#deflate: bad block";
const char wuffs_deflate__error__bad_distance[] = "#deflate: bad distance";
const char wuffs_deflate__error__bad_distance_code_count[] = "#deflate: bad distance code count";
const char wuffs_deflate__error__bad_literal_length_code_count[] = "#deflate: bad literal/length code count";
const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length";
const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code";
const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes";
const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state";
const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O";
const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance";
const char wuffs_deflate__error__internal_error_inconsistent_n_bits[] = "#deflate: internal error: inconsistent n_bits";
// ---------------- Private Consts
@@ -14445,7 +15297,7 @@ wuffs_deflate__decoder__initialize(
wuffs_deflate__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -14457,7 +15309,7 @@ wuffs_deflate__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -14471,9 +15323,9 @@ wuffs_deflate__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -16123,8 +16975,8 @@ wuffs_deflate__decoder__decode_huffman_slow(
// ---------------- Status Codes Implementations
const char* wuffs_lzw__error__bad_code = "#lzw: bad code";
const char* wuffs_lzw__error__internal_error_inconsistent_i_o = "#lzw: internal error: inconsistent I/O";
const char wuffs_lzw__error__bad_code[] = "#lzw: bad code";
const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O";
// ---------------- Private Consts
@@ -16163,7 +17015,7 @@ wuffs_lzw__decoder__initialize(
wuffs_lzw__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -16175,7 +17027,7 @@ wuffs_lzw__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -16189,9 +17041,9 @@ wuffs_lzw__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -16649,13 +17501,13 @@ wuffs_lzw__decoder__flush(
// ---------------- Status Codes Implementations
const char* wuffs_gif__error__bad_extension_label = "#gif: bad extension label";
const char* wuffs_gif__error__bad_frame_size = "#gif: bad frame size";
const char* wuffs_gif__error__bad_graphic_control = "#gif: bad graphic control";
const char* wuffs_gif__error__bad_header = "#gif: bad header";
const char* wuffs_gif__error__bad_literal_width = "#gif: bad literal width";
const char* wuffs_gif__error__bad_palette = "#gif: bad palette";
const char* wuffs_gif__error__internal_error_inconsistent_ri_wi = "#gif: internal error: inconsistent ri/wi";
const char wuffs_gif__error__bad_extension_label[] = "#gif: bad extension label";
const char wuffs_gif__error__bad_frame_size[] = "#gif: bad frame size";
const char wuffs_gif__error__bad_graphic_control[] = "#gif: bad graphic control";
const char wuffs_gif__error__bad_header[] = "#gif: bad header";
const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width";
const char wuffs_gif__error__bad_palette[] = "#gif: bad palette";
const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi";
// ---------------- Private Consts
@@ -16901,7 +17753,7 @@ wuffs_gif__config_decoder__initialize(
wuffs_gif__config_decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -16913,7 +17765,7 @@ wuffs_gif__config_decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -16927,9 +17779,9 @@ wuffs_gif__config_decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -16968,7 +17820,7 @@ wuffs_gif__decoder__initialize(
wuffs_gif__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -16980,7 +17832,7 @@ wuffs_gif__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -16994,9 +17846,9 @@ wuffs_gif__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -17004,7 +17856,7 @@ wuffs_gif__decoder__initialize(
{
wuffs_base__status z = wuffs_lzw__decoder__initialize(
&self->private_data.f_lzw, sizeof(self->private_data.f_lzw), WUFFS_VERSION, initialize_flags);
&self->private_data.f_lzw, sizeof(self->private_data.f_lzw), WUFFS_VERSION, options);
if (z.repr) {
return z;
}
@@ -21129,10 +21981,10 @@ wuffs_gif__decoder__copy_to_image_buffer(
// ---------------- Status Codes Implementations
const char* wuffs_gzip__error__bad_checksum = "#gzip: bad checksum";
const char* wuffs_gzip__error__bad_compression_method = "#gzip: bad compression method";
const char* wuffs_gzip__error__bad_encoding_flags = "#gzip: bad encoding flags";
const char* wuffs_gzip__error__bad_header = "#gzip: bad header";
const char wuffs_gzip__error__bad_checksum[] = "#gzip: bad checksum";
const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method";
const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags";
const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
// ---------------- Private Consts
@@ -21161,7 +22013,7 @@ wuffs_gzip__decoder__initialize(
wuffs_gzip__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -21173,7 +22025,7 @@ wuffs_gzip__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -21187,9 +22039,9 @@ wuffs_gzip__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -21197,14 +22049,14 @@ wuffs_gzip__decoder__initialize(
{
wuffs_base__status z = wuffs_crc32__ieee_hasher__initialize(
&self->private_data.f_checksum, sizeof(self->private_data.f_checksum), WUFFS_VERSION, initialize_flags);
&self->private_data.f_checksum, sizeof(self->private_data.f_checksum), WUFFS_VERSION, options);
if (z.repr) {
return z;
}
}
{
wuffs_base__status z = wuffs_deflate__decoder__initialize(
&self->private_data.f_flate, sizeof(self->private_data.f_flate), WUFFS_VERSION, initialize_flags);
&self->private_data.f_flate, sizeof(self->private_data.f_flate), WUFFS_VERSION, options);
if (z.repr) {
return z;
}
@@ -21629,13 +22481,13 @@ wuffs_gzip__decoder__transform_io(
// ---------------- Status Codes Implementations
const char* wuffs_json__error__bad_c0_control_code = "#json: bad C0 control code";
const char* wuffs_json__error__bad_utf_8 = "#json: bad UTF-8";
const char* wuffs_json__error__bad_backslash_escape = "#json: bad backslash-escape";
const char* wuffs_json__error__bad_input = "#json: bad input";
const char* wuffs_json__error__unsupported_number_length = "#json: unsupported number length";
const char* wuffs_json__error__unsupported_recursion_depth = "#json: unsupported recursion depth";
const char* wuffs_json__error__internal_error_inconsistent_i_o = "#json: internal error: inconsistent I/O";
const char wuffs_json__error__bad_c0_control_code[] = "#json: bad C0 control code";
const char wuffs_json__error__bad_utf_8[] = "#json: bad UTF-8";
const char wuffs_json__error__bad_backslash_escape[] = "#json: bad backslash-escape";
const char wuffs_json__error__bad_input[] = "#json: bad input";
const char wuffs_json__error__unsupported_number_length[] = "#json: unsupported number length";
const char wuffs_json__error__unsupported_recursion_depth[] = "#json: unsupported recursion depth";
const char wuffs_json__error__internal_error_inconsistent_i_o[] = "#json: internal error: inconsistent I/O";
// ---------------- Private Consts
@@ -21937,7 +22789,7 @@ wuffs_json__decoder__initialize(
wuffs_json__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -21949,7 +22801,7 @@ wuffs_json__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -21963,9 +22815,9 @@ wuffs_json__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -23827,7 +24679,7 @@ wuffs_json__decoder__decode_trailing_new_line(
// ---------------- Status Codes Implementations
const char* wuffs_wbmp__error__bad_header = "#wbmp: bad header";
const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
// ---------------- Private Consts
@@ -23883,7 +24735,7 @@ wuffs_wbmp__decoder__initialize(
wuffs_wbmp__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -23895,7 +24747,7 @@ wuffs_wbmp__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -23909,9 +24761,9 @@ wuffs_wbmp__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -24623,12 +25475,12 @@ wuffs_wbmp__decoder__workbuf_len(
// ---------------- Status Codes Implementations
const char* wuffs_zlib__note__dictionary_required = "@zlib: dictionary required";
const char* wuffs_zlib__error__bad_checksum = "#zlib: bad checksum";
const char* wuffs_zlib__error__bad_compression_method = "#zlib: bad compression method";
const char* wuffs_zlib__error__bad_compression_window_size = "#zlib: bad compression window size";
const char* wuffs_zlib__error__bad_parity_check = "#zlib: bad parity check";
const char* wuffs_zlib__error__incorrect_dictionary = "#zlib: incorrect dictionary";
const char wuffs_zlib__note__dictionary_required[] = "@zlib: dictionary required";
const char wuffs_zlib__error__bad_checksum[] = "#zlib: bad checksum";
const char wuffs_zlib__error__bad_compression_method[] = "#zlib: bad compression method";
const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size";
const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check";
const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary";
// ---------------- Private Consts
@@ -24657,7 +25509,7 @@ wuffs_zlib__decoder__initialize(
wuffs_zlib__decoder* self,
size_t sizeof_star_self,
uint64_t wuffs_version,
uint32_t initialize_flags){
uint32_t options){
if (!self) {
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
}
@@ -24669,7 +25521,7 @@ wuffs_zlib__decoder__initialize(
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
}
if ((initialize_flags & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
// The whole point of this if-check is to detect an uninitialized *self.
// We disable the warning on GCC. Clang-5.0 does not have this warning.
#if !defined(__clang__) && defined(__GNUC__)
@@ -24683,9 +25535,9 @@ wuffs_zlib__decoder__initialize(
#pragma GCC diagnostic pop
#endif
} else {
if ((initialize_flags & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
memset(self, 0, sizeof(*self));
initialize_flags |= WUFFS_INITIALIZE__ALREADY_ZEROED;
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
} else {
memset(&(self->private_impl), 0, sizeof(self->private_impl));
}
@@ -24693,21 +25545,21 @@ wuffs_zlib__decoder__initialize(
{
wuffs_base__status z = wuffs_adler32__hasher__initialize(
&self->private_data.f_checksum, sizeof(self->private_data.f_checksum), WUFFS_VERSION, initialize_flags);
&self->private_data.f_checksum, sizeof(self->private_data.f_checksum), WUFFS_VERSION, options);
if (z.repr) {
return z;
}
}
{
wuffs_base__status z = wuffs_adler32__hasher__initialize(
&self->private_data.f_dict_id_hasher, sizeof(self->private_data.f_dict_id_hasher), WUFFS_VERSION, initialize_flags);
&self->private_data.f_dict_id_hasher, sizeof(self->private_data.f_dict_id_hasher), WUFFS_VERSION, options);
if (z.repr) {
return z;
}
}
{
wuffs_base__status z = wuffs_deflate__decoder__initialize(
&self->private_data.f_flate, sizeof(self->private_data.f_flate), WUFFS_VERSION, initialize_flags);
&self->private_data.f_flate, sizeof(self->private_data.f_flate), WUFFS_VERSION, options);
if (z.repr) {
return z;
}