summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2001-03-20 18:55:18 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:47:06 +0200
commit6d269edda0f49741484c1da6c71d24c031abc9ce (patch)
tree9ab1d8a21978e97ba9325f393c945cf9522b2987
parent4b55feb026b1f64555d7c11c2840fddd8fd029fe (diff)
downloaddev86-6d269edda0f49741484c1da6c71d24c031abc9ce.tar.gz
Import Dev86src-0.15.5.tar.gzv0.15.5
-rw-r--r--Libc_version2
-rw-r--r--ar/Makefile3
-rw-r--r--ar/ar.c64
-rw-r--r--as/Makefile8
-rw-r--r--bcc/Makefile8
-rw-r--r--bootblocks/Makefile6
-rw-r--r--copt/Makefile2
-rw-r--r--elksemu/Kernel_patch1
-rw-r--r--elksemu/Makefile12
-rw-r--r--elksemu/binfmt_elks.c1
-rw-r--r--elksemu/linux/vm86.h8
-rw-r--r--ld/Makefile6
-rw-r--r--libc/Config.dflt4
-rw-r--r--libc/Makefile2
-rw-r--r--libc/malloc/Config1
-rw-r--r--libc/malloc/Makefile (renamed from libc/malloc1/Makefile)0
-rw-r--r--libc/malloc/README (renamed from libc/malloc1/README)0
-rw-r--r--libc/malloc/malloc.c (renamed from libc/malloc1/malloc.c)0
-rw-r--r--libc/malloc/malloc.h (renamed from libc/malloc1/malloc.h)0
-rw-r--r--libc/malloc1/Config1
-rw-r--r--libc/malloc2/Config1
-rw-r--r--libc/malloc2/Makefile14
-rw-r--r--libc/malloc2/README19
-rw-r--r--libc/malloc2/malloc.c126
-rw-r--r--libc/malloc2/malloc.h21
-rw-r--r--libc/malloc2/stack.c10
-rw-r--r--libc/stdio/Config4
-rw-r--r--libc/stdio/Makefile (renamed from libc/stdio2/Makefile)0
-rw-r--r--libc/stdio/printf.c (renamed from libc/stdio2/printf.c)0
-rw-r--r--libc/stdio/scanf.c (renamed from libc/stdio2/scanf.c)0
-rw-r--r--libc/stdio/stdio.c (renamed from libc/stdio2/stdio.c)0
-rw-r--r--libc/stdio/stdio.h (renamed from libc/stdio2/stdio.h)0
-rw-r--r--libc/stdio1/BUGS15
-rw-r--r--libc/stdio1/Config3
-rw-r--r--libc/stdio1/NOTICE17
-rw-r--r--libc/stdio1/README8
-rw-r--r--libc/stdio1/TODO33
-rw-r--r--libc/stdio1/__ffillbuf.c55
-rw-r--r--libc/stdio1/__stdio_init.c66
-rw-r--r--libc/stdio1/fclose.c41
-rw-r--r--libc/stdio1/fcntl.h72
-rw-r--r--libc/stdio1/fflush.c36
-rw-r--r--libc/stdio1/fgetc.c39
-rw-r--r--libc/stdio1/fgets.c50
-rw-r--r--libc/stdio1/fopen.c80
-rw-r--r--libc/stdio1/fputc.c53
-rw-r--r--libc/stdio1/fputs.c32
-rw-r--r--libc/stdio1/idealgetline.c67
-rw-r--r--libc/stdio1/makefile36
-rw-r--r--libc/stdio1/old_printf.c230
-rw-r--r--libc/stdio1/printf.c649
-rw-r--r--libc/stdio1/puts.c26
-rw-r--r--libc/stdio1/scanf.c151
-rw-r--r--libc/stdio1/stdio.h135
-rwxr-xr-xlibc/stdio1/test.sh12
-rw-r--r--libc/stdio2/Config4
-rw-r--r--makefile.in6
-rw-r--r--unproto/Makefile2
58 files changed, 98 insertions, 2144 deletions
diff --git a/Libc_version b/Libc_version
index 7ffdfa1..1282fff 100644
--- a/Libc_version
+++ b/Libc_version
@@ -1 +1 @@
-0.15.4
+0.15.5
diff --git a/ar/Makefile b/ar/Makefile
index f3b890d..61772df 100644
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -2,7 +2,6 @@
# This file is part of the Linux-8086 Development environment and is
# distributed under the GNU General Public License.
-xCC=bcc -0
LIBDIR =/usr/bin
CFLAGS =-O
LDFLAGS =
@@ -12,7 +11,7 @@ OBJS= ar.o
all: ar86
ar86: $(OBJS)
- $(CC) $(LDFLAGS) $(OBJS) -o $@
+ $(CC) $(LDFLAGS) $^ -o $@
install: ar86
install -d $(LIBDIR)
diff --git a/ar/ar.c b/ar/ar.c
index 1cc3443..e57ddfb 100644
--- a/ar/ar.c
+++ b/ar/ar.c
@@ -19,6 +19,11 @@
#include <stdio.h>
#include <stdlib.h>
+#ifdef __STDC__
+#include <unistd.h>
+#include <string.h>
+#include <utime.h>
+#endif
#include <fcntl.h>
#include <time.h>
#include <sys/types.h>
@@ -214,6 +219,7 @@ struct ar_hdr symdef_header;
/* Name this program was run with. */
char *program_name;
+#ifndef __STDC__
char *xmalloc (), *xrealloc ();
void free ();
@@ -236,6 +242,57 @@ void update_symdefs ();
void delete_members (), move_members (), replace_members ();
void quick_append ();
char *basename ();
+void print_modes ();
+char *make_tempname ();
+void copy_out_member ();
+#else
+/* Grrr. */
+extern void error ();
+extern void fatal ();
+extern void extract_members ();
+
+extern char *basename (char *path);
+extern char *concat (char *s1, char *s2, char *s3);
+extern char *make_tempname (char *name);
+extern char *xmalloc (unsigned int size);
+extern char *xrealloc (char *ptr, unsigned int size);
+extern int filter_symbols (struct nlist *syms, unsigned int symcount);
+extern int insert_in_map (char *name, struct mapelt *map, struct mapelt *after);
+extern int main (int argc, char **argv);
+extern int move_in_map (char *name, struct mapelt *map, struct mapelt *after);
+extern int read_header_info (struct mapelt *mapelt, int desc, long int offset, long int *syms_offset, unsigned int *syms_size, long int *strs_offset, unsigned int *strs_size);
+extern struct mapelt *find_mapelt (struct mapelt *map, char *name);
+extern struct mapelt *find_mapelt_noerror (struct mapelt *map, register char *name);
+extern struct mapelt *last_mapelt (struct mapelt *map);
+extern struct mapelt *make_map (int nonexistent_ok);
+extern struct mapelt *prev_mapelt (struct mapelt *map, struct mapelt *elt);
+extern void add_to_map (struct member_desc member);
+extern void close_archive (void);
+extern void copy_out_member (struct mapelt *mapelt, int archive_indesc, int outdesc, char *outname);
+extern void delete_from_map (char *name, struct mapelt *map);
+extern void delete_members (void);
+extern void error_with_file (char *string, struct mapelt *mapelt);
+extern void extract_member (struct member_desc member, FILE *istream);
+extern void header_from_map (struct ar_hdr *header, struct mapelt *mapelt);
+extern void lock_for_update (void);
+extern void make_new_symdefs (struct mapelt *mapelt, int archive_indesc);
+extern void move_members (void);
+extern void mywrite (int desc, char *buf, int bytes, char *file);
+extern void perror_with_name (char *name);
+extern void pfatal_with_name (char *name);
+extern void print_contents (struct member_desc member, FILE *istream);
+extern void print_descr (struct member_desc member);
+extern void print_modes (int modes);
+extern void quick_append (void);
+extern void read_old_symdefs (struct mapelt *map, int archive_indesc);
+extern void replace_members (void);
+extern void touch_symdef_member (int outdesc, char *outname);
+extern void two_operations (void);
+extern void update_symdefs (struct mapelt *map, int archive_indesc);
+extern void usage (char *s1, char *s2);
+extern void write_archive (struct mapelt *map, int appendflag);
+extern void write_symdef_member (struct mapelt *mapelt, struct mapelt *map, int outdesc, char *outname);
+#endif
/* Output BYTES of data at BUF to the descriptor DESC.
FILE is the name of the file (for error messages). */
@@ -539,8 +596,6 @@ scan (function, crflag)
fclose (arcstream);
}
-void print_modes ();
-
void
print_descr (member)
struct member_desc member;
@@ -872,9 +927,6 @@ close_archive ()
to do any I/O on the archive file.
*/
-char *make_tempname ();
-void copy_out_member ();
-
void
write_archive (map, appendflag)
struct mapelt *map;
@@ -1327,7 +1379,7 @@ replace_members ()
change_map = change_map->next;
if (!changed && (!symdef_flag || symdef_exists))
/* Nothing changed. */
- close_archive (change_map);
+ close_archive ();
else
write_archive (change_map, 0);
}
diff --git a/as/Makefile b/as/Makefile
index 2928397..bc62091 100644
--- a/as/Makefile
+++ b/as/Makefile
@@ -12,13 +12,13 @@ OBJS =as.o assemble.o error.o express.o \
all: as86 as86_encap
as86: $(OBJS)
- $(CC) $(LDFLAGS) $(OBJS) -o as86
+ $(CC) $(LDFLAGS) $(OBJS) -o $@
as86_encap: as86_encap.sh
sed -e "s:%%LIBDIR%%:$(LIBDIR):" -e "s:%%BINDIR%%:$(BINDIR):" \
- < as86_encap.sh > tmp
- @mv -f tmp as86_encap
- chmod +x as86_encap
+ < $^ > tmp
+ @mv -f tmp $@
+ chmod +x $@
install: all
install -d $(LIBDIR)
diff --git a/bcc/Makefile b/bcc/Makefile
index 3b84f5a..ed4854f 100644
--- a/bcc/Makefile
+++ b/bcc/Makefile
@@ -26,16 +26,16 @@ install: all
install -m 755 bcc-cc1 $(LIBDIR)/bcc-cc1
bcc: bcc.c
- $(CC) $(ANSI) $(CFLAGS) $(BCCDEFS) $(LDFLAGS) bcc.c -o $@
+ $(CC) $(ANSI) $(CFLAGS) $(BCCDEFS) $(LDFLAGS) $^ -o $@
ncc: bcc.c
- $(CC) $(ANSI) $(CFLAGS) -DL_TREE -DDEFARCH=0 $(LDFLAGS) bcc.c -o $@
+ $(CC) $(ANSI) $(CFLAGS) -DL_TREE -DDEFARCH=0 $(LDFLAGS) $^ -o $@
bcc09: bcc.c
- $(CC) $(ANSI) $(CFLAGS) -DMC6809 $(BCCDEFS) $(LDFLAGS) bcc.c -o $@
+ $(CC) $(ANSI) $(CFLAGS) -DMC6809 $(BCCDEFS) $(LDFLAGS) $^ -o $@
ccc: bcc.c
- $(CC) $(ANSI) $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) bcc.c -o $@
+ $(CC) $(ANSI) $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) $^ -o $@
bcc-cc1: $(OBJS)
$(CC) $(BCCARCH) $(LDFLAGS) $(OBJS) -o bcc-cc1
diff --git a/bootblocks/Makefile b/bootblocks/Makefile
index 068613c..7378819 100644
--- a/bootblocks/Makefile
+++ b/bootblocks/Makefile
@@ -54,6 +54,12 @@ boottar.sys: $(MSRC) $(MINC) tarboot.bin
mv monitor.out boottar.sys
@rm -f $(MOBJ)
+bootminix.sys: $(MSRC) $(MINC) tarboot.bin
+ @rm -f $(MOBJ)
+ make 'CFLAGS=$(CFLAGS) -DMINFLOPPY -i-' monitor.out
+ mv monitor.out bootminix.sys
+ @rm -f $(MOBJ)
+
monitor: $(MSRC) $(MINC)
@rm -f $(MOBJ)
make 'CFLAGS=-ansi -H0x8000' monitor.out
diff --git a/copt/Makefile b/copt/Makefile
index 329557b..ae886fb 100644
--- a/copt/Makefile
+++ b/copt/Makefile
@@ -1,6 +1,6 @@
copt: copt.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o copt copt.c
+ $(CC) $(ANSI) $(CFLAGS) $(LDFLAGS) -o $@ $<
realclean clean:
rm -f *.o copt
diff --git a/elksemu/Kernel_patch b/elksemu/Kernel_patch
index 1a9d93e..9752353 100644
--- a/elksemu/Kernel_patch
+++ b/elksemu/Kernel_patch
@@ -3,6 +3,7 @@ on a Linux-i386 (1.2.13) system.
It requires V0.0.2 or better of elksemu in the file "/lib/elksemu".
If you are using kernel 1.3.* or later try the module: binfmt_elks.o
+If you are using 2.0.36, 2.1.43 or 2.2.* and later use binfmt_misc.
--- orig-13/fs/exec.c Sun Sep 24 13:22:37 1995
+++ linux/fs/exec.c Sun Feb 11 20:11:47 1996
diff --git a/elksemu/Makefile b/elksemu/Makefile
index 4b3e056..f613fde 100644
--- a/elksemu/Makefile
+++ b/elksemu/Makefile
@@ -10,11 +10,6 @@ ifeq ($(CC),ncc)
CFLAGS=-Ml -ansi -s $(DEFS)
endif
-# For gcc
-ifeq ($(CC),gcc)
-CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS)
-endif
-
# Default
ifeq ($(CFLAGS),)
CFLAGS=-O
@@ -29,7 +24,7 @@ endif
OBJ=elks.o elks_sys.o elks_signal.o minix.o
elksemu: $(OBJ)
- $(CC) $(CFLAGS) -o elksemu $(OBJ)
+ $(CC) $(CFLAGS) -o $@ $^
elks_sys.o: call_tab.v
$(OBJ): elks.h
@@ -40,13 +35,14 @@ call_tab.v: dummy
dummy:
-# The kernel patch or module _requires_ this location.
+# The kernel patch or module _requires_ this location but binfmt-misc is easy
+# to redirect.
install: elksemu
install -d $(DIST)/lib
install -s -o root -g root -m 4555 elksemu $(DIST)/lib/elksemu
clean realclean:
- rm -f $(OBJ) elksemu call_tab.v defn_tab.v
+ rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v
module: binfmt_elks.o
diff --git a/elksemu/binfmt_elks.c b/elksemu/binfmt_elks.c
index 07babe4..cf40819 100644
--- a/elksemu/binfmt_elks.c
+++ b/elksemu/binfmt_elks.c
@@ -5,7 +5,6 @@
* original #!-checking implemented by tytso.
* ELKS hack added by Chad Page...
* Cleaned up some more by Robert de Bath
- * I can't make it work with 1.2.13 tho! :-(
*/
#include <linux/module.h>
diff --git a/elksemu/linux/vm86.h b/elksemu/linux/vm86.h
deleted file mode 100644
index c099980..0000000
--- a/elksemu/linux/vm86.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Since 1.3.99 vm86.h has moved from it's original position, this file
- * redirects sys/vm86.h to the correct location if it hasn't been updated
- * yet.
- *
- * Use "-idirafter . " on the command line.
- */
-#include <asm/vm86.h>
diff --git a/ld/Makefile b/ld/Makefile
index ec4e91e..393876c 100644
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -21,11 +21,11 @@ OBJS= dumps.o io.o ld.o readobj.o table.o typeconv.o linksyms.o \
all: ld86 objchop catimage objdump86
ld86: $(OBJS)
- $(CC) $(LDFLAGS) $(OBJS) -o $@
+ $(CC) $(LDFLAGS) $^ -o $@
install: ld86
install -d $(LIBDIR)
- install -m 755 ld86 $(LIBDIR)
+ install -m 755 $^ $(LIBDIR)
clean realclean clobber:
rm -f *.o ld86 ld86r objchop catimage objdump86
@@ -39,7 +39,7 @@ ar.h:
ln ../libc/include/ar.h .
writebin.o: writebin.c
- $(CC) $(CFLAGS) $(DEFS) $(NATIVE) -c writebin.c
+ $(CC) $(CFLAGS) $(DEFS) $(NATIVE) -c $<
writerel.o: writebin.c
diff --git a/libc/Config.dflt b/libc/Config.dflt
index 7444bae..1927f1e 100644
--- a/libc/Config.dflt
+++ b/libc/Config.dflt
@@ -5,11 +5,11 @@ getent:+:
gtermcap:+:
i386fp:+:
i386sys:+:
-malloc1:+:
+malloc:+:
misc:+:
msdos:+:
regexp:+:
-stdio2:+:
+stdio:+:
string:+:
syscall:+:
termios:+:
diff --git a/libc/Makefile b/libc/Makefile
index 41865d6..408d92c 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -11,7 +11,7 @@ endif
VERMAJOR=0
VERMINOR=15
-VERPATCH=4
+VERPATCH=5
VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH)
CC=bcc
diff --git a/libc/malloc/Config b/libc/malloc/Config
new file mode 100644
index 0000000..45cf008
--- /dev/null
+++ b/libc/malloc/Config
@@ -0,0 +1 @@
+malloc: Malloc routines
diff --git a/libc/malloc1/Makefile b/libc/malloc/Makefile
index e762582..e762582 100644
--- a/libc/malloc1/Makefile
+++ b/libc/malloc/Makefile
diff --git a/libc/malloc1/README b/libc/malloc/README
index 95f5928..95f5928 100644
--- a/libc/malloc1/README
+++ b/libc/malloc/README
diff --git a/libc/malloc1/malloc.c b/libc/malloc/malloc.c
index 86ffd42..86ffd42 100644
--- a/libc/malloc1/malloc.c
+++ b/libc/malloc/malloc.c
diff --git a/libc/malloc1/malloc.h b/libc/malloc/malloc.h
index e8fdb0a..e8fdb0a 100644
--- a/libc/malloc1/malloc.h
+++ b/libc/malloc/malloc.h
diff --git a/libc/malloc1/Config b/libc/malloc1/Config
deleted file mode 100644
index 4404398..0000000
--- a/libc/malloc1/Config
+++ /dev/null
@@ -1 +0,0 @@
-malloc: Robert's malloc routines
diff --git a/libc/malloc2/Config b/libc/malloc2/Config
deleted file mode 100644
index 11c476d..0000000
--- a/libc/malloc2/Config
+++ /dev/null
@@ -1 +0,0 @@
-malloc: Joel's malloc functions
diff --git a/libc/malloc2/Makefile b/libc/malloc2/Makefile
deleted file mode 100644
index edfc8f5..0000000
--- a/libc/malloc2/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-
-OBJ=malloc.o stack.o
-
-CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
-
-all: $(LIBC)($(OBJ))
- @$(RM) $(OBJ)
-
-clean:
- rm -f *.o libc.a
-
-transfer:
- -@rm ../include/malloc.h
- cp -p malloc.h ../include/.
diff --git a/libc/malloc2/README b/libc/malloc2/README
deleted file mode 100644
index ecf3fd2..0000000
--- a/libc/malloc2/README
+++ /dev/null
@@ -1,19 +0,0 @@
-This is just the malloc for libc. It is untested; it won't even compile
-right now. In particular, __malloc_init needs some bug fixing!
-
-Apparently, there is another malloc that Robert Debath wrote which probably
-works by now. However, I honestly think that my malloc may be just as
-good when it's finished.
-
-In about six months, you'll probably see something like this:
-
-
-Linux/less-than-32-bit installation program
-Do you want
- 1. Chad Page's kernel
- 2. Alan Cox's kernel
-Enter your chioce --> 2
-Do you want
- 1. Robert Debath's malloc
- 2. Joel Weber's malloc
-[more choices for compilers, filetools, etc]
diff --git a/libc/malloc2/malloc.c b/libc/malloc2/malloc.c
deleted file mode 100644
index 2e1cc04..0000000
--- a/libc/malloc2/malloc.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* simplified linux malloc.h
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <malloc.h>
-
-typedef struct __malloc_struct malloc_struct;
-
-typedef union __malloc_union
-{
- char *c;
- malloc_struct *m;
-} malloc_union;
-
-
-struct __malloc_struct
-{
- unsigned char status;
-#define ALLOC 0x53
-#define FREE 0x55
-#define END_OF_WORLD 0x57
- malloc_union next;
-} *malloc_start;
-
-extern int __STACKSIZE;
-
-/* WARNING: this init will only work if there is a hard limit on the
- amount of RAM that can be allocated.
- */
-
-#ifdef __AS386_16__
-#asm
- loc 1 ! Make sure the pointer is in the correct segment
-auto_func: ! Label for bcc -M to work.
- .word _malloc_init ! Pointer to the autorun function
- .text ! So the function after is also in the correct seg.
-#endasm
-#endif
-
-malloc_init()
-{
- extern unsigned int sbrk();
-
- unsigned int ptr, sz, count;
-
- malloc_start = (malloc_struct*) ((sbrk(16)+1)&~1);
- malloc_start->status = FREE;
-
- count=254;
- for(sz=16384; sz>64; )
- {
- ptr= sbrk(sz);
- if( ptr == (unsigned)-1 ) sz>>=1;
- else count+=sz;
- }
- if( __STACKSIZE > count || __STACKSIZE <= 0 ) __STACKSIZE = ((count>>1)&-2);
- ptr = sbrk(-__STACKSIZE);
-
- malloc_start->next.m = ((malloc_struct*)ptr) - 1;
-
- malloc_start->next.m->status = END_OF_WORLD;
-}
-
-char *malloc(size)
-size_t size;
-{
- register malloc_union tmp, tmp2;
-
- /* Make sure we don't lose the alignment */
- size = (size+sizeof(malloc_struct)-1)/sizeof(malloc_struct);
-
- tmp.m = malloc_start;
- while ( ( tmp.m->next.m - tmp.m - 2 ) < size
- || ( tmp.m->status == ALLOC ))
- tmp.m = tmp.m->next.m;
-
- if (tmp.m->status == FREE){
- tmp2.m = size + tmp.m + 1;
- tmp2.m->status = FREE;
- tmp2.m->next.c = tmp.m->next.c;
- tmp.m->status = ALLOC;
- tmp.m->next.c = tmp2.c;
- }
- else return 0;
- tmp.m++;
- return tmp.c;
-}
-
-__malloc_cleanup() /* finds consecutive free blocks and joins them */
-{
- malloc_struct *tmp;
-
- tmp = malloc_start;
- while ((tmp->status != END_OF_WORLD)&&(tmp->next.m->status != END_OF_WORLD)){
- if ((tmp->status==FREE)&&(tmp->next.m->status==FREE))
- tmp->next.m = tmp->next.m->next.m;
- else tmp = tmp->next.m;
- }
-}
-
-free(what)
-char *what;
-{
- malloc_union tmp;
-
- tmp.c = what; tmp.m--;
- if( tmp.m->status == ALLOC )
- {
- tmp.m->status = FREE;
- __malloc_cleanup;
- }
-}
diff --git a/libc/malloc2/malloc.h b/libc/malloc2/malloc.h
deleted file mode 100644
index ffcb3a4..0000000
--- a/libc/malloc2/malloc.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* simplified linux malloc.h
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-char *malloc(size);
-void free(what);
-char *realloc(what, size);
diff --git a/libc/malloc2/stack.c b/libc/malloc2/stack.c
deleted file mode 100644
index 5f33e21..0000000
--- a/libc/malloc2/stack.c
+++ /dev/null
@@ -1,10 +0,0 @@
-
-/*
- * Under Linux 8086 the stack and heap areas are at the top and bottom
- * of the same area of memory, this version of malloc requires that the
- * malloc area is of a fixed size this means that there must also be a
- * specific amount of stack space reserved outside of this. The number
- * of bytes to be reserved is specified below.
- */
-
-int __STACKSIZE = 2048;
diff --git a/libc/stdio/Config b/libc/stdio/Config
new file mode 100644
index 0000000..8f2b307
--- /dev/null
+++ b/libc/stdio/Config
@@ -0,0 +1,4 @@
+#
+
+stdio: Stdio package
+
diff --git a/libc/stdio2/Makefile b/libc/stdio/Makefile
index 0fd8d97..0fd8d97 100644
--- a/libc/stdio2/Makefile
+++ b/libc/stdio/Makefile
diff --git a/libc/stdio2/printf.c b/libc/stdio/printf.c
index e41eca4..e41eca4 100644
--- a/libc/stdio2/printf.c
+++ b/libc/stdio/printf.c
diff --git a/libc/stdio2/scanf.c b/libc/stdio/scanf.c
index 1e0f282..1e0f282 100644
--- a/libc/stdio2/scanf.c
+++ b/libc/stdio/scanf.c
diff --git a/libc/stdio2/stdio.c b/libc/stdio/stdio.c
index 6b0dba0..6b0dba0 100644
--- a/libc/stdio2/stdio.c
+++ b/libc/stdio/stdio.c
diff --git a/libc/stdio2/stdio.h b/libc/stdio/stdio.h
index fd10923..fd10923 100644
--- a/libc/stdio2/stdio.h
+++ b/libc/stdio/stdio.h
diff --git a/libc/stdio1/BUGS b/libc/stdio1/BUGS
deleted file mode 100644
index 0e8e0db..0000000
--- a/libc/stdio1/BUGS
+++ /dev/null
@@ -1,15 +0,0 @@
-Error checking is known to be wanting. However the author just wants to
-get it working right now.
-
-fread() and fwrite() are not supported. open(), read(), write(), and close()
-work very well for binary data.
-
-fopen() is the only way to open a file. None of the temp stuff is supported,
-and frepon() is unsupported.
-
-GNU extensions are unsupported.
-
-Some printf specifications may not work. Read the code for details of what
-IS supported.
-
-Other than that, this should be a perfectly normal stdio lib when it's finished.
diff --git a/libc/stdio1/Config b/libc/stdio1/Config
deleted file mode 100644
index 3b3b35f..0000000
--- a/libc/stdio1/Config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-stdio: Joel's stdio package altered by Nat
diff --git a/libc/stdio1/NOTICE b/libc/stdio1/NOTICE
deleted file mode 100644
index 25ca5b6..0000000
--- a/libc/stdio1/NOTICE
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
diff --git a/libc/stdio1/README b/libc/stdio1/README
deleted file mode 100644
index ead7846..0000000
--- a/libc/stdio1/README
+++ /dev/null
@@ -1,8 +0,0 @@
-I found that it was helpful to have the extern stuff actually defined in
-one file as not external...
-
-Still trying to find the other problems
-
-Whether it is desireable to list stdio.h as a dependency is debateable
-
--Joel
diff --git a/libc/stdio1/TODO b/libc/stdio1/TODO
deleted file mode 100644
index 481f6d9..0000000
--- a/libc/stdio1/TODO
+++ /dev/null
@@ -1,33 +0,0 @@
-Sun Jan 21 18:16:03 EST 1996 -- Nat Friedman
-============================================
-I've made a load of changes to this code, but there's still a lot to be done.
-- scanf, fscanf
-
-
-
-
-input, file positioning, eof, declarations of functions, printf
-
-look for unsigned char references
-
-specifically
-fix printf and figure out what's going on in there.
-write idealgetline, scanf, other stuff
-then deal with above stuff...
-
-
-LATEST LIST:
-printf, fprintf
-scanf, fscanf
-feof
-seek support
-error handling (not too hard since system calls only in a few places)
-atexit stuff (close files; will need to add a linked list of files)
-setvbuf if desired
-check that fopen() and stdio_init() fill in ALL the fields
-testing!
-
-rm NOTICE
-
-
-
diff --git a/libc/stdio1/__ffillbuf.c b/libc/stdio1/__ffillbuf.c
deleted file mode 100644
index e705cbf..0000000
--- a/libc/stdio1/__ffillbuf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* simplified linux __ffillbuf.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <unistd.h>
-#include "stdio.h"
-
-/* this function makes the mistake of assuming the buffer really DOES
-need to be filled. */
-
-/* RDB:
- * Added simple processing for EOF and errors
- * As this is _only_ called from getc() the memory footprint is smaller
- * if it pretends to be getc in the complex case.
- */
-
-int
-__ffillbuf(stream)
-FILE *stream;
-{
- int stat;
-
- if( stream->fd < 0 || ferror(stream) ) return EOF;
-
- stat = read(stream->fd, (char *) stream->bufstart, stream->bufend - stream->bufstart);
- if( stat > 0 )
- stream->bufread = stream->bufstart + stat;
- else if( stat == 0 )
- {
- stream->fc_eof = 1;
- return EOF;
- }
- else
- {
- stream->fc_err = 1;
- return EOF;
- }
-
- stream->bufpos = stream->bufstart;
-
- return getc(stream);
-}
diff --git a/libc/stdio1/__stdio_init.c b/libc/stdio1/__stdio_init.c
deleted file mode 100644
index b49bb28..0000000
--- a/libc/stdio1/__stdio_init.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* simplified linux __stdio_init.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include "stdio.h"
-
-/*
- OK, Complete hackup here, I've removed the need for the init function.
- Not also I've make the types into 'unsigned char' this is so it doesn't
- return EOF when it really means '\377'
- */
-
-static unsigned char __stdinbuf[BUFSIZ], __stdoutbuf[BUFSIZ], __stderrbuf[80];
-
-static FILE __the_stdin = {
- 0,
- __stdinbuf,
- __stdinbuf,
- __stdinbuf,
- __stdinbuf+sizeof(__stdinbuf),
- _IOLBF,
- _MODE_READ,
- 0, 0,
- 0, 0, 1
-};
-
-static FILE __the_stdout = {
- 1,
- __stdoutbuf,
- __stdoutbuf,
- __stdoutbuf,
- __stdoutbuf+sizeof(__stdoutbuf),
- _IOLBF,
- _MODE_WRITE,
- 0, 0,
- 0, 0, 1
-};
-
-static FILE __the_stderr = {
- 2,
- __stderrbuf,
- __stderrbuf,
- __stderrbuf,
- __stderrbuf+sizeof(__stderrbuf),
- _IOLBF,
- _MODE_WRITE,
- 0, 0,
- 0, 0, 1
-};
-
-FILE *stdin = &__the_stdin,
- *stdout = &__the_stdout,
- *stderr = &__the_stderr;
diff --git a/libc/stdio1/fclose.c b/libc/stdio1/fclose.c
deleted file mode 100644
index 7ec233e..0000000
--- a/libc/stdio1/fclose.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* simplified linux fclose.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <unistd.h>
-#include "stdio.h"
-
-int fclose (stream)
-FILE *stream;
-{
- /* only allow fclose() on what was fopen()ed. */
- /*
- This isn't right, there's nothing wrong with fclosing stdin
- but the next fopen/open will be given fd 0 and so become stdin
- Of course you do have to be a little careful :-)
- RDB
- */
-
- if ((stream == stdin) || (stream == stdout) || (stream == stderr)) return EOF;
-
- if (fflush(stream)) return EOF;
-
- if (close(stream->fd)) return EOF;
-
- free(stream->bufstart);
- free(stream);
- return 0;
-}
diff --git a/libc/stdio1/fcntl.h b/libc/stdio1/fcntl.h
deleted file mode 100644
index 69fdb90..0000000
--- a/libc/stdio1/fcntl.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __FCNTL_H
-#define __FCNTL_H
-
-/*
- * Definitions taken from the i386 Linux kernel.
- */
-
-/* open/fcntl */
-
-#define O_ACCMODE 0003
-#define O_RDONLY 00
-#define O_WRONLY 01
-#define O_RDWR 02
-#define O_CREAT 0100 /* not fcntl */
-#define O_EXCL 0200 /* not fcntl */
-#define O_NOCTTY 0400 /* not fcntl */
-#define O_TRUNC 01000 /* not fcntl */
-#define O_APPEND 02000
-#define O_NONBLOCK 04000
-#define O_NDELAY O_NONBLOCK
-#if 0
-#define O_SYNC 010000 /* Not supported */
-#define FASYNC 020000 /* Not supported */
-#endif
-
-#define F_DUPFD 0 /* dup */
-#define F_GETFD 1 /* get f_flags */
-#define F_SETFD 2 /* set f_flags */
-#define F_GETFL 3 /* more flags (cloexec) */
-#define F_SETFL 4
-#define F_GETLK 5
-#define F_SETLK 6
-#define F_SETLKW 7
-
-#define F_SETOWN 8 /* for sockets. */
-#define F_GETOWN 9 /* for sockets. */
-
-/* for F_[GET|SET]FL */
-#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
-
-/* for posix fcntl() and lockf() */
-#define F_RDLCK 0
-#define F_WRLCK 1
-#define F_UNLCK 2
-
-/* for old implementation of bsd flock () */
-#define F_EXLCK 4 /* or 3 */
-#define F_SHLCK 8 /* or 4 */
-
-/* operations for bsd flock(), also used by the kernel implementation */
-#define LOCK_SH 1 /* shared lock */
-#define LOCK_EX 2 /* exclusive lock */
-#define LOCK_NB 4 /* or'd with one of the above to prevent
- blocking */
-#define LOCK_UN 8 /* remove lock */
-
-#ifdef __KERNEL__
-#define F_POSIX 1
-#define F_FLOCK 2
-#endif /* __KERNEL__ */
-
-#if 0
-struct flock {
- short l_type;
- short l_whence;
- off_t l_start;
- off_t l_len;
- pid_t l_pid;
-};
-#endif
-
-#endif
diff --git a/libc/stdio1/fflush.c b/libc/stdio1/fflush.c
deleted file mode 100644
index c9cdac7..0000000
--- a/libc/stdio1/fflush.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* simplified linux fflush.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <unistd.h>
-#include "stdio.h"
-
-int fflush(stream)
-FILE *stream;
-{
- if (stream == 0) return 0;
- if ((stream->file_mode == _MODE_WRITE)
- ||(stream->file_mode == (_MODE_WRITE & _MODE_RDWR))){
- write(stream->fd, (char *) stream->bufstart,
- stream->bufpos - stream->bufstart);
- stream->bufpos = stream->bufstart;
- }
- return 0;
-}
-/* TODO: return EOF or 0; support NULL stream */
-/* The only place an error can come from is the write; you're not checking RDB
- */
diff --git a/libc/stdio1/fgetc.c b/libc/stdio1/fgetc.c
deleted file mode 100644
index 2c41062..0000000
--- a/libc/stdio1/fgetc.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "stdio.h"
-
-/*
- * Make this not dependent on getc() then we can:
- #define getc(fp) fgetc(fp)
- * if memory is _really_ tight.
- */
-
-int fgetc(stream)
-FILE *stream;
-{
- if( stream->ungetted )
- {
- stream->ungetted = 0;
- return stream->ungetchar;
- }
- if( stream->bufpos == stream->bufread )
- return __ffillbuf(stream);
- else
- return *stream->bufpos++;
-}
diff --git a/libc/stdio1/fgets.c b/libc/stdio1/fgets.c
deleted file mode 100644
index c085970..0000000
--- a/libc/stdio1/fgets.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* fgets.c for limited linux stdio
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "stdio.h"
-
-/*
- RDB BZZZT! This should only read upto and including any newline!
-*/
-
-char *fgets(s, count, f)
-char *s;
-size_t count;
-FILE *f;
-{
- char *ret;
- register size_t i;
- register int ch;
-
- ret = s;
- for(i=count; i>0; i--)
- {
- ch = getc(f);
- if( ch == EOF )
- {
- if(s==ret) return 0;
- break;
- }
- *s++ = (char) ch;
- if( ch == '\n' ) break;
- }
- *s = 0;
-
- if( ferror(f) ) return 0;
- return ret;
-}
diff --git a/libc/stdio1/fopen.c b/libc/stdio1/fopen.c
deleted file mode 100644
index 1265ff5..0000000
--- a/libc/stdio1/fopen.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* simplified linux fopen.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include "stdio.h"
-#include <malloc.h>
-
-FILE * fopen(name, openmode)
-char *name;
-char *openmode;
-{
- FILE *new;
- int openplus=0;
- char basemode;
-
- basemode = openmode[0];
- while (openmode[0] != 0){
- switch(openmode[0]){
- case '+': openplus=1; break;
- }
- openmode++;
- }
-
- new = malloc(sizeof(new));
- if( new == 0 ) return 0;
- new->bufread = new->bufpos = new->bufstart = malloc(BUFSIZ);
- if( new->bufstart == 0 ) { free(new) ; return 0; }
-
- new->bufend = new->bufstart + BUFSIZ;
- new->buffer_mode = _IOFBF;
- new->iotrans = 0;
- new->fd = -1;
- if (openplus){
- new->file_mode = _MODE_RDWR;
- switch (basemode){
- case 'a':
- new->fd = open(name, O_RDWR | O_APPEND | O_CREAT);
- break;
- case 'r':
- new->fd = open(name, O_RDWR);
- break;
- case 'w':
- new->fd = open(name, O_RDWR | O_TRUNC | O_CREAT);
- break;
- }
- } else switch (basemode){
- case 'a':
- new->fd = open(name, O_WRONLY | O_APPEND | O_CREAT);
- new->file_mode = _MODE_WRITE;
- break;
- case 'r':
- new->fd = open(name, O_RDONLY);
- new->file_mode = _MODE_READ;
- break;
- case 'w':
- new->fd = open(name, O_WRONLY | O_TRUNC | O_CREAT);
- new->file_mode = _MODE_WRITE;
- break;
- }
- if( new->fd < 0 )
- {
- free(new->bufstart);
- free(new);
- return 0;
- }
- return new;
-}
diff --git a/libc/stdio1/fputc.c b/libc/stdio1/fputc.c
deleted file mode 100644
index 939a721..0000000
--- a/libc/stdio1/fputc.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* simplified linux fputc.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include "stdio.h"
-
-/*
- * Make this not dependent on putc() then we can:
- #define putc(c, fp) fputc(c, fp)
- * if memory is _really_ tight.
- */
-
-#undef putc
-#define putc(c, stream) \
- (((stream)->bufpos[0] = (c)), \
- ((stream)->bufpos++), \
- ((((stream)->bufpos == (stream)->bufend) \
- ||((stream)->buffer_mode == _IONBF) \
- ||(((stream)->buffer_mode == _IOLBF) \
- && ((stream)->bufpos != (stream)->bufstart) \
- && ((stream)->bufpos[-1] == '\n'))) \
- ? fflush(stream):0))
-
-#define new_putc(c, stream) \
- ((unsigned char)( \
- ((stream)->bufpos>=(stream)->bufread) ? fputc((c), (stream)) \
- : *(stream)->bufpos++ = (c) \
- ))
-
-int
-fputc(int c, FILE * stream)
-{
-#ifdef __MSDOS__
- if( c == '\n' && stream->iotrans ) fputc('\r', stream);
-#endif
- return putc(c, stream);
-}
-
-
-
diff --git a/libc/stdio1/fputs.c b/libc/stdio1/fputs.c
deleted file mode 100644
index 41e2998..0000000
--- a/libc/stdio1/fputs.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* simplified linux fputs.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <unistd.h>
-#include <string.h>
-#include "stdio.h"
-
-int
-fputs(__const char * string, FILE * stream)
-{
- if (stream->buffer_mode != _IONBF){
- while (string[0] != 0){
- putc(string[0], stream);
- string++;
- }
- } else write(stream->fd, string, strlen(string));
- return 0;
-}
diff --git a/libc/stdio1/idealgetline.c b/libc/stdio1/idealgetline.c
deleted file mode 100644
index 7eacc9e..0000000
--- a/libc/stdio1/idealgetline.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* idealgetline.c -- my idea of an ideal getline function for stdio
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* I actually intend to use this in 32 bit programs, unlike the other stuff
- in this lib. IMHO GNU getline is broken. It is too hard to use.
-
- Just pass this function a FILE * and it will retrieve a line for you using
- getc(). It will realloc() exactly the amount of memory needed, and will
- generate error messages for non-ascii characters on stderr.
-
- This may not be your ideal. It probably generates far too many errors.
- It doesn't work well for those who don't use English (but since
- Linux-less-than-32 libc and kernels are each being produced by one
- person in the US and one in the UK, this isn't a problem). It probably
- is not what you (or I) want for interactive input.
-
- You're welcome to modify this routine to meet your needs. However, if
- you change the semantics significantly, please change the name.
-
- (Maybe I should have put my own name on it so there will be no confusion
- about who thought it was ideal). */
-
-#include <stdio.h>
-#include <malloc.h>
-
-char *idealgetline(f)
-FILE *f;
-{
- char c;
- char *ret;
- int size = 0, bufsize = 256;
-
- ret = malloc(256);
- c = getc(f);
- while ((c != EOF) && (c != '\n')){
- if ((c >= ' ') && (c <= 126)){
- ret[size] = c;
- size++;
- if (size == bufsize){
- bufsize += 256;
- ret = realloc(ret, bufsize);
- }
- } else {
- fprintf(stderr, "Unexpected character 0x%x encountered in input", c);
- free(ret);
- return 0;
- }
- }
- ret[size] = '\0';
- size++;
- return realloc(ret, size);
-}
diff --git a/libc/stdio1/makefile b/libc/stdio1/makefile
deleted file mode 100644
index d8058b0..0000000
--- a/libc/stdio1/makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-TOP=..
-include $(TOP)/Make.defs
-OBJ = __ffillbuf.o __stdio_init.o fflush.o fgetc.o fgets.o \
- fputc.o fputs.o puts.o printf.o fopen.o fclose.o scanf.o
-
-#missing functions from above: printf etc, scanf etc, idealgetline
-#seek
-
-#fopen.c, fclose.c removed because of malloc() use
-
-CFLAGS+=$(WALL)
-
-ifeq ($(PLATFORM),i86-ELKS)
-CFLAGS=$(CCFLAGS) $(DEFS) -ansi
-endif
-
-all: $(OBJ)
-
-libc.a: $(OBJ)
- ar r ../$(LIBC) $(OBJ)
- @touch libc.a
-
-$(OBJ): stdio.h
-
-test: test.o $(OBJ)
- $(CC) -o test test.o $(OBJ)
-
-%.o: %.c
- $(CC) $(CFLAGS) -o $@ $< -c
-
-clean:
- rm -f *.o test libc.a
-
-transfer:
- -@rm -f ../include/stdio.h
- cp -p stdio.h ../include/.
diff --git a/libc/stdio1/old_printf.c b/libc/stdio1/old_printf.c
deleted file mode 100644
index 81d62ac..0000000
--- a/libc/stdio1/old_printf.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/* fprintf.c for limited Linux libc
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* Thanks Alan for writing the hard routine for me :-)
- * Alan said that this works "most of the time". Something tells me I'm making
- * it even worse! */
-/* The basic idea here is to make fprintf the core routine. printf obviously
- can just call fprintf with stdout followed by all of its arguments.
- sprintf() works using the fake file &the_sprintf. It's marked as fully
- buffered, so that it will only write(2) when &the_sprintf->bufpos ==
- &the_sprintf->bufend, which I doubt will happen since &the_sprintf->bufend
- = 0. The trick is that sprintf must set &the_sprintf->bufstart =
- &the_sprintf->bufpos = its first argument. Not as orthagonal (is that
- the right word?) as glibc's facilities for non-files, but this isn't a
- library for people who have unlimited RAM budgets. (not like the libc
- I use on linux/i586 enjoys an unlimited RAM budget either; I only have
- 8 MB
-
- I'm not sure what the "correct" way to pass the variable arguments
- from one function to the next is. Rather than pass the arguments
- themselves, I'm passing a pointer to them. However, the following
- explaination from Alan is probably a polite way of saying it will not
- work on a 386 anyway.
- Joel Weber
-
- [ I've migrated all of this code over to the ELKS stdarg that I wrote.
- The accepted way to do it is for the wrapper function to accept a
- variable number of arguments, use stdarg to make an argument pointer,
- and then pass the argument pointer on to the core function, as I've
- done here. This should definitely work on a 386, as the arguments
- are still passed in the stack, and stack order is maintained. -Nat ]
- */
-
-/*
- * This is NOT stunningly portable, but works
- * for pretty dumb non ANSI compilers and is
- * tight. Adjust the sizes to taste.
- *
- * Illegal format strings will break it. Only the
- * following simple subset is supported
- *
- * %x - hex
- * %d - decimal
- * %s - string
- * %c - char
- *
- * And the h/l length specifiers for %d/%x
- *
- * Alan Cox.
- */
-
-#include <stdarg.h>
-#include "stdio.h"
-
-/* 17 to make sure that there's room for the trailing newline.
- I'm not really sure if this is ideal... */
-static char nstring[17]="0123456789ABCDEF";
-
-static unsigned char *
-__numout(long i, int base)
-{
- static unsigned char out[16];
- int n;
- int flg = 0;
- unsigned long val;
-
- if (i<0 && base==10)
- {
- flg = 1;
- i = -i;
- }
- val = i;
-
- for (n = 0; n < 15; n++)
- out[n] = ' ';
- out[15] = '\0';
- n = 14;
- do{
- out[n] = nstring[val % base];
- n--;
- val /= base;
- }
- while(val);
- if(flg) out[n--] = '-';
- return &out[n+1];
-}
-
-static int
-internal_fprintf(FILE * stream, __const char * fmt, va_list ap)
-{
- register int c;
- int count = 0;
- int type, base;
-
- while(c=*fmt++)
- {
- if(c!='%')
- {
- putc(c, stream);
- count++;
- }
- else
- {
- type=1;
- do { c=*fmt++; } while( c=='.' || (c>='0' && c<='9'));
- if( c == 0 ) break;
- if(c=='h')
- {
- c=*fmt++;
- type = 0;
- }
- else if(c=='l')
- {
- c=*fmt++;
- type = 2;
- }
-
- switch(c)
- {
- case 'x':
- case 'o':
- case 'd':
- if (c=='x') base=16;
- if (c=='o') base=8;
- if (c=='d') base=10;
- {
- long val=0;
- switch(type)
- {
- case 0:
- val=va_arg(ap, short);
- break;
- case 1:
- val=va_arg(ap, int);
- break;
- case 2:
- val=va_arg(ap, long);
- break;
- }
- fputs((__const char *)__numout(val,base),stream);
- }
- break;
- case 's':
- {
- char *cp;
- cp=va_arg(ap, char *);
- while(*cp)
- putc(*cp++, stream);
- break;
- }
- case 'c':
- putc(va_arg(ap, int), stream);
- break;
- default:
- putc(c, stream);
- }
- }
- }
- return count;
-}
-
-
-int
-fprintf(FILE * stream, __const char * fmt, ...)
-{
- va_list ap;
- int retval;
- va_start(ap, fmt);
- retval=internal_fprintf(stream, fmt, ap);
- va_end(ap);
- return(retval);
-}
-
-int
-printf(__const char * fmt, ...)
-{
- va_list ap;
- int retval;
- va_start(ap, fmt);
- retval=internal_fprintf(stdout, fmt, ap);
- va_end(ap);
- return(retval);
-}
-
-/* This is a strange way of doing sprintf, but it should work */
-int sprintf(char * s, __const char * fmt, ...)
-{
- static FILE the_sprintf = {
- -1,
- 0,
- 0,
- 0,
- 0,
- _IOFBF,
- _MODE_WRITE,
- 0, 0,
- 0, 0};
- va_list ap;
- int retval;
-
- va_start(ap, fmt);
- the_sprintf.bufstart = the_sprintf.bufpos = (unsigned char *) s;
- the_sprintf.fc_err = 0;
-
- retval = internal_fprintf(&the_sprintf, fmt, ap);
- /* null-terminate the string */
- putc('\0', &the_sprintf);
-
- va_end(ap);
- return retval;
-}
-
-
-
-
-
diff --git a/libc/stdio1/printf.c b/libc/stdio1/printf.c
deleted file mode 100644
index f2a39bd..0000000
--- a/libc/stdio1/printf.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/* fprintf.c for limited Linux libc
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* Thanks Alan for writing the hard routine for me :-)
- * Alan said that this works "most of the time". Something tells me I'm making
- * it even worse! */
-/* The basic idea here is to make fprintf the core routine. printf obviously
- can just call fprintf with stdout followed by all of its arguments.
- sprintf() works using the fake file &the_sprintf. It's marked as fully
- buffered, so that it will only write(2) when &the_sprintf->bufpos ==
- &the_sprintf->bufend, which I doubt will happen since &the_sprintf->bufend
- = 0. The trick is that sprintf must set &the_sprintf->bufstart =
- &the_sprintf->bufpos = its first argument. Not as orthagonal (is that
- the right word?) as glibc's facilities for non-files, but this isn't a
- library for people who have unlimited RAM budgets. (not like the libc
- I use on linux/i586 enjoys an unlimited RAM budget either; I only have
- 8 MB
-
- I'm not sure what the "correct" way to pass the variable arguments
- from one function to the next is. Rather than pass the arguments
- themselves, I'm passing a pointer to them. However, the following
- explaination from Alan is probably a polite way of saying it will not
- work on a 386 anyway.
- Joel Weber
-
- [ I've migrated all of this code over to the ELKS stdarg that I wrote.
- The accepted way to do it is for the wrapper function to accept a
- variable number of arguments, use stdarg to make an argument pointer,
- and then pass the argument pointer on to the core function, as I've
- done here. This should definitely work on a 386, as the arguments
- are still passed in the stack, and stack order is maintained. -Nat ]
- */
-
-/*
- * This is NOT stunningly portable, but works
- * for pretty dumb non ANSI compilers and is
- * tight. Adjust the sizes to taste.
- *
- * Illegal format strings will break it. Only the
- * following simple subset is supported
- *
- * %x - hex
- * %d - decimal
- * %s - string
- * %c - char
- *
- * And the h/l length specifiers for %d/%x
- *
- * Alan Cox.
- */
-
-#include <stdarg.h>
-#include "stdio.h"
-
-/* 17 to make sure that there's room for the trailing newline.
- I'm not really sure if this is ideal... */
-static char nstring[17]="0123456789ABCDEF";
-
-static unsigned char *
-__numout(long i, int base)
-{
- static unsigned char out[16];
- int n;
- int flg = 0;
- unsigned long val;
-
- if (i<0 && base==10)
- {
- flg = 1;
- i = -i;
- }
- val = i;
-
- for (n = 0; n < 15; n++)
- out[n] = ' ';
- out[15] = '\0';
- n = 14;
- do{
- out[n] = nstring[val % base];
- n--;
- val /= base;
- }
- while(val);
- if(flg) out[n--] = '-';
- return &out[n+1];
-}
-
-int
-fprintf(FILE * stream, __const char * fmt, ...)
-{
- va_list ap;
- int retval;
- va_start(ap, fmt);
- retval=internal_fprintf(stream, fmt, ap);
- va_end(ap);
- return(retval);
-}
-
-int
-printf(__const char * fmt, ...)
-{
- va_list ap;
- int retval;
- va_start(ap, fmt);
- retval=internal_fprintf(stdout, fmt, ap);
- va_end(ap);
- return(retval);
-}
-
-/* This is a strange way of doing sprintf, but it should work */
-int sprintf(char * s, __const char * fmt, ...)
-{
- static FILE the_sprintf = {
- -1,
- 0,
- 0,
- 0,
- 0,
- _IOFBF,
- _MODE_WRITE,
- 0, 0,
- 0, 0};
- va_list ap;
- int retval;
-
- va_start(ap, fmt);
- the_sprintf.bufstart = the_sprintf.bufpos = (unsigned char *) s;
- the_sprintf.fc_err = 0;
-
- retval = internal_fprintf(&the_sprintf, fmt, ap);
- /* null-terminate the string */
- putc('\0', &the_sprintf);
-
- va_end(ap);
- return retval;
-}
-
-
-
-
-
-/*
- * printf.c - This is the more complete fprintf() replacement for libc8086
- * Copyright (C) 1996 Steven Huang <sthuang@hns.com>.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-/*
- * This decides if the little test main program gets included
- */
-#undef TEST
-/*
- * This decides if printf() should act like standard. When undefined,
- * - prints out "(err)" if a bad format is encountered
- * - supports the %b (binary) format
- */
-#define STANDARD
-
-/*
- * Shut bcc up about 'const', which doesn't seem to be handled right
- * by unproto.
- */
-#ifdef __BCC__
-#define const
-#endif
-
-#define BUF_SIZE 128
-#define OUTC(c) { putc(c, stream); n++; }
-#define max(a, b) ((a > b) ? a : b)
-/*
- * if you change the ff, you need to change the order of characters in
- * the string 'flagstr' defined in _printf()
- */
-#define FLAG_PADZERO (1<<0)
-#define FLAG_LEFTJUST (1<<1)
-#define FLAG_SIGNED (1<<2)
-#define FLAG_ALT (1<<3)
-#define FLAG_SPACE (1<<4)
-
-static char *utoa(unsigned int val, char *buf, int radix)
-/*
- * Converts an integer to a variable-radix string representation
- *
- * Note:
- * Does not perform sanity checking for 'radix'
- * Assumes 'buf' has memory allocated to it
- */
-{
- int divisor;
- char *p = buf;
- const char *digitstr = "0123456789abcdef";
-
- for (divisor = 1; val / divisor >= radix; divisor *= radix);
- do {
- *p++ = digitstr[val / divisor];
- val %= divisor;
- divisor /= radix;
- } while (divisor >= 1);
- *p = '\0';
- return(buf);
-}
-
-static
-internal_fprintf(FILE * stream, const char * fmt, char *args)
-
-/* static int _printf(FILE *stream, const char *fmt, char *args) */
-/*
- * The one that does all the work.
- * This is a fairly complete implementation of printf(), supporting
- * everything EXCEPT:
- * - floating point (eEDOUfg formats)
- * - pointers (realizes them but doesn't understand how to print them)
- * - short and long (h/l) modifiers (dunno what to do about them)
- * It's even slightly faster than gcc's printf() on Linux. Can't beat
- * HP-UX's printf() though ;)
- *
- * Supports:
- * d, signed integer
- * i
- * o unsigned octal integer
- * u unsigned integer
- * x unsigned hex lowercase a-f
- * X unsigned hex uppercase A-F
- * c character
- * s string (character pointer)
- * p void pointer (ignores it)
- * % % character
- * n number of characters output so far
- *
- * Special feature: (no really, it's not a bug =) )
- * b prints an integer in binary form (i think this might come
- * in handy *somewhere*)
- *
- * # alternate format for octal (leading 0) and hex (0x/0X)
- * 0 leading zeroes for d, i, o, u, x, and X
- * - left justify, overrides '0'
- * ' ' (space) force a blank in front of positive numbers
- * + force a sign in front of any number
- *
- * width.precision, including support for '*' (reads value from
- * the parameter list (MUST BE INT))
- *
- * h, short/long modifiers, recognized but ignored.
- * l
- *
- * Warning:
- * The way varargs is implemented in libc is evil. Don't think
- * there's a better way, but misaligned or wrong parameters
- * passed to printf() can break a lot of things. I've tried my
- * best to handle errors in the format string, though.
- *
- * Each %something field cannot exceed 'BUF_SIZE' characters,
- * which I set to 128 right now. %s fields are not subject to
- * this limit.
- *
- * Note:
- * The semicolon -looks- missing in a few places but that's
- * because of the macro def of 'OUTC'. did it that way to
- * save a few lines of source ;)
- *
- * Expects a 'char *' as varargs parameter, unlike libc8086's
- * printf(), which takes a 'int *' then casts it to a 'char *'.
- * Either has to change, but it should be trivial.
- *
- * This function aborts whenever it scans an illegal format, unlike
- * gcc's libc which prints out the illegal format as if it's -not-
- * a format string. The 'STANDARD' preprocessor flag controls if
- * if just aborts (when defined) or prints out "(err)" (when undefined).
- */
-{
- /*
- * the "0-+# " and "dcs..." strings are listed in my idea of their
- * frequency of use, with the most popular in front. not terribly
- * important but strchr() might have an easier time that way.
- * if you change the ordering of 'flagstr', make sure you update
- * the #define FLAG_* stuff on top of this file too.
- */
- char c, *s, *f;
- const char *flagstr = "0-+# ",
-#ifdef STANDARD
- *typestr = "dcsixXuop";
-#else
- *typestr = "dcsixXuopb";
-#endif
- int n = 0, flags, width, actwidth, prec, bad = 0, neg, i;
- static char buf[BUF_SIZE];
-
- for (c = *fmt++; c && !bad;) {
- if (c != '%') { /* just copy */
- OUTC(c);
- c = *fmt++;
- }
- else {
- c = *fmt++; /* chew the % sign */
- flags = width = prec = 0;
- /*
- * Parse the "0-+# " flags
- */
- while ((f = strchr(flagstr, c)) != NULL) {
- flags |= 1 << (f - flagstr);
- c = *fmt++;
- }
- /*
- * The '*' parameter says fetch width value from varargs
- */
- if (c == '*') {
- width = *(int *) args;
- args += sizeof(int);
- if (width < 0) {
- width = abs(width);
- flags |= FLAG_LEFTJUST; /* set '-' flag */
- }
- c = *fmt++;
- }
- else
- /*
- * scan and convert the width parameter
- */
- if (isdigit(c))
- while (isdigit(c)) {
- width *= 10;
- width += c - '0';
- c = *fmt++;
- }
- /*
- * a '.' means there may be a precision parameter
- */
- if (c == '.') {
- c = *fmt++;
- /*
- * fetch precision value from varargs
- */
- if (c == '*') {
- prec = *(int *) args;
- if (prec < 0)
- prec = 0;
- args += sizeof(int);
- c = *fmt++;
- }
- else
- /*
- * scan and convert precision field
- */
- if (isdigit(c))
- while (isdigit(c)) {
- prec *= 10;
- prec += c - '0';
- c = *fmt++;
- }
- }
- /*
- * short and long modifiers. ignored for the moment
- */
- if (c == 'h') {
- c = *fmt++;
- }
- else
- if (c == 'l') {
- c = *fmt++;
- }
- /*
- * check if it's a valid type "dioux..."
- */
- if (strchr(typestr, c) != NULL) {
- neg = 0;
- switch (c) {
- case 'd':
- case 'i': {
- int val = *(int *) args;
- args += sizeof(int);
- neg = (val < 0);
- val = abs(val);
- actwidth = strlen(utoa(val, buf, 10)); }
- /*
- * if negative or '+'/' ' flags set
- */
- if (neg || (flags & FLAG_SIGNED) || (flags & FLAG_SPACE))
- actwidth++;
- break;
- case 'u': {
- unsigned int uval = *(unsigned int *) args;
- args += sizeof(unsigned int);
- actwidth = strlen(utoa(uval, buf, 10)); }
- /*
- * if '+'/' ' flags set
- */
- if ((flags & FLAG_SIGNED) || (flags & FLAG_SPACE))
- actwidth++;
- break;
- case 'x':
- case 'X': {
- int val = *(int *) args;
- args += sizeof(int);
- actwidth = strlen(utoa(val, buf, 16)); }
- if (flags & FLAG_ALT)
- actwidth += 2;
- break;
- case 'o': {
- int val = *(int *) args;
- args += sizeof(int);
- actwidth = strlen(utoa(val, buf, 8)); }
- if (flags & FLAG_ALT)
- actwidth++;
- break;
- case 's':
- s = *(char **) args;
- args += sizeof(char *);
- actwidth = strlen(s);
- break;
- case 'c':
- buf[0] = *(char *) args;
- buf[1] = '\0';
- args += sizeof(char);
- actwidth = 1;
- break;
- /*
- * dunno how to handle pointers - what's the format of
- * linux86 pointers?! right now just prints "(ptr)"
- */
- case 'p':
- strcpy(buf, "(ptr)");
- args += sizeof(void *);
- actwidth = strlen(buf);
- s = buf; /* pretend we're a string */
- c = 's';
- break;
-#ifndef STANDARD
- case 'b': {
- int val = *(int *) args;
- args += sizeof(int);
- actwidth = strlen(utoa(val, buf, 2)); }
- break;
-#endif
- }
- /*
- * strings behave differently to the width.precision
- * parameters, so handle separately. besides, we avoid
- * an extra 'memcpy' to 'buf'
- */
- if (c == 's') {
- if (prec == 0)
- prec = actwidth;
- width = max(width, prec);
- /*
- * pad to the left if not left justified
- */
- if (!(flags & FLAG_LEFTJUST)) {
- for (i = width; i > prec; i--)
- OUTC(' ');
- }
- /*
- * print out entire string if no precision specified, otherwise
- * that's our upper limit
- */
- if (prec == 0)
- for (; *s; s++)
- OUTC(*s) /* no semicolon here */
- else
- for (i = 0; i < prec; i++)
- OUTC(s[i]);
- }
- else {
- /*
- * precision is as wide as width if it's not specified and
- * the leading zero '0' flag is set, and left-justify is
- * -not- set. c standard says left justify overrides the
- * leading 0.
- */
- if (prec == 0 && (flags & FLAG_PADZERO) && !(flags & FLAG_LEFTJUST))
- prec = width;
- /*
- * expand width.precision to fit the actual width. printf
- * width specifies the -minimum-, and aside from the
- * precision of %s fields, there's no way to specify maximum
- */
- prec = max(prec, actwidth);
- width = max(width, prec);
- /*
- * pad to the left if we're not left justified
- */
- if (!(flags & FLAG_LEFTJUST)) {
- for (i = width; i > prec; i--)
- OUTC(' ');
- }
- /*
- * check if we might need to print the sign
- */
- if (strchr("diu", c) != NULL) {
- if (neg) /* print if negative */
- OUTC('-') /* yes, no ';' here =) */
- else
- if (flags & FLAG_SIGNED) /* or '+' specified */
- OUTC('+') /* nor here */
- else
- if (flags & FLAG_SPACE) /* or ' ' specified */
- OUTC(' ') /* nor here */
- }
- /*
- * the alternate '#' flag is set. doesn't affect all though
- */
- if (flags & FLAG_ALT) {
- switch (c) {
- case 'o':
- OUTC('0'); /* leading zero for octals */
- break;
- case 'x':
- case 'X': /* prints 0x or 0X */
- OUTC('0');
- OUTC(c);
- break;
- }
- }
- /*
- * fill the precision field with either spaces or zeroes,
- * depending if we're printing numbers
- */
- if (strchr("diuxXo", c) != NULL)
- for (i = prec; i > actwidth; i--)
- OUTC('0')
- else
- for (i = prec; i > actwidth; i--)
- OUTC(' ');
- /*
- * print the field, except for 'X', which we convert to caps
- */
- if (c != 'X')
- for (f = buf; *f; f++)
- OUTC(*f) /* none here either */
- else
- for (f = buf; *f; f++)
- OUTC(toupper(*f));
- }
- /*
- * if we're left justified, we now need to pad spaces to the
- * right so that width will be correct
- */
- if (flags & FLAG_LEFTJUST)
- for (i = width; i > prec; i--)
- OUTC(' ');
- }
- else {
- /*
- * miscellaneous %thingies
- */
- switch (c) {
- case '%': /* %% -> % */
- OUTC('%');
- break;
- case 'n': /* %n writes current output count */
- *(*(int **) args) = n;
- args += sizeof(int *);
- break;
- default: /* oops, got a bad %thingy */
- bad = 1;
- }
- }
- c = *fmt++;
- }
- }
-#ifndef STANDARD
- /*
- * dunno what the standard wants if the format string is badly
- * formed, so i print (err) if the debug flag is set
- */
- if (bad) {
- OUTC('(');
- OUTC('e');
- OUTC('r');
- OUTC('r');
- OUTC(')');
- }
-#endif
- return(n);
-}
-
-#ifdef TEST
-
-#include <time.h>
-
-int main()
-{
- static unsigned char xbuf[128], *x;
- char *fmt = "%s, %s %d, %.*d:%.*d\n";
- int rv1, rv2, i, dt1, dt2;
- clock_t t1, t2;
-
- x = xbuf;
- *(char **) x = "Sun";
- x += sizeof(char *);
- *(char **) x = "Feb";
- x += sizeof(char *);
- *(int *) x = 18;
- x += sizeof(int);
- *(int *) x = 2;
- x += sizeof(int);
- *(int *) x = 10;
- x += sizeof(int);
- *(int *) x = 2;
- x += sizeof(int);
- *(int *) x = 56;
- x += sizeof(int);
- t1 = clock();
- for (i = 0; i < 1000; i++)
- rv1 = _printf(stdout, fmt, xbuf);
- t2 = clock();
- dt1 = t2 - t1;
-
- t1 = clock();
- for (i = 0; i < 1000; i++)
- rv2 = printf(fmt, "Sun", "Feb", 18, 2, 10, 2, 56);
- t2 = clock();
- dt2 = t2 - t1;
-
- printf("\nrv1: %d, rv2: %d, dt1: %d, dt2: %d\n", rv1, rv2, dt1, dt2);
- return(0);
-}
-
-#endif
diff --git a/libc/stdio1/puts.c b/libc/stdio1/puts.c
deleted file mode 100644
index d9bb8d0..0000000
--- a/libc/stdio1/puts.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* simplified linux puts.c
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include "stdio.h"
-
-int puts (string)
-char *string;
-{
- fputs(string, stdout);
- putc('\n', stdout);
- return 0;
-}
diff --git a/libc/stdio1/scanf.c b/libc/stdio1/scanf.c
deleted file mode 100644
index 81900a1..0000000
--- a/libc/stdio1/scanf.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* scanf.c for limited Linux libc
- Copyright (C) 1996 Joel N. Weber II <nemo@koa.iolani.honolulu.hi.us>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* This scanf code was derived from my printf code, which in turn was
- * derived from Alan Cox's printk. It was tested by [no one so far...]
- */
-
-/* Disclaimer: I haven't even THOUGHT about testing this. If you do decide
- * to be brave and test it, and it doesn't work, you have the following
- * options:
- * o Send me mail telling me it doesn't work, which I will ignore
- * since I already knew that.
- * o Fix it yourself
- * o isolate the problem and send it to the list, and maybe
- * I'll fix it
- */
-
-/* BTW, the above comment may be destroyed once this has been tested. It's
- * not nessisary for my great great grandchildren to see it when they
- * take Ancient Linux History...
- */
-
-/* Incidentally, if it doesn't work, it may well be because I never bothered
- * to learn how to use scanf()...I briefly tried it for the usaco qualification
- * round, but had some wierd problems...ask me after mid February...BTW the
- * problems had nothing to do with scanf(); it was still broken (hopelessly)
- * when I went to getchar().
- */
-
-/* Note, too that the current version probably assumes some things with
- * variable argument handling that it shouldn't. Don't expect this to
- * work on a 386 in 32 bit mode, don't expect this to work on a Z80,
- * or anything other than an 8086. In fact, don't expect it to even
- * work on an 8086 ;-)
- */
-
-/* One of these days the headers will work painlessly... */
-/* #include <linuxmt/types.h> */
-/* #include <linuxmt/fcntl.h> */
-#include "stdio.h"
-
-/* note that we assume base == 10... */
-static int numin(int *num, int base, FILE *stream, int c)
-{
- if ((c < '0') || (c > '9')) return 0;
- *num = 0;
- while ((c >= '0') && (c <= '9')) {
- *num = *num * base + c - '0';
- c = getc(stream);
- }
- ungetc(c, stream);
-}
-
-/* currently, the h/l specifications are ignored */
-static int internal_scanf(stream,fmt,a1)
-FILE *stream;
-char *fmt;
-int *a1;
-{
- unsigned char *p=(char *)a1;
- char c;
- int inc;
- int count = 0;
-
- while(c=*fmt++)
- {
- do {
- inc = getc(stream);
- } while ((inc == ' ') || (inc == '\t') || (inc == '\n'));
-
- if ((c == '\n') || (c == '\t') || (c == ' '))
- ;
- else if (c!='%') {
- if (c != inc) {
- ungetc(inc, stream);
- return count;
- }
- } else {
- int len=2;
- c=*fmt++;
- if(c=='h') c=*fmt++;
- else if(c=='l') c=*fmt++;
-
- switch(c)
- {
- case 'x':
- if (numin(p, 16, stream, inc)) count++;
- else return count;
- p+=2;
- break;
- case 'd':
- if (numin(p, 10, stream, inc)) count++;
- else return count;
- p+=2;
- break;
- case 's':
- {
- char *cp=*((char **)p);
- p+=sizeof(char *);
- while(*cp)
- putc(cp++, stream);
- while ((inc != ' ') && (inc != '\t')
- && (inc != '\n') && (inc != EOF)) {
- *cp++ = inc;
- inc = getc(stream);
- }
- ungetc(inc, stream);
- break;
- }
- case 'c':
- *p++ = inc;
- p++;
- break;
- default:
- putc('?', stream);
- }
- }
- }
- return count;
-}
-
-
-int fscanf(stream,fmt,a1)
-FILE *stream;
-char *fmt;
-int a1;
-{
- return internal_fscanf(stream,fmt,&a1);
-}
-
-int scanf(fmt,a1)
-char *fmt;
-int a1;
-{
- return internal_fscanf(stdout,fmt,&a1);
-}
diff --git a/libc/stdio1/stdio.h b/libc/stdio1/stdio.h
deleted file mode 100644
index 4bd1989..0000000
--- a/libc/stdio1/stdio.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* simplified linux stdio.h
- Copyright (C) 1995 Joel N. Weber II
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <fcntl.h>
-#include <sys/types.h>
-#include <malloc.h>
-
-#ifndef __STDIO_H
-#define __STDIO_H
-
-/* when you add or change fields here, be sure to change the initialization
- * in stdio_init and fopen */
-struct __stdio_file {
- int fd; /* the file descriptor associated with the stream */
- unsigned char *bufstart; /* the start of the buffer */
- unsigned char *bufpos; /* the next byte to write to or read from */
- unsigned char *bufread; /* the end of data returned by last read() */
- unsigned char *bufend; /* the end of the buffer; ie the byte after the last
- malloc()ed byte */
- int buffer_mode;
-#define _IONBF 0xB111 /* no buffering */
-#define _IOLBF 0xB112 /* line buffering */
-#define _IOFBF 0xB113 /* full buffering */
- int file_mode;
-#define _MODE_READ 0xB121
-#define _MODE_WRITE 0xB122
-#define _MODE_RDWR 0xB124 /* used when a file is readwrite and is ord with
- what's in the buffer now */
- unsigned char ungetted, ungetchar;
- /* ungetted = 1 if there's data unread; else 0
- ungetchar contains the character */
- int fc_eof:1;
- int fc_err:1; /* eof and error conditions */
- int iotrans:1; /* Translate \n -> \r\n on MSDOS */
-};
-
-#define EOF (-1)
-
-typedef struct __stdio_file FILE;
-
-#define BUFSIZ 256
-
-extern FILE *stdin, *stdout, *stderr, *__stdsprintf;
-
-/* The following macros are used for all access to the buffers. If you
- * know the file is unbuffered, however, you may write to it directly, as
- * fputs.c does. However, be aware that sprintf assumes that by setting
- * bufend to 0, no file writing will occur. Also, since NO streams use
- * unbuffered mode by default and the function to change this behavior is
- * not implemented yet, I'm considering disallowing raw access at the cost
- * of having each byte of a string written individually. However, that
- * IS what you're asking for with non-buffered mode.
- *
- * RDB: It's considered very bad form to use the raw read() & write()
- * calls on the same files you use the stdio functions.
- */
-#ifdef __MSDOS__
-#define putc(c, fp) fputc(c, fp)
-#define getc(fp) fgetc(fp)
-#else
-#define putc(c, stream) \
- (((stream)->bufpos[0] = (c)), \
- ((stream)->bufpos++), \
- ((((stream)->bufpos == (stream)->bufend) \
- ||((stream)->buffer_mode == _IONBF) \
- ||(((stream)->buffer_mode == _IOLBF) \
- && ((stream)->bufpos != (stream)->bufstart) \
- && ((stream)->bufpos[-1] == '\n'))) \
- ? fflush(stream):0))
-
-#define getc(stream) \
- ((stream)->ungetted ? (((stream)->ungetted = 0), ((stream)->ungetchar)) : \
- (((stream)->bufpos == (stream)->bufread)?__ffillbuf(stream): \
- (*(stream)->bufpos++)))
-
-#endif
-
-#define putchar(c) putc((c), stdout)
-#define getchar() getc(stdin)
-#define ungetc(c, stream) (((stream)->ungetted = 1), ((stream)->ungetchar = c))
-
-#define ferror(fp) ((fp)->fc_err)
-#define feof(fp) ((fp)->fc_eof)
-
-#define fileno(fp) ((fp)->fd)
-/* declare functions; not like it makes much difference without ANSI */
-/* RDB: The return values _are_ important, especially if we ever use
- 8086 'large' model
- */
-
-#ifndef __P
-#define __P(x) ()
-#endif
-
-int setvbuf __P((FILE*, char*, int, size_t));
-int __ffillbuf __P((FILE*));
-void __stdio_init __P((void));
-int fclose __P((FILE*));
-int fflush __P((FILE*));
-int fgetc __P((FILE*));
-char *fgets __P((char*, size_t, FILE*));
-FILE *fopen __P((char*, char*));
-
-int fputc __P((int, FILE*));
-int fputs __P((__const char*, FILE*));
-char *idealgetline __P((FILE*));
-int puts __P((char*));
-
-int printf __P ((__const char *, ...));
-int fprintf __P ((FILE *, __const char *, ...));
-int sprintf __P ((char *, __const char *, ...));
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-
-#endif /* __STDIO_H */
-/* TODO: add scanf, fscanf */
diff --git a/libc/stdio1/test.sh b/libc/stdio1/test.sh
deleted file mode 100755
index 9d872dc..0000000
--- a/libc/stdio1/test.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-echo 'rm -f *.o test *.a'
-rm -f *.o test *.a
-echo 'make'
-make
-echo 'ar r libnat.a *.o'
-ar r libnat.a *.o
-echo 'ranlib libnat.a'
-ranlib libnat.a
-echo 'gcc test.c -I- -I../include -fno-builtin -o test.o -L./ -lnat'
-gcc test.c -I- -I../include -fno-builtin -o test.o -L./ -lnat
diff --git a/libc/stdio2/Config b/libc/stdio2/Config
deleted file mode 100644
index 665045f..0000000
--- a/libc/stdio2/Config
+++ /dev/null
@@ -1,4 +0,0 @@
-#
-
-stdio: Robert's stdio package
-
diff --git a/makefile.in b/makefile.in
index 19828a2..25ea4d4 100644
--- a/makefile.in
+++ b/makefile.in
@@ -67,9 +67,15 @@ BCCARCH =-Mf -O
#endif
# Alter these if for some reason you don't want this done as root.
+#ifdef __BCC__
+INDAT=-o root -g root -m 644
+INEXE=-o root -g root -m 755
+INSCR=-o root -g root -m 755
+#else
INDAT=-o root -g root -m 644
INEXE=-o root -g root -m 755 -s
INSCR=-o root -g root -m 755
+#endif
#ifdef GNUMAKE
all: check_config bcc unproto copt as86 ar86 ld86 objdump86 \
diff --git a/unproto/Makefile b/unproto/Makefile
index 957209c..a9a8c04 100644
--- a/unproto/Makefile
+++ b/unproto/Makefile
@@ -89,7 +89,7 @@ CCFLAGS = $(CFLAGS) -w $(PIPE) $(SKIP) $(BELL) $(MAP) $(ALIAS) -DREOPEN
#CFLAGS = -g $(PIPE) $(SKIP) $(BELL) $(MAP) $(ALIAS) -DDEBUG
$(PROG): $(OBJECTS)
- $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(MALLOC)
+ $(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $^ $(MALLOC)
.c.o:
$(CC) $(CCFLAGS) -c $< -o $@