diff options
Diffstat (limited to 'third_party/brotli/dec/transform.h')
-rw-r--r-- | third_party/brotli/dec/transform.h | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/third_party/brotli/dec/transform.h b/third_party/brotli/dec/transform.h index f47eeb4..8c08f3f 100644 --- a/third_party/brotli/dec/transform.h +++ b/third_party/brotli/dec/transform.h @@ -9,8 +9,6 @@ #ifndef BROTLI_DEC_TRANSFORM_H_ #define BROTLI_DEC_TRANSFORM_H_ -#include <stdio.h> -#include <ctype.h> #include "./port.h" #include "./types.h" @@ -19,27 +17,27 @@ extern "C" { #endif enum WordTransformType { - kIdentity = 0, - kOmitLast1 = 1, - kOmitLast2 = 2, - kOmitLast3 = 3, - kOmitLast4 = 4, - kOmitLast5 = 5, - kOmitLast6 = 6, - kOmitLast7 = 7, - kOmitLast8 = 8, - kOmitLast9 = 9, + kIdentity = 0, + kOmitLast1 = 1, + kOmitLast2 = 2, + kOmitLast3 = 3, + kOmitLast4 = 4, + kOmitLast5 = 5, + kOmitLast6 = 6, + kOmitLast7 = 7, + kOmitLast8 = 8, + kOmitLast9 = 9, kUppercaseFirst = 10, - kUppercaseAll = 11, - kOmitFirst1 = 12, - kOmitFirst2 = 13, - kOmitFirst3 = 14, - kOmitFirst4 = 15, - kOmitFirst5 = 16, - kOmitFirst6 = 17, - kOmitFirst7 = 18, - kOmitFirst8 = 19, - kOmitFirst9 = 20 + kUppercaseAll = 11, + kOmitFirst1 = 12, + kOmitFirst2 = 13, + kOmitFirst3 = 14, + kOmitFirst4 = 15, + kOmitFirst5 = 16, + kOmitFirst6 = 17, + kOmitFirst7 = 18, + kOmitFirst8 = 19, + kOmitFirst9 = 20 }; typedef struct { @@ -68,15 +66,15 @@ enum { kPFix_SP = 1, kPFix_COMMASP = 3, kPFix_SPofSPtheSP = 6, - kPFix_SPtheSP = 9, + kPFix_SPtheSP = 9, kPFix_eSP = 12, - kPFix_SPofSP = 15, + kPFix_SPofSP = 15, kPFix_sSP = 20, kPFix_DOT = 23, kPFix_SPandSP = 25, kPFix_SPinSP = 31, kPFix_DQUOT = 36, - kPFix_SPtoSP = 38, + kPFix_SPtoSP = 38, kPFix_DQUOTGT = 43, kPFix_NEWLINE = 46, kPFix_DOTSP = 48, @@ -86,20 +84,20 @@ enum { kPFix_SPthatSP = 63, kPFix_SQUOT = 70, kPFix_SPwithSP = 72, - kPFix_SPfromSP = 79, - kPFix_SPbySP = 86, + kPFix_SPfromSP = 79, + kPFix_SPbySP = 86, kPFix_OPEN = 91, kPFix_DOTSPTheSP = 93, - kPFix_SPonSP = 100, - kPFix_SPasSP = 105, - kPFix_SPisSP = 110, + kPFix_SPonSP = 100, + kPFix_SPasSP = 105, + kPFix_SPisSP = 110, kPFix_ingSP = 115, kPFix_NEWLINETAB = 120, kPFix_COLON = 123, kPFix_edSP = 125, kPFix_EQDQUOT = 129, kPFix_SPatSP = 132, - kPFix_lySP = 137, + kPFix_lySP = 137, kPFix_COMMA = 141, kPFix_EQSQUOT = 143, kPFix_DOTcomSLASH = 146, @@ -116,7 +114,6 @@ enum { kPFix_ousSP = 203 }; - static const Transform kTransforms[] = { { kPFix_EMPTY, kIdentity, kPFix_EMPTY }, { kPFix_EMPTY, kIdentity, kPFix_SP }, @@ -243,7 +240,7 @@ static const Transform kTransforms[] = { static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]); -static int ToUpperCase(uint8_t *p) { +static int ToUpperCase(uint8_t* p) { if (p[0] < 0xc0) { if (p[0] >= 'a' && p[0] <= 'z') { p[0] ^= 32; @@ -269,22 +266,19 @@ static BROTLI_NOINLINE int TransformDictionaryWord( } { const int t = kTransforms[transform].transform; - int skip = t < kOmitFirst1 ? 0 : t - (kOmitFirst1 - 1); int i = 0; - uint8_t* uppercase; - if (skip > len) { - skip = len; - } - word += skip; - len -= skip; - if (t <= kOmitLast9) { + int skip = t - (kOmitFirst1 - 1); + if (skip > 0) { + word += skip; + len -= skip; + } else if (t <= kOmitLast9) { len -= t; } while (i < len) { dst[idx++] = word[i++]; } - uppercase = &dst[idx - len]; if (t == kUppercaseFirst) { - ToUpperCase(uppercase); + ToUpperCase(&dst[idx - len]); } else if (t == kUppercaseAll) { + uint8_t* uppercase = &dst[idx - len]; while (len > 0) { int step = ToUpperCase(uppercase); uppercase += step; @@ -300,7 +294,7 @@ static BROTLI_NOINLINE int TransformDictionaryWord( } #if defined(__cplusplus) || defined(c_plusplus) -} /* extern "C" */ +} /* extern "C" */ #endif #endif /* BROTLI_DEC_TRANSFORM_H_ */ |