summaryrefslogtreecommitdiff
path: root/libc/misc/lsearch
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/lsearch')
-rw-r--r--libc/misc/lsearch/.indent.pro33
-rw-r--r--libc/misc/lsearch/Makefile42
-rw-r--r--libc/misc/lsearch/lsearch.c43
3 files changed, 118 insertions, 0 deletions
diff --git a/libc/misc/lsearch/.indent.pro b/libc/misc/lsearch/.indent.pro
new file mode 100644
index 000000000..492ecf1c7
--- /dev/null
+++ b/libc/misc/lsearch/.indent.pro
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
diff --git a/libc/misc/lsearch/Makefile b/libc/misc/lsearch/Makefile
new file mode 100644
index 000000000..604207226
--- /dev/null
+++ b/libc/misc/lsearch/Makefile
@@ -0,0 +1,42 @@
+# Makefile for uCLibc
+#
+# Copyright (C) 2000 by Lineo, inc.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources. Files within this library are copyright by their
+# respective copyright holders.
+
+TOPDIR=../../
+include $(TOPDIR)Rules.make
+LIBC=$(TOPDIR)libc.a
+
+CSRC=lsearch.c
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+OBJS=$(COBJS)
+
+all: $(OBJS) $(LIBC)
+
+$(LIBC): ar-target
+
+ar-target: $(OBJS)
+ $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+
+$(OBJS): Makefile
+
+clean:
+ rm -f *.[oa] *~ core
+
diff --git a/libc/misc/lsearch/lsearch.c b/libc/misc/lsearch/lsearch.c
new file mode 100644
index 000000000..aed4b1e7d
--- /dev/null
+++ b/libc/misc/lsearch/lsearch.c
@@ -0,0 +1,43 @@
+/*
+ * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
+ *
+ *
+ * Dale Schumacher 399 Beacon Ave.
+ * (alias: Dalnefre') St. Paul, MN 55104
+ * dal@syntel.UUCP United States of America
+ * "It's not reality that's important, but how you perceive things."
+ */
+
+#include <stdio.h>
+
+char *lfind(key, base, num, size, cmp)
+register char *key, *base;
+unsigned int *num;
+register unsigned int size;
+register int (*cmp) ();
+{
+ register int n = *num;
+
+ while (n--) {
+ if ((*cmp) (base, key) == 0)
+ return (base);
+ base += size;
+ }
+ return (NULL);
+}
+
+char *lsearch(key, base, num, size, cmp)
+char *key, *base;
+register unsigned int *num;
+register unsigned int size;
+int (*cmp) ();
+{
+ register char *p;
+ char *memcpy();
+
+ if ((p = lfind(key, base, num, size, cmp)) == NULL) {
+ p = memcpy((base + (size * (*num))), key, size);
+ ++(*num);
+ }
+ return (p);
+}