Moved matchstr to global util
authorSebastian Hammer <quinn@indexdata.com>
Tue, 20 Feb 1996 16:33:02 +0000 (16:33 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 20 Feb 1996 16:33:02 +0000 (16:33 +0000)
retrieval/Makefile
util/Makefile
util/yaz-util.c [new file with mode: 0644]

index bf296ef..a75f3ae 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.4 1995-12-14 11:09:50 quinn Exp $
+# $Id: Makefile,v 1.5 1996-02-20 16:33:02 quinn Exp $
 
 SHELL=/bin/sh
 RANLIB=ranlib
 
 SHELL=/bin/sh
 RANLIB=ranlib
@@ -7,7 +7,7 @@ CFLAGS=-g -Wall -pedantic -ansi
 DEFS=$(INCLUDE)
 LIB=../lib/libret.a
 PO = d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
 DEFS=$(INCLUDE)
 LIB=../lib/libret.a
 PO = d1_read.o d1_attset.o d1_tagset.o d1_absyn.o d1_grs.o \
-       d1_matchstr.o d1_sutrs.o d1_varset.o d1_espec.o \
+       d1_sutrs.o d1_varset.o d1_espec.o \
        d1_doespec.o d1_map.o d1_marc.o d1_write.o d1_expout.o
 CPP=$(CC) -E
 
        d1_doespec.o d1_map.o d1_marc.o d1_write.o d1_expout.o
 CPP=$(CC) -E
 
index 87b1967..9ed18bf 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
 # Copyright (C) 1994, Index Data I/S 
 # All rights reserved.
 # Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.17 1995-11-08 17:41:43 quinn Exp $
+# $Id: Makefile,v 1.18 1996-02-20 16:33:06 quinn Exp $
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
 
 SHELL=/bin/sh
 INCLUDE=-I../include -I.
@@ -12,7 +12,7 @@ DEFS=$(INCLUDE)
 LIB=$(LIBDIR)/libutil.a
 LIBS=
 PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o \
 LIB=$(LIBDIR)/libutil.a
 LIBS=
 PO = options.o log.o marcdisp.o yaz-ccl.o pquery.o oid.o wrbuf.o \
-       xmalloc.o readconf.o tpath.o nmem.o # dmalloc.o 
+       xmalloc.o readconf.o tpath.o nmem.o yaz-util.o # dmalloc.o 
 CPP=$(CC) -E
 RANLIB=ranlib
 
 CPP=$(CC) -E
 RANLIB=ranlib
 
diff --git a/util/yaz-util.c b/util/yaz-util.c
new file mode 100644 (file)
index 0000000..87fb1d5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1995, Index Data.
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: yaz-util.c,v $
+ * Revision 1.1  1996-02-20 16:33:06  quinn
+ * Moved matchstr to global util
+ *
+ * Revision 1.1  1995/11/01  11:56:08  quinn
+ * Added Retrieval (data management) functions en masse.
+ *
+ *
+ */
+
+#include <ctype.h>
+
+/*
+ * Match strings, independently of case and occurences of '-'.
+ * fairly inefficient - will be replaced with an indexing scheme for
+ * the various subsystems if we get a bottleneck here.
+ */
+
+int yaz_matchstr(char *s1, char *s2)
+{
+    while (*s1 && *s2)
+    {
+       char c1, c2;
+
+       if (*s1 == '-')
+           s1++;
+       if (*s2 == '-')
+           s2++;
+       if (!*s1 || !*s2)
+           break;
+       c1 = *s1;
+       c2 = *s2;
+       if (isupper(c1))
+           c1 = tolower(c1);
+       if (isupper(c2))
+           c2 = tolower(c2);
+       if (c1 != c2)
+           break;
+       s1++;
+       s2++;
+    }
+    return *s1 || *s2;
+}