Skip to content

Commit 055de94

Browse files
committed
Fix a number of minor issues discovered with "-pedantic"
svn path=/trunk/matplotlib/; revision=5111
1 parent 8e7c63c commit 055de94

9 files changed

Lines changed: 23 additions & 16 deletions

File tree

src/MPL_isnan.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ code only works on doubles.
88
99
*/
1010

11+
#ifdef _ISOC99_SOURCE
12+
#include <stdint.h>
13+
#endif
14+
1115
#if defined(SIZEOF_VOID_P)
1216
#if SIZEOF_VOID_P == 8
1317
#define MPL_LP64 1
@@ -24,9 +28,13 @@ typedef long int MPL_Int64;
2428
#if defined(_MSC_VER)
2529
typedef __int64 MPL_Int64;
2630
#else
31+
#if defined(_ISOC99_SOURCE)
32+
typedef int64_t MPL_Int64;
33+
#else
2734
typedef long long MPL_Int64;
2835
#endif
2936
#endif
37+
#endif
3038

3139
#if !defined(MPL_U64)
3240
#define MPL_U64(u) (* (MPL_Int64 *) &(u) )

src/_backend_agg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi,
249249
//theRasterizer->filling_rule(agg::fill_even_odd);
250250
//theRasterizer->filling_rule(agg::fill_non_zero);
251251

252-
};
252+
}
253253

254254
void RendererAgg::create_alpha_buffers() {
255255
if (!alphaBuffer) {
@@ -1762,4 +1762,4 @@ DL_EXPORT(void)
17621762
static _backend_agg_module* _backend_agg = NULL;
17631763
_backend_agg = new _backend_agg_module;
17641764

1765-
};
1765+
}

src/_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ _image_module::from_images(const Py::Tuple& args) {
826826
for (size_t i=0; i<thisim->colsOut; i++) {
827827
thisx = i+ox;
828828
thisy = j+oy;
829-
if (thisx<0 || thisx>=numcols || thisy<0 || thisy>=numrows) {
829+
if (thisx>=numcols || thisy>=numrows) {
830830
ind +=4;
831831
continue;
832832
}

src/_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Image : public Py::PythonExtension<Image> {
6161
MITCHELL,
6262
SINC,
6363
LANCZOS,
64-
BLACKMAN,};
64+
BLACKMAN};
6565

6666
//enum { BICUBIC=0, BILINEAR, BLACKMAN100, BLACKMAN256, BLACKMAN64,
6767
// NEAREST, SINC144, SINC256, SINC64, SPLINE16, SPLINE36};

src/_path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,4 +1161,4 @@ extern "C"
11611161

11621162
static _path_module* _path = NULL;
11631163
_path = new _path_module;
1164-
};
1164+
}

src/_tkagg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#else
2828
# include <tk.h>
2929
#endif
30-
};
30+
}
3131

3232

3333

src/_ttconv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static PyMethodDef ttconv_methods[] = {
204204
"the values are the stream content needed to render that glyph. This\n"
205205
"is useful to generate the CharProcs dictionary in a PDF Type 3 font.\n"
206206
},
207-
{NULL} /* Sentinel */
207+
{0, 0, 0, 0} /* Sentinel */
208208
};
209209

210210
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */

src/cntr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,7 @@ static PyMethodDef Cntr_methods[] = {
16881688
" Optional argument: nchunk; approximate number of grid points\n"
16891689
" per chunk. 0 (default) for no chunking.\n"
16901690
},
1691-
{NULL} /* Sentinel */
1691+
{0, 0, 0, 0} /* Sentinel */
16921692
};
16931693

16941694
static PyTypeObject CntrType = {

src/ft2font.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ FT2Image::py_write_bitmap(const Py::Tuple & args) {
153153
void
154154
FT2Image::draw_rect(unsigned long x0, unsigned long y0,
155155
unsigned long x1, unsigned long y1) {
156-
if ( x0<0 || y0<0 || x1<0 || y1<0 ||
157-
x0>_width || x1>_width ||
156+
if ( x0>_width || x1>_width ||
158157
y0>_height || y1>_height )
159158
throw Py::ValueError("Rect coords outside image bounds");
160159

@@ -197,10 +196,10 @@ FT2Image::py_draw_rect(const Py::Tuple & args) {
197196

198197
void FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0,
199198
unsigned long x1, unsigned long y1) {
200-
x0 = CLAMP(x0, 0, _width);
201-
y0 = CLAMP(y0, 0, _height);
202-
x1 = CLAMP(x1, 0, _width);
203-
y1 = CLAMP(y1, 0, _height);
199+
x0 = std::min(x0, _width);
200+
y0 = std::min(y0, _height);
201+
x1 = std::min(x1, _width);
202+
y1 = std::min(y1, _height);
204203

205204
for (size_t j=y0; j<y1+1; j++) {
206205
for (size_t i=x0; i<x1+1; i++) {
@@ -1207,7 +1206,7 @@ char FT2Font::draw_glyph_to_bitmap__doc__[] =
12071206
"draw_glyphs_to_bitmap. This function is intended for people who\n"
12081207
"want to render individual glyphs at precise locations, eg, a\n"
12091208
"a glyph returned by load_char\n";
1210-
;
1209+
12111210
Py::Object
12121211
FT2Font::draw_glyph_to_bitmap(const Py::Tuple & args) {
12131212
_VERBOSE("FT2Font::draw_glyph_to_bitmap");
@@ -1768,7 +1767,7 @@ FT2Font::init_type() {
17681767

17691768
behaviors().supportGetattr();
17701769
behaviors().supportSetattr();
1771-
};
1770+
}
17721771

17731772
//todo add module docs strings
17741773

0 commit comments

Comments
 (0)