Forráskód Böngészése

Merge branch 'rebrand'

scossu 1 hónapja
szülő
commit
1e1c1d2f1d

+ 1 - 1
Doxyfile

@@ -48,7 +48,7 @@ PROJECT_NAME           = Volksdata
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = 1.0b5
+PROJECT_NUMBER         = 1.0b3
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewers a

+ 0 - 2
include/volksdata/codec.h

@@ -116,8 +116,6 @@ typedef void (*gr_encode_done_fn_t)(void *it);
  *
  * @param[in] rep NT representation of the term.
  *
- * @param[in] nsm Namespace map handle.
- *
  * @param[out] term Pointer to the term handle to be created. Implementaions
  *  SHOULD return NULL on a parse error.
  *

+ 0 - 3
include/volksdata/codec/parser_nt.h

@@ -8,9 +8,6 @@
  *
  * @param[in] rep N-Triples representation as a character string.
  *
- * @param[in] map Unused: there is no namespace prefixing in N-triples. Kept
- *  for interface compatibility. May be NULL.
- *
  * @param[out] term Term to be created from the string.
  *
  * @return VOLK_OK on success, VOLK_VALUE_ERR if the string is not valid

+ 1 - 1
include/volksdata/core.h

@@ -22,7 +22,7 @@
 #include "xxhash.h"
 
 
-#define VOLK_VERSION "1.0b2"
+#define VOLK_VERSION "1.0b3"
 
 
 // Logging and debugging.

+ 1 - 1
include/volksdata/graph.h

@@ -46,7 +46,7 @@ VOLK_graph_new (VOLK_Store *store, const char *uri_str);
  * #VOLK_store_new(), or NULL; in the latter case, it defaults to a temporary
  * HTable store that is freed together with the graph.
  *
- * @param[in] uri_str URI string of the new graph. It MUST be a namespace-
+ * @param[in] ns_str URI string of the new graph. It MUST be a namespace-
  *  prefixed URI registered in the global namespace map. It cannot be NULL.
  *
  * @return New graph, or NULL on error. Must be freed with #VOLK_graph_free().

+ 0 - 10
include/volksdata/namespace.h

@@ -41,8 +41,6 @@ extern struct hashmap *VOLK_default_nsm;
  *
  * If the prefix already exists, it is quietly updated with the new value.
  *
- * @param[in] map The map to add to.
- *
  * @param[in] pfx The namespace prefix.
  *
  * @param[in] nsstr Fully qualified namespace.
@@ -55,8 +53,6 @@ VOLK_nsmap_add (const char *pfx, const char *nsstr);
 
 
 /** @brief Remove a prefix -> namespace pair from a map.
- *
- * @param[in] map The map to remove from.
  *
  * @param[in] pfx The namespace prefix to remove.
  *
@@ -67,8 +63,6 @@ VOLK_nsmap_remove (const char *pfx);
 
 
 /** @brief Get the namespace for a prefix.
- *
- * @param[in] map The map to look up the namespace in.
  *
  * @param[in] pfx The prefix to look up.
  *
@@ -80,8 +74,6 @@ VOLK_nsmap_get_ns (const char *pfx);
 
 
 /** @brief Get the prefix for a namespace.
- *
- * @param[in] map The map to look up the prefix in.
  *
  * @param[in] ns The namespace to look up.
  *
@@ -132,8 +124,6 @@ VOLK_nsmap_denormalize_uri (const char *fq_uri, char **pfx_uri);
 
 
 /** @brief Dump all entries of the namespace map.
- *
- * @param[in] map Map to dump.
  *
  * @return 2-dimensional array of strings, with as many rows as namespace
  *  entries, and two columns: the first for the namespace prefix, the second

+ 1 - 1
src/codec.c

@@ -115,7 +115,7 @@ escape_lit (const char *in, char **out_p)
 char *
 fmt_header (char *pfx)
 {
-    char *body = "Generated by lsup_rdf v" VOLK_VERSION " on ";
+    char *body = "Generated by Volksdata v" VOLK_VERSION " on ";
     time_t now = time (NULL);
     char date[16];
     strftime (date, sizeof (date), "%m/%d/%Y", gmtime (&now));

+ 17 - 9
src/codec/codec_ttl.c

@@ -6,11 +6,11 @@
  * This iterator yields one or more triples at a time, one group per subject,
  * with the most compact form allowed by Turtle, e.g.
  *
- * :s :p1 :o1, :o2, o3; p2 o4, o5, <http://example.com/ext1> .
+ * ```:s :p1 :o1, :o2, o3; :p2 :o4, :o5, <http://example.com/ext1> .```
  */
 typedef struct {
     const VOLK_Codec *  codec;      ///< Codec that generated this iterator.
-    const VOLK_Graph *  gr;        ///< Graph being encoded.
+    const VOLK_Graph *  gr;         ///< Graph being encoded.
     VOLK_TermSet *      subjects;   ///< All subjects in the graph.
     size_t              s_cur;      ///< Term set cursor.
     VOLK_rc             rc;         ///< Internal return code.
@@ -26,8 +26,10 @@ static VOLK_rc
 term_to_ttl (const VOLK_Term *term, char **out_p)
 {
     VOLK_rc rc;
-    char *tmp = NULL, *out = NULL;
-    char *metadata = NULL;
+    char
+        *tmp = NULL,
+        *out = NULL,
+        *metadata = NULL;
     size_t buf_len;
 
     VOLK_rc md_rc = VOLK_NORESULT;
@@ -36,18 +38,23 @@ term_to_ttl (const VOLK_Term *term, char **out_p)
             if (strcmp (term->data, VOLK_RDF_TYPE) == 0) {
                 // Shorten RDF type
                 buf_len = 2;
-                tmp = "a";
+                out = realloc (*out_p, 2);
+                if (UNLIKELY (!out)) return VOLK_MEM_ERR;
+                out[0] = 'a';
+                out[1] = '\0';
             } else {
                 md_rc = VOLK_nsmap_denormalize_uri (term->data, &tmp);
                 PRCCK (md_rc);
                 if (md_rc == VOLK_NORESULT) {
                     // If URI counld not be shortened, add `<>`
-                    out = realloc (*out_p, strlen (tmp) + 3);
+                    // and copy term from the original.
+                    out = realloc (*out_p, strlen (term->data) + 3);
                     if (UNLIKELY (!out)) return VOLK_MEM_ERR;
-                    sprintf (out, "<%s>", tmp);
-                    free (tmp);
-
+                    sprintf (out, "<%s>", term->data);
                 } else {
+                    // If URI was shortened, write it out without `<>` and
+                    // use previously allocated data from denormalization.
+                    // Free previous output pointer
                     free (*out_p);
                     out = tmp;
                 }
@@ -147,6 +154,7 @@ term_to_ttl (const VOLK_Term *term, char **out_p)
 
         default:
             out = *out_p;  // This is considered garbage.
+            log_error ("Invalid term type: %d", term->type);
             rc = VOLK_PARSE_ERR;
     }
     free (metadata);

+ 2 - 0
src/codec/lexer_ttl.re

@@ -364,6 +364,8 @@ VOLK_ttl_parse_doc (FILE *fh, VOLK_Graph **gr_p, size_t *ct, char **err_p)
     *err_p = NULL;
     *gr_p = NULL;
 
+    if (!fh) return VOLK_VALUE_ERR;
+
     VOLK_TTLParserState *state = malloc (sizeof (*state));
     if (UNLIKELY (!state)) return VOLK_MEM_ERR;
     state->base = NULL;