# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.9 1995/04/17 09:31:34 adam
+# Revision 1.10 1995/05/11 14:03:56 adam
+# Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+# New variable ccl_case_sensitive, which controls whether reserved
+# words and field names are case sensitive or not.
+#
+# Revision 1.9 1995/04/17 09:31:34 adam
# Improved handling of qualifiers. Aliases or reserved words.
#
# Revision 1.8 1995/04/10 10:22:35 quinn
#CFLAGS=-g -Wall -pedantic -ansi
TPROG1=cclsh
LIB=../lib/ccl.a
-PO=cclfind.o ccltoken.o cclerrms.o cclqual.o cclptree.o cclqfile.o
+PO=cclfind.o ccltoken.o cclerrms.o cclqual.o cclptree.o cclqfile.o cclstr.o
CPP=$(CC) -E
DEFS=$(INCLUDE)
-all: $(LIB)
+all: $(LIB) $(TPROG1)
$(TPROG1): $(TPROG1).o $(LIB)
$(CC) $(CFLAGS) -o $(TPROG1) $(TPROG1).o $(LIB)
-# $Id: bib1,v 1.4 1995/04/17 09:31:38 adam Exp $
+# $Id: bib1,v 1.5 1995/05/11 14:03:56 adam Exp $
# CCL qualifiers and their mapping to a bib-1 subset
#
term s=pw t=l,r
note u=63 s=pw
af u=1006 s=pw
rel s=9
+cln
# Relation Attributes
rel:lt r=1
* Europagate, 1995
*
* $Log: cclqfile.c,v $
- * Revision 1.1 1995/04/17 09:31:45 adam
+ * Revision 1.2 1995/05/11 14:03:56 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ * Revision 1.1 1995/04/17 09:31:45 adam
* Improved handling of qualifiers. Aliases or reserved words.
*
*/
#include <ccl.h>
+void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name)
+{
+ char qual_type[128];
+ int no_scan;
+ int pair[128];
+ int pair_no = 0;
+
+ while (1)
+ {
+ char *qual_value;
+ char *split;
+
+ if (sscanf (cp, "%s%n", qual_type, &no_scan) != 1)
+ break;
+
+ if (!(split = strchr (qual_type, '=')))
+ break;
+ cp += no_scan;
+
+ *split++ = '\0';
+ while (1)
+ {
+ int type, value;
+
+ qual_value = split;
+ if ((split = strchr (qual_value, ',')))
+ *split++ = '\0';
+ value = atoi (qual_value);
+ switch (qual_type[0])
+ {
+ case 'u':
+ case 'U':
+ type = CCL_BIB1_USE;
+ break;
+ case 'r':
+ case 'R':
+ type = CCL_BIB1_REL;
+ if (!ccl_stricmp (qual_value, "o"))
+ value = CCL_BIB1_REL_ORDER;
+ break;
+ case 'p':
+ case 'P':
+ type = CCL_BIB1_POS;
+ break;
+ case 's':
+ case 'S':
+ type = CCL_BIB1_STR;
+ if (!ccl_stricmp (qual_value, "pw"))
+ value = CCL_BIB1_STR_WP;
+ break;
+ case 't':
+ case 'T':
+ type = CCL_BIB1_TRU;
+ if (!ccl_stricmp (qual_value, "l"))
+ value = CCL_BIB1_TRU_CAN_LEFT;
+ else if (!ccl_stricmp (qual_value, "r"))
+ value = CCL_BIB1_TRU_CAN_RIGHT;
+ else if (!ccl_stricmp (qual_value, "b"))
+ value = CCL_BIB1_TRU_CAN_BOTH;
+ else if (!ccl_stricmp (qual_value, "n"))
+ value = CCL_BIB1_TRU_CAN_NONE;
+ break;
+ case 'c':
+ case 'C':
+ type = CCL_BIB1_COM;
+ break;
+ default:
+ type = atoi (qual_type);
+ }
+ pair[pair_no*2] = type;
+ pair[pair_no*2+1] = value;
+ pair_no++;
+ if (!split)
+ break;
+ }
+ }
+ ccl_qual_add (bibset, qual_name, pair_no, pair);
+}
+
/*
* ccl_qual_file: Read bibset definition from file.
* bibset: Bibset
char line[256];
char *cp;
char qual_name[128];
- char qual_des[128];
int no_scan;
while (fgets (line, 255, inf))
if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
continue; /* also ignore empty lines */
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);
- }
- ccl_qual_add (bibset, qual_name, 1, pair);
- if (!split)
- break;
- qual_value = split;
- }
- }
+ ccl_qual_fitem (bibset, cp, qual_name);
}
}
* Europagate, 1995
*
* $Log: cclqual.c,v $
- * Revision 1.7 1995/04/17 09:31:46 adam
+ * Revision 1.8 1995/05/11 14:03:57 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ * Revision 1.7 1995/04/17 09:31:46 adam
* Improved handling of qualifiers. Aliases or reserved words.
*
* Revision 1.6 1995/02/23 08:32:00 adam
assert (b);
for (q = b->list; q; q = q->next)
- if (strlen(q->name) == len && !memcmp (name, q->name, len))
- return q->attr_list;
+ if (strlen(q->name) == len)
+ if (ccl_case_sensitive)
+ {
+ if (!memcmp (name, q->name, len))
+ return q->attr_list;
+ }
+ else
+ {
+ if (!ccl_memicmp (name, q->name, len))
+ return q->attr_list;
+ }
return NULL;
}
* Europagate 1995
*
* $Log: cclsh.c,v $
- * Revision 1.9 1995/02/23 08:32:00 adam
+ * Revision 1.10 1995/05/11 14:03:57 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ * Revision 1.9 1995/02/23 08:32:00 adam
* Changed header.
*
* Revision 1.7 1995/02/15 17:42:16 adam
{
switch (argv[0][1])
{
+ case 'c':
+ ccl_case_sensitive = 0;
+ break;
case 'd':
debug = 1;
break;
--- /dev/null
+/* CCL string compare utilities
+ * Europagate, 1995
+ *
+ * $Log: cclstr.c,v $
+ * Revision 1.1 1995/05/11 14:03:57 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ */
+#include <ctype.h>
+#include <stdio.h>
+
+#include <ccl.h>
+
+static int ccli_toupper (int c)
+{
+ return toupper (c);
+}
+
+int (*ccl_toupper)(int c) = NULL;
+
+int ccl_stricmp (const char *s1, const char *s2)
+{
+ if (!ccl_toupper)
+ ccl_toupper = ccli_toupper;
+ while (*s1 && *s2)
+ {
+ int c1, c2;
+ c1 = (*ccl_toupper)(*s1);
+ c2 = (*ccl_toupper)(*s2);
+ if (c1 != c2)
+ return c1 - c2;
+ s1++;
+ s2++;
+ }
+ return (*ccl_toupper)(*s1) - (*ccl_toupper)(*s2);
+}
+
+int ccl_memicmp (const char *s1, const char *s2, size_t n)
+{
+ if (!ccl_toupper)
+ ccl_toupper = ccli_toupper;
+ while (1)
+ {
+ int c1, c2;
+
+ c1 = (*ccl_toupper)(*s1);
+ c2 = (*ccl_toupper)(*s2);
+ if (n <= 1 || c1 != c2)
+ return c1 - c2;
+ s1++;
+ s2++;
+ --n;
+ }
+}
+
* Europagate, 1995
*
* $Log: ccltoken.c,v $
- * Revision 1.7 1995/04/19 12:11:24 adam
+ * Revision 1.8 1995/05/11 14:03:57 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ * Revision 1.7 1995/04/19 12:11:24 adam
* Minor change.
*
* Revision 1.6 1995/04/17 09:31:48 adam
const char *ccl_token_or = "or";
const char *ccl_token_not = "not andnot";
const char *ccl_token_set = "set";
+int ccl_case_sensitive = 1;
/*
* token_cmp: Compare token with keyword(s)
return 0;
while ((cp2 = strchr (cp1, ' ')))
{
- if (token->len == cp2-cp1 &&
- !memcmp (cp1, token->name, token->len))
- return 1;
+ if (token->len == cp2-cp1)
+ if (ccl_case_sensitive)
+ {
+ if (!memcmp (cp1, token->name, token->len))
+ return 1;
+ }
+ else
+ {
+ if (!ccl_memicmp (cp1, token->name, token->len))
+ return 1;
+ }
cp1 = cp2+1;
}
- return token->len == strlen(cp1)
- && !memcmp (cp1, token->name, token->len);
+ if (ccl_case_sensitive)
+ return token->len == strlen(cp1)
+ && !memcmp (cp1, token->name, token->len);
+ return token->len == strlen(cp1) &&
+ !ccl_memicmp (cp1, token->name, token->len);
}
/*
* Europagate, 1995
*
* $Log: ccl.h,v $
- * Revision 1.5 1995/02/23 08:32:11 adam
+ * Revision 1.6 1995/05/11 14:04:03 adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ * Revision 1.5 1995/02/23 08:32:11 adam
* Changed header.
*
* Revision 1.3 1995/02/16 13:20:10 adam
void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr);
void ccl_qual_file (CCL_bibset bibset, FILE *inf);
+void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name);
CCL_bibset ccl_qual_mk (void);
void ccl_qual_rm (CCL_bibset *b);
extern const char *ccl_token_or;
extern const char *ccl_token_not;
extern const char *ccl_token_set;
+extern int ccl_case_sensitive;
+extern int (*ccl_toupper)(int c);
+int ccl_stricmp (const char *s1, const char *s2);
+int ccl_memicmp (const char *s1, const char *s2, size_t n);
struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len);
#endif