--- /dev/null
+# $Id: bib1,v 1.1 1995/02/14 16:20:53 adam Exp $
+# CCL qualifiers and their mapping to a bib-1 subset
+#
+term s=pw t=l,r
+au u=1 s=pw
+ti u=4 s=pw
+isbn u=7
+issn u=8
+cc u=20
+su u=21 s=pw
+date u=30 r=o
+dp u=31 r=o
+da u=32 r=o
+la u=54 s=pw
+ab u=62 s=pw
+note u=63 s=pw
+af u=1006 s=pw
* Europagate, 1995
*
* $Log: ccl.h,v $
- * Revision 1.3 1995/02/14 10:25:55 adam
+ * Revision 1.4 1995/02/14 16:20:53 adam
+ * Qualifiers are read from a file now.
+ *
+ * Revision 1.3 1995/02/14 10:25:55 adam
* The constructions 'qualifier rel term ...' implemented.
*
* Revision 1.2 1995/02/13 15:15:06 adam
#define CCL_ERR_DOBBLE_QUAL 7
#define CCL_ERR_EQ_EXPECTED 8
#define CCL_ERR_BAD_RELATION 9
+#define CCL_ERR_TRUNC_NOT_LEFT 10
+#define CCL_ERR_TRUNC_NOT_BOTH 11
+#define CCL_ERR_TRUNC_NOT_RIGHT 12
struct ccl_rpn_attr {
struct ccl_rpn_attr *next;
void ccl_pr_tree (struct ccl_rpn_node *rpn);
void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr);
+void ccl_qual_file (CCL_bibset bibset, FILE *inf);
CCL_bibset ccl_qual_mk (void);
void ccl_qual_rm (CCL_bibset *b);
struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len);
#define CCL_BIB1_STR_WP (-1)
#define CCL_BIB1_REL_ORDER (-1)
-#define CCL_TRUNC_L 1
-#define CCL_TRUNC_R 2
-#define CCL_TRUNC_LR 4
-#define CCL_TRUNC_NONE 8
-#define CCL_TRUNC_HASH 16
-#define CCL_TRUNC_REG 32
+#define CCL_BIB1_TRU_CAN_LEFT (-1)
+#define CCL_BIB1_TRU_CAN_RIGHT (-2)
+#define CCL_BIB1_TRU_CAN_BOTH (-3)
+#define CCL_BIB1_TRU_CAN_NONE (-4)
* Europagate, 1995
*
* $Log: cclerrms.c,v $
- * Revision 1.3 1995/02/14 10:25:56 adam
+ * Revision 1.4 1995/02/14 16:20:54 adam
+ * Qualifiers are read from a file now.
+ *
+ * Revision 1.3 1995/02/14 10:25:56 adam
* The constructions 'qualifier rel term ...' implemented.
*
* Revision 1.2 1995/02/13 15:15:06 adam
"Unknown qualifier",
"Qualifiers applied twice",
"'=' expected",
- "Bad relation"
+ "Bad relation",
+ "Left truncation not supported",
+ "Both left - and right truncation not supported",
+ "Right truncation not supported"
};
const char *ccl_err_msg (int ccl_errno)
* Europagate, 1995
*
* $Log: cclfind.c,v $
- * Revision 1.5 1995/02/14 14:12:41 adam
+ * Revision 1.6 1995/02/14 16:20:55 adam
+ * Qualifiers are read from a file now.
+ *
+ * Revision 1.5 1995/02/14 14:12:41 adam
* Ranges for ordered qualfiers implemented (e.g. pd=1980-1990).
*
* Revision 1.4 1995/02/14 13:16:29 adam
return NULL;
}
+static int qual_val_type (struct ccl_rpn_attr *list, int type, int value)
+{
+ while (list)
+ {
+ if (list->type == type && list->value == value)
+ return 1;
+ list = list->next;
+ }
+ return 0;
+}
+
static void strxcat (char *n, const char *src, int len)
{
while (*n)
static struct ccl_rpn_node *search_term (struct ccl_rpn_attr **qa)
{
struct ccl_rpn_node *p;
+ struct ccl_rpn_attr *attr;
struct ccl_token *lookahead = look_token;
int len = 0;
int no, i;
if (i)
strcat (p->u.t.term, " ");
strxcat (p->u.t.term, src_str, src_len);
- ADVANCE;
+ ADVANCE;
}
if (qa)
{
int i;
- struct ccl_rpn_attr *attr;
for (i=0; qa[i]; i++)
{
struct ccl_rpn_attr *attr;
if (attr->value > 0)
add_attr (p, attr->type, attr->value);
}
- if ((attr = qual_val (qa[0], CCL_BIB1_STR)) &&
- attr->value == CCL_BIB1_STR_WP)
- {
- if (no == 1)
- add_attr (p, CCL_BIB1_STR, 2);
- else
- add_attr (p, CCL_BIB1_STR, 1);
- }
+ attr = qa[0];
+ }
+ else
+ attr = ccl_qual_search (bibset, "term", 4);
+ if (attr && qual_val_type (attr, CCL_BIB1_STR, CCL_BIB1_STR_WP))
+ {
+ if (no == 1)
+ add_attr (p, CCL_BIB1_STR, 2);
+ else
+ add_attr (p, CCL_BIB1_STR, 1);
}
if (left_trunc && right_trunc)
+ {
+ if (attr && !qual_val_type (attr, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_BOTH))
+ {
+ ccl_error = CCL_ERR_TRUNC_NOT_BOTH;
+ if (qa)
+ free (qa);
+ ccl_rpn_delete (p);
+ return NULL;
+ }
add_attr (p, CCL_BIB1_TRU, 3);
+ }
else if (right_trunc)
+ {
+ if (attr && !qual_val_type (attr, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_RIGHT))
+ {
+ ccl_error = CCL_ERR_TRUNC_NOT_RIGHT;
+ if (qa)
+ free (qa);
+ ccl_rpn_delete (p);
+ return NULL;
+ }
add_attr (p, CCL_BIB1_TRU, 1);
+ }
else if (left_trunc)
+ {
+ if (attr && !qual_val_type (attr, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_LEFT))
+ {
+ ccl_error = CCL_ERR_TRUNC_NOT_LEFT;
+ if (qa)
+ free (qa);
+ ccl_rpn_delete (p);
+ return NULL;
+ }
add_attr (p, CCL_BIB1_TRU, 2);
+ }
+ else
+ {
+ if (attr && qual_val_type (attr, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_NONE))
+ add_attr (p, CCL_BIB1_TRU, 100);
+ }
return p;
}
ADVANCE;
}
ap[i] = NULL;
- if (! (attr = qual_val (ap[0], CCL_BIB1_REL)) || attr->value == 3)
+ if (! (attr = qual_val (ap[0], CCL_BIB1_REL)) ||
+ attr->value != CCL_BIB1_REL_ORDER)
{
/* unordered relation */
struct ccl_rpn_node *p;
* Europagate, 1995
*
* $Log: cclqual.c,v $
- * Revision 1.2 1995/02/14 10:25:56 adam
+ * Revision 1.3 1995/02/14 16:20:56 adam
+ * Qualifiers are read from a file now.
+ *
+ * Revision 1.2 1995/02/14 10:25:56 adam
* The constructions 'qualifier rel term ...' implemented.
*
* Revision 1.1 1995/02/13 15:15:07 adam
void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
{
- struct ccl_qualifier *new_qual;
+ struct ccl_qualifier *q;
struct ccl_rpn_attr **attrp;
-
- assert (b);
- new_qual = malloc (sizeof(*new_qual));
- assert (new_qual);
-
- new_qual->next = b->list;
- b->list = new_qual;
-
- new_qual->name = malloc (strlen(name)+1);
- assert (new_qual->name);
- strcpy (new_qual->name, name);
- attrp = &new_qual->attr_list;
+ assert (b);
+ for (q = b->list; q; q = q->next)
+ if (!strcmp (name, q->name))
+ break;
+ if (!q)
+ {
+ struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
+ assert (new_qual);
+
+ new_qual->next = b->list;
+ b->list = new_qual;
+
+ new_qual->name = malloc (strlen(name)+1);
+ assert (new_qual->name);
+ strcpy (new_qual->name, name);
+ attrp = &new_qual->attr_list;
+ }
+ else
+ {
+ attrp = &q->attr_list;
+ while (*attrp)
+ attrp = &(*attrp)->next;
+ }
while (--no >= 0)
{
struct ccl_rpn_attr *attr;
return q->attr_list;
return NULL;
}
+
+void ccl_qual_file (CCL_bibset bibset, FILE *inf)
+{
+ char line[256];
+ char *cp;
+ char qual_name[128];
+ char qual_des[128];
+ int no_scan;
+
+ while (fgets (line, 255, inf))
+ {
+ cp = line;
+ if (*cp == '#')
+ continue;
+ if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
+ continue;
+ cp += no_scan;
+ while (1)
+ {
+ int pair[2];
+ char *qual_type;
+ char *qual_value;
+ char *split;
+
+ if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
+ break;
+
+ if (!(split = strchr (qual_des, '=')))
+ break;
+ cp += no_scan;
+
+ *split++ = '\0';
+ qual_type = qual_des;
+ qual_value = split;
+ while (1)
+ {
+ if ((split = strchr (qual_value, ',')))
+ *split++ = '\0';
+ pair[1] = atoi (qual_value);
+ switch (qual_type[0])
+ {
+ case 'u':
+ pair[0] = CCL_BIB1_USE;
+ break;
+ case 'r':
+ pair[0] = CCL_BIB1_REL;
+ if (!strcmp (qual_value, "o"))
+ pair[1] = CCL_BIB1_REL_ORDER;
+ break;
+ case 'p':
+ pair[0] = CCL_BIB1_POS;
+ break;
+ case 's':
+ pair[0] = CCL_BIB1_STR;
+ if (!strcmp (qual_value, "pw"))
+ pair[1] = CCL_BIB1_STR_WP;
+ break;
+ case 't':
+ pair[0] = CCL_BIB1_TRU;
+ if (!strcmp (qual_value, "l"))
+ pair[1] = CCL_BIB1_TRU_CAN_LEFT;
+ else if (!strcmp (qual_value, "r"))
+ pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
+ else if (!strcmp (qual_value, "b"))
+ pair[1] = CCL_BIB1_TRU_CAN_BOTH;
+ else if (!strcmp (qual_value, "n"))
+ pair[1] = CCL_BIB1_TRU_CAN_NONE;
+ break;
+ case 'c':
+ pair[0] = CCL_BIB1_COM;
+ break;
+ default:
+ pair[0] = atoi (qual_type);
+ }
+ printf ("adding %s t=%d, v=%d\n", qual_name, pair[0], pair[1]);
+ ccl_qual_add (bibset, qual_name, 1, pair);
+ if (!split)
+ break;
+ qual_value = split;
+ }
+ }
+ }
+}
* Europagate 1995
*
* $Log: cclsh.c,v $
- * Revision 1.4 1995/02/14 14:12:42 adam
+ * Revision 1.5 1995/02/14 16:20:57 adam
+ * Qualifiers are read from a file now.
+ *
+ * Revision 1.4 1995/02/14 14:12:42 adam
* Ranges for ordered qualfiers implemented (e.g. pd=1980-1990).
*
* Revision 1.3 1995/02/14 10:25:57 adam
int main (int argc, char **argv)
{
CCL_bibset bibset;
+ FILE *bib_inf;
+ char *bib_fname;
prog = *argv;
bibset = ccl_qual_mk ();
while (--argc > 0)
{
- ++argv;
if (**++argv == '-')
{
switch (argv[0][1])
case 'd':
debug = 1;
break;
+ case 'b':
+ if (argv[0][2])
+ bib_fname = argv[0]+2;
+ else if (argc > 0)
+ {
+ --argc;
+ bib_fname = *++argv;
+ }
+ else
+ {
+ fprintf (stderr, "%s: missing bib filename\n", prog);
+ exit (1);
+ }
+ bib_inf = fopen (bib_fname, "r");
+ if (!bib_inf)
+ {
+ fprintf (stderr, "%s: cannot open %s\n", prog,
+ bib_fname);
+ exit (1);
+ }
+ ccl_qual_file (bibset, bib_inf);
+ fclose (bib_inf);
+ break;
default:
fprintf (stderr, "%s: unknown option '%s'\n",
prog, *argv);
exit (1);
}
}
- ccl_qual_add (bibset, "ti", sizeof(ti_attr)/(2*sizeof(int)), ti_attr);
- ccl_qual_add (bibset, "au", sizeof(au_attr)/(2*sizeof(int)), au_attr);
- ccl_qual_add (bibset, "pd", sizeof(pd_attr)/(2*sizeof(int)), pd_attr);
while (1)
{
char buf[80];
putchar ('\n');
return 0;
}
-
-