get_header_tar: shrink 6->64 sign extension code
function old new delta getOctal 125 107 -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
9c28fb8d28
commit
f74f280a14
@ -79,10 +79,10 @@ static unsigned long long getOctal(char *str, int len)
|
|||||||
*
|
*
|
||||||
* NB: tarballs with NEGATIVE unix times encoded that way were seen!
|
* NB: tarballs with NEGATIVE unix times encoded that way were seen!
|
||||||
*/
|
*/
|
||||||
v = first;
|
/* Sign-extend 7bit 'first' to 64bit 'v' (that is, using 6th bit as sign): */
|
||||||
/* Sign-extend using 6th bit: */
|
first <<= 1;
|
||||||
v <<= sizeof(unsigned long long)*8 - 7;
|
first >>= 1; /* now 7th bit = 6th bit */
|
||||||
v = (long long)v >> (sizeof(unsigned long long)*8 - 7);
|
v = first; /* sign-extend 8 bits to 64 */
|
||||||
while (--len != 0)
|
while (--len != 0)
|
||||||
v = (v << 8) + (unsigned char) *str++;
|
v = (v << 8) + (unsigned char) *str++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user