Skip to content

Commit f2309d8

Browse files
committed
Remove "deprecated conversion from string constant to char*" warnings.
svn path=/trunk/matplotlib/; revision=3694
1 parent ccfe237 commit f2309d8

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

src/_ttconv.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PythonFileWriter : public TTStreamWriter {
3939

4040
virtual void write(const char* a) {
4141
if (_write_method)
42-
if (! PyObject_CallFunction(_write_method, "s", a))
42+
if (! PyObject_CallFunction(_write_method, (char *)"s", a))
4343
throw PythonExceptionOccurred();
4444
}
4545
};
@@ -83,10 +83,12 @@ convert_ttf_to_ps(PyObject* self, PyObject* args, PyObject* kwds) {
8383
int fonttype;
8484
std::vector<int> glyph_ids;
8585

86-
static char *kwlist[] = { "filename", "output", "fonttype", "glyph_ids", NULL };
86+
static const char *kwlist[] = {
87+
"filename", "output", "fonttype", "glyph_ids", NULL };
8788
if (! PyArg_ParseTupleAndKeywords
8889
(args, kwds,
89-
"sO&i|O&:convert_ttf_to_ps", kwlist,
90+
"sO&i|O&:convert_ttf_to_ps",
91+
(char**)kwlist,
9092
&filename,
9193
fileobject_to_PythonFileWriter,
9294
&output,
@@ -140,10 +142,11 @@ py_get_pdf_charprocs(PyObject* self, PyObject* args, PyObject* kwds) {
140142
std::vector<int> glyph_ids;
141143
PyObject* result;
142144

143-
static char *kwlist[] = { "filename", "glyph_ids", NULL };
145+
static const char *kwlist[] = { "filename", "glyph_ids", NULL };
144146
if (! PyArg_ParseTupleAndKeywords
145147
(args, kwds,
146-
"s|O&:convert_ttf_to_ps", kwlist,
148+
"s|O&:convert_ttf_to_ps",
149+
(char **)kwlist,
147150
&filename,
148151
pyiterable_to_vector_int,
149152
&glyph_ids))

src/ft2font.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,8 +1411,8 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
14111411
std::string tagname = Py::String(args[0]);
14121412

14131413
int tag;
1414-
char *tags[] = {"head", "maxp", "OS/2", "hhea",
1415-
"vhea", "post", "pclt", NULL};
1414+
const char *tags[] = {"head", "maxp", "OS/2", "hhea",
1415+
"vhea", "post", "pclt", NULL};
14161416

14171417
for (tag=0; tags[tag] != NULL; tag++)
14181418
if (strcmp(tagname.c_str(), tags[tag]) == 0)

ttconv/pprdrv_tt.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Fixed getFixed(BYTE *s)
107107
** is always 4 characters, though the last characters may be
108108
** padding spaces.
109109
-----------------------------------------------------------------------*/
110-
BYTE *GetTable(struct TTFONT *font, char *name)
110+
BYTE *GetTable(struct TTFONT *font, const char *name)
111111
{
112112
BYTE *ptr;
113113
ULONG x;
@@ -181,10 +181,10 @@ void Read_name(struct TTFONT *font)
181181
/* Set default values to avoid future references to */
182182
/* undefined pointers. */
183183
font->PostName = font->FullName =
184-
font->FamilyName = font->Version = font->Style = "unknown";
184+
font->FamilyName = font->Version = font->Style = (char*)"unknown";
185185
font->Copyright = font->Trademark = (char*)NULL;
186186

187-
table_ptr = GetTable(font,"name"); /* pointer to table */
187+
table_ptr = GetTable(font, "name"); /* pointer to table */
188188
try {
189189
numrecords = getUSHORT( table_ptr + 2 ); /* number of names */
190190
strings = table_ptr + getUSHORT( table_ptr + 4 ); /* start of string storage */
@@ -654,10 +654,10 @@ void sfnts_glyf_table(TTStreamWriter& stream, struct TTFONT *font, ULONG oldoffs
654654
*/
655655
void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
656656
{
657-
char *table_names[]= /* The names of all tables */
658-
{ /* which it is worth while */
659-
"cvt ", /* to include in a Type 42 */
660-
"fpgm", /* PostScript font. */
657+
static const char *table_names[] = /* The names of all tables */
658+
{ /* which it is worth while */
659+
"cvt ", /* to include in a Type 42 */
660+
"fpgm", /* PostScript font. */
661661
"glyf",
662662
"head",
663663
"hhea",
@@ -828,7 +828,7 @@ void ttfont_sfnts(TTStreamWriter& stream, struct TTFONT *font)
828828
** this array will instead convert PostScript character names
829829
** to executable proceedures.
830830
--------------------------------------------------------------*/
831-
char *Apple_CharStrings[]={
831+
const char *Apple_CharStrings[]={
832832
".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign",
833833
"dollar","percent","ampersand","quotesingle","parenleft","parenright",
834834
"asterisk","plus", "comma","hyphen","period","slash","zero","one","two",
@@ -871,7 +871,7 @@ char *Apple_CharStrings[]={
871871
** This routine is called by the one below.
872872
** It is also called from pprdrv_tt2.c
873873
*/
874-
char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex)
874+
const char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex)
875875
{
876876
int GlyphIndex;
877877
static char temp[80];
@@ -1227,7 +1227,7 @@ void get_pdf_charprocs(const char *filename, std::vector<int>& glyph_ids, TTDict
12271227
i != glyph_ids.end(); ++i) {
12281228
StringStreamWriter writer;
12291229
tt_type3_charproc(writer, &font, *i);
1230-
char* name = ttfont_CharStrings_getname(&font, *i);
1230+
const char* name = ttfont_CharStrings_getname(&font, *i);
12311231
dict.add_pair(name, writer.str().c_str());
12321232
}
12331233
}

ttconv/truetype.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Fixed getFixed(BYTE *p);
9898

9999
/* This is the one routine in pprdrv_tt.c that is */
100100
/* called from pprdrv_tt.c. */
101-
char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex);
101+
const char *ttfont_CharStrings_getname(struct TTFONT *font, int charindex);
102102

103103
void tt_type3_charproc(TTStreamWriter& stream, struct TTFONT *font, int charindex);
104104

0 commit comments

Comments
 (0)