Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6497461

Browse files
committed
Suppress various compiler warnings in new xml code.
1 parent426030e commit6497461

File tree

2 files changed

+51
-45
lines changed

2 files changed

+51
-45
lines changed

‎src/backend/utils/adt/xml.c

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.1 2006/12/21 16:05:15 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.2 2006/12/23 04:56:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -112,12 +112,12 @@ xml_out(PG_FUNCTION_ARGS)
112112
xmltype*s=PG_GETARG_XML_P(0);
113113
char*result;
114114
int32len;
115-
115+
116116
len=VARSIZE(s)-VARHDRSZ;
117117
result=palloc(len+1);
118118
memcpy(result,VARDATA(s),len);
119119
result[len]='\0';
120-
120+
121121
PG_RETURN_CSTRING(result);
122122
}
123123

@@ -344,7 +344,7 @@ xmlvalidate(PG_FUNCTION_ARGS)
344344
ctxt=xmlNewParserCtxt();
345345
if (ctxt==NULL)
346346
xml_ereport(ERROR,"could not allocate parser context",ctxt);
347-
doc=xmlCtxtReadMemory(ctxt, (char*)VARDATA(data),
347+
doc=xmlCtxtReadMemory(ctxt, (char*)VARDATA(data),
348348
VARSIZE(data)-VARHDRSZ,PG_XML_DEFAULT_URI,NULL,0);
349349
if (doc==NULL)
350350
xml_ereport(ERROR,"could not parse XML data",ctxt);
@@ -371,15 +371,15 @@ xmlvalidate(PG_FUNCTION_ARGS)
371371

372372
if (xmlValidateDtd(xmlNewValidCtxt(),doc,dtd)==1)
373373
result= TRUE;
374-
374+
375375
#if0
376376
xmlFreeURI(uri);
377377
xmlFreeDtd(dtd);
378378
xmlFreeDoc(doc);
379379
xmlFreeParserCtxt(ctxt);
380380
xmlCleanupParser();
381381
#endif
382-
382+
383383
if (!result)
384384
xml_ereport(NOTICE,"validation against DTD failed",ctxt);
385385

@@ -405,15 +405,15 @@ xml_init(void)
405405
* if we can work.
406406
*/
407407
if (sizeof (char)!=sizeof (xmlChar))
408-
ereport(ERROR,
409-
(errmsg("cannot initialize XML library"),
410-
errdetail("libxml2 has incompatible char type: sizeof(char)=%u, sizeof(xmlChar)=%u.",
411-
sizeof(char),sizeof(xmlChar))));
412-
408+
ereport(ERROR,
409+
(errmsg("could not initialize XML library"),
410+
errdetail("libxml2 has incompatible char type: sizeof(char)=%u, sizeof(xmlChar)=%u.",
411+
(int)sizeof(char), (int)sizeof(xmlChar))));
412+
413413
xmlMemSetup(xml_pfree,xml_palloc,xml_repalloc,xml_pstrdup);
414414
xmlInitParser();
415415
LIBXML_TEST_VERSION;
416-
/* do not flood PG's logfile with libxml error messages - reset error handler*/
416+
/* do not flood PG's logfile with libxml error messages - reset error handler*/
417417
xmlSetGenericErrorFunc(NULL,xml_errorHandler);
418418
xml_errmsg=NULL;
419419
xml_errbuf=palloc(XML_ERRBUF_SIZE);
@@ -446,20 +446,21 @@ xml_parse(text *data, int opts, bool is_document)
446446
#endif
447447

448448
xml_init();
449-
449+
450450
len=VARSIZE(data)-VARHDRSZ;/* will be useful later */
451451
string=xml_text2xmlChar(data);
452-
452+
453453
ctxt=xmlNewParserCtxt();
454454
if (ctxt==NULL)
455455
xml_ereport(ERROR,"could not allocate parser context",ctxt);
456-
457-
/* first, we try to parse the string asit isXML doc, then, as XML chunk */
456+
457+
/* first, we try to parse the string as XML doc, then, as XML chunk */
458458
ereport(DEBUG3, (errmsg("string to parse: %s",string)));
459459
if (len>4&&CMP5(string,'<','?','x','m','l'))
460460
{
461461
/* consider it as DOCUMENT */
462-
doc=xmlCtxtReadMemory(ctxt,string,len,PG_XML_DEFAULT_URI,NULL,opts);
462+
doc=xmlCtxtReadMemory(ctxt, (char*)string,len,
463+
PG_XML_DEFAULT_URI,NULL,opts);
463464
if (doc==NULL)
464465
{
465466
xml_ereport(ERROR,"could not parse XML data",ctxt);
@@ -509,38 +510,38 @@ xml_parse(text *data, int opts, bool is_document)
509510
validationFailed= TRUE;
510511
}
511512
}
512-
513+
513514
if (validationFailed)
514515
xml_ereport(WARNING,"validation against DTD failed",ctxt);
515-
516-
/* TODO encoding issues
516+
517+
/* TODO encoding issues
517518
* (thoughts:
518519
* CASE:
519520
* - XML data has explicit encoding attribute in its prolog
520521
* - if not, assume that enc. of XML data is the same as client's one
521-
*
522+
*
522523
* The common rule is to accept the XML data only if its encoding
523524
* is the same as encoding of the storage (server's). The other possible
524525
* option is to accept all the docs, but DO TRANSFORMATION and, if needed,
525526
* change the prolog.
526-
*
527-
* I think I'd stick the first way (for the 1st version),
527+
*
528+
* I think I'd stick the first way (for the 1st version),
528529
* it's much simplier (less errors...)
529530
* ) */
530531
/* ... */
531-
532+
532533
xmlFreeParserCtxt(ctxt);
533534
xmlCleanupParser();
534-
535-
ereport(DEBUG3, (errmsg("XML data successfully parsed, encoding: %s",
535+
536+
ereport(DEBUG3, (errmsg("XML data successfully parsed, encoding: %s",
536537
(char*)doc->encoding)));
537-
538+
538539
returndoc;
539540
}
540541

541542

542-
/*
543-
* xmlChar<->text convertions
543+
/*
544+
* xmlChar<->text convertions
544545
*/
545546
staticxmlChar*
546547
xml_text2xmlChar(text*in)
@@ -551,13 +552,13 @@ xml_text2xmlChar(text *in)
551552
res=palloc(len+1);
552553
memcpy(res,VARDATA(in),len);
553554
res[len]='\0';
554-
555+
555556
return(res);
556557
}
557558

558559

559-
/*
560-
* Wrappers for memory management functions
560+
/*
561+
* Wrappers for memory management functions
561562
*/
562563
staticvoid*
563564
xml_palloc(size_tsize)
@@ -588,7 +589,7 @@ xml_pstrdup(const char *string)
588589

589590

590591
/*
591-
* Wrapper for "ereport" function.
592+
* Wrapper for "ereport" function.
592593
* Adds detail - libxml's native error message, if any.
593594
*/
594595
staticvoid
@@ -597,16 +598,16 @@ xml_ereport(int level, char *msg, void *ctxt)
597598
char*xmlErrDetail;
598599
intxmlErrLen,i;
599600
xmlErrorPtrlibxmlErr=NULL;
600-
601+
601602
if (xml_errmsg!=NULL)
602603
{
603604
ereport(DEBUG1, (errmsg("%s",xml_errmsg)));
604605
pfree(xml_errmsg);
605606
}
606-
607+
607608
if (ctxt!=NULL)
608609
libxmlErr=xmlCtxtGetLastError(ctxt);
609-
610+
610611
if (libxmlErr==NULL)
611612
{
612613
if (level==ERROR)
@@ -645,7 +646,7 @@ static void
645646
xml_errorHandler(void*ctxt,constchar*msg,...)
646647
{
647648
va_listargs;
648-
649+
649650
va_start(args,msg);
650651
vsnprintf(xml_errbuf,XML_ERRBUF_SIZE,msg,args);
651652
va_end(args);
@@ -841,13 +842,13 @@ xml_ereport_by_code(int level, char *msg, int code)
841842
det="Unregistered error (libxml error code: %d)";
842843
ereport(DEBUG1, (errmsg("Check out \"libxml/xmlerror.h\" and bring errcode \"%d\" processing to \"xml.c\".",code)));
843844
}
844-
845+
845846
if (xml_errmsg!=NULL)
846847
{
847848
ereport(DEBUG1, (errmsg("%s",xml_errmsg)));
848849
pfree(xml_errmsg);
849850
}
850-
851+
851852
ereport(level, (errmsg(msg),errdetail(det,code)));
852853
}
853854

@@ -857,11 +858,16 @@ xml_ereport_by_code(int level, char *msg, int code)
857858
* codepoint.
858859
*/
859860
staticpg_wchar
860-
sqlchar_to_unicode(unsignedchar*s)
861+
sqlchar_to_unicode(char*s)
861862
{
862863
intsave_enc;
863864
pg_wcharret;
864-
char*utf8string=pg_do_encoding_conversion(s,pg_mblen(s),GetDatabaseEncoding(),PG_UTF8);
865+
char*utf8string;
866+
867+
utf8string= (char*)pg_do_encoding_conversion((unsignedchar*)s,
868+
pg_mblen(s),
869+
GetDatabaseEncoding(),
870+
PG_UTF8);
865871

866872
save_enc=GetDatabaseEncoding();
867873
SetDatabaseEncoding(PG_UTF8);
@@ -898,11 +904,11 @@ is_valid_xml_namechar(pg_wchar c)
898904
* Map SQL identifier to XML name; see SQL/XML:2003 section 9.1.
899905
*/
900906
char*
901-
map_sql_identifier_to_xml_name(unsignedchar*ident,boolfully_escaped)
907+
map_sql_identifier_to_xml_name(char*ident,boolfully_escaped)
902908
{
903909
#ifdefUSE_LIBXML
904910
StringInfoDatabuf;
905-
unsignedchar*p;
911+
char*p;
906912

907913
initStringInfo(&buf);
908914

‎src/include/utils/xml.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.1 2006/12/21 16:05:16 petere Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.2 2006/12/23 04:56:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -32,6 +32,6 @@ extern Datum xmlpi(PG_FUNCTION_ARGS);
3232
externDatumxmlroot(PG_FUNCTION_ARGS);
3333
externDatumxmlvalidate(PG_FUNCTION_ARGS);
3434

35-
externchar*map_sql_identifier_to_xml_name(unsignedchar*ident,boolfully_escaped);
35+
externchar*map_sql_identifier_to_xml_name(char*ident,boolfully_escaped);
3636

3737
#endif/* XML_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp