diff options
author | Dave Beckett <dave@dajobe.org> | 2003-03-30 20:43:08 +0000 |
---|---|---|
committer | Dave Beckett <dave@dajobe.org> | 2003-03-30 20:43:08 +0000 |
commit | 1b4b381432d833761b1a355ce7e067900446bdff (patch) | |
tree | ddbcce9aaea6923eea6a2ea6417e7a0d6a0d6408 | |
parent | 5ceab31d2d057ae397a0f91bbc6ef4c688d52e75 (diff) | |
download | raptor-1b4b381432d833761b1a355ce7e067900446bdff.tar.gz |
(main) Moved raptor_validate_xml_ID, raptor_xml_escape_string test
code to raptor_xml.c
-rw-r--r-- | src/raptor_general.c | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/src/raptor_general.c b/src/raptor_general.c index 5736dc79..e18daf9f 100644 --- a/src/raptor_general.c +++ b/src/raptor_general.c @@ -1252,115 +1252,3 @@ raptor_stats_print(raptor_parser *rdf_parser, FILE *stream) } } #endif - - - - - -#ifdef STANDALONE - -/* static prototypes */ -void raptor_bad_string_print(const unsigned char *input, FILE *stream); -int main(int argc, char *argv[]); - -void -raptor_bad_string_print(const unsigned char *input, FILE *stream) -{ - while(*input) { - char c=*input; - if(isprint(c)) - fputc(c, stream); - else - fprintf(stream, "\\x%02X", (c & 0xff)); - input++; - } -} - - -int -main(int argc, char *argv[]) -{ - char *program=argv[0]; - struct tv { - const unsigned char *string; - const char quote; - const unsigned char *result; - }; - struct tv *t; - struct tv test_values[]={ - {"&", 0, "&"}, - {"<", 0, "<"}, - {">", 0, ">"}, - - {"'&'", '\'', "'&'"}, - {"'<'", '\'', "'<'"}, - {"'>'", '\'', "'>'"}, - - {"\"&\"", '\"', ""&""}, - {"\"<\"", '\"', ""<""}, - {"\">\"", '\"', "">""}, - - {"&", 0, "&amp;"}, - {"<foo>", 0, "<foo>"}, - - {"\x1f", 0, ""}, - {"\xc2\x80", 0, "€"}, - {"\xe0\xa0\x80", 0, "ࠀ"}, - {"\xf0\x90\x80\x80", 0, "𐀀"}, - - {"\x7f", 0, ""}, - {"\xdf\xbf", 0, "߿"}, - {"\xef\xbf\xbd", 0, "�"}, - {"\xf4\x8f\xbf\xbf", 0, ""}, - - {"\xc3\xbf", 0, "ÿ"}, - {"\xf0\x8f\xbf\xbf", 0, ""}, - - {NULL, 0, 0} - }; - int i; - int failures=0; - - for(i=0; (t=&test_values[i]) && t->string; i++) { - const unsigned char *utf8_string=t->string; - int quote=t->quote; - size_t utf8_string_len=strlen(utf8_string); - unsigned char *xml_string; - int xml_string_len=0; - - xml_string_len=raptor_xml_escape_string(NULL, utf8_string, utf8_string_len, - NULL, 0, quote); - xml_string=(char*)RAPTOR_MALLOC(cstring, xml_string_len+1); - - xml_string_len=raptor_xml_escape_string(NULL, utf8_string, utf8_string_len, - xml_string, xml_string_len, quote); - if(!xml_string) { - fprintf(stderr, "%s: raptor_xml_escape_string FAILED to escape string '", - program); - raptor_bad_string_print(utf8_string, stderr); - fputs("'\n", stderr); - failures++; - continue; - } - if(strcmp(xml_string, t->result)) { - fprintf(stderr, "%s: raptor_xml_escape_string FAILED to escape string '", - program); - raptor_bad_string_print(utf8_string, stderr); - fprintf(stderr, "', expected '%s', result was '%s'\n", - t->result, xml_string); - failures++; - continue; - } - - fprintf(stderr, "%s: raptor_xml_escape_string escaped string to '%s' ok\n", - program, xml_string); - RAPTOR_FREE(cstring, xml_string); - } - - if(!failures) - fprintf(stderr, "%s: raptor_xml_escape_string all tests OK\n", program); - - return failures; -} - -#endif |