projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Save register type for TERMIDs and snippets.
[idzebra-moved-to-github.git]
/
data1
/
d1_marc.c
diff --git
a/data1/d1_marc.c
b/data1/d1_marc.c
index
511de28
..
a04ef89
100644
(file)
--- a/
data1/d1_marc.c
+++ b/
data1/d1_marc.c
@@
-1,6
+1,6
@@
-/* $Id: d1_marc.c,v 1.8 2004-11-19 10:26:53 heikki Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
- Index Data Aps
+/* $Id: d1_marc.c,v 1.12 2005-02-02 19:37:27 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
This file is part of the Zebra server.
This file is part of the Zebra server.
@@
-26,8
+26,8
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+#include <yaz/log.h>
#include <yaz/oid.h>
#include <yaz/oid.h>
-#include <yaz/ylog.h>
#include <yaz/marcdisp.h>
#include <yaz/readconf.h>
#include <yaz/xmalloc.h>
#include <yaz/marcdisp.h>
#include <yaz/readconf.h>
#include <yaz/xmalloc.h>
@@
-164,7
+164,7
@@
data1_marctab *data1_read_marctab (data1_handle dh, const char *file)
* Locate some data under this node. This routine should handle variants
* prettily.
*/
* Locate some data under this node. This routine should handle variants
* prettily.
*/
-static char *get_data(data1_node *n, int *len)
+static char *get_data(data1_node *n, int *len, int chop)
{
char *r;
{
char *r;
@@
-174,15
+174,21
@@
static char *get_data(data1_node *n, int *len)
{
int i;
*len = n->u.data.len;
{
int i;
*len = n->u.data.len;
-
- for (i = 0; i<*len; i++)
- if (!d1_isspace(n->u.data.data[i]))
- break;
- while (*len && d1_isspace(n->u.data.data[*len - 1]))
- (*len)--;
- *len = *len - i;
- if (*len > 0)
- return n->u.data.data + i;
+
+ if (chop)
+ {
+ for (i = 0; i<*len; i++)
+ if (!d1_isspace(n->u.data.data[i]))
+ break;
+ while (*len && d1_isspace(n->u.data.data[*len - 1]))
+ (*len)--;
+ *len = *len - i;
+ if (*len > 0)
+ return n->u.data.data + i;
+ }
+ else
+ if (*len > 0)
+ return n->u.data.data;
}
if (n->which == DATA1N_tag)
n = n->child;
}
if (n->which == DATA1N_tag)
n = n->child;
@@
-265,7
+271,7
@@
static int nodetomarc(data1_handle dh,
else if (!strcmp(field->u.tag.tag, "leader"))
{
int dlen = 0;
else if (!strcmp(field->u.tag.tag, "leader"))
{
int dlen = 0;
- char *dbuf = get_data(subf, &dlen);
+ char *dbuf = get_data(subf, &dlen, 0);
if (dlen > 24)
dlen = 24;
if (dbuf && dlen > 0)
if (dlen > 24)
dlen = 24;
if (dbuf && dlen > 0)
@@
-310,7
+316,7
@@
static int nodetomarc(data1_handle dh,
{
if (!control_field)
len += p->identifier_length;
{
if (!control_field)
len += p->identifier_length;
- get_data(subf, &dlen);
+ get_data(subf, &dlen, control_field ? 0 : 1);
len += dlen;
}
}
len += dlen;
}
}
@@
-391,9
+397,9
@@
static int nodetomarc(data1_handle dh,
if (!strcmp(xa->name, "ind1"))
indicator_data[0] = xa->value[0];
if (!strcmp(xa->name, "ind2"))
if (!strcmp(xa->name, "ind1"))
indicator_data[0] = xa->value[0];
if (!strcmp(xa->name, "ind2"))
- indicator_data[1] = xa->value[1];
+ indicator_data[1] = xa->value[0];
if (!strcmp(xa->name, "ind3"))
if (!strcmp(xa->name, "ind3"))
- indicator_data[2] = xa->value[2];
+ indicator_data[2] = xa->value[0];
}
}
if (!control_field)
}
}
if (!control_field)
@@
-427,7
+433,7
@@
static int nodetomarc(data1_handle dh,
memcpy (op + data_p+1, identifier, p->identifier_length-1);
data_p += p->identifier_length;
}
memcpy (op + data_p+1, identifier, p->identifier_length-1);
data_p += p->identifier_length;
}
- data = get_data(subf, &dlen);
+ data = get_data(subf, &dlen, control_field ? 0 : 1);
memcpy (op + data_p, data, dlen);
data_p += dlen;
}
memcpy (op + data_p, data, dlen);
data_p += dlen;
}