From 7826e2c92b1a07182ba5bfb94c304f1fa7d27387 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Tue, 20 Feb 1996 16:33:02 +0000 Subject: [PATCH 1/1] Moved matchstr to global util --- retrieval/Makefile | 4 ++-- util/Makefile | 4 ++-- util/yaz-util.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 util/yaz-util.c diff --git a/retrieval/Makefile b/retrieval/Makefile index bf296ef..a75f3ae 100644 --- a/retrieval/Makefile +++ b/retrieval/Makefile @@ -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 @@ -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 \ - 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 diff --git a/util/Makefile b/util/Makefile index 87b1967..9ed18bf 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,7 +1,7 @@ # 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. @@ -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 \ - 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 diff --git a/util/yaz-util.c b/util/yaz-util.c new file mode 100644 index 0000000..87fb1d5 --- /dev/null +++ b/util/yaz-util.c @@ -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 + +/* + * 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; +} -- 1.7.10.4