/* This file is part of Pazpar2.
- Copyright (C) 2006-2009 Index Data
+ Copyright (C) 2006-2010 Index Data
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
\brief MARC MAP utilities (hash lookup etc)
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#else
+/* disable inline if AC_C_INLINE is not in use (Windows) */
+#define inline
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <yaz/nmem.h>
#include "jenkins_hash.h"
-#include <marchash.h>
+#include "marchash.h"
-inline void strtrimcat(char *dest, const char *src)
+static inline void strtrimcat(char *dest, const char *src)
{
const char *in;
char *out;
*(++last_nonspace) = '\0';
}
-inline void strtrimcpy(char *dest, const char *src)
+static inline void strtrimcpy(char *dest, const char *src)
{
*dest = '\0';
strtrimcat(dest, src);
field = NULL;
if (!strcmp((const char *) field_node->name, "controlfield"))
{
- field = marchash_add_field(
- marchash,
- (const char *) xmlGetProp(field_node, BAD_CAST "tag"),
- (const char *) xmlNodeGetContent(field_node));
+ xmlChar *content = xmlNodeGetContent(field_node);
+ xmlChar *tag = xmlGetProp(field_node, BAD_CAST "tag");
+ if (tag && content)
+ field = marchash_add_field(
+ marchash, (const char *) tag, (const char *) content);
+ xmlFree(content);
+ xmlFree(tag);
}
else if (!strcmp((const char *) field_node->name, "datafield"))
{
- field = marchash_add_field(
- marchash,
- (const char *) xmlGetProp(field_node, BAD_CAST "tag"),
- (const char *) xmlNodeGetContent(field_node));
+ xmlChar *content = xmlNodeGetContent(field_node);
+ xmlChar *tag = xmlGetProp(field_node, BAD_CAST "tag");
+ if (tag && content)
+ field = marchash_add_field(
+ marchash, (const char *) tag, (const char *) content);
+ xmlFree(content);
+ xmlFree(tag);
}
if (field)
{
if ((sub_node->type == XML_ELEMENT_NODE) &&
!strcmp((const char *) sub_node->name, "subfield"))
{
- marchash_add_subfield(
- marchash, field,
- xmlGetProp(sub_node, BAD_CAST "code")[0],
- (const char *) xmlNodeGetContent(sub_node));
+ xmlChar *content = xmlNodeGetContent(sub_node);
+ xmlChar *code = xmlGetProp(sub_node, BAD_CAST "code");
+ if (code && content)
+ marchash_add_subfield(
+ marchash, field,
+ code[0], (const char *) content);
+ xmlFree(content);
+ xmlFree(code);
}
sub_node = sub_node->next;
}