Skip to content

Commit

Permalink
small changes to syntax to get rid of compiler warnings. No changes to
Browse files Browse the repository at this point in the history
* error.c HTMLparser.c testC14N.c testHTML.c testURI.c
  xmlcatalog.c xmlmemory.c xmlreader.c xmlschemastypes.c
  python/libxml.c include/libxml/xmlmemory.h: small changes
  to syntax to get rid of compiler warnings.  No changes
  to logic.
  • Loading branch information
William M. Brack committed Aug 5, 2003
1 parent c758c22 commit c193956
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 49 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Tue Aug 5 23:51:21 HKT 2003 William Brack <wbrack@mmm.com.hk>

* error.c HTMLparser.c testC14N.c testHTML.c testURI.c
xmlcatalog.c xmlmemory.c xmlreader.c xmlschemastypes.c
python/libxml.c include/libxml/xmlmemory.h: small changes
to syntax to get rid of compiler warnings. No changes
to logic.

Mon Aug 4 22:40:54 CEST 2003 Daniel Veillard <daniel@veillard.com>

* doc/libxml2-api.xml doc/html/*: rebuilt the API and docs.
Expand Down
4 changes: 2 additions & 2 deletions HTMLparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4331,7 +4331,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
*/
static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third, int comment) {
xmlChar next, xmlChar third, int iscomment) {
int base, len;
htmlParserInputPtr in;
const xmlChar *buf;
Expand All @@ -4354,7 +4354,7 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
if (third) len -= 2;
else if (next) len --;
for (;base < len;base++) {
if (!incomment && (base + 4 < len) && !comment) {
if (!incomment && (base + 4 < len) && !iscomment) {
if ((buf[base] == '<') && (buf[base + 1] == '!') &&
(buf[base + 2] == '-') && (buf[base + 3] == '-')) {
incomment = 1;
Expand Down
17 changes: 10 additions & 7 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <stdarg.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h> /* for char constants */
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
Expand Down Expand Up @@ -149,29 +150,31 @@ xmlParserPrintFileInfo(xmlParserInputPtr input) {
void
xmlParserPrintFileContext(xmlParserInputPtr input) {
const xmlChar *cur, *base;
int n, col;
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
xmlChar content[81]; /* space for 80 chars + line terminator */
xmlChar *ctnt;

if (input == NULL) return;
cur = input->cur;
base = input->base;
/* skip backwards over any end-of-lines */
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
cur--;
}
n = 0;
/* search backwards for beginning-of-line (to max buff size) */
while ((n++ < sizeof(content)-1) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
(*(cur) != '\n') && (*(cur) != '\r'))
cur--;
if ((*cur == '\n') || (*cur == '\r')) cur++;
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
/* calculate the error position in terms of the current position */
col = input->cur - cur;
/* search forward for end-of-line (to max buff size) */
n = 0;
ctnt = content;
/* copy selected text to our buffer */
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < sizeof(content)-1)) {
while ((*cur != 0) && (*(cur) != '\n') &&
(*(cur) != '\r') && (n < sizeof(content)-1)) {
*ctnt++ = *cur++;
n++;
}
Expand All @@ -183,8 +186,8 @@ xmlParserPrintFileContext(xmlParserInputPtr input) {
ctnt = content;
/* (leave buffer space for pointer + line terminator) */
while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
if (*ctnt!='\t')
*ctnt = ' ';
if (*(ctnt) != '\t')
*(ctnt) = ' ';
*ctnt++;
}
*ctnt++ = '^';
Expand Down
7 changes: 6 additions & 1 deletion include/libxml/xmlmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int xmlGcMemGet (xmlFreeFunc *freeFunc,
int xmlInitMemory (void);

/*
* Those are specific to the XML debug memory wrapper.
* These are specific to the XML debug memory wrapper.
*/
int xmlMemUsed (void);
void xmlMemDisplay (FILE *fp);
Expand All @@ -131,6 +131,11 @@ void * xmlMemMalloc (size_t size);
void * xmlMemRealloc (void *ptr,size_t size);
void xmlMemFree (void *ptr);
char * xmlMemoryStrdup (const char *str);
void * xmlMallocLoc (size_t size, const char *file, int line);
void * xmlReallocLoc (void *ptr, size_t size, const char *file, int line);
void * xmlMallocAtomicLoc (size_t size, const char *file, int line);
char * xmlMemStrdupLoc (const char *str, const char *file, int line);


#ifdef DEBUG_MEMORY_LOCATION
/**
Expand Down
6 changes: 3 additions & 3 deletions python/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pythonExternalEntityLoader(const char *URL, const char *ID,
if (result == NULL) {
Py_DECREF(ret);
} else if (URL != NULL) {
result->filename = xmlStrdup((const xmlChar *)URL);
result->filename = (char *) xmlStrdup((const xmlChar *)URL);
result->directory = xmlParserGetDirectory((const char *) URL);
}
}
Expand Down Expand Up @@ -2690,7 +2690,7 @@ libxml_xmlRelaxNGSetValidErrors(ATTRIBUTE_UNUSED PyObject * self, PyObject * arg
#endif

ctxt = PyrelaxNgValidCtxt_Get(pyobj_ctx);
if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, &pyCtxt) == -1)
if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == -1)
{
py_retval = libxml_intWrap(-1);
return(py_retval);
Expand Down Expand Up @@ -2736,7 +2736,7 @@ libxml_xmlRelaxNGFreeValidCtxt(ATTRIBUTE_UNUSED PyObject *self, PyObject *args)
return(NULL);
ctxt = (xmlRelaxNGValidCtxtPtr) PyrelaxNgValidCtxt_Get(pyobj_ctxt);

if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, &pyCtxt) == 0)
if (xmlRelaxNGGetValidErrors(ctxt, NULL, NULL, (void **) &pyCtxt) == 0)
{
if (pyCtxt != NULL)
{
Expand Down
8 changes: 3 additions & 5 deletions testC14N.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename);

static xmlChar **parse_list(xmlChar *str);

static void print_xpath_nodes(xmlNodeSetPtr nodes);
/* static void print_xpath_nodes(xmlNodeSetPtr nodes); */

static int
test_c14n(const char* xml_filename, int with_comments, int exclusive,
Expand Down Expand Up @@ -313,6 +313,7 @@ load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
return(xpath);
}

/*
static void
print_xpath_nodes(xmlNodeSetPtr nodes) {
xmlNodePtr cur;
Expand Down Expand Up @@ -343,10 +344,7 @@ print_xpath_nodes(xmlNodeSetPtr nodes) {
}
}
}




*/

#else
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion testHTML.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar
outlen = sizeof output - 1;
htmlEncodeEntities(output, &outlen, att, &attlen, '\'');
output[outlen] = 0;
fprintf(stdout, "%s", output);
fprintf(stdout, "%s", (char *) output);
att += attlen;
}
fprintf(stdout, "'");
Expand Down
4 changes: 2 additions & 2 deletions testURI.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void handleURI(const char *str) {
if (escape != 0) {
parsed = xmlSaveUri(uri);
res = xmlURIEscape(parsed);
printf("%s\n", res);
printf("%s\n", (char *) res);

} else {
xmlPrintURI(stdout, uri);
Expand All @@ -45,7 +45,7 @@ static void handleURI(const char *str) {
} else {
res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
if (res != NULL) {
printf("%s\n", res);
printf("%s\n", (char *) res);
}
else
printf("::ERROR::\n");
Expand Down
10 changes: 5 additions & 5 deletions xmlcatalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static void usershell(void) {
if (ans == NULL) {
printf("No entry for PUBLIC %s\n", argv[0]);
} else {
printf("%s\n", ans);
printf("%s\n", (char *) ans);
xmlFree(ans);
}
}
Expand All @@ -206,7 +206,7 @@ static void usershell(void) {
if (ans == NULL) {
printf("No entry for SYSTEM %s\n", argv[0]);
} else {
printf("%s\n", ans);
printf("%s\n", (char *) ans);
xmlFree(ans);
}
}
Expand Down Expand Up @@ -256,7 +256,7 @@ static void usershell(void) {
if (ans == NULL) {
printf("Resolver failed to find an answer\n");
} else {
printf("%s\n", ans);
printf("%s\n", (char *) ans);
xmlFree(ans);
}
}
Expand Down Expand Up @@ -539,7 +539,7 @@ int main(int argc, char **argv) {
printf("No entry for PUBLIC %s\n", argv[i]);
exit_value = 4;
} else {
printf("%s\n", ans);
printf("%s\n", (char *) ans);
xmlFree(ans);
}
} else {
Expand All @@ -549,7 +549,7 @@ int main(int argc, char **argv) {
printf("No entry for SYSTEM %s\n", argv[i]);
exit_value = 4;
} else {
printf("%s\n", ans);
printf("%s\n", (char *) ans);
xmlFree(ans);
}
}
Expand Down
4 changes: 0 additions & 4 deletions xmlmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
#include <libxml/xmlerror.h>

void xmlMallocBreakpoint(void);
void * xmlMemMalloc(size_t size);
void * xmlMemRealloc(void *ptr,size_t size);
void xmlMemFree(void *ptr);
char * xmlMemoryStrdup(const char *str);

/************************************************************************
* *
Expand Down
16 changes: 0 additions & 16 deletions xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,12 @@ static void
xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
const xmlChar **atts) {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserCtxtPtr origctxt;
xmlTextReaderPtr reader = ctxt->_private;

#ifdef DEBUG_CALLBACKS
printf("xmlTextReaderStartElement(%s)\n", fullname);
#endif
if ((reader != NULL) && (reader->startElement != NULL)) {
/*
* when processing an entity, the context may have been changed
*/
origctxt = reader->ctxt;
reader->startElement(ctx, fullname, atts);
if ((ctxt->node != NULL) && (ctxt->input != NULL) &&
(ctxt->input->cur != NULL) && (ctxt->input->cur[0] == '/') &&
Expand All @@ -266,18 +261,12 @@ xmlTextReaderStartElement(void *ctx, const xmlChar *fullname,
static void
xmlTextReaderEndElement(void *ctx, const xmlChar *fullname) {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserCtxtPtr origctxt;
xmlTextReaderPtr reader = ctxt->_private;

#ifdef DEBUG_CALLBACKS
printf("xmlTextReaderEndElement(%s)\n", fullname);
#endif
if ((reader != NULL) && (reader->endElement != NULL)) {
/*
* when processing an entity, the context may have been changed
*/
origctxt = reader->ctxt;

reader->endElement(ctx, fullname);
}
}
Expand All @@ -294,18 +283,13 @@ static void
xmlTextReaderCharacters(void *ctx, const xmlChar *ch, int len)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserCtxtPtr origctxt;
xmlTextReaderPtr reader = ctxt->_private;

#ifdef DEBUG_CALLBACKS
printf("xmlTextReaderCharacters()\n");
#endif
if ((reader != NULL) && (reader->characters != NULL)) {
reader->characters(ctx, ch, len);
/*
* when processing an entity, the context may have been changed
*/
origctxt = reader->ctxt;
}
}

Expand Down
6 changes: 3 additions & 3 deletions xmlschemastypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ struct _xmlSchemaValDecimal {
unsigned long hi;
unsigned int extra;
unsigned int sign:1;
int frac:7;
int total:8;
unsigned int frac:7;
unsigned int total:8;
};

typedef struct _xmlSchemaValQName xmlSchemaValQName;
Expand Down Expand Up @@ -1413,7 +1413,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar *value,
goto return0;
case XML_SCHEMAS_DECIMAL: {
const xmlChar *cur = value, *tmp;
int frac = 0, len, neg = 0;
unsigned int frac = 0, len, neg = 0;
unsigned long base = 0;
if (cur == NULL)
goto return1;
Expand Down

0 comments on commit c193956

Please sign in to comment.