diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-11 23:54:37 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-11 23:54:37 +0000 |
commit | a99617fe8fdb56b3e877558bfd6572ce65ad39de (patch) | |
tree | 26c3182125188cb7681885830ea7e32e179c7565 /libc/misc | |
parent | d1c3ee2a075fc4e855e352e5a5cf10371f2e77aa (diff) |
Finish reorganizing things. At least I think I've finished.
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/Makefile | 2 | ||||
-rw-r--r-- | libc/misc/internals/Makefile | 42 | ||||
-rw-r--r-- | libc/misc/internals/itoa.c | 21 | ||||
-rw-r--r-- | libc/misc/internals/ltoa.c | 40 | ||||
-rw-r--r-- | libc/misc/internals/ltostr.c | 52 | ||||
-rw-r--r-- | libc/misc/regex/Makefile | 2 | ||||
-rw-r--r-- | libc/misc/time/Makefile | 2 |
7 files changed, 158 insertions, 3 deletions
diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 03d2b2b40..30c92fcf8 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -21,7 +21,7 @@ # respective copyright holders. -DIRS = assert crypt ctype fnmatch glob lsearch +DIRS = assert crypt ctype fnmatch glob internals lsearch regex shm time all: libc.a diff --git a/libc/misc/internals/Makefile b/libc/misc/internals/Makefile new file mode 100644 index 000000000..eb4e61ac8 --- /dev/null +++ b/libc/misc/internals/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=itoa.c ltoa.c ltostr.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/internals/itoa.c b/libc/misc/internals/itoa.c new file mode 100644 index 000000000..a683b8018 --- /dev/null +++ b/libc/misc/internals/itoa.c @@ -0,0 +1,21 @@ +/* itoa.c <ndf@linux.mit.edu> */ +#define __MAX_INT_CHARS 7 + +char *itoa(int i) +{ + static char a[__MAX_INT_CHARS]; + char *b = a + sizeof(a) - 1; + int sign = (i < 0); + + if (sign) + i = -i; + *b = 0; + do { + *--b = '0' + (i % 10); + i /= 10; + } + while (i); + if (sign) + *--b = '-'; + return b; +} diff --git a/libc/misc/internals/ltoa.c b/libc/misc/internals/ltoa.c new file mode 100644 index 000000000..da8b6d3df --- /dev/null +++ b/libc/misc/internals/ltoa.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +static char buf[12]; + +extern char *ultoa(); + +char *ltoa(val) +long val; +{ + char *p; + int flg = 0; + + if (val < 0) { + flg++; + val = -val; + } + p = ultoa(val); + if (flg) + *--p = '-'; + return p; +} + +char *ultoa(val) +unsigned long val; +{ + char *p; + + p = buf + sizeof(buf); + *--p = '\0'; + + do { + *--p = '0' + val % 10; + val /= 10; + } + while (val); + return p; +} diff --git a/libc/misc/internals/ltostr.c b/libc/misc/internals/ltostr.c new file mode 100644 index 000000000..da6fad232 --- /dev/null +++ b/libc/misc/internals/ltostr.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +static char buf[34]; + +extern char *ultostr(); + +char *ltostr(val, radix, uppercase) +long val; +int radix; +int uppercase; +{ + char *p; + int flg = 0; + + if (val < 0) { + flg++; + val = -val; + } + p = ultostr(val, radix, uppercase); + if (p && flg) + *--p = '-'; + return p; +} + +char *ultostr(val, radix, uppercase) +unsigned long val; +int radix; +int uppercase; +{ + register char *p; + register int c; + + if (radix > 36 || radix < 2) + return 0; + + p = buf + sizeof(buf); + *--p = '\0'; + + do { + c = val % radix; + val /= radix; + if (c > 9) + *--p = (uppercase ? 'A' : 'a') - 10 + c; + else + *--p = '0' + c; + } + while (val); + return p; +} diff --git a/libc/misc/regex/Makefile b/libc/misc/regex/Makefile index 006ea75cc..7289186f7 100644 --- a/libc/misc/regex/Makefile +++ b/libc/misc/regex/Makefile @@ -20,7 +20,7 @@ # other sundry sources. Files within this library are copyright by their # respective copyright holders. -TOPDIR=../ +TOPDIR=../../ include $(TOPDIR)Rules.make LIBC=$(TOPDIR)libc.a diff --git a/libc/misc/time/Makefile b/libc/misc/time/Makefile index e3c2c26d6..e5387a56a 100644 --- a/libc/misc/time/Makefile +++ b/libc/misc/time/Makefile @@ -20,7 +20,7 @@ # other sundry sources. Files within this library are copyright by their # respective copyright holders. -TOPDIR=../ +TOPDIR=../../ include $(TOPDIR)Rules.make LIBC=$(TOPDIR)libc.a |