wok-current diff liblrdf/stuff/raptor2.diff @ rev 22380

updated openexr again (2.2.0 -> 2.3.0)
author Hans-G?nter Theisgen
date Thu Nov 28 08:57:35 2019 +0100 (2019-11-28)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/liblrdf/stuff/raptor2.diff	Thu Nov 28 08:57:35 2019 +0100
     1.3 @@ -0,0 +1,193 @@
     1.4 +--- src/Makefile.am
     1.5 ++++ src/Makefile.am
     1.6 +@@ -4,5 +4,5 @@ lib_LTLIBRARIES = liblrdf.la
     1.7 + noinst_HEADERS = lrdf_md5.h md5_loc.h ladspa.h
     1.8 + 
     1.9 + liblrdf_la_SOURCES = lrdf.c lrdf_multi.c md5.c
    1.10 +-liblrdf_la_LIBADD = -lraptor
    1.11 ++liblrdf_la_LIBADD = -lraptor2
    1.12 + liblrdf_la_LDFLAGS = -version-info @LRDF_LIBTOOL_VERSION@
    1.13 +--- src/lrdf.c
    1.14 ++++ src/lrdf.c
    1.15 +@@ -18,6 +18,7 @@
    1.16 + static unsigned int lrdf_uid = 0;	/* A unique(ish) id to append to genid's to
    1.17 + 					 * avoid clashses */
    1.18 + 
    1.19 ++static raptor_world *world = NULL;
    1.20 + static lrdf_statement *triples = NULL;
    1.21 + static lrdf_statement *free_triples;
    1.22 + static lrdf_string_hash *resources_hash[LRDF_HASH_SIZE];
    1.23 +@@ -43,8 +44,7 @@ static void lrdf_remove_triple_hash(lrdf_triple_hash ** tbl,
    1.24 + 				    lrdf_hash hash, lrdf_statement * s);
    1.25 + static void lrdf_add_closure_hash(lrdf_closure_hash ** tbl,
    1.26 + 				  lrdf_hash subject, lrdf_hash object);
    1.27 +-static void lrdf_store(void *user_data,
    1.28 +-		       const raptor_statement * statement);
    1.29 ++static void lrdf_store(void *user_data, raptor_statement * statement);
    1.30 + void lrdf_free_statements(lrdf_statement * s);
    1.31 + void lrdf_copy_statement(lrdf_statement * from, lrdf_statement * to);
    1.32 + void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl,
    1.33 +@@ -71,7 +71,7 @@ void lrdf_init()
    1.34 +     unsigned int i;
    1.35 +     struct timeval tv;
    1.36 + 
    1.37 +-    raptor_init();
    1.38 ++    world = raptor_new_world();
    1.39 +     lrdf_more_triples(256);
    1.40 + 
    1.41 +     /* A UID to add to genids to make them safer */
    1.42 +@@ -112,7 +112,8 @@ void lrdf_more_triples(int count)
    1.43 + 
    1.44 + void lrdf_cleanup()
    1.45 + {
    1.46 +-    raptor_finish();
    1.47 ++    raptor_free_world(world);
    1.48 ++    world = NULL;
    1.49 + 
    1.50 +     lrdf_free_string_hash(resources_hash);
    1.51 +     lrdf_free_string_hash(literals_hash);
    1.52 +@@ -232,26 +233,29 @@ void lrdf_remove_matches(lrdf_statement *pattern)
    1.53 +     }
    1.54 + }
    1.55 + 
    1.56 +-static void lrdf_store(void *user_data, const raptor_statement * statement)
    1.57 ++static const char *lrdf_term_as_string(char *tmp, int tmp_len,
    1.58 ++				       const raptor_term *term)
    1.59 ++{
    1.60 ++    switch (term->type) {
    1.61 ++    case RAPTOR_TERM_TYPE_URI:
    1.62 ++	return (const char *) raptor_uri_as_string(term->value.uri);
    1.63 ++    case RAPTOR_TERM_TYPE_LITERAL:
    1.64 ++	return (const char *) term->value.literal.string;
    1.65 ++    case RAPTOR_TERM_TYPE_BLANK:
    1.66 ++	snprintf(tmp, tmp_len, "_:%s.%x", term->value.blank.string, lrdf_uid);
    1.67 ++	return tmp;
    1.68 ++    default:
    1.69 ++	return "(?)";
    1.70 ++    }
    1.71 ++}
    1.72 ++
    1.73 ++static void lrdf_store(void *user_data, raptor_statement * statement)
    1.74 + {
    1.75 +     lrdf_statement *s = lrdf_alloc_statement();
    1.76 +     char tmps[128], tmpp[128], tmpo[128];
    1.77 +-    char *subj = (char *) statement->subject,
    1.78 +-	 *pred = (char *) statement->predicate,
    1.79 +-	 *obj = (char *) statement->object;
    1.80 +-
    1.81 +-    if (statement->subject_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
    1.82 +-	snprintf(tmps, 127, "_:%s.%x", subj, lrdf_uid);
    1.83 +-	subj = tmps;
    1.84 +-    }
    1.85 +-    if (statement->predicate_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
    1.86 +-	snprintf(tmpp, 127, "_:%s.%x", pred, lrdf_uid);
    1.87 +-	pred = tmpp;
    1.88 +-    }
    1.89 +-    if (statement->object_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
    1.90 +-	snprintf(tmpo, 127, "_:%s.%x", obj, lrdf_uid);
    1.91 +-	obj = tmpo;
    1.92 +-    }
    1.93 ++    const char *subj = lrdf_term_as_string(tmps, 128, statement->subject),
    1.94 ++	       *pred = lrdf_term_as_string(tmpp, 128, statement->predicate),
    1.95 ++	       *obj = lrdf_term_as_string(tmpo, 128, statement->object);
    1.96 + 
    1.97 +     s->shash = lrdf_gen_hash(subj);
    1.98 +     s->phash = lrdf_gen_hash(pred);
    1.99 +@@ -261,7 +265,7 @@ static void lrdf_store(void *user_data, const raptor_statement * statement)
   1.100 + 
   1.101 +     s->subject = lrdf_check_hash(resources_hash, s->shash, subj);
   1.102 +     s->predicate = lrdf_check_hash(resources_hash, s->phash, pred);
   1.103 +-    if (statement->object_type == RAPTOR_IDENTIFIER_TYPE_LITERAL) {
   1.104 ++    if (statement->object->type == RAPTOR_TERM_TYPE_LITERAL) {
   1.105 + 	s->object = lrdf_check_hash(literals_hash, s->ohash, obj);
   1.106 + 	s->object_type = lrdf_literal;
   1.107 +     } else {
   1.108 +@@ -537,28 +541,22 @@ void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl,
   1.109 +     free(pathto);
   1.110 + }
   1.111 + 
   1.112 +-static void lrdf_error_handler(void *data, raptor_locator * locator,
   1.113 +-			       const char *message);
   1.114 ++static void lrdf_log_handler(void *data, raptor_log_message *message);
   1.115 + 
   1.116 +-static void lrdf_error_handler(void *data, raptor_locator * locator,
   1.117 +-			       const char *message)
   1.118 ++static void lrdf_log_handler(void *data, raptor_log_message *message)
   1.119 + {
   1.120 +-    fprintf(stderr, "liblrdf: error - ");
   1.121 +-    raptor_print_locator(stderr, locator);
   1.122 +-    fprintf(stderr, " - %s\n", message);
   1.123 +-
   1.124 +-    raptor_parse_abort((raptor_parser*)data);
   1.125 +-}
   1.126 ++    const char *severity = "error";
   1.127 ++    if (message->level == RAPTOR_LOG_LEVEL_WARN) {
   1.128 ++	severity = "warning";
   1.129 ++    }
   1.130 + 
   1.131 +-static void lrdf_warning_handler(void *data, raptor_locator * locator,
   1.132 +-				 const char *message);
   1.133 ++    fprintf(stderr, "liblrdf: %s - ", severity);
   1.134 ++    raptor_locator_print(message->locator, stderr);
   1.135 ++    fprintf(stderr, " - %s\n", message->text);
   1.136 + 
   1.137 +-static void lrdf_warning_handler(void *data, raptor_locator * locator,
   1.138 +-				 const char *message)
   1.139 +-{
   1.140 +-    fprintf(stderr, "liblrdf: warning - ");
   1.141 +-    raptor_print_locator(stderr, locator);
   1.142 +-    fprintf(stderr, " - %s\n", message);
   1.143 ++    if (message->level != RAPTOR_LOG_LEVEL_WARN) {
   1.144 ++	raptor_parser_parse_abort((raptor_parser*)data);
   1.145 ++    }
   1.146 + }
   1.147 + 
   1.148 + 
   1.149 +@@ -593,15 +591,15 @@ int lrdf_read_file_intl(const char *uri)
   1.150 +     lrdf_hash source;
   1.151 + 
   1.152 +     //printf("lrdf: reading %s\n", uri);
   1.153 +-    ruri = raptor_new_uri(uri);
   1.154 +-    furi = raptor_new_uri(uri);
   1.155 ++    ruri = raptor_new_uri(world, (const unsigned char *) uri);
   1.156 ++    furi = raptor_new_uri(world, (const unsigned char *) uri);
   1.157 +     source = lrdf_gen_hash(uri);
   1.158 +     lrdf_check_hash(resources_hash, source, uri);
   1.159 + 
   1.160 +     if (strstr(uri, ".rdf")) {
   1.161 +-	parser = raptor_new_parser("rdfxml");
   1.162 ++	parser = raptor_new_parser(world, "rdfxml");
   1.163 +     } else {
   1.164 +-	parser = raptor_new_parser("ntriples");
   1.165 ++	parser = raptor_new_parser(world, "ntriples");
   1.166 +     }
   1.167 +     if (!parser) {
   1.168 + 	fprintf(stderr, "liblrdf: failed to create parser\n");
   1.169 +@@ -609,12 +607,11 @@ int lrdf_read_file_intl(const char *uri)
   1.170 + 	return 1;
   1.171 +     }
   1.172 + 
   1.173 +-    raptor_set_error_handler(parser, parser, lrdf_error_handler);
   1.174 +-    raptor_set_warning_handler(parser, NULL, lrdf_warning_handler);
   1.175 +-    raptor_set_statement_handler(parser, &source, lrdf_store);
   1.176 +-    raptor_set_default_generate_id_parameters(parser, NULL, ++lrdf_uid);
   1.177 ++    raptor_world_set_log_handler(world, parser, lrdf_log_handler);
   1.178 ++    raptor_parser_set_statement_handler(parser, &source, lrdf_store);
   1.179 ++    raptor_world_set_generate_bnodeid_parameters(world, NULL, ++lrdf_uid);
   1.180 + 
   1.181 +-    if (raptor_parse_file(parser, furi, ruri)) {
   1.182 ++    if (raptor_parser_parse_file(parser, furi, ruri)) {
   1.183 + 	raptor_free_uri(furi);
   1.184 + 	raptor_free_uri(ruri);
   1.185 + 	raptor_free_parser(parser);
   1.186 +--- configure.ac
   1.187 ++++ configure.ac
   1.188 +@@ -18,7 +18,7 @@
   1.189 + AC_HEADER_STDC
   1.190 + AC_CHECK_HEADERS([errno.h limits.h stdlib.h string.h unistd.h])
   1.191 + 
   1.192 +-PKG_CHECK_MODULES(RAPTOR, raptor >= 0.9.11)
   1.193 ++PKG_CHECK_MODULES(RAPTOR, raptor2 >= 0.9.11)
   1.194 + 
   1.195 + # Checks for typedefs, structures, and compiler characteristics.
   1.196 + AC_C_CONST