~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/erl_interface/src/decode/decode_long.c

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        {
48
48
            int sign = get8(s);
49
49
            int i;
50
 
            n = 0;
 
50
            unsigned long u = 0;
51
51
 
52
52
            /* Little Endian, and n always positive, except for LONG_MIN */
53
53
            for (i = 0; i < arity; i++) {
54
54
                if (i < 4) {
55
 
                    n |= get8(s) << (i * 8);
 
55
                    u |= get8(s) << (i * 8);
56
56
                } else if (get8(s) != 0) {
57
57
                    return -1; /* All but first byte have to be 0 */
58
58
                }
60
60
 
61
61
            /* check for overflow */
62
62
            if (sign) {
63
 
                if ((n - 1) < 0) return -1;
64
 
                n = -n;
 
63
                if (u > 0x80000000UL) {
 
64
                    return -1;
 
65
                }
 
66
                n = -((long)u);
65
67
            } else {
66
 
                if (n < 0) return -1;
 
68
                if (u > 0x7FFFFFFF) {
 
69
                    return -1;
 
70
                }
 
71
                n = (long)u;
67
72
            }
68
73
        }
69
74
        break;