Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
afbb8db8
Commit
afbb8db8
authored
Dec 31, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in long masking ops.
parent
768a3f0a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
28 deletions
+31
-28
Objects/longobject.c
Objects/longobject.c
+31
-28
No files found.
Objects/longobject.c
View file @
afbb8db8
...
...
@@ -1145,6 +1145,9 @@ long_lshift(a, b)
return
(
object
*
)
long_znormalize
(
z
);
}
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
/* Logical or the absolute values of two long integers.
The second value is first xor'ed with 'mask'. */
...
...
@@ -1155,22 +1158,23 @@ x_or(a, b, mask)
int
mask
;
{
int
size_a
=
ZABS
(
a
->
ob_size
),
size_b
=
ZABS
(
b
->
ob_size
);
int
size_max
=
MAX
(
size_a
,
size_b
);
int
size_min
=
MIN
(
size_a
,
size_b
);
longobject
*
z
;
int
i
;
/* Ensure a is the larger of the two: */
if
(
size_a
<
size_b
)
{
{
longobject
*
temp
=
a
;
a
=
b
;
b
=
temp
;
}
{
int
size_temp
=
size_a
;
size_a
=
size_b
;
size_b
=
size_temp
;
}
}
z
=
alloclongobject
(
size_a
);
z
=
alloclongobject
(
size_max
);
if
(
z
==
NULL
)
return
NULL
;
for
(
i
=
0
;
i
<
size_
b
;
++
i
)
{
for
(
i
=
0
;
i
<
size_
min
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
|
(
b
->
ob_digit
[
i
]
^
mask
);
}
/* At most one of the following two loops executes */
for
(;
i
<
size_a
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
|
mask
;
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
|
(
0
^
mask
);
}
for
(;
i
<
size_b
;
++
i
)
{
z
->
ob_digit
[
i
]
=
0
|
(
b
->
ob_digit
[
i
]
^
mask
);
}
return
long_znormalize
(
z
);
}
...
...
@@ -1185,22 +1189,23 @@ x_and(a, b, mask)
int
mask
;
{
int
size_a
=
ZABS
(
a
->
ob_size
),
size_b
=
ZABS
(
b
->
ob_size
);
int
size_max
=
MAX
(
size_a
,
size_b
);
int
size_min
=
MIN
(
size_a
,
size_b
);
longobject
*
z
;
int
i
;
/* Ensure a is the larger of the two: */
if
(
size_a
<
size_b
)
{
{
longobject
*
temp
=
a
;
a
=
b
;
b
=
temp
;
}
{
int
size_temp
=
size_a
;
size_a
=
size_b
;
size_b
=
size_temp
;
}
}
z
=
alloclongobject
(
size_a
);
z
=
alloclongobject
(
size_max
);
if
(
z
==
NULL
)
return
NULL
;
for
(
i
=
0
;
i
<
size_
b
;
++
i
)
{
for
(
i
=
0
;
i
<
size_
min
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
&
(
b
->
ob_digit
[
i
]
^
mask
);
}
/* At most one of the following two loops executes */
for
(;
i
<
size_a
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
&
mask
;
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
&
(
0
^
mask
);
}
for
(;
i
<
size_b
;
++
i
)
{
z
->
ob_digit
[
i
]
=
0
&
(
b
->
ob_digit
[
i
]
^
mask
);
}
return
long_znormalize
(
z
);
}
...
...
@@ -1208,36 +1213,34 @@ x_and(a, b, mask)
/* Logical xor the absolute values of two long integers.
The second value is first xor'ed with 'mask'. */
static
longobject
*
x_
and
PROTO
((
longobject
*
,
longobject
*
,
int
));
static
longobject
*
x_
xor
PROTO
((
longobject
*
,
longobject
*
,
int
));
static
longobject
*
x_xor
(
a
,
b
,
mask
)
longobject
*
a
,
*
b
;
int
mask
;
{
int
size_a
=
ZABS
(
a
->
ob_size
),
size_b
=
ZABS
(
b
->
ob_size
);
int
size_max
=
MAX
(
size_a
,
size_b
);
int
size_min
=
MIN
(
size_a
,
size_b
);
longobject
*
z
;
int
i
;
/* Ensure a is the larger of the two: */
if
(
size_a
<
size_b
)
{
{
longobject
*
temp
=
a
;
a
=
b
;
b
=
temp
;
}
{
int
size_temp
=
size_a
;
size_a
=
size_b
;
size_b
=
size_temp
;
}
}
z
=
alloclongobject
(
size_a
);
z
=
alloclongobject
(
size_max
);
if
(
z
==
NULL
)
return
NULL
;
for
(
i
=
0
;
i
<
size_
b
;
++
i
)
{
for
(
i
=
0
;
i
<
size_
min
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
^
(
b
->
ob_digit
[
i
]
^
mask
);
}
/* At most one of the following two loops executes */
for
(;
i
<
size_a
;
++
i
)
{
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
^
mask
;
z
->
ob_digit
[
i
]
=
a
->
ob_digit
[
i
]
^
(
0
^
mask
);
}
for
(;
i
<
size_b
;
++
i
)
{
z
->
ob_digit
[
i
]
=
0
^
(
b
->
ob_digit
[
i
]
^
mask
);
}
return
long_znormalize
(
z
);
}
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
static
object
*
long_and
(
a
,
w
)
longobject
*
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment