Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/marc_read_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,14 @@ int yaz_marc_read_line(yaz_marc_t mt,
next = cp;
while ((next = strchr(next, marker_ch)))
{
/* allow only alphanumeric characters */
if ((next[1] >= 'A' && next[1] <= 'Z')
||(next[1] >= 'a' && next[1] <= 'z')
||(next[1] >= '0' && next[1] <= '9'))
{
if (!marker_skip)
break;
else if (next[2] == ' ')
else if (next[-1] == ' ')
break;
}
next++;
Expand All @@ -216,20 +217,13 @@ int yaz_marc_read_line(yaz_marc_t mt,
if (next)
len = next - cp - marker_skip;

if (marker_skip)
if (marker_skip && len > 1 && cp[1] == ' ')
{
/* remove ' ' after subfield marker */
char *cp_blank = strchr(cp, ' ');
if (cp_blank)
{
len--;
while (cp_blank != cp)
{
cp_blank[0] = cp_blank[-1];
cp_blank--;
}
cp++;
}
char *cp_mod = (char *) cp; /* line is allocated locally, so we can modify it */
cp_mod[1] = cp_mod[0]; /* does not deal with multi-byte subfields */
len--;
cp++;
}
yaz_marc_add_subfield(mt, cp, len);
if (!next)
Expand Down
4 changes: 2 additions & 2 deletions src/retrieval.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ int yaz_retrieval_request(yaz_retrieval_t p,
schema_ok = 1;
else
{
char *cp = 0;
const char *cp = 0;
wrbuf_rewind(w);
if (el->split && *el->split && (cp = strchr(schema, *el->split)))
wrbuf_write(w, schema, cp - schema);
Expand Down Expand Up @@ -361,7 +361,7 @@ int yaz_retrieval_request(yaz_retrieval_t p,
{
if (*el->backend_name)
{
char *cp;
const char *cp;
wrbuf_rewind(w);
wrbuf_puts(w, el->backend_name);
if (el->split && *el->split && schema
Expand Down
12 changes: 5 additions & 7 deletions src/solr.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr,
Z_SRW_scanResponse *scr)
{
xmlNodePtr node;
char *pos;
const char *pos;
int i = 0;

/* find the actual list */
Expand Down Expand Up @@ -297,19 +297,17 @@ static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr,
* This is due to SOLR not being able to encode them into 2 separate attributes.
*/
pos = strchr(val, '^');
if (pos != NULL)
if (pos)
{
term->displayTerm = odr_strdup(o, pos + 1);
*pos = '\0';
term->value = odr_strdup(o, val);
*pos = '^';
term->value = odr_strdupn(o, val, pos - val);
}
else
{
term->value = odr_strdup(o, val);
term->displayTerm = NULL;
term->displayTerm = 0;
}
term->whereInList = NULL;
term->whereInList = 0;
i++;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/zoom-record-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ static ZOOM_record record_cache_add(ZOOM_resultset r,
{
if (diag->uri)
{
char *cp;
rc->rec.diag_set = odr_strdup(r->odr, diag->uri);
if ((cp = strrchr(rc->rec.diag_set, '/')))
*cp = '\0';
const char *cp = strrchr(diag->uri, '/');
if (cp)
rc->rec.diag_set = odr_strdupn(r->odr, diag->uri, cp - diag->uri);
else
rc->rec.diag_set = odr_strdup(r->odr, diag->uri);
rc->rec.diag_uri = odr_strdup(r->odr, diag->uri);
}
rc->rec.diag_message = odr_strdup_null(r->odr, diag->message);
Expand Down
10 changes: 9 additions & 1 deletion test/test_marc_read_sax.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ static void tst1(void)
yaz_marc_t mt = yaz_marc_create();
yaz_marc_sax_t yt = yaz_marc_sax_new(mt, handler, &user_data);
xmlSAXHandlerPtr sax_ptr = yaz_marc_sax_get_handler(yt);
xmlParserCtxtPtr parser_ctxt = xmlCreatePushParserCtxt(sax_ptr, yt,
marcxml,
strlen(marcxml), 0);

xmlSAXUserParseMemory(sax_ptr, yt, marcxml, strlen(marcxml));
YAZ_CHECK(parser_ctxt);
if (parser_ctxt)
{
YAZ_CHECK_EQ(xmlParseChunk(parser_ctxt, 0, 0, 1), 0);
xmlFreeParserCtxt(parser_ctxt);
}

const char *expect = "<record xmlns=\"http://www.loc.gov/MARC21/slim\">\n"
" <leader>00062cgm a2200037Ia 4500</leader>\n"
Expand Down
9 changes: 4 additions & 5 deletions test/test_tpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
* Copyright (C) Index Data
* See the file LICENSE for details.
*/
#include <yaz/tpath.h>
#include <yaz/test.h>
#include <string.h>
#include <yaz/log.h>

#if HAVE_CONFIG_H
#include <config.h>
#endif

#include <yaz/tpath.h>
#include <yaz/test.h>
#include <string.h>
#include <yaz/log.h>

static void tst_tpath(void)
{
Expand Down