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
b6f1fdc9
Commit
b6f1fdc9
authored
Apr 12, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up trailing whitespace.
parent
682faf8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
Objects/bytesobject.c
Objects/bytesobject.c
+18
-18
No files found.
Objects/bytesobject.c
View file @
b6f1fdc9
...
@@ -77,7 +77,7 @@ PyBytes_FromStringAndSize(const char *bytes, Py_ssize_t size)
...
@@ -77,7 +77,7 @@ PyBytes_FromStringAndSize(const char *bytes, Py_ssize_t size)
memcpy
(
new
->
ob_bytes
,
bytes
,
size
);
memcpy
(
new
->
ob_bytes
,
bytes
,
size
);
}
}
new
->
ob_size
=
new
->
ob_alloc
=
size
;
new
->
ob_size
=
new
->
ob_alloc
=
size
;
return
(
PyObject
*
)
new
;
return
(
PyObject
*
)
new
;
}
}
...
@@ -160,7 +160,7 @@ bytes_concat(PyBytesObject *self, PyObject *other)
...
@@ -160,7 +160,7 @@ bytes_concat(PyBytesObject *self, PyObject *other)
"can't concat bytes to %.100s"
,
other
->
ob_type
->
tp_name
);
"can't concat bytes to %.100s"
,
other
->
ob_type
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
mysize
=
self
->
ob_size
;
mysize
=
self
->
ob_size
;
size
=
mysize
+
((
PyBytesObject
*
)
other
)
->
ob_size
;
size
=
mysize
+
((
PyBytesObject
*
)
other
)
->
ob_size
;
if
(
size
<
0
)
if
(
size
<
0
)
...
@@ -244,7 +244,7 @@ bytes_irepeat(PyBytesObject *self, Py_ssize_t count)
...
@@ -244,7 +244,7 @@ bytes_irepeat(PyBytesObject *self, Py_ssize_t count)
self
->
ob_size
=
size
;
self
->
ob_size
=
size
;
else
if
(
PyBytes_Resize
((
PyObject
*
)
self
,
size
)
<
0
)
else
if
(
PyBytes_Resize
((
PyObject
*
)
self
,
size
)
<
0
)
return
NULL
;
return
NULL
;
if
(
mysize
==
1
)
if
(
mysize
==
1
)
memset
(
self
->
ob_bytes
,
self
->
ob_bytes
[
0
],
size
);
memset
(
self
->
ob_bytes
,
self
->
ob_bytes
[
0
],
size
);
else
{
else
{
...
@@ -263,7 +263,7 @@ bytes_substring(PyBytesObject *self, PyBytesObject *other)
...
@@ -263,7 +263,7 @@ bytes_substring(PyBytesObject *self, PyBytesObject *other)
Py_ssize_t
i
;
Py_ssize_t
i
;
if
(
other
->
ob_size
==
1
)
{
if
(
other
->
ob_size
==
1
)
{
return
memchr
(
self
->
ob_bytes
,
other
->
ob_bytes
[
0
],
return
memchr
(
self
->
ob_bytes
,
other
->
ob_bytes
[
0
],
self
->
ob_size
)
!=
NULL
;
self
->
ob_size
)
!=
NULL
;
}
}
if
(
other
->
ob_size
==
0
)
if
(
other
->
ob_size
==
0
)
...
@@ -332,7 +332,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
...
@@ -332,7 +332,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
&
start
,
&
stop
,
&
step
,
&
slicelength
)
<
0
)
{
&
start
,
&
stop
,
&
step
,
&
slicelength
)
<
0
)
{
return
NULL
;
return
NULL
;
}
}
if
(
slicelength
<=
0
)
if
(
slicelength
<=
0
)
return
PyBytes_FromStringAndSize
(
""
,
0
);
return
PyBytes_FromStringAndSize
(
""
,
0
);
else
if
(
step
==
1
)
{
else
if
(
step
==
1
)
{
...
@@ -343,10 +343,10 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
...
@@ -343,10 +343,10 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
char
*
source_buf
=
PyBytes_AS_STRING
(
self
);
char
*
source_buf
=
PyBytes_AS_STRING
(
self
);
char
*
result_buf
=
(
char
*
)
PyMem_Malloc
(
slicelength
);
char
*
result_buf
=
(
char
*
)
PyMem_Malloc
(
slicelength
);
PyObject
*
result
;
PyObject
*
result
;
if
(
result_buf
==
NULL
)
if
(
result_buf
==
NULL
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
for
(
cur
=
start
,
i
=
0
;
i
<
slicelength
;
for
(
cur
=
start
,
i
=
0
;
i
<
slicelength
;
cur
+=
step
,
i
++
)
{
cur
+=
step
,
i
++
)
{
result_buf
[
i
]
=
source_buf
[
cur
];
result_buf
[
i
]
=
source_buf
[
cur
];
...
@@ -361,7 +361,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
...
@@ -361,7 +361,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
return
NULL
;
return
NULL
;
}
}
}
}
static
int
static
int
bytes_setslice
(
PyBytesObject
*
self
,
Py_ssize_t
lo
,
Py_ssize_t
hi
,
bytes_setslice
(
PyBytesObject
*
self
,
Py_ssize_t
lo
,
Py_ssize_t
hi
,
PyObject
*
values
)
PyObject
*
values
)
...
@@ -467,7 +467,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
...
@@ -467,7 +467,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
{
{
Py_ssize_t
start
,
stop
,
step
,
slicelen
,
needed
;
Py_ssize_t
start
,
stop
,
step
,
slicelen
,
needed
;
char
*
bytes
;
char
*
bytes
;
if
(
PyIndex_Check
(
item
))
{
if
(
PyIndex_Check
(
item
))
{
Py_ssize_t
i
=
PyNumber_AsSsize_t
(
item
,
PyExc_IndexError
);
Py_ssize_t
i
=
PyNumber_AsSsize_t
(
item
,
PyExc_IndexError
);
...
@@ -481,7 +481,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
...
@@ -481,7 +481,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
PyErr_SetString
(
PyExc_IndexError
,
"bytes index out of range"
);
PyErr_SetString
(
PyExc_IndexError
,
"bytes index out of range"
);
return
-
1
;
return
-
1
;
}
}
if
(
values
==
NULL
)
{
if
(
values
==
NULL
)
{
/* Fall through to slice assignment */
/* Fall through to slice assignment */
start
=
i
;
start
=
i
;
...
@@ -573,7 +573,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
...
@@ -573,7 +573,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
if
(
needed
==
0
)
{
if
(
needed
==
0
)
{
/* Delete slice */
/* Delete slice */
Py_ssize_t
cur
,
i
;
Py_ssize_t
cur
,
i
;
if
(
step
<
0
)
{
if
(
step
<
0
)
{
stop
=
start
+
1
;
stop
=
start
+
1
;
start
=
stop
+
step
*
(
slicelen
-
1
)
-
1
;
start
=
stop
+
step
*
(
slicelen
-
1
)
-
1
;
...
@@ -585,7 +585,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
...
@@ -585,7 +585,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
if
(
cur
+
step
>=
PyBytes_GET_SIZE
(
self
))
if
(
cur
+
step
>=
PyBytes_GET_SIZE
(
self
))
lim
=
PyBytes_GET_SIZE
(
self
)
-
cur
-
1
;
lim
=
PyBytes_GET_SIZE
(
self
)
-
cur
-
1
;
memmove
(
self
->
ob_bytes
+
cur
-
i
,
memmove
(
self
->
ob_bytes
+
cur
-
i
,
self
->
ob_bytes
+
cur
+
1
,
lim
);
self
->
ob_bytes
+
cur
+
1
,
lim
);
}
}
...
@@ -605,7 +605,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
...
@@ -605,7 +605,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
else
{
else
{
/* Assign slice */
/* Assign slice */
Py_ssize_t
cur
,
i
;
Py_ssize_t
cur
,
i
;
if
(
needed
!=
slicelen
)
{
if
(
needed
!=
slicelen
)
{
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"attempt to assign bytes of size %zd "
"attempt to assign bytes of size %zd "
...
@@ -1489,7 +1489,7 @@ replace_interleave(PyBytesObject *self,
...
@@ -1489,7 +1489,7 @@ replace_interleave(PyBytesObject *self,
/* 1 at the end plus 1 after every character */
/* 1 at the end plus 1 after every character */
count
=
self_len
+
1
;
count
=
self_len
+
1
;
if
(
maxcount
<
count
)
if
(
maxcount
<
count
)
count
=
maxcount
;
count
=
maxcount
;
/* Check for overflow */
/* Check for overflow */
...
@@ -1770,7 +1770,7 @@ replace_single_character(PyBytesObject *self,
...
@@ -1770,7 +1770,7 @@ replace_single_character(PyBytesObject *self,
end
=
self_s
+
self_len
;
end
=
self_s
+
self_len
;
while
(
count
--
>
0
)
{
while
(
count
--
>
0
)
{
next
=
findchar
(
start
,
end
-
start
,
from_c
);
next
=
findchar
(
start
,
end
-
start
,
from_c
);
if
(
next
==
NULL
)
if
(
next
==
NULL
)
break
;
break
;
if
(
next
==
start
)
{
if
(
next
==
start
)
{
...
@@ -2141,7 +2141,7 @@ bytes_partition(PyBytesObject *self, PyObject *sep_obj)
...
@@ -2141,7 +2141,7 @@ bytes_partition(PyBytesObject *self, PyObject *sep_obj)
result
=
stringlib_partition
(
result
=
stringlib_partition
(
(
PyObject
*
)
self
,
(
PyObject
*
)
self
,
PyBytes_AS_STRING
(
self
),
PyBytes_GET_SIZE
(
self
),
PyBytes_AS_STRING
(
self
),
PyBytes_GET_SIZE
(
self
),
bytesep
,
bytesep
,
PyBytes_AS_STRING
(
bytesep
),
PyBytes_GET_SIZE
(
bytesep
)
PyBytes_AS_STRING
(
bytesep
),
PyBytes_GET_SIZE
(
bytesep
)
);
);
...
@@ -2168,7 +2168,7 @@ bytes_rpartition(PyBytesObject *self, PyObject *sep_obj)
...
@@ -2168,7 +2168,7 @@ bytes_rpartition(PyBytesObject *self, PyObject *sep_obj)
result
=
stringlib_rpartition
(
result
=
stringlib_rpartition
(
(
PyObject
*
)
self
,
(
PyObject
*
)
self
,
PyBytes_AS_STRING
(
self
),
PyBytes_GET_SIZE
(
self
),
PyBytes_AS_STRING
(
self
),
PyBytes_GET_SIZE
(
self
),
bytesep
,
bytesep
,
PyBytes_AS_STRING
(
bytesep
),
PyBytes_GET_SIZE
(
bytesep
)
PyBytes_AS_STRING
(
bytesep
),
PyBytes_GET_SIZE
(
bytesep
)
);
);
...
@@ -2448,7 +2448,7 @@ able to handle UnicodeDecodeErrors.");
...
@@ -2448,7 +2448,7 @@ able to handle UnicodeDecodeErrors.");
static
PyObject
*
static
PyObject
*
bytes_decode
(
PyObject
*
self
,
PyObject
*
args
)
bytes_decode
(
PyObject
*
self
,
PyObject
*
args
)
{
{
const
char
*
encoding
=
NULL
;
const
char
*
encoding
=
NULL
;
const
char
*
errors
=
NULL
;
const
char
*
errors
=
NULL
;
...
...
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