Skip to content

Commit

Permalink
Issue python#18722: Remove uses of the "register" keyword in C code.
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Aug 13, 2013
1 parent 9eaa3e6 commit 9ed5f27
Show file tree
Hide file tree
Showing 38 changed files with 288 additions and 286 deletions.
10 changes: 5 additions & 5 deletions Include/bytesobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
0-terminated (passing a string with embedded NULL characters will
cause an exception). */
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
register PyObject *obj, /* string or Unicode object */
register char **s, /* pointer to buffer variable */
register Py_ssize_t *len /* pointer to length variable or NULL
(only possible for 0-terminated
strings) */
PyObject *obj, /* string or Unicode object */
char **s, /* pointer to buffer variable */
Py_ssize_t *len /* pointer to length variable or NULL
(only possible for 0-terminated
strings) */
);

/* Using the current locale, insert the thousands grouping
Expand Down
8 changes: 4 additions & 4 deletions Include/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ PyAPI_FUNC(int) PyUnicode_Resize(
*/

PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject(
register PyObject *obj, /* Object */
PyObject *obj, /* Object */
const char *encoding, /* encoding */
const char *errors /* error handling */
);
Expand All @@ -878,7 +878,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject(
*/

PyAPI_FUNC(PyObject*) PyUnicode_FromObject(
register PyObject *obj /* Object */
PyObject *obj /* Object */
);

PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(
Expand Down Expand Up @@ -1015,7 +1015,7 @@ PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void);
The buffer is copied into the new object. */

PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar(
register const wchar_t *w, /* wchar_t buffer */
const wchar_t *w, /* wchar_t buffer */
Py_ssize_t size /* size of buffer */
);

Expand All @@ -1033,7 +1033,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar(

PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
PyObject *unicode, /* Unicode object */
register wchar_t *w, /* wchar_t buffer */
wchar_t *w, /* wchar_t buffer */
Py_ssize_t size /* size of buffer */
);

Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Projected Release date: 2013-09-08
Core and Builtins
-----------------

- Issue #18722: Remove uses of the "register" keyword in C code.

- Issue #18667: Add missing "HAVE_FCHOWNAT" symbol to posix._have_functions.

- Issue #16499: Add command line option for isolated mode.
Expand Down
6 changes: 3 additions & 3 deletions Modules/_codecsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ escape_encode(PyObject *self,
return NULL;
}
else {
register Py_ssize_t i;
register char c;
register char *p = PyBytes_AS_STRING(v);
Py_ssize_t i;
char c;
char *p = PyBytes_AS_STRING(v);

for (i = 0; i < size; i++) {
/* There's at least enough room for a hex escape */
Expand Down
14 changes: 7 additions & 7 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ newdbmobject(char *file, int flags, int mode)
/* Methods */

static void
dbm_dealloc(register dbmobject *dp)
dbm_dealloc(dbmobject *dp)
{
if ( dp->di_dbm )
dbm_close(dp->di_dbm);
Expand Down Expand Up @@ -91,7 +91,7 @@ dbm_length(dbmobject *dp)
}

static PyObject *
dbm_subscript(dbmobject *dp, register PyObject *key)
dbm_subscript(dbmobject *dp, PyObject *key)
{
datum drec, krec;
Py_ssize_t tmp_size;
Expand Down Expand Up @@ -166,7 +166,7 @@ static PyMappingMethods dbm_as_mapping = {
};

static PyObject *
dbm__close(register dbmobject *dp, PyObject *unused)
dbm__close(dbmobject *dp, PyObject *unused)
{
if (dp->di_dbm)
dbm_close(dp->di_dbm);
Expand All @@ -176,9 +176,9 @@ dbm__close(register dbmobject *dp, PyObject *unused)
}

static PyObject *
dbm_keys(register dbmobject *dp, PyObject *unused)
dbm_keys(dbmobject *dp, PyObject *unused)
{
register PyObject *v, *item;
PyObject *v, *item;
datum key;
int err;

Expand Down Expand Up @@ -249,7 +249,7 @@ static PySequenceMethods dbm_as_sequence = {
};

static PyObject *
dbm_get(register dbmobject *dp, PyObject *args)
dbm_get(dbmobject *dp, PyObject *args)
{
datum key, val;
PyObject *defvalue = Py_None;
Expand All @@ -272,7 +272,7 @@ dbm_get(register dbmobject *dp, PyObject *args)
}

static PyObject *
dbm_setdefault(register dbmobject *dp, PyObject *args)
dbm_setdefault(dbmobject *dp, PyObject *args)
{
datum key, val;
PyObject *defvalue = NULL;
Expand Down
22 changes: 11 additions & 11 deletions Modules/_gdbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ newdbmobject(char *file, int flags, int mode)
/* Methods */

static void
dbm_dealloc(register dbmobject *dp)
dbm_dealloc(dbmobject *dp)
{
if (dp->di_dbm)
gdbm_close(dp->di_dbm);
Expand Down Expand Up @@ -112,7 +112,7 @@ dbm_length(dbmobject *dp)
}

static PyObject *
dbm_subscript(dbmobject *dp, register PyObject *key)
dbm_subscript(dbmobject *dp, PyObject *key)
{
PyObject *v;
datum drec, krec;
Expand Down Expand Up @@ -232,7 +232,7 @@ PyDoc_STRVAR(dbm_close__doc__,
Closes the database.");

static PyObject *
dbm_close(register dbmobject *dp, PyObject *unused)
dbm_close(dbmobject *dp, PyObject *unused)
{
if (dp->di_dbm)
gdbm_close(dp->di_dbm);
Expand All @@ -247,9 +247,9 @@ PyDoc_STRVAR(dbm_keys__doc__,
Get a list of all keys in the database.");

static PyObject *
dbm_keys(register dbmobject *dp, PyObject *unused)
dbm_keys(dbmobject *dp, PyObject *unused)
{
register PyObject *v, *item;
PyObject *v, *item;
datum key, nextkey;
int err;

Expand Down Expand Up @@ -328,9 +328,9 @@ hash values, and won't be sorted by the key values. This method\n\
returns the starting key.");

static PyObject *
dbm_firstkey(register dbmobject *dp, PyObject *unused)
dbm_firstkey(dbmobject *dp, PyObject *unused)
{
register PyObject *v;
PyObject *v;
datum key;

check_dbmobject_open(dp);
Expand Down Expand Up @@ -358,9 +358,9 @@ to create a list in memory that contains them all:\n\
k = db.nextkey(k)");

static PyObject *
dbm_nextkey(register dbmobject *dp, PyObject *args)
dbm_nextkey(dbmobject *dp, PyObject *args)
{
register PyObject *v;
PyObject *v;
datum key, nextkey;

if (!PyArg_ParseTuple(args, "s#:nextkey", &key.dptr, &key.dsize))
Expand All @@ -387,7 +387,7 @@ by using this reorganization; otherwise, deleted file space will be\n\
kept and reused as new (key,value) pairs are added.");

static PyObject *
dbm_reorganize(register dbmobject *dp, PyObject *unused)
dbm_reorganize(dbmobject *dp, PyObject *unused)
{
check_dbmobject_open(dp);
errno = 0;
Expand All @@ -408,7 +408,7 @@ When the database has been opened in fast mode, this method forces\n\
any unwritten data to be written to the disk.");

static PyObject *
dbm_sync(register dbmobject *dp, PyObject *unused)
dbm_sync(dbmobject *dp, PyObject *unused)
{
check_dbmobject_open(dp);
gdbm_sync(dp->di_dbm);
Expand Down
6 changes: 3 additions & 3 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
static PyObject *
getarrayitem(PyObject *op, Py_ssize_t i)
{
register arrayobject *ap;
arrayobject *ap;
assert(array_Check(op));
ap = (arrayobject *)op;
assert(i>=0 && i<Py_SIZE(ap));
Expand Down Expand Up @@ -1225,8 +1225,8 @@ Byteswap all items of the array. If the items in the array are not 1, 2,\n\
static PyObject *
array_reverse(arrayobject *self, PyObject *unused)
{
register Py_ssize_t itemsize = self->ob_descr->itemsize;
register char *p, *q;
Py_ssize_t itemsize = self->ob_descr->itemsize;
char *p, *q;
/* little buffer to hold items while swapping */
char tmp[256]; /* 8 is probably enough -- but why skimp */
assert((size_t)itemsize <= sizeof(tmp));
Expand Down
12 changes: 6 additions & 6 deletions Objects/bytearrayobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,9 @@ bytearray_repr(PyByteArrayObject *self)
/* 15 == strlen(quote_prefix) + 2 + strlen(quote_postfix) + 1 */
size_t newsize;
PyObject *v;
register Py_ssize_t i;
register char c;
register char *p;
Py_ssize_t i;
char c;
char *p;
int quote;
char *test, *start;
char *buffer;
Expand Down Expand Up @@ -1431,9 +1431,9 @@ table, which must be a bytes object of length 256.");
static PyObject *
bytearray_translate(PyByteArrayObject *self, PyObject *args)
{
register char *input, *output;
register const char *table;
register Py_ssize_t i, c;
char *input, *output;
const char *table;
Py_ssize_t i, c;
PyObject *input_obj = (PyObject*)self;
const char *output_start;
Py_ssize_t inlen;
Expand Down
30 changes: 15 additions & 15 deletions Objects/bytes_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isspace(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;

/* Shortcut for single character strings */
if (len == 1 && Py_ISSPACE(*p))
Expand Down Expand Up @@ -40,9 +40,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isalpha(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;

/* Shortcut for single character strings */
if (len == 1 && Py_ISALPHA(*p))
Expand Down Expand Up @@ -70,9 +70,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isalnum(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;

/* Shortcut for single character strings */
if (len == 1 && Py_ISALNUM(*p))
Expand Down Expand Up @@ -100,9 +100,9 @@ and there is at least one character in B, False otherwise.");
PyObject*
_Py_bytes_isdigit(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;

/* Shortcut for single character strings */
if (len == 1 && Py_ISDIGIT(*p))
Expand Down Expand Up @@ -130,9 +130,9 @@ at least one cased character in B, False otherwise.");
PyObject*
_Py_bytes_islower(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;
int cased;

/* Shortcut for single character strings */
Expand Down Expand Up @@ -164,9 +164,9 @@ at least one cased character in B, False otherwise.");
PyObject*
_Py_bytes_isupper(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;
int cased;

/* Shortcut for single character strings */
Expand Down Expand Up @@ -200,9 +200,9 @@ otherwise.");
PyObject*
_Py_bytes_istitle(const char *cptr, Py_ssize_t len)
{
register const unsigned char *p
const unsigned char *p
= (unsigned char *) cptr;
register const unsigned char *e;
const unsigned char *e;
int cased, previous_is_cased;

/* Shortcut for single character strings */
Expand All @@ -217,7 +217,7 @@ _Py_bytes_istitle(const char *cptr, Py_ssize_t len)
cased = 0;
previous_is_cased = 0;
for (; p < e; p++) {
register const unsigned char ch = *p;
const unsigned char ch = *p;

if (Py_ISUPPER(ch)) {
if (previous_is_cased)
Expand Down
Loading

0 comments on commit 9ed5f27

Please sign in to comment.