diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:51:54 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:51:54 -0800 |
commit | 8fb5d44a47dd3657c8be0de5dcf220935b04e98e (patch) | |
tree | 838aeb98297028e098849fd8a589b36a92ee89dc /base85.c | |
parent | 578b62bfa239caca89e37fca05dcbed5add17699 (diff) | |
parent | c5034673fd92b6278e6c9d55683770ec01fafc89 (diff) | |
download | git-8fb5d44a47dd3657c8be0de5dcf220935b04e98e.tar.gz git-8fb5d44a47dd3657c8be0de5dcf220935b04e98e.tar.xz |
Merge branch 'maint-1.6.2' into maint
* maint-1.6.2:
base85: Make the code more obvious instead of explaining the non-obvious
base85: encode_85() does not use the decode table
base85 debug code: Fix length byte calculation
checkout -m: do not try to fall back to --merge from an unborn branch
Conflicts:
diff.c
Diffstat (limited to 'base85.c')
-rw-r--r-- | base85.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len) de = de85[ch]; if (--de < 0) return error("invalid base85 alphabet %c", ch); - /* - * Detect overflow. The largest - * 5-letter possible is "|NsC0" to - * encode 0xffffffff, and "|NsC" gives - * 0x03030303 at this point (i.e. - * 0xffffffff = 0x03030303 * 85). - */ - if (0x03030303 < acc || + /* Detect overflow. */ + if (0xffffffff / 85 < acc || 0xffffffff - de < (acc *= 85)) return error("invalid base85 sequence %.5s", buffer-5); acc += de; @@ -84,8 +78,6 @@ int decode_85(char *dst, const char *buffer, int len) void encode_85(char *buf, const unsigned char *data, int bytes) { - prep_base85(); - say("encode 85"); while (bytes) { unsigned acc = 0; @@ -118,7 +110,7 @@ int main(int ac, char **av) int len = strlen(av[2]); encode_85(buf, av[2], len); if (len <= 26) len = len + 'A' - 1; - else len = len + 'a' - 26 + 1; + else len = len + 'a' - 26 - 1; printf("encoded: %c%s\n", len, buf); return 0; } |