Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit e4cc1b6

Browse files
committed
[[ Cleanup ]] revxml: Use const C strings whereever appropriate.
Removes a large number of GCC "write-strings" warnings.
1 parent 2c828e5 commit e4cc1b6

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

revxml/src/cxml.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class CXMLAttribute;
5050
//xmldoc.cpp
5151
int util_strnicmp(const char *s1, const char *s2, int n);
5252
int util_strncmp(const char *s1, const char *s2, int n);
53-
void util_concatstring(char *s, int slen, char *&d, int &dlen, int &dalloc);
54-
char *util_strchr(char *sptr, char target, int l);
53+
void util_concatstring(const char *s, int slen, char *&d, int &dlen, int &dalloc);
54+
const char *util_strchr(const char *sptr, char target, int l);
5555

5656
extern void CB_startDocument();
5757
extern void CB_endDocument();

revxml/src/revxml.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void REVXML_QUIT()
217217
}
218218

219219
//------------------------------------UTILITY FUNCTIONS--------------------------
220-
void DispatchMetaCardMessage(char *messagename,char *tmessage)
220+
void DispatchMetaCardMessage(const char *messagename, const char *tmessage)
221221
{
222222
int retvalue = 0;
223223
SetGlobal("xmlvariable",tmessage,&retvalue);
@@ -227,7 +227,7 @@ sprintf(mcmessage,"global xmlvariable;try;send \"%s xmlvariable\" to current car
227227
SendCardMessage(mcmessage, &retvalue);
228228
}
229229

230-
bool stringToBool(char *p_string)
230+
bool stringToBool(const char *p_string)
231231
{
232232
if (stricmp(p_string, "true") == 0)
233233
return true;

revxml/src/xmldoc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int util_strncmp(const char *one, const char *two, int n)
6262
return 1;
6363
}
6464

65-
char *util_strchr(char *sptr, char target, int l)
65+
const char *util_strchr(const char *sptr, char target, int l)
6666
{
6767
if (!l) l = strlen(sptr);
6868
const char *eptr = sptr + l;
@@ -76,7 +76,7 @@ char *util_strchr(char *sptr, char target, int l)
7676
}
7777

7878
//utility function used to concat two strings..and reallocate string if neccessary
79-
void util_concatstring(char *s, int slen, char *&d, int &dlen, int &dalloc)
79+
void util_concatstring(const char *s, int slen, char *&d, int &dlen, int &dalloc)
8080
{
8181
int newbufsize = dalloc;
8282
while (dlen + slen + 1 > newbufsize)
@@ -408,7 +408,7 @@ Bool CXMLDocument::GetElementByPath(CXMLElement *telement, char *tpath)
408408
return False;
409409

410410
if (*sptr == '/') sptr++;
411-
char *nameend;
411+
const char *nameend;
412412
char *nextname = strchr(sptr, '/');
413413
if (!nextname)
414414
{
@@ -418,7 +418,7 @@ Bool CXMLDocument::GetElementByPath(CXMLElement *telement, char *tpath)
418418
isroot = True;
419419

420420
}
421-
char *numpointer = util_strchr(sptr,'[',nextname-sptr);
421+
const char *numpointer = util_strchr(sptr,'[',nextname-sptr);
422422
if (numpointer)
423423
nameend = numpointer;
424424
else

revxml/src/xmlelement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,16 @@ return True if element found
615615
Bool CXMLElement::GoChildByPath(char *tpath)
616616
{
617617
if (!isinited()) return False;
618-
char *sptr = tpath;
618+
const char *sptr = tpath;
619619
char *childpointer = NULL;
620620
CXMLElement telement;
621621
telement.CopyElement(this);
622622
if (*sptr == '/') sptr++; //skip first slash
623623
Bool foundmatch = False;
624-
char *endptr = sptr + strlen(sptr);
624+
const char *endptr = sptr + strlen(sptr);
625625
while (sptr < endptr)
626626
{
627-
char *namestart,*nameend,*nextname,*numpointer;
627+
const char *namestart,*nameend,*nextname,*numpointer;
628628
nextname = strchr(sptr, '/' );
629629
if (!nextname) nextname = endptr;
630630
namestart = sptr;

0 commit comments

Comments
 (0)