Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Clean-up some irritating extra whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Ballance committed Feb 21, 2010
1 parent 64d15fb commit 6197b7f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
48 changes: 24 additions & 24 deletions decoder.c
@@ -1,22 +1,22 @@
/*
* Copyright 2009, R. Tyler Ballance <tyler@monkeypox.org>
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
*
* 3. Neither the name of R. Tyler Ballance nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -28,7 +28,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
*/


#include <Python.h>
Expand Down Expand Up @@ -168,23 +168,23 @@ static int handle_end_dict(void *ctx)

length = py_yajl_ps_length(self->elements);
if (length == 1) {
/*
/*
* If this is the last element in the stack
* then it's "root" and we should finish up
*/
self->root = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
self->root = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
return success;
} else if (length < 2) {
return failure;
}

/*
* If not, then we should properly add this dict
* to it's appropriate parent
*/
popped = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
popped = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
last = py_yajl_ps_current(self->elements);

return _PlaceObject(self, last, popped);
Expand All @@ -209,31 +209,31 @@ static int handle_end_list(void *ctx)

length = py_yajl_ps_length(self->elements);
if (length == 1) {
self->root = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
self->root = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
return success;
} else if (length < 2) {
return failure;
}
popped = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);

popped = py_yajl_ps_current(self->elements);
py_yajl_ps_pop(self->elements);
last = py_yajl_ps_current(self->elements);

return _PlaceObject(self, last, popped);
}

static yajl_callbacks decode_callbacks = {
handle_null,
handle_bool,
NULL,
handle_bool,
NULL,
NULL,
handle_number,
handle_string,
handle_start_dict,
handle_dict_key,
handle_end_dict,
handle_start_list,
handle_start_list,
handle_end_list
};

Expand All @@ -259,17 +259,17 @@ PyObject *_internal_decode(_YajlDecoder *self, char *buffer, unsigned int buflen
yajl_free(parser);

if (yrc != yajl_status_ok) {
PyErr_SetObject(PyExc_ValueError,
PyErr_SetObject(PyExc_ValueError,
PyUnicode_FromString(yajl_status_to_string(yrc)));
return NULL;
}

if (self->root == NULL) {
PyErr_SetObject(PyExc_ValueError,
PyErr_SetObject(PyExc_ValueError,
PyUnicode_FromString("The root object is NULL"));
return NULL;
}

// Callee now owns memory, we'll leave refcnt at one and
// null out our pointer.
PyObject *root = self->root;
Expand All @@ -287,7 +287,7 @@ PyObject *py_yajldecoder_decode(PYARGS)
return NULL;

if (!buflen) {
PyErr_SetObject(PyExc_ValueError,
PyErr_SetObject(PyExc_ValueError,
PyUnicode_FromString("Cannot parse an empty buffer"));
return NULL;
}
Expand Down
26 changes: 13 additions & 13 deletions encoder.c
@@ -1,23 +1,23 @@

/*
* Copyright 2009, R. Tyler Ballance <tyler@monkeypox.org>
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
*
* 3. Neither the name of R. Tyler Ballance nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -29,7 +29,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
*/

#include <Python.h>

Expand Down Expand Up @@ -91,7 +91,7 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
}
if (PyList_Check(object)) {
/*
* Recurse and handle the list
* Recurse and handle the list
*/
iterator = PyObject_GetIter(object);
if (iterator == NULL)
Expand All @@ -117,26 +117,26 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
return yajl_gen_map_close(handle);
}


exit:
return yajl_gen_in_error_state;
}

yajl_alloc_funcs *y_allocs = NULL;

/* a structure used to pass context to our printer function */
struct StringAndUsedCount
struct StringAndUsedCount
{
PyObject * str;
size_t used;
size_t used;
};


static void py_yajl_printer(void * ctx,
const char * str,
unsigned int len)
{
struct StringAndUsedCount * sauc = (struct StringAndUsedCount *) ctx;
struct StringAndUsedCount * sauc = (struct StringAndUsedCount *) ctx;
size_t newsize;

if (!sauc || !sauc->str) return;
Expand All @@ -148,7 +148,7 @@ static void py_yajl_printer(void * ctx,
#ifdef IS_PYTHON3
_PyBytes_Resize(&(sauc->str), newsize);
#else
_PyString_Resize(&(sauc->str), newsize);
_PyString_Resize(&(sauc->str), newsize);
#endif
if (!sauc->str)
return;
Expand Down
36 changes: 18 additions & 18 deletions yajl.c
@@ -1,22 +1,22 @@
/*
* Copyright 2009, R. Tyler Ballance <tyler@monkeypox.org>
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
*
* 3. Neither the name of R. Tyler Ballance nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand All @@ -28,7 +28,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
*/
#include <Python.h>

#include "py_yajl.h"
Expand Down Expand Up @@ -86,7 +86,7 @@ static PyTypeObject YajlDecoderType = {
0, /* tp_dictoffset */
(initproc)(yajldecoder_init),/* tp_init */
0, /* tp_alloc */
};
};

static PyTypeObject YajlEncoderType = {
#ifdef IS_PYTHON3
Expand Down Expand Up @@ -131,7 +131,7 @@ static PyTypeObject YajlEncoderType = {
0, /* tp_dictoffset */
(initproc)(yajlencoder_init),/* tp_init */
0, /* tp_alloc */
};
};

static PyObject *py_loads(PYARGS)
{
Expand All @@ -143,7 +143,7 @@ static PyObject *py_loads(PYARGS)
if (!PyArg_ParseTuple(args, "z#", &buffer, &buflen)) {
return NULL;
}

decoder = PyObject_Call((PyObject *)(&YajlDecoderType), NULL, NULL);
if (decoder == NULL) {
return NULL;
Expand All @@ -159,13 +159,13 @@ static char *__config_gen_config(PyObject *indent, yajl_gen_config *config)
long indentLevel = -1;
char *spaces = NULL;

if (!indent)
if (!indent)
return NULL;

if ((indent != Py_None) && (!PyLong_Check(indent))
if ((indent != Py_None) && (!PyLong_Check(indent))
#ifndef IS_PYTHON3
&& (!PyInt_Check(indent))
#endif
#endif
) {
PyErr_SetObject(PyExc_TypeError,
PyUnicode_FromString("`indent` must be int or None"));
Expand All @@ -180,7 +180,7 @@ static char *__config_gen_config(PyObject *indent, yajl_gen_config *config)
if (indentLevel == 0) {
config->indentString = "";
}
else {
else {
spaces = (char *)(malloc(sizeof(char) * (indentLevel + 1)));
memset((void *)(spaces), (int)' ', indentLevel);
spaces[indentLevel] = '\0';
Expand Down Expand Up @@ -289,7 +289,7 @@ static PyObject *py_iterload(PYARGS)
}

static PyObject *__write = NULL;
static PyObject *_internal_stream_dump(PyObject *object, PyObject *stream, unsigned int blocking,
static PyObject *_internal_stream_dump(PyObject *object, PyObject *stream, unsigned int blocking,
yajl_gen_config config)
{
PyObject *encoder = NULL;
Expand Down Expand Up @@ -353,10 +353,10 @@ and object members will be pretty-printed with that indent level. \n\
An indent level of 0 will only insert newlines. None (the default) \n\
selects the most compact representation.\n\
"},
{"loads", (PyCFunction)(py_loads), METH_VARARGS,
{"loads", (PyCFunction)(py_loads), METH_VARARGS,
"yajl.loads(string)\n\n\
Returns a decoded object based on the given JSON `string`"},
{"load", (PyCFunction)(py_load), METH_VARARGS,
{"load", (PyCFunction)(py_load), METH_VARARGS,
"yajl.load(fp)\n\n\
Returns a decoded object based on the JSON read from the `fp` stream-like\n\
object; *Note:* It is expected that `fp` supports the `read()` method"},
Expand Down Expand Up @@ -385,7 +385,7 @@ static struct PyModuleDef yajlmodule = {
PyMODINIT_FUNC inityajl(void)
{

PyObject *module = Py_InitModule3("yajl", yajl_methods,
PyObject *module = Py_InitModule3("yajl", yajl_methods,
#endif
"Providing a pythonic interface to the yajl (Yet Another JSON Library) parser\n\n\
The interface is similar to that of simplejson or jsonlib providing a consistent syntax for JSON\n\
Expand All @@ -402,7 +402,7 @@ yajl.dumps():\t\t681.0221ms"
, -1, yajl_methods, NULL, NULL, NULL, NULL
};

PyMODINIT_FUNC PyInit_yajl(void)
PyMODINIT_FUNC PyInit_yajl(void)
{
PyObject *module = PyModule_Create(&yajlmodule);
#else
Expand Down

0 comments on commit 6197b7f

Please sign in to comment.