1.1 --- a/iixr/data.py Tue Jan 25 00:36:31 2011 +0100
1.2 +++ b/iixr/data.py Tue Jan 25 01:55:43 2011 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Variable-length integer functions.
1.6
1.7 -Copyright (C) 2009, 2010 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2009, 2010, 2011 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -65,6 +65,16 @@
1.13 else:
1.14 bytes.append(number)
1.15
1.16 +def vint_from_array(bytes):
1.17 +
1.18 + "Read a variable-length integer from 'bytes', returning a number."
1.19 +
1.20 + number = 0
1.21 + while bytes:
1.22 + number <<= 7
1.23 + number += bytes.pop() & 127
1.24 + return number
1.25 +
1.26 def string_to_array(s, bytes):
1.27
1.28 "Write the given string 's' to 'bytes'."