mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Rename errors from "?msg" to "#msg"
This commit is contained in:
1 parent
c341ac5078
commit
045f180a6c
16 files changed
+203
-203
No files matched your search
@@ -157,12 +157,12 @@ typedef const char* wuffs_base__status;
|
|||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_complete(wuffs_base__status z) {
|
wuffs_base__status__is_complete(wuffs_base__status z) {
|
||||||
return (z == NULL) || ((*z != '$') && (*z != '?'));
|
return (z == NULL) || ((*z != '$') && (*z != '#'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_error(wuffs_base__status z) {
|
wuffs_base__status__is_error(wuffs_base__status z) {
|
||||||
return z && (*z == '?');
|
return z && (*z == '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
@@ -177,7 +177,7 @@ wuffs_base__status__is_suspension(wuffs_base__status z) {
|
|||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_warning(wuffs_base__status z) {
|
wuffs_base__status__is_warning(wuffs_base__status z) {
|
||||||
return z && (*z != '$') && (*z != '?');
|
return z && (*z != '$') && (*z != '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func Do(args []string) error {
|
|||||||
pre := "warning"
|
pre := "warning"
|
||||||
if msg[0] == '$' {
|
if msg[0] == '$' {
|
||||||
pre = "suspension"
|
pre = "suspension"
|
||||||
} else if msg[0] == '?' {
|
} else if msg[0] == '#' {
|
||||||
pre = "error"
|
pre = "error"
|
||||||
}
|
}
|
||||||
b.printf("const char* wuffs_base__%s__%s = \"%sbase: %s\";\n",
|
b.printf("const char* wuffs_base__%s__%s = \"%sbase: %s\";\n",
|
||||||
@@ -190,7 +190,7 @@ type status struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func statusMsgIsError(msg string) bool {
|
func statusMsgIsError(msg string) bool {
|
||||||
return (len(msg) != 0) && (msg[0] == '?')
|
return (len(msg) != 0) && (msg[0] == '#')
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusMsgIsSuspension(msg string) bool {
|
func statusMsgIsSuspension(msg string) bool {
|
||||||
@@ -198,7 +198,7 @@ func statusMsgIsSuspension(msg string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func statusMsgIsWarning(msg string) bool {
|
func statusMsgIsWarning(msg string) bool {
|
||||||
return (len(msg) == 0) || (msg[0] != '$' && msg[0] != '?')
|
return (len(msg) == 0) || (msg[0] != '$' && msg[0] != '#')
|
||||||
}
|
}
|
||||||
|
|
||||||
type buffer []byte
|
type buffer []byte
|
||||||
@@ -676,7 +676,7 @@ func (g *gen) addStatus(qid t.QID, msg string, public bool) error {
|
|||||||
category := "warning__"
|
category := "warning__"
|
||||||
if msg[0] == '$' {
|
if msg[0] == '$' {
|
||||||
category = "suspension__"
|
category = "suspension__"
|
||||||
} else if msg[0] == '?' {
|
} else if msg[0] == '#' {
|
||||||
category = "error__"
|
category = "error__"
|
||||||
}
|
}
|
||||||
z := status{
|
z := status{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ const baseCorePublicH = "" +
|
|||||||
"ceholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
"ceholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" +
|
"// --------\n\n// A status is either NULL (meaning OK) or a string message. That message is\n// human-readable, for programmers, but it is not for end users. It is not\n// localized, and does not contain additional contextual information such as a\n// source filename.\n//\n// Status strings are statically allocated and should never be free'd. They can\n// be compared by the == operator and not just by strcmp.\n//\n// Statuses come in four categories:\n// - OK: the request was completed, successfully.\n// - Warnings: the request was completed, unsuccessfully.\n// - Suspensions: the request was not completed, but can be re-tried.\n// - Errors: the request was not completed, permanently.\n//\n// When a function returns an incomplete status, a suspension means that that\n// function should be called again within a new context, such as after flushing\n// or re-filling an I/O buffer. An error means that an irrecoverable failure\n// state was reached.\ntypedef const char* wuffs_base__status;\n\n// !! INSERT wuffs_bas" +
|
||||||
"e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '?'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '?');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '?');\n}\n\n" +
|
"e__status names.\n\nstatic inline bool //\nwuffs_base__status__is_complete(wuffs_base__status z) {\n return (z == NULL) || ((*z != '$') && (*z != '#'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(wuffs_base__status z) {\n return z && (*z == '#');\n}\n\nstatic inline bool //\nwuffs_base__status__is_ok(wuffs_base__status z) {\n return z == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(wuffs_base__status z) {\n return z && (*z == '$');\n}\n\nstatic inline bool //\nwuffs_base__status__is_warning(wuffs_base__status z) {\n return z && (*z != '$') && (*z != '#');\n}\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" +
|
"// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n" +
|
||||||
"" +
|
"" +
|
||||||
|
|||||||
+2
-2
@@ -43,7 +43,7 @@
|
|||||||
- Marked some internal status codes as private.
|
- Marked some internal status codes as private.
|
||||||
- Removed closed-for-read/write built-in status codes.
|
- Removed closed-for-read/write built-in status codes.
|
||||||
- Changed the string messages for built-in status codes.
|
- Changed the string messages for built-in status codes.
|
||||||
- Changed `error "foo"` to `"?foo"` or `base."?bar"`.
|
- Changed `error "foo"` to `"#foo"` or `base."#bar"`.
|
||||||
- Added warnings as another status code category.
|
- Added warnings as another status code category.
|
||||||
- Made the status type a `const char *`, not an `int32_t`.
|
- Made the status type a `const char *`, not an `int32_t`.
|
||||||
- Disallowed `__double_underscore` prefixed names.
|
- Disallowed `__double_underscore` prefixed names.
|
||||||
@@ -67,4 +67,4 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Updated on December 2018.
|
Updated on February 2019.
|
||||||
+1
-1
@@ -302,7 +302,7 @@ const MaxExprDepth = 255
|
|||||||
// - List0: <Arg|Expr> function call args, assoc. op args or list members.
|
// - List0: <Arg|Expr> function call args, assoc. op args or list members.
|
||||||
//
|
//
|
||||||
// A zero ID0 means an identifier or literal in ID2, like `foo`, `42` or a
|
// A zero ID0 means an identifier or literal in ID2, like `foo`, `42` or a
|
||||||
// status literal like `"?foo"` or `pkg."$bar"`. For status literals, ID1 is
|
// status literal like `"#foo"` or `pkg."$bar"`. For status literals, ID1 is
|
||||||
// the package.
|
// the package.
|
||||||
//
|
//
|
||||||
// For unary operators, ID0 is the operator and RHS is the operand.
|
// For unary operators, ID0 is the operator and RHS is the operand.
|
||||||
|
|||||||
+15
-15
@@ -28,21 +28,21 @@ var Statuses = [...]string{
|
|||||||
`"$short write"`,
|
`"$short write"`,
|
||||||
|
|
||||||
// Errors.
|
// Errors.
|
||||||
`"?bad argument (length too short)"`,
|
`"#bad argument (length too short)"`,
|
||||||
`"?bad argument"`,
|
`"#bad argument"`,
|
||||||
`"?bad call sequence"`,
|
`"#bad call sequence"`,
|
||||||
`"?bad receiver"`,
|
`"#bad receiver"`,
|
||||||
`"?bad restart"`,
|
`"#bad restart"`,
|
||||||
`"?bad sizeof receiver"`,
|
`"#bad sizeof receiver"`,
|
||||||
`"?bad workbuf length"`,
|
`"#bad workbuf length"`,
|
||||||
`"?bad wuffs version"`,
|
`"#bad wuffs version"`,
|
||||||
`"?cannot return a suspension"`,
|
`"#cannot return a suspension"`,
|
||||||
`"?disabled by previous error"`,
|
`"#disabled by previous error"`,
|
||||||
`"?initialize falsely claimed already zeroed"`,
|
`"#initialize falsely claimed already zeroed"`,
|
||||||
`"?initialize not called"`,
|
`"#initialize not called"`,
|
||||||
`"?interleaved coroutine calls"`,
|
`"#interleaved coroutine calls"`,
|
||||||
`"?not enough data"`,
|
`"#not enough data"`,
|
||||||
`"?too much data"`,
|
`"#too much data"`,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: a collection of forbidden variable names like and, or, not, as, ref,
|
// TODO: a collection of forbidden variable names like and, or, not, as, ref,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func init() {
|
|||||||
|
|
||||||
func isErrorStatus(literal t.ID, tm *t.Map) bool {
|
func isErrorStatus(literal t.ID, tm *t.Map) bool {
|
||||||
s := literal.Str(tm)
|
s := literal.Str(tm)
|
||||||
return (len(s) >= 2) && (s[0] == '"') && (s[1] == '?')
|
return (len(s) >= 2) && (s[0] == '"') && (s[1] == '#')
|
||||||
}
|
}
|
||||||
|
|
||||||
func btoi(b bool) *big.Int {
|
func btoi(b bool) *big.Int {
|
||||||
|
|||||||
@@ -190,12 +190,12 @@ extern const char* wuffs_base__error__too_much_data;
|
|||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_complete(wuffs_base__status z) {
|
wuffs_base__status__is_complete(wuffs_base__status z) {
|
||||||
return (z == NULL) || ((*z != '$') && (*z != '?'));
|
return (z == NULL) || ((*z != '$') && (*z != '#'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_error(wuffs_base__status z) {
|
wuffs_base__status__is_error(wuffs_base__status z) {
|
||||||
return z && (*z == '?');
|
return z && (*z == '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
@@ -210,7 +210,7 @@ wuffs_base__status__is_suspension(wuffs_base__status z) {
|
|||||||
|
|
||||||
static inline bool //
|
static inline bool //
|
||||||
wuffs_base__status__is_warning(wuffs_base__status z) {
|
wuffs_base__status__is_warning(wuffs_base__status z) {
|
||||||
return z && (*z != '$') && (*z != '?');
|
return z && (*z != '$') && (*z != '#');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
@@ -4787,27 +4787,27 @@ const char* wuffs_base__warning__end_of_data = "~base: end of data";
|
|||||||
const char* wuffs_base__suspension__short_read = "$base: short read";
|
const char* wuffs_base__suspension__short_read = "$base: short read";
|
||||||
const char* wuffs_base__suspension__short_write = "$base: short write";
|
const char* wuffs_base__suspension__short_write = "$base: short write";
|
||||||
const char* wuffs_base__error__bad_argument_length_too_short =
|
const char* wuffs_base__error__bad_argument_length_too_short =
|
||||||
"?base: 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_argument = "#base: bad argument";
|
||||||
const char* wuffs_base__error__bad_call_sequence = "?base: bad call sequence";
|
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_receiver = "#base: bad receiver";
|
||||||
const char* wuffs_base__error__bad_restart = "?base: bad restart";
|
const char* wuffs_base__error__bad_restart = "#base: bad restart";
|
||||||
const char* wuffs_base__error__bad_sizeof_receiver =
|
const char* wuffs_base__error__bad_sizeof_receiver =
|
||||||
"?base: bad sizeof receiver";
|
"#base: bad sizeof receiver";
|
||||||
const char* wuffs_base__error__bad_workbuf_length = "?base: bad workbuf length";
|
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__bad_wuffs_version = "#base: bad wuffs version";
|
||||||
const char* wuffs_base__error__cannot_return_a_suspension =
|
const char* wuffs_base__error__cannot_return_a_suspension =
|
||||||
"?base: cannot return a suspension";
|
"#base: cannot return a suspension";
|
||||||
const char* wuffs_base__error__disabled_by_previous_error =
|
const char* wuffs_base__error__disabled_by_previous_error =
|
||||||
"?base: disabled by previous error";
|
"#base: disabled by previous error";
|
||||||
const char* wuffs_base__error__initialize_falsely_claimed_already_zeroed =
|
const char* wuffs_base__error__initialize_falsely_claimed_already_zeroed =
|
||||||
"?base: initialize falsely claimed already zeroed";
|
"#base: initialize falsely claimed already zeroed";
|
||||||
const char* wuffs_base__error__initialize_not_called =
|
const char* wuffs_base__error__initialize_not_called =
|
||||||
"?base: initialize not called";
|
"#base: initialize not called";
|
||||||
const char* wuffs_base__error__interleaved_coroutine_calls =
|
const char* wuffs_base__error__interleaved_coroutine_calls =
|
||||||
"?base: interleaved coroutine calls";
|
"#base: interleaved coroutine calls";
|
||||||
const char* wuffs_base__error__not_enough_data = "?base: not enough data";
|
const char* wuffs_base__error__not_enough_data = "#base: not enough data";
|
||||||
const char* wuffs_base__error__too_much_data = "?base: too much data";
|
const char* wuffs_base__error__too_much_data = "#base: too much data";
|
||||||
|
|
||||||
// ---------------- Images
|
// ---------------- Images
|
||||||
|
|
||||||
@@ -6150,38 +6150,38 @@ wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
|||||||
// ---------------- Status Codes Implementations
|
// ---------------- Status Codes Implementations
|
||||||
|
|
||||||
const char* wuffs_deflate__error__bad_huffman_code_over_subscribed =
|
const char* wuffs_deflate__error__bad_huffman_code_over_subscribed =
|
||||||
"?deflate: bad Huffman code (over-subscribed)";
|
"#deflate: bad Huffman code (over-subscribed)";
|
||||||
const char* wuffs_deflate__error__bad_huffman_code_under_subscribed =
|
const char* wuffs_deflate__error__bad_huffman_code_under_subscribed =
|
||||||
"?deflate: bad Huffman code (under-subscribed)";
|
"#deflate: bad Huffman code (under-subscribed)";
|
||||||
const char* wuffs_deflate__error__bad_huffman_code_length_count =
|
const char* wuffs_deflate__error__bad_huffman_code_length_count =
|
||||||
"?deflate: bad Huffman code length count";
|
"#deflate: bad Huffman code length count";
|
||||||
const char* wuffs_deflate__error__bad_huffman_code_length_repetition =
|
const char* wuffs_deflate__error__bad_huffman_code_length_repetition =
|
||||||
"?deflate: bad Huffman code length repetition";
|
"#deflate: bad Huffman code length repetition";
|
||||||
const char* wuffs_deflate__error__bad_huffman_code =
|
const char* wuffs_deflate__error__bad_huffman_code =
|
||||||
"?deflate: bad Huffman code";
|
"#deflate: bad Huffman code";
|
||||||
const char* wuffs_deflate__error__bad_huffman_minimum_code_length =
|
const char* wuffs_deflate__error__bad_huffman_minimum_code_length =
|
||||||
"?deflate: 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_block = "#deflate: bad block";
|
||||||
const char* wuffs_deflate__error__bad_distance = "?deflate: bad distance";
|
const char* wuffs_deflate__error__bad_distance = "#deflate: bad distance";
|
||||||
const char* wuffs_deflate__error__bad_distance_code_count =
|
const char* wuffs_deflate__error__bad_distance_code_count =
|
||||||
"?deflate: bad distance code count";
|
"#deflate: bad distance code count";
|
||||||
const char* wuffs_deflate__error__bad_literal_length_code_count =
|
const char* wuffs_deflate__error__bad_literal_length_code_count =
|
||||||
"?deflate: bad literal/length code count";
|
"#deflate: bad literal/length code count";
|
||||||
const char* wuffs_deflate__error__inconsistent_stored_block_length =
|
const char* wuffs_deflate__error__inconsistent_stored_block_length =
|
||||||
"?deflate: inconsistent stored block length";
|
"#deflate: inconsistent stored block length";
|
||||||
const char* wuffs_deflate__error__missing_end_of_block_code =
|
const char* wuffs_deflate__error__missing_end_of_block_code =
|
||||||
"?deflate: missing end-of-block code";
|
"#deflate: missing end-of-block code";
|
||||||
const char* wuffs_deflate__error__no_huffman_codes =
|
const char* wuffs_deflate__error__no_huffman_codes =
|
||||||
"?deflate: no Huffman codes";
|
"#deflate: no Huffman codes";
|
||||||
const char*
|
const char*
|
||||||
wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state =
|
wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state =
|
||||||
"?deflate: internal error: inconsistent Huffman decoder state";
|
"#deflate: internal error: inconsistent Huffman decoder state";
|
||||||
const char* wuffs_deflate__error__internal_error_inconsistent_i_o =
|
const char* wuffs_deflate__error__internal_error_inconsistent_i_o =
|
||||||
"?deflate: internal error: inconsistent I/O";
|
"#deflate: internal error: inconsistent I/O";
|
||||||
const char* wuffs_deflate__error__internal_error_inconsistent_distance =
|
const char* wuffs_deflate__error__internal_error_inconsistent_distance =
|
||||||
"?deflate: internal error: inconsistent distance";
|
"#deflate: internal error: inconsistent distance";
|
||||||
const char* wuffs_deflate__error__internal_error_inconsistent_n_bits =
|
const char* wuffs_deflate__error__internal_error_inconsistent_n_bits =
|
||||||
"?deflate: internal error: inconsistent n_bits";
|
"#deflate: internal error: inconsistent n_bits";
|
||||||
|
|
||||||
// ---------------- Private Consts
|
// ---------------- Private Consts
|
||||||
|
|
||||||
@@ -8068,9 +8068,9 @@ exit:
|
|||||||
|
|
||||||
// ---------------- Status Codes Implementations
|
// ---------------- Status Codes Implementations
|
||||||
|
|
||||||
const char* wuffs_lzw__error__bad_code = "?lzw: bad code";
|
const char* wuffs_lzw__error__bad_code = "#lzw: bad code";
|
||||||
const char* wuffs_lzw__error__internal_error_inconsistent_i_o =
|
const char* wuffs_lzw__error__internal_error_inconsistent_i_o =
|
||||||
"?lzw: internal error: inconsistent I/O";
|
"#lzw: internal error: inconsistent I/O";
|
||||||
|
|
||||||
// ---------------- Private Consts
|
// ---------------- Private Consts
|
||||||
|
|
||||||
@@ -8578,13 +8578,13 @@ wuffs_lzw__decoder__flush(wuffs_lzw__decoder* self) {
|
|||||||
|
|
||||||
// ---------------- Status Codes Implementations
|
// ---------------- Status Codes Implementations
|
||||||
|
|
||||||
const char* wuffs_gif__error__bad_block = "?gif: bad block";
|
const char* wuffs_gif__error__bad_block = "#gif: bad block";
|
||||||
const char* wuffs_gif__error__bad_extension_label = "?gif: bad extension label";
|
const char* wuffs_gif__error__bad_extension_label = "#gif: bad extension label";
|
||||||
const char* wuffs_gif__error__bad_graphic_control = "?gif: bad graphic control";
|
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_header = "#gif: bad header";
|
||||||
const char* wuffs_gif__error__bad_literal_width = "?gif: bad literal width";
|
const char* wuffs_gif__error__bad_literal_width = "#gif: bad literal width";
|
||||||
const char* wuffs_gif__error__internal_error_inconsistent_ri_wi =
|
const char* wuffs_gif__error__internal_error_inconsistent_ri_wi =
|
||||||
"?gif: internal error: inconsistent ri/wi";
|
"#gif: internal error: inconsistent ri/wi";
|
||||||
|
|
||||||
// ---------------- Private Consts
|
// ---------------- Private Consts
|
||||||
|
|
||||||
@@ -10832,11 +10832,11 @@ label_0_break:;
|
|||||||
|
|
||||||
// ---------------- Status Codes Implementations
|
// ---------------- Status Codes Implementations
|
||||||
|
|
||||||
const char* wuffs_gzip__error__bad_checksum = "?gzip: bad checksum";
|
const char* wuffs_gzip__error__bad_checksum = "#gzip: bad checksum";
|
||||||
const char* wuffs_gzip__error__bad_compression_method =
|
const char* wuffs_gzip__error__bad_compression_method =
|
||||||
"?gzip: 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_encoding_flags = "#gzip: bad encoding flags";
|
||||||
const char* wuffs_gzip__error__bad_header = "?gzip: bad header";
|
const char* wuffs_gzip__error__bad_header = "#gzip: bad header";
|
||||||
|
|
||||||
// ---------------- Private Consts
|
// ---------------- Private Consts
|
||||||
|
|
||||||
@@ -11314,14 +11314,14 @@ exit:
|
|||||||
|
|
||||||
// ---------------- Status Codes Implementations
|
// ---------------- Status Codes Implementations
|
||||||
|
|
||||||
const char* wuffs_zlib__error__bad_checksum = "?zlib: bad checksum";
|
const char* wuffs_zlib__error__bad_checksum = "#zlib: bad checksum";
|
||||||
const char* wuffs_zlib__error__bad_compression_method =
|
const char* wuffs_zlib__error__bad_compression_method =
|
||||||
"?zlib: bad compression method";
|
"#zlib: bad compression method";
|
||||||
const char* wuffs_zlib__error__bad_compression_window_size =
|
const char* wuffs_zlib__error__bad_compression_window_size =
|
||||||
"?zlib: 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__bad_parity_check = "#zlib: bad parity check";
|
||||||
const char* wuffs_zlib__error__todo_unsupported_preset_dictionary =
|
const char* wuffs_zlib__error__todo_unsupported_preset_dictionary =
|
||||||
"?zlib: TODO: unsupported preset dictionary";
|
"#zlib: TODO: unsupported preset dictionary";
|
||||||
|
|
||||||
// ---------------- Private Consts
|
// ---------------- Private Consts
|
||||||
|
|
||||||
|
|||||||
@@ -12,24 +12,24 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
pub status "?bad Huffman code (over-subscribed)"
|
pub status "#bad Huffman code (over-subscribed)"
|
||||||
pub status "?bad Huffman code (under-subscribed)"
|
pub status "#bad Huffman code (under-subscribed)"
|
||||||
pub status "?bad Huffman code length count"
|
pub status "#bad Huffman code length count"
|
||||||
pub status "?bad Huffman code length repetition"
|
pub status "#bad Huffman code length repetition"
|
||||||
pub status "?bad Huffman code"
|
pub status "#bad Huffman code"
|
||||||
pub status "?bad Huffman minimum code length"
|
pub status "#bad Huffman minimum code length"
|
||||||
pub status "?bad block"
|
pub status "#bad block"
|
||||||
pub status "?bad distance"
|
pub status "#bad distance"
|
||||||
pub status "?bad distance code count"
|
pub status "#bad distance code count"
|
||||||
pub status "?bad literal/length code count"
|
pub status "#bad literal/length code count"
|
||||||
pub status "?inconsistent stored block length"
|
pub status "#inconsistent stored block length"
|
||||||
pub status "?missing end-of-block code"
|
pub status "#missing end-of-block code"
|
||||||
pub status "?no Huffman codes"
|
pub status "#no Huffman codes"
|
||||||
|
|
||||||
pri status "?internal error: inconsistent Huffman decoder state"
|
pri status "#internal error: inconsistent Huffman decoder state"
|
||||||
pri status "?internal error: inconsistent I/O"
|
pri status "#internal error: inconsistent I/O"
|
||||||
pri status "?internal error: inconsistent distance"
|
pri status "#internal error: inconsistent distance"
|
||||||
pri status "?internal error: inconsistent n_bits"
|
pri status "#internal error: inconsistent n_bits"
|
||||||
|
|
||||||
// TODO: replace the placeholder 1 value with either 0 or (32768 + 512),
|
// TODO: replace the placeholder 1 value with either 0 or (32768 + 512),
|
||||||
// depending on whether we'll move decoder.history into the workbuf.
|
// depending on whether we'll move decoder.history into the workbuf.
|
||||||
@@ -228,7 +228,7 @@ pri func decoder.decode_blocks?(dst base.io_writer, src base.io_reader) {
|
|||||||
} else if type == 2 {
|
} else if type == 2 {
|
||||||
this.init_dynamic_huffman?(src:args.src)
|
this.init_dynamic_huffman?(src:args.src)
|
||||||
} else {
|
} else {
|
||||||
return "?bad block"
|
return "#bad block"
|
||||||
}
|
}
|
||||||
|
|
||||||
this.end_of_block = false
|
this.end_of_block = false
|
||||||
@@ -258,14 +258,14 @@ pri func decoder.decode_uncompressed?(dst base.io_writer, src base.io_reader) {
|
|||||||
//
|
//
|
||||||
// Ditto for decode_huffman_slow and decode_huffman_fast.
|
// Ditto for decode_huffman_slow and decode_huffman_fast.
|
||||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||||
return "?internal error: inconsistent n_bits"
|
return "#internal error: inconsistent n_bits"
|
||||||
}
|
}
|
||||||
this.n_bits = 0
|
this.n_bits = 0
|
||||||
this.bits = 0
|
this.bits = 0
|
||||||
|
|
||||||
length = args.src.read_u32le?()
|
length = args.src.read_u32le?()
|
||||||
if (length.low_bits(n:16) + length.high_bits(n:16)) != 0xFFFF {
|
if (length.low_bits(n:16) + length.high_bits(n:16)) != 0xFFFF {
|
||||||
return "?inconsistent stored block length"
|
return "#inconsistent stored block length"
|
||||||
}
|
}
|
||||||
length = length.low_bits(n:16)
|
length = length.low_bits(n:16)
|
||||||
while true {
|
while true {
|
||||||
@@ -350,12 +350,12 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
}
|
}
|
||||||
n_lit = bits.low_bits(n:5) + 257
|
n_lit = bits.low_bits(n:5) + 257
|
||||||
if n_lit > 286 {
|
if n_lit > 286 {
|
||||||
return "?bad literal/length code count"
|
return "#bad literal/length code count"
|
||||||
}
|
}
|
||||||
bits >>= 5
|
bits >>= 5
|
||||||
n_dist = bits.low_bits(n:5) + 1
|
n_dist = bits.low_bits(n:5) + 1
|
||||||
if n_dist > 30 {
|
if n_dist > 30 {
|
||||||
return "?bad distance code count"
|
return "#bad distance code count"
|
||||||
}
|
}
|
||||||
bits >>= 5
|
bits >>= 5
|
||||||
n_clen = bits.low_bits(n:4) + 4
|
n_clen = bits.low_bits(n:4) + 4
|
||||||
@@ -413,7 +413,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
// For H-CL, there should be no redirections and all symbols should be
|
// For H-CL, there should be no redirections and all symbols should be
|
||||||
// literals.
|
// literals.
|
||||||
if (table_entry >> 24) != 0x80 {
|
if (table_entry >> 24) != 0x80 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
table_entry = (table_entry >> 8) & 0xFF
|
table_entry = (table_entry >> 8) & 0xFF
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
if table_entry == 16 {
|
if table_entry == 16 {
|
||||||
n_extra_bits = 2
|
n_extra_bits = 2
|
||||||
if i <= 0 {
|
if i <= 0 {
|
||||||
return "?bad Huffman code length repetition"
|
return "#bad Huffman code length repetition"
|
||||||
}
|
}
|
||||||
rep_symbol = this.code_lengths[i - 1] & 15
|
rep_symbol = this.code_lengths[i - 1] & 15
|
||||||
rep_count = 3
|
rep_count = 3
|
||||||
@@ -447,7 +447,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
rep_count = 11
|
rep_count = 11
|
||||||
assert rep_count <= 11
|
assert rep_count <= 11
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
while n_bits < n_extra_bits,
|
while n_bits < n_extra_bits,
|
||||||
inv i < 320,
|
inv i < 320,
|
||||||
@@ -466,7 +466,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
while rep_count > 0 {
|
while rep_count > 0 {
|
||||||
// TODO: hoist this check up one level?
|
// TODO: hoist this check up one level?
|
||||||
if i >= (n_lit + n_dist) {
|
if i >= (n_lit + n_dist) {
|
||||||
return "?bad Huffman code length count"
|
return "#bad Huffman code length count"
|
||||||
}
|
}
|
||||||
assert i < (288 + 32) via "a < (b + c): a < (b0 + c0); b0 <= b; c0 <= c"(b0:n_lit, c0:n_dist)
|
assert i < (288 + 32) via "a < (b + c): a < (b0 + c0); b0 <= b; c0 <= c"(b0:n_lit, c0:n_dist)
|
||||||
this.code_lengths[i] = rep_symbol
|
this.code_lengths[i] = rep_symbol
|
||||||
@@ -476,10 +476,10 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if i != (n_lit + n_dist) {
|
if i != (n_lit + n_dist) {
|
||||||
return "?bad Huffman code length count"
|
return "#bad Huffman code length count"
|
||||||
}
|
}
|
||||||
if this.code_lengths[256] == 0 {
|
if this.code_lengths[256] == 0 {
|
||||||
return "?missing end-of-block code"
|
return "#missing end-of-block code"
|
||||||
}
|
}
|
||||||
|
|
||||||
status = this.init_huff!(which:0, n_codes0:0, n_codes1:n_lit, base_symbol:257)
|
status = this.init_huff!(which:0, n_codes0:0, n_codes1:n_lit, base_symbol:257)
|
||||||
@@ -562,13 +562,13 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
// TODO: this if should be unnecessary. Have some way to assert that,
|
// TODO: this if should be unnecessary. Have some way to assert that,
|
||||||
// for all j, counts[j] <= i, and thus counts[j]++ will not overflow.
|
// for all j, counts[j] <= i, and thus counts[j]++ will not overflow.
|
||||||
if counts[this.code_lengths[i] & 15] >= 320 {
|
if counts[this.code_lengths[i] & 15] >= 320 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
counts[this.code_lengths[i] & 15] += 1
|
counts[this.code_lengths[i] & 15] += 1
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
if ((counts[0] as base.u32) + args.n_codes0) == args.n_codes1 {
|
if ((counts[0] as base.u32) + args.n_codes0) == args.n_codes1 {
|
||||||
return "?no Huffman codes"
|
return "#no Huffman codes"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the Huffman code completely covers all possible input bits.
|
// Check that the Huffman code completely covers all possible input bits.
|
||||||
@@ -576,19 +576,19 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
i = 1
|
i = 1
|
||||||
while i <= 15 {
|
while i <= 15 {
|
||||||
if remaining > (1 << 30) {
|
if remaining > (1 << 30) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
// Each iteration doubles the number of possible remaining codes.
|
// Each iteration doubles the number of possible remaining codes.
|
||||||
remaining <<= 1
|
remaining <<= 1
|
||||||
if remaining < (counts[i] as base.u32) {
|
if remaining < (counts[i] as base.u32) {
|
||||||
return "?bad Huffman code (over-subscribed)"
|
return "#bad Huffman code (over-subscribed)"
|
||||||
}
|
}
|
||||||
remaining -= counts[i] as base.u32
|
remaining -= counts[i] as base.u32
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
if remaining != 0 {
|
if remaining != 0 {
|
||||||
// TODO: when is a degenerate Huffman table valid?
|
// TODO: when is a degenerate Huffman table valid?
|
||||||
return "?bad Huffman code (under-subscribed)"
|
return "#bad Huffman code (under-subscribed)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate offsets and n_symbols.
|
// Calculate offsets and n_symbols.
|
||||||
@@ -608,7 +608,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
offsets[i] = n_symbols as base.u16
|
offsets[i] = n_symbols as base.u16
|
||||||
count = counts[i] as base.u32
|
count = counts[i] as base.u32
|
||||||
if n_symbols > (320 - count) {
|
if n_symbols > (320 - count) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (n_symbols + count) <= 320 via "(a + b) <= c: a <= (c - b)"()
|
assert (n_symbols + count) <= 320 via "(a + b) <= c: a <= (c - b)"()
|
||||||
// TODO: change this to n_symbols += count, once the proof engine's
|
// TODO: change this to n_symbols += count, once the proof engine's
|
||||||
@@ -617,7 +617,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
if n_symbols > 288 {
|
if n_symbols > 288 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate symbols.
|
// Calculate symbols.
|
||||||
@@ -645,11 +645,11 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
assert i < 320 via "a < b: a < c; c <= b"(c:args.n_codes1)
|
assert i < 320 via "a < b: a < c; c <= b"(c:args.n_codes1)
|
||||||
// TODO: this if check should be unnecessary.
|
// TODO: this if check should be unnecessary.
|
||||||
if i < args.n_codes0 {
|
if i < args.n_codes0 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
if this.code_lengths[i] != 0 {
|
if this.code_lengths[i] != 0 {
|
||||||
if offsets[this.code_lengths[i] & 15] >= 320 {
|
if offsets[this.code_lengths[i] & 15] >= 320 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
symbols[offsets[this.code_lengths[i] & 15]] = (i - args.n_codes0) as base.u16
|
symbols[offsets[this.code_lengths[i] & 15]] = (i - args.n_codes0) as base.u16
|
||||||
offsets[this.code_lengths[i] & 15] += 1
|
offsets[this.code_lengths[i] & 15] += 1
|
||||||
@@ -670,7 +670,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if min_cl >= 9 {
|
if min_cl >= 9 {
|
||||||
return "?bad Huffman minimum code length"
|
return "#bad Huffman minimum code length"
|
||||||
}
|
}
|
||||||
min_cl += 1
|
min_cl += 1
|
||||||
}
|
}
|
||||||
@@ -683,7 +683,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
}
|
}
|
||||||
if max_cl <= 1 {
|
if max_cl <= 1 {
|
||||||
// TODO: when is a degenerate Huffman table valid?
|
// TODO: when is a degenerate Huffman table valid?
|
||||||
return "?no Huffman codes"
|
return "#no Huffman codes"
|
||||||
}
|
}
|
||||||
max_cl -= 1
|
max_cl -= 1
|
||||||
}
|
}
|
||||||
@@ -708,10 +708,10 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
// - this.huffs[0][0b11111] = 0x80001805 (literal, symbols[9]=0x18, code_length=5)
|
// - this.huffs[0][0b11111] = 0x80001805 (literal, symbols[9]=0x18, code_length=5)
|
||||||
i = 0
|
i = 0
|
||||||
if (n_symbols != (offsets[max_cl] as base.u32)) or (n_symbols != (offsets[15] as base.u32)) {
|
if (n_symbols != (offsets[max_cl] as base.u32)) or (n_symbols != (offsets[15] as base.u32)) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
if (args.n_codes0 + (symbols[0] as base.u32)) >= 320 {
|
if (args.n_codes0 + (symbols[0] as base.u32)) >= 320 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
initial_high_bits = 1 << 9
|
initial_high_bits = 1 << 9
|
||||||
@@ -731,13 +731,13 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
inv n_symbols <= 288,
|
inv n_symbols <= 288,
|
||||||
{
|
{
|
||||||
if (args.n_codes0 + (symbols[i] as base.u32)) >= 320 {
|
if (args.n_codes0 + (symbols[i] as base.u32)) >= 320 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
cl = (this.code_lengths[args.n_codes0 + (symbols[i] as base.u32)] & 15) as base.u32
|
cl = (this.code_lengths[args.n_codes0 + (symbols[i] as base.u32)] & 15) as base.u32
|
||||||
if cl > prev_cl {
|
if cl > prev_cl {
|
||||||
code <<= cl - prev_cl
|
code <<= cl - prev_cl
|
||||||
if code >= (1 << 15) {
|
if code >= (1 << 15) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// For the remainder of this loop body, prev_cl is the original code
|
// For the remainder of this loop body, prev_cl is the original code
|
||||||
@@ -770,20 +770,20 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
}
|
}
|
||||||
remaining -= counts[j] as base.u32
|
remaining -= counts[j] as base.u32
|
||||||
if remaining > (1 << 30) {
|
if remaining > (1 << 30) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
remaining <<= 1
|
remaining <<= 1
|
||||||
j += 1
|
j += 1
|
||||||
}
|
}
|
||||||
if (j <= 9) or (15 < j) {
|
if (j <= 9) or (15 < j) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
j -= 9
|
j -= 9
|
||||||
initial_high_bits = (1 as base.u32) << j
|
initial_high_bits = (1 as base.u32) << j
|
||||||
|
|
||||||
top = next_top
|
top = next_top
|
||||||
if (top + ((1 as base.u32) << j)) > huffs_table_size {
|
if (top + ((1 as base.u32) << j)) > huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (top + ((1 as base.u32) << j)) <= 1024 via "a <= b: a <= c; c <= b"(c:huffs_table_size)
|
assert (top + ((1 as base.u32) << j)) <= 1024 via "a <= b: a <= c; c <= b"(c:huffs_table_size)
|
||||||
next_top = top + ((1 as base.u32) << j)
|
next_top = top + ((1 as base.u32) << j)
|
||||||
@@ -793,7 +793,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key >= (1 << 9)) or (counts[prev_cl] <= 0) {
|
if (key >= (1 << 9)) or (counts[prev_cl] <= 0) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
counts[prev_cl] -= 1
|
counts[prev_cl] -= 1
|
||||||
|
|
||||||
@@ -816,7 +816,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
value = dcode_magic_numbers[symbol & 31] | cl
|
value = dcode_magic_numbers[symbol & 31] | cl
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// The table uses log2(initial_high_bits) bits, but reversed_key only
|
// The table uses log2(initial_high_bits) bits, but reversed_key only
|
||||||
@@ -831,7 +831,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
{
|
{
|
||||||
high_bits -= delta
|
high_bits -= delta
|
||||||
if (top + ((high_bits | reversed_key) & 511)) >= huffs_table_size {
|
if (top + ((high_bits | reversed_key) & 511)) >= huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (top + ((high_bits | reversed_key) & 511)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
assert (top + ((high_bits | reversed_key) & 511)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||||
this.huffs[args.which][top + ((high_bits | reversed_key) & 511)] = value
|
this.huffs[args.which][top + ((high_bits | reversed_key) & 511)] = value
|
||||||
@@ -844,7 +844,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
|||||||
assert i < 288 via "a < b: a < c; c <= b"(c:n_symbols)
|
assert i < 288 via "a < b: a < c; c <= b"(c:n_symbols)
|
||||||
code += 1
|
code += 1
|
||||||
if code >= (1 << 15) {
|
if code >= (1 << 15) {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok
|
return ok
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
var hdist base.u32
|
var hdist base.u32
|
||||||
|
|
||||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||||
return "?internal error: inconsistent n_bits"
|
return "#internal error: inconsistent n_bits"
|
||||||
}
|
}
|
||||||
|
|
||||||
bits = this.bits
|
bits = this.bits
|
||||||
@@ -131,7 +131,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
redir_top = (table_entry >> 8) & 0xFFFF
|
redir_top = (table_entry >> 8) & 0xFFFF
|
||||||
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
||||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||||
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
||||||
@@ -150,20 +150,20 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
this.end_of_block = true
|
this.end_of_block = true
|
||||||
break:loop
|
break:loop
|
||||||
} else if (table_entry >> 28) != 0 {
|
} else if (table_entry >> 28) != 0 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
} else if (table_entry >> 27) != 0 {
|
} else if (table_entry >> 27) != 0 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once again, redundant but explicit assertions.
|
// Once again, redundant but explicit assertions.
|
||||||
assert args.src.available() >= 8
|
assert args.src.available() >= 8
|
||||||
|
|
||||||
} else if (table_entry >> 27) != 0 {
|
} else if (table_entry >> 27) != 0 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// length = base_number_minus_3 + 3 + extra_bits.
|
// length = base_number_minus_3 + 3 + extra_bits.
|
||||||
@@ -245,7 +245,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
redir_top = (table_entry >> 8) & 0xFFFF
|
redir_top = (table_entry >> 8) & 0xFFFF
|
||||||
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
||||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||||
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
||||||
@@ -259,9 +259,9 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
// For H-D, all symbols should be base_number + extra_bits.
|
// For H-D, all symbols should be base_number + extra_bits.
|
||||||
if (table_entry >> 24) != 0x40 {
|
if (table_entry >> 24) != 0x40 {
|
||||||
if (table_entry >> 24) == 0x08 {
|
if (table_entry >> 24) == 0x08 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
}
|
}
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// dist_minus_1 = base_number_minus_1 + extra_bits.
|
// dist_minus_1 = base_number_minus_1 + extra_bits.
|
||||||
@@ -316,7 +316,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
length = 0
|
length = 0
|
||||||
}
|
}
|
||||||
if this.history_index < hdist {
|
if this.history_index < hdist {
|
||||||
return "?bad distance"
|
return "#bad distance"
|
||||||
}
|
}
|
||||||
// Re-purpose the hdist variable as the this.history index to
|
// Re-purpose the hdist variable as the this.history index to
|
||||||
// start copying from.
|
// start copying from.
|
||||||
@@ -354,7 +354,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((dist_minus_1 + 1) as base.u64) > args.dst.since_mark().length() {
|
if ((dist_minus_1 + 1) as base.u64) > args.dst.since_mark().length() {
|
||||||
return "?internal error: inconsistent distance"
|
return "#internal error: inconsistent distance"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Once again, redundant but explicit assertions.
|
// Once again, redundant but explicit assertions.
|
||||||
@@ -389,7 +389,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
if args.src.can_undo_byte() {
|
if args.src.can_undo_byte() {
|
||||||
args.src.undo_byte!()
|
args.src.undo_byte!()
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +397,6 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
|||||||
this.n_bits = n_bits
|
this.n_bits = n_bits
|
||||||
|
|
||||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||||
return "?internal error: inconsistent n_bits"
|
return "#internal error: inconsistent n_bits"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
// correctness and performance.
|
// correctness and performance.
|
||||||
|
|
||||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||||
return "?internal error: inconsistent n_bits"
|
return "#internal error: inconsistent n_bits"
|
||||||
}
|
}
|
||||||
|
|
||||||
bits = this.bits
|
bits = this.bits
|
||||||
@@ -80,7 +80,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
||||||
while true {
|
while true {
|
||||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||||
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
||||||
@@ -107,17 +107,17 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
this.end_of_block = true
|
this.end_of_block = true
|
||||||
break:loop
|
break:loop
|
||||||
} else if (table_entry >> 28) != 0 {
|
} else if (table_entry >> 28) != 0 {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
} else if (table_entry >> 27) != 0 {
|
} else if (table_entry >> 27) != 0 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (table_entry >> 27) != 0 {
|
} else if (table_entry >> 27) != 0 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// length = base_number_minus_3 + 3 + extra_bits.
|
// length = base_number_minus_3 + 3 + extra_bits.
|
||||||
@@ -162,7 +162,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
redir_mask = ((1 as base.u32) << ((table_entry >> 4) & 0x0F)) - 1
|
||||||
while true {
|
while true {
|
||||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||||
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
||||||
@@ -182,9 +182,9 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
// For H-D, all symbols should be base_number + extra_bits.
|
// For H-D, all symbols should be base_number + extra_bits.
|
||||||
if (table_entry >> 24) != 0x40 {
|
if (table_entry >> 24) != 0x40 {
|
||||||
if (table_entry >> 24) == 0x08 {
|
if (table_entry >> 24) == 0x08 {
|
||||||
return "?bad Huffman code"
|
return "#bad Huffman code"
|
||||||
}
|
}
|
||||||
return "?internal error: inconsistent Huffman decoder state"
|
return "#internal error: inconsistent Huffman decoder state"
|
||||||
}
|
}
|
||||||
|
|
||||||
// dist_minus_1 = base_number_minus_1 + extra_bits.
|
// dist_minus_1 = base_number_minus_1 + extra_bits.
|
||||||
@@ -226,7 +226,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
length = 0
|
length = 0
|
||||||
}
|
}
|
||||||
if this.history_index < hdist {
|
if this.history_index < hdist {
|
||||||
return "?bad distance"
|
return "#bad distance"
|
||||||
}
|
}
|
||||||
// Re-purpose the hdist variable as the this.history index to
|
// Re-purpose the hdist variable as the this.history index to
|
||||||
// start copying from.
|
// start copying from.
|
||||||
@@ -288,6 +288,6 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
|||||||
this.n_bits = n_bits
|
this.n_bits = n_bits
|
||||||
|
|
||||||
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
if (this.n_bits >= 8) or ((this.bits >> (this.n_bits & 7)) != 0) {
|
||||||
return "?internal error: inconsistent n_bits"
|
return "#internal error: inconsistent n_bits"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+21
-21
@@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
use "std/lzw"
|
use "std/lzw"
|
||||||
|
|
||||||
pub status "?bad block"
|
pub status "#bad block"
|
||||||
pub status "?bad extension label"
|
pub status "#bad extension label"
|
||||||
pub status "?bad graphic control"
|
pub status "#bad graphic control"
|
||||||
pub status "?bad header"
|
pub status "#bad header"
|
||||||
pub status "?bad literal width"
|
pub status "#bad literal width"
|
||||||
|
|
||||||
pri status "?internal error: inconsistent ri/wi"
|
pri status "#internal error: inconsistent ri/wi"
|
||||||
|
|
||||||
// TODO: replace the placeholder 1 value with either 0 or 0xFFFF (plus
|
// TODO: replace the placeholder 1 value with either 0 or 0xFFFF (plus
|
||||||
// lzw.decoder_workbuf_len_max_incl_worst_case), depending on whether we'll
|
// lzw.decoder_workbuf_len_max_incl_worst_case), depending on whether we'll
|
||||||
@@ -131,7 +131,7 @@ pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_re
|
|||||||
var ffio base.bool
|
var ffio base.bool
|
||||||
|
|
||||||
if this.call_sequence >= 1 {
|
if this.call_sequence >= 1 {
|
||||||
return base."?bad call sequence"
|
return base."#bad call sequence"
|
||||||
}
|
}
|
||||||
|
|
||||||
this.decode_header?(src:args.src)
|
this.decode_header?(src:args.src)
|
||||||
@@ -198,7 +198,7 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
|
|||||||
|
|
||||||
pub func decoder.restart_frame!(index base.u64, io_position base.u64) base.status {
|
pub func decoder.restart_frame!(index base.u64, io_position base.u64) base.status {
|
||||||
if this.call_sequence == 0 {
|
if this.call_sequence == 0 {
|
||||||
return base."?bad call sequence"
|
return base."#bad call sequence"
|
||||||
}
|
}
|
||||||
this.end_of_data = false
|
this.end_of_data = false
|
||||||
this.restarted = true
|
this.restarted = true
|
||||||
@@ -299,7 +299,7 @@ pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
|
|||||||
if not this.restarted {
|
if not this.restarted {
|
||||||
this.frame_config_io_position = args.src.position()
|
this.frame_config_io_position = args.src.position()
|
||||||
} else if this.frame_config_io_position != args.src.position() {
|
} else if this.frame_config_io_position != args.src.position() {
|
||||||
return base."?bad restart"
|
return base."#bad restart"
|
||||||
} else {
|
} else {
|
||||||
this.restarted = false
|
this.restarted = false
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ pri func decoder.decode_up_to_id_part1?(src base.io_reader) {
|
|||||||
this.end_of_data = true
|
this.end_of_data = true
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
return "?bad block"
|
return "#bad block"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ pri func decoder.decode_header?(src base.io_reader) {
|
|||||||
}
|
}
|
||||||
if (c[0] != 0x47) or (c[1] != 0x49) or (c[2] != 0x46) or (c[3] != 0x38) or
|
if (c[0] != 0x47) or (c[1] != 0x49) or (c[2] != 0x46) or (c[3] != 0x38) or
|
||||||
((c[4] != 0x37) and (c[4] != 0x39)) or (c[5] != 0x61) {
|
((c[4] != 0x37) and (c[4] != 0x39)) or (c[5] != 0x61) {
|
||||||
return "?bad header"
|
return "#bad header"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,11 +502,11 @@ pri func decoder.decode_gc?(src base.io_reader) {
|
|||||||
var gc_duration_centiseconds base.u16
|
var gc_duration_centiseconds base.u16
|
||||||
|
|
||||||
if this.seen_graphic_control {
|
if this.seen_graphic_control {
|
||||||
return "?bad graphic control"
|
return "#bad graphic control"
|
||||||
}
|
}
|
||||||
c = args.src.read_u8?()
|
c = args.src.read_u8?()
|
||||||
if c != 4 {
|
if c != 4 {
|
||||||
return "?bad graphic control"
|
return "#bad graphic control"
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = args.src.read_u8?()
|
flags = args.src.read_u8?()
|
||||||
@@ -537,7 +537,7 @@ pri func decoder.decode_gc?(src base.io_reader) {
|
|||||||
|
|
||||||
c = args.src.read_u8?()
|
c = args.src.read_u8?()
|
||||||
if c != 0 {
|
if c != 0 {
|
||||||
return "?bad graphic control"
|
return "#bad graphic control"
|
||||||
}
|
}
|
||||||
this.seen_graphic_control = true
|
this.seen_graphic_control = true
|
||||||
}
|
}
|
||||||
@@ -663,7 +663,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
|||||||
|
|
||||||
lw = args.src.read_u8?()
|
lw = args.src.read_u8?()
|
||||||
if (lw < 2) or (8 < lw) {
|
if (lw < 2) or (8 < lw) {
|
||||||
return "?bad literal width"
|
return "#bad literal width"
|
||||||
}
|
}
|
||||||
this.lzw.set_literal_width!(lw:lw as base.u32)
|
this.lzw.set_literal_width!(lw:lw as base.u32)
|
||||||
|
|
||||||
@@ -718,12 +718,12 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if decoder_workbuf_len_max_incl_worst_case > args.workbuf.length() {
|
if decoder_workbuf_len_max_incl_worst_case > args.workbuf.length() {
|
||||||
return base."?bad workbuf length"
|
return base."#bad workbuf length"
|
||||||
}
|
}
|
||||||
|
|
||||||
while:inner true {
|
while:inner true {
|
||||||
if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) {
|
if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) {
|
||||||
return "?internal error: inconsistent ri/wi"
|
return "#internal error: inconsistent ri/wi"
|
||||||
}
|
}
|
||||||
io_bind (io:r, data:this.compressed[this.compressed_ri:this.compressed_wi]) {
|
io_bind (io:r, data:this.compressed[this.compressed_ri:this.compressed_wi]) {
|
||||||
lzw_status =? this.lzw.decode_io_writer?(
|
lzw_status =? this.lzw.decode_io_writer?(
|
||||||
@@ -764,7 +764,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
|||||||
if (this.dst_y < this.frame_rect_y1) and
|
if (this.dst_y < this.frame_rect_y1) and
|
||||||
(this.frame_rect_x0 != this.frame_rect_x1) and
|
(this.frame_rect_x0 != this.frame_rect_x1) and
|
||||||
(this.frame_rect_y0 != this.frame_rect_y1) {
|
(this.frame_rect_y0 != this.frame_rect_y1) {
|
||||||
return base."?not enough data"
|
return base."#not enough data"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -795,7 +795,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
src = args.src[src_ri:]
|
src = args.src[src_ri:]
|
||||||
|
|
||||||
if this.dst_y >= this.frame_rect_y1 {
|
if this.dst_y >= this.frame_rect_y1 {
|
||||||
return base."?too much data"
|
return base."#too much data"
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, copy from src to that part of the frame rect that is inside
|
// First, copy from src to that part of the frame rect that is inside
|
||||||
@@ -833,7 +833,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
if args.src.length() == src_ri {
|
if args.src.length() == src_ri {
|
||||||
break
|
break
|
||||||
} else if args.src.length() < src_ri {
|
} else if args.src.length() < src_ri {
|
||||||
return "?internal error: inconsistent ri/wi"
|
return "#internal error: inconsistent ri/wi"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second, skip over src for that part of the frame rect that is
|
// Second, skip over src for that part of the frame rect that is
|
||||||
@@ -857,7 +857,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if src_ri != args.src.length() {
|
if src_ri != args.src.length() {
|
||||||
return "?internal error: inconsistent ri/wi"
|
return "#internal error: inconsistent ri/wi"
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
use "std/crc32"
|
use "std/crc32"
|
||||||
use "std/deflate"
|
use "std/deflate"
|
||||||
|
|
||||||
pub status "?bad checksum"
|
pub status "#bad checksum"
|
||||||
pub status "?bad compression method"
|
pub status "#bad compression method"
|
||||||
pub status "?bad encoding flags"
|
pub status "#bad encoding flags"
|
||||||
pub status "?bad header"
|
pub status "#bad header"
|
||||||
|
|
||||||
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
|
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
|
||||||
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
|
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
|
||||||
@@ -55,15 +55,15 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
// Read the header.
|
// Read the header.
|
||||||
c = args.src.read_u8?()
|
c = args.src.read_u8?()
|
||||||
if c != 0x1F {
|
if c != 0x1F {
|
||||||
return "?bad header"
|
return "#bad header"
|
||||||
}
|
}
|
||||||
c = args.src.read_u8?()
|
c = args.src.read_u8?()
|
||||||
if c != 0x8B {
|
if c != 0x8B {
|
||||||
return "?bad header"
|
return "#bad header"
|
||||||
}
|
}
|
||||||
c = args.src.read_u8?()
|
c = args.src.read_u8?()
|
||||||
if c != 0x08 {
|
if c != 0x08 {
|
||||||
return "?bad compression method"
|
return "#bad compression method"
|
||||||
}
|
}
|
||||||
flags = args.src.read_u8?()
|
flags = args.src.read_u8?()
|
||||||
// TODO: API for returning the header's MTIME field.
|
// TODO: API for returning the header's MTIME field.
|
||||||
@@ -106,7 +106,7 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
|
|
||||||
// Reserved flags bits must be zero.
|
// Reserved flags bits must be zero.
|
||||||
if (flags & 0xE0) != 0 {
|
if (flags & 0xE0) != 0 {
|
||||||
return "?bad encoding flags"
|
return "#bad encoding flags"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode and checksum the DEFLATE-encoded payload.
|
// Decode and checksum the DEFLATE-encoded payload.
|
||||||
@@ -126,6 +126,6 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
decoded_length_want = args.src.read_u32le?()
|
decoded_length_want = args.src.read_u32le?()
|
||||||
if (not this.ignore_checksum) and
|
if (not this.ignore_checksum) and
|
||||||
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
|
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
|
||||||
return "?bad checksum"
|
return "#bad checksum"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
pub status "?bad code"
|
pub status "#bad code"
|
||||||
|
|
||||||
pri status "?internal error: inconsistent I/O"
|
pri status "#internal error: inconsistent I/O"
|
||||||
|
|
||||||
// TODO: move bulk data buffers like decoder.suffixes or decoder.output into
|
// TODO: move bulk data buffers like decoder.suffixes or decoder.output into
|
||||||
// the workbuf? The first attempt at this was a performance regression for
|
// the workbuf? The first attempt at this was a performance regression for
|
||||||
@@ -116,9 +116,9 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
} else if this.read_from_return_value == 2 {
|
} else if this.read_from_return_value == 2 {
|
||||||
yield base."$short read"
|
yield base."$short read"
|
||||||
} else if this.read_from_return_value == 3 {
|
} else if this.read_from_return_value == 3 {
|
||||||
return "?bad code"
|
return "#bad code"
|
||||||
} else {
|
} else {
|
||||||
return "?internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,7 +336,7 @@ pri func decoder.write_to?(dst base.io_writer) {
|
|||||||
|
|
||||||
while this.output_wi > 0 {
|
while this.output_wi > 0 {
|
||||||
if this.output_ri > this.output_wi {
|
if this.output_ri > this.output_wi {
|
||||||
return "?internal error: inconsistent I/O"
|
return "#internal error: inconsistent I/O"
|
||||||
}
|
}
|
||||||
s = this.output[this.output_ri:this.output_wi]
|
s = this.output[this.output_ri:this.output_wi]
|
||||||
n = args.dst.copy_from_slice!(s:s)
|
n = args.dst.copy_from_slice!(s:s)
|
||||||
|
|||||||
+10
-10
@@ -15,12 +15,12 @@
|
|||||||
use "std/adler32"
|
use "std/adler32"
|
||||||
use "std/deflate"
|
use "std/deflate"
|
||||||
|
|
||||||
pub status "?bad checksum"
|
pub status "#bad checksum"
|
||||||
pub status "?bad compression method"
|
pub status "#bad compression method"
|
||||||
pub status "?bad compression window size"
|
pub status "#bad compression window size"
|
||||||
pub status "?bad parity check"
|
pub status "#bad parity check"
|
||||||
|
|
||||||
pri status "?TODO: unsupported preset dictionary"
|
pri status "#TODO: unsupported preset dictionary"
|
||||||
|
|
||||||
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
|
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
|
||||||
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
|
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
|
||||||
@@ -52,16 +52,16 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
|
|
||||||
x = args.src.read_u16be?()
|
x = args.src.read_u16be?()
|
||||||
if ((x >> 8) & 0x0F) != 0x08 {
|
if ((x >> 8) & 0x0F) != 0x08 {
|
||||||
return "?bad compression method"
|
return "#bad compression method"
|
||||||
}
|
}
|
||||||
if (x >> 12) > 0x07 {
|
if (x >> 12) > 0x07 {
|
||||||
return "?bad compression window size"
|
return "#bad compression window size"
|
||||||
}
|
}
|
||||||
if (x & 0x20) != 0 {
|
if (x & 0x20) != 0 {
|
||||||
return "?TODO: unsupported preset dictionary"
|
return "#TODO: unsupported preset dictionary"
|
||||||
}
|
}
|
||||||
if (x % 31) != 0 {
|
if (x % 31) != 0 {
|
||||||
return "?bad parity check"
|
return "#bad parity check"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode and checksum the DEFLATE-encoded payload.
|
// Decode and checksum the DEFLATE-encoded payload.
|
||||||
@@ -78,6 +78,6 @@ pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workb
|
|||||||
}
|
}
|
||||||
checksum_want = args.src.read_u32be?()
|
checksum_want = args.src.read_u32be?()
|
||||||
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
|
if (not this.ignore_checksum) and (checksum_got != checksum_want) {
|
||||||
return "?bad checksum"
|
return "#bad checksum"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -141,7 +141,7 @@ const char* test_basic_status_is_error() {
|
|||||||
const char* test_basic_status_strings() {
|
const char* test_basic_status_strings() {
|
||||||
CHECK_FOCUS(__func__);
|
CHECK_FOCUS(__func__);
|
||||||
const char* s1 = wuffs_base__error__bad_wuffs_version;
|
const char* s1 = wuffs_base__error__bad_wuffs_version;
|
||||||
const char* t1 = "?base: bad wuffs version";
|
const char* t1 = "#base: bad wuffs version";
|
||||||
if (strcmp(s1, t1)) {
|
if (strcmp(s1, t1)) {
|
||||||
RETURN_FAIL("got \"%s\", want \"%s\"", s1, t1);
|
RETURN_FAIL("got \"%s\", want \"%s\"", s1, t1);
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ const char* test_basic_status_strings() {
|
|||||||
RETURN_FAIL("got \"%s\", want \"%s\"", s2, t2);
|
RETURN_FAIL("got \"%s\", want \"%s\"", s2, t2);
|
||||||
}
|
}
|
||||||
const char* s3 = wuffs_gif__error__bad_header;
|
const char* s3 = wuffs_gif__error__bad_header;
|
||||||
const char* t3 = "?gif: bad header";
|
const char* t3 = "#gif: bad header";
|
||||||
if (strcmp(s3, t3)) {
|
if (strcmp(s3, t3)) {
|
||||||
RETURN_FAIL("got \"%s\", want \"%s\"", s3, t3);
|
RETURN_FAIL("got \"%s\", want \"%s\"", s3, t3);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ const char* test_basic_status_used_package() {
|
|||||||
// The function call here is from "std/gif" but the argument is from
|
// The function call here is from "std/gif" but the argument is from
|
||||||
// "std/lzw". The former package depends on the latter.
|
// "std/lzw". The former package depends on the latter.
|
||||||
const char* s0 = wuffs_lzw__error__bad_code;
|
const char* s0 = wuffs_lzw__error__bad_code;
|
||||||
const char* t0 = "?lzw: bad code";
|
const char* t0 = "#lzw: bad code";
|
||||||
if (strcmp(s0, t0)) {
|
if (strcmp(s0, t0)) {
|
||||||
RETURN_FAIL("got \"%s\", want \"%s\"", s0, t0);
|
RETURN_FAIL("got \"%s\", want \"%s\"", s0, t0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user