diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:48:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:48:47 -0800 |
commit | 96aa7adda3b0254e4b9904f53bb38cd76bfea7bb (patch) | |
tree | d1eb57fbedb2e8c321889794c60ded86a9a2e88b /base85.c | |
parent | textconv: stop leaking file descriptors (diff) | |
parent | base85: Make the code more obvious instead of explaining the non-obvious (diff) | |
download | tgif-96aa7adda3b0254e4b9904f53bb38cd76bfea7bb.tar.xz |
Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0:
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
branch: die explicitly why when calling "git branch [-a|-r] branchname".
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; } |