X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclqfile.c;h=b4aab41fe3fcf507ed5035fa236479e02bef5665;hb=c63b8160e6b822d640a4e92ca4c3d5fb79828bbc;hp=fa93894c7f0b26b063b0d33c4d86f74b0c484992;hpb=e5324215018e129dd19734acd0e683e5af748423;p=yaz-moved-to-github.git diff --git a/ccl/cclqfile.c b/ccl/cclqfile.c index fa93894..b4aab41 100644 --- a/ccl/cclqfile.c +++ b/ccl/cclqfile.c @@ -44,33 +44,9 @@ /* CCL qualifiers * Europagate, 1995 * - * $Log: cclqfile.c,v $ - * Revision 1.8 2001-02-21 13:46:53 adam - * C++ fixes. + * $Id: cclqfile.c,v 1.13 2002-06-06 12:54:24 adam Exp $ * - * Revision 1.7 2001/01/24 11:55:31 adam - * Fixed nasty bug introduced by previous commit (attribute sets not - * properly allocated). - * - * Revision 1.6 2000/11/16 09:58:02 adam - * Implemented local AttributeSet setting for CCL field maps. - * - * Revision 1.5 2000/10/17 19:50:28 adam - * Implemented and-list and or-list for CCL module. - * - * Revision 1.4 2000/01/31 13:15:21 adam - * Removed uses of assert(3). Cleanup of ODR. CCL parser update so - * that some characters are not surrounded by spaces in resulting term. - * ILL-code updates. - * - * Revision 1.3 1999/11/30 13:47:11 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.2 1997/04/30 08:52:06 quinn - * Null - * - * Revision 1.1 1996/10/11 15:00:25 adam - * CCL parser from Europagate Email gateway 1.0. + * Old Europagate Log: * * Revision 1.3 1995/05/16 09:39:26 adam * LICENSE. @@ -91,10 +67,9 @@ #include -void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) +void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name) { char qual_spec[128]; - int no_scan; int pair[256]; char *attsets[128]; int pair_no = 0; @@ -103,12 +78,20 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) { char *qual_value, *qual_type; char *split, *setp; + int no_scan = 0; - if (sscanf (cp, "%s%n", qual_spec, &no_scan) != 1) + if (sscanf (cp, "%100s%n", qual_spec, &no_scan) < 1) break; if (!(split = strchr (qual_spec, '='))) + { + if (pair_no == 0) + { + ccl_qual_add_combi (bibset, qual_name, cp); + return; + } break; + } cp += no_scan; *split++ = '\0'; @@ -178,7 +161,7 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) pair[pair_no*2+1] = value; if (setp) { - attsets[pair_no] = (char*) malloc (strlen(qual_spec)+1); + attsets[pair_no] = (char*) xmalloc (strlen(qual_spec)+1); strcpy (attsets[pair_no], qual_spec); } else @@ -191,6 +174,14 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) ccl_qual_add_set (bibset, qual_name, pair_no, pair, attsets); } +void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) +{ + if (*qual_name == '@') + ccl_qual_add_special(bibset, qual_name+1, cp); + else + ccl_qual_field(bibset, cp, qual_name); +} + /* * ccl_qual_file: Read bibset definition from file. * bibset: Bibset @@ -207,18 +198,22 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) void ccl_qual_file (CCL_bibset bibset, FILE *inf) { char line[256]; - char *cp; + char *cp, *cp1; char qual_name[128]; - int no_scan; while (fgets (line, 255, inf)) { + int no_scan = 0; + cp = line; if (*cp == '#') continue; /* ignore lines starting with # */ - if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1) + if (sscanf (cp, "%100s%n", qual_name, &no_scan) < 1) continue; /* also ignore empty lines */ cp += no_scan; + cp1 = strchr(cp, '#'); + if (cp1) + *cp1 = '\0'; ccl_qual_fitem (bibset, cp, qual_name); } } @@ -230,5 +225,6 @@ int ccl_qual_fname (CCL_bibset bibset, const char *fname) if (!inf) return -1; ccl_qual_file (bibset, inf); + fclose (inf); return 0; }