Temporarily removing menuetlibc
git-svn-id: svn://kolibrios.org@4799 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
include $(MENUETDEV)/osrules.mak
|
||||
|
||||
all: process_subdirs
|
||||
make -f Makefile-link OUTFILE="libc.a"
|
||||
ifdef ON_MINGW
|
||||
copy libc.a $(MENUETDEV)\lib
|
||||
del libc.a
|
||||
else
|
||||
mv libc.a $(MENUETDEV)/lib
|
||||
endif
|
||||
|
||||
process_subdirs:
|
||||
@echo $(CC) $(LD) $(CFLAGS) $(LDFLAGS)
|
||||
@$(D_ECHO) > ../tmp_make
|
||||
make -C ansi
|
||||
make -C ansif
|
||||
make -C compat
|
||||
make -C crt0
|
||||
make -C dos
|
||||
make -C fsext
|
||||
make -C menuetos
|
||||
make -C net
|
||||
make -C pc_hw
|
||||
make -C posix
|
||||
make -C termios
|
||||
make -C emu_layer
|
||||
|
||||
clean:
|
||||
make -C ansi clean
|
||||
make -C ansif clean
|
||||
make -C compat clean
|
||||
make -C crt0 clean
|
||||
make -C dos clean
|
||||
make -C fsext clean
|
||||
make -C menuetos clean
|
||||
make -C net clean
|
||||
make -C pc_hw clean
|
||||
make -C posix clean
|
||||
make -C termios clean
|
||||
make -C emu_layer clean
|
||||
|
||||
depend:
|
||||
make -C ansi depend
|
||||
make -C ansif depend
|
||||
make -C compat depend
|
||||
make -C crt0 depend
|
||||
make -C dos depend
|
||||
make -C fsext depend
|
||||
make -C menuetos depend
|
||||
make -C net depend
|
||||
make -C pc_hw depend
|
||||
make -C posix depend
|
||||
make -C termios depend
|
||||
make -C emu_layer depend
|
@@ -1,10 +0,0 @@
|
||||
include $(MENUETDEV)/osrules.mak
|
||||
|
||||
all:
|
||||
ifdef ON_MINGW
|
||||
..\mks $(OUTFILE) < ..\tmp_make > tmp_make.ars
|
||||
else
|
||||
../mks $(OUTFILE) < ../tmp_make > tmp_make.ars
|
||||
endif
|
||||
ar -M < tmp_make.ars
|
||||
$(RM) tmp_make.ars
|
@@ -1,40 +0,0 @@
|
||||
SUBDIRS = assert ctype errno locale math setjmp stdio stdlib string time
|
||||
|
||||
all: process_subdirs
|
||||
|
||||
process_subdirs:
|
||||
make -C assert
|
||||
make -C ctype
|
||||
make -C errno
|
||||
make -C locale
|
||||
make -C math
|
||||
make -C setjmp
|
||||
make -C stdio
|
||||
make -C stdlib
|
||||
make -C string
|
||||
make -C time
|
||||
|
||||
|
||||
clean:
|
||||
make -C assert clean
|
||||
make -C ctype clean
|
||||
make -C errno clean
|
||||
make -C locale clean
|
||||
make -C math clean
|
||||
make -C setjmp clean
|
||||
make -C stdio clean
|
||||
make -C stdlib clean
|
||||
make -C string clean
|
||||
make -C time clean
|
||||
|
||||
depend:
|
||||
make -C assert depend
|
||||
make -C ctype depend
|
||||
make -C errno depend
|
||||
make -C locale depend
|
||||
make -C math depend
|
||||
make -C setjmp depend
|
||||
make -C stdio depend
|
||||
make -C stdlib depend
|
||||
make -C string depend
|
||||
make -C time depend
|
@@ -1,3 +0,0 @@
|
||||
THIS_SRCS = assert.c unimplemented.c debug.c
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,11 +0,0 @@
|
||||
#include<assert.h>
|
||||
#include<menuet/os.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void __dj_assert(const char *msg, const char *file, int line)
|
||||
{
|
||||
__libclog_printf("Assertion failed at line %u in file %s\n",
|
||||
line,file);
|
||||
__libclog_printf("Assertion: '%s'\n",msg);
|
||||
exit(-1);
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
#include<menuet/os.h>
|
||||
#include<stdlib.h>
|
||||
#include<stdarg.h>
|
||||
#include<stdio.h>
|
||||
|
||||
static inline int vdprintf_help(char c)
|
||||
{
|
||||
int d0;
|
||||
if(c=='\n')
|
||||
{
|
||||
c='\r';
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
c='\n';
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
return 0;
|
||||
}
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
static char log_buf[1024];
|
||||
|
||||
static char xputs(char * s)
|
||||
{
|
||||
for(;*s;s++) vdprintf_help(*s);
|
||||
}
|
||||
|
||||
int __libclog_vprintf(const char *fmt, va_list args)
|
||||
{
|
||||
int ret_val;
|
||||
ret_val = vsprintf(log_buf,fmt,args);
|
||||
xputs(log_buf);
|
||||
__menuet__delay100(1);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
int __libclog_printf(const char * fmt,...)
|
||||
{
|
||||
int v;
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
v=__libclog_vprintf(fmt,ap);
|
||||
__menuet__delay100(1);
|
||||
return v;
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
#include<assert.h>
|
||||
#include<menuet/os.h>
|
||||
|
||||
void __dj_unimp(const char *fn)
|
||||
{
|
||||
__libclog_printf(fn);
|
||||
exit(-1);
|
||||
for(;;);
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
THIS_SRCS = ct_flags.c ct_lower.c ct_upper.c isalnum.c isalpha.c isascii.c \
|
||||
iscntrl.c isdigit.c isgraph.c islower.c isprint.c ispunct.c \
|
||||
isspace.c isupper.c isxdigit.c toascii.c tolower.c toupper.c
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,263 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
unsigned short __dj_ctype_flags[] = {
|
||||
0, /* CTRL+?, 0xffff */
|
||||
__dj_ISCNTRL, /* CTRL+@, 0x00 */
|
||||
__dj_ISCNTRL, /* CTRL+A, 0x01 */
|
||||
__dj_ISCNTRL, /* CTRL+B, 0x02 */
|
||||
__dj_ISCNTRL, /* CTRL+C, 0x03 */
|
||||
__dj_ISCNTRL, /* CTRL+D, 0x04 */
|
||||
__dj_ISCNTRL, /* CTRL+E, 0x05 */
|
||||
__dj_ISCNTRL, /* CTRL+F, 0x06 */
|
||||
__dj_ISCNTRL, /* CTRL+G, 0x07 */
|
||||
__dj_ISCNTRL, /* CTRL+H, 0x08 */
|
||||
__dj_ISCNTRL | __dj_ISSPACE, /* CTRL+I, 0x09 */
|
||||
__dj_ISCNTRL | __dj_ISSPACE, /* CTRL+J, 0x0a */
|
||||
__dj_ISCNTRL | __dj_ISSPACE, /* CTRL+K, 0x0b */
|
||||
__dj_ISCNTRL | __dj_ISSPACE, /* CTRL+L, 0x0c */
|
||||
__dj_ISCNTRL | __dj_ISSPACE, /* CTRL+M, 0x0d */
|
||||
__dj_ISCNTRL, /* CTRL+N, 0x0e */
|
||||
__dj_ISCNTRL, /* CTRL+O, 0x0f */
|
||||
__dj_ISCNTRL, /* CTRL+P, 0x10 */
|
||||
__dj_ISCNTRL, /* CTRL+Q, 0x11 */
|
||||
__dj_ISCNTRL, /* CTRL+R, 0x12 */
|
||||
__dj_ISCNTRL, /* CTRL+S, 0x13 */
|
||||
__dj_ISCNTRL, /* CTRL+T, 0x14 */
|
||||
__dj_ISCNTRL, /* CTRL+U, 0x15 */
|
||||
__dj_ISCNTRL, /* CTRL+V, 0x16 */
|
||||
__dj_ISCNTRL, /* CTRL+W, 0x17 */
|
||||
__dj_ISCNTRL, /* CTRL+X, 0x18 */
|
||||
__dj_ISCNTRL, /* CTRL+Y, 0x19 */
|
||||
__dj_ISCNTRL, /* CTRL+Z, 0x1a */
|
||||
__dj_ISCNTRL, /* CTRL+[, 0x1b */
|
||||
__dj_ISCNTRL, /* CTRL+\, 0x1c */
|
||||
__dj_ISCNTRL, /* CTRL+], 0x1d */
|
||||
__dj_ISCNTRL, /* CTRL+^, 0x1e */
|
||||
__dj_ISCNTRL, /* CTRL+_, 0x1f */
|
||||
__dj_ISPRINT | __dj_ISSPACE, /* ` ', 0x20 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `!', 0x21 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x22 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `#', 0x23 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `$', 0x24 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `%', 0x25 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `&', 0x26 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x27 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `(', 0x28 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `)', 0x29 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `*', 0x2a */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `+', 0x2b */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `,', 0x2c */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `-', 0x2d */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `.', 0x2e */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `/', 0x2f */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `0', 0x30 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `1', 0x31 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `2', 0x32 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `3', 0x33 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `4', 0x34 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `5', 0x35 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `6', 0x36 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `7', 0x37 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `8', 0x38 */
|
||||
__dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `9', 0x39 */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `:', 0x3a */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `;', 0x3b */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `<', 0x3c */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `=', 0x3d */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `>', 0x3e */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `?', 0x3f */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `@', 0x40 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `A', 0x41 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `B', 0x42 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `C', 0x43 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `D', 0x44 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `E', 0x45 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `F', 0x46 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `G', 0x47 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `H', 0x48 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `I', 0x49 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `J', 0x4a */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `K', 0x4b */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `L', 0x4c */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `M', 0x4d */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `N', 0x4e */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `O', 0x4f */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `P', 0x50 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Q', 0x51 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `R', 0x52 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `S', 0x53 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `T', 0x54 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `U', 0x55 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `V', 0x56 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `W', 0x57 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `X', 0x58 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Y', 0x59 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Z', 0x5a */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `[', 0x5b */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x5c */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `]', 0x5d */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `^', 0x5e */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `_', 0x5f */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x60 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `a', 0x61 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `b', 0x62 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `c', 0x63 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `d', 0x64 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `e', 0x65 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `f', 0x66 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `g', 0x67 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `h', 0x68 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `i', 0x69 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `j', 0x6a */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `k', 0x6b */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `l', 0x6c */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `m', 0x6d */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `n', 0x6e */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `o', 0x6f */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `p', 0x70 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `q', 0x71 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `r', 0x72 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `s', 0x73 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `t', 0x74 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `u', 0x75 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `v', 0x76 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `w', 0x77 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `x', 0x78 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `y', 0x79 */
|
||||
__dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `z', 0x7a */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `{', 0x7b */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `|', 0x7c */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `}', 0x7d */
|
||||
__dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `~', 0x7e */
|
||||
__dj_ISCNTRL, /* 0x7f */
|
||||
0, /* 0x80 */
|
||||
0, /* 0x81 */
|
||||
0, /* 0x82 */
|
||||
0, /* 0x83 */
|
||||
0, /* 0x84 */
|
||||
0, /* 0x85 */
|
||||
0, /* 0x86 */
|
||||
0, /* 0x87 */
|
||||
0, /* 0x88 */
|
||||
0, /* 0x89 */
|
||||
0, /* 0x8a */
|
||||
0, /* 0x8b */
|
||||
0, /* 0x8c */
|
||||
0, /* 0x8d */
|
||||
0, /* 0x8e */
|
||||
0, /* 0x8f */
|
||||
0, /* 0x90 */
|
||||
0, /* 0x91 */
|
||||
0, /* 0x92 */
|
||||
0, /* 0x93 */
|
||||
0, /* 0x94 */
|
||||
0, /* 0x95 */
|
||||
0, /* 0x96 */
|
||||
0, /* 0x97 */
|
||||
0, /* 0x98 */
|
||||
0, /* 0x99 */
|
||||
0, /* 0x9a */
|
||||
0, /* 0x9b */
|
||||
0, /* 0x9c */
|
||||
0, /* 0x9d */
|
||||
0, /* 0x9e */
|
||||
0, /* 0x9f */
|
||||
0, /* 0xa0 */
|
||||
0, /* 0xa1 */
|
||||
0, /* 0xa2 */
|
||||
0, /* 0xa3 */
|
||||
0, /* 0xa4 */
|
||||
0, /* 0xa5 */
|
||||
0, /* 0xa6 */
|
||||
0, /* 0xa7 */
|
||||
0, /* 0xa8 */
|
||||
0, /* 0xa9 */
|
||||
0, /* 0xaa */
|
||||
0, /* 0xab */
|
||||
0, /* 0xac */
|
||||
0, /* 0xad */
|
||||
0, /* 0xae */
|
||||
0, /* 0xaf */
|
||||
0, /* 0xb0 */
|
||||
0, /* 0xb1 */
|
||||
0, /* 0xb2 */
|
||||
0, /* 0xb3 */
|
||||
0, /* 0xb4 */
|
||||
0, /* 0xb5 */
|
||||
0, /* 0xb6 */
|
||||
0, /* 0xb7 */
|
||||
0, /* 0xb8 */
|
||||
0, /* 0xb9 */
|
||||
0, /* 0xba */
|
||||
0, /* 0xbb */
|
||||
0, /* 0xbc */
|
||||
0, /* 0xbd */
|
||||
0, /* 0xbe */
|
||||
0, /* 0xbf */
|
||||
0, /* 0xc0 */
|
||||
0, /* 0xc1 */
|
||||
0, /* 0xc2 */
|
||||
0, /* 0xc3 */
|
||||
0, /* 0xc4 */
|
||||
0, /* 0xc5 */
|
||||
0, /* 0xc6 */
|
||||
0, /* 0xc7 */
|
||||
0, /* 0xc8 */
|
||||
0, /* 0xc9 */
|
||||
0, /* 0xca */
|
||||
0, /* 0xcb */
|
||||
0, /* 0xcc */
|
||||
0, /* 0xcd */
|
||||
0, /* 0xce */
|
||||
0, /* 0xcf */
|
||||
0, /* 0xd0 */
|
||||
0, /* 0xd1 */
|
||||
0, /* 0xd2 */
|
||||
0, /* 0xd3 */
|
||||
0, /* 0xd4 */
|
||||
0, /* 0xd5 */
|
||||
0, /* 0xd6 */
|
||||
0, /* 0xd7 */
|
||||
0, /* 0xd8 */
|
||||
0, /* 0xd9 */
|
||||
0, /* 0xda */
|
||||
0, /* 0xdb */
|
||||
0, /* 0xdc */
|
||||
0, /* 0xdd */
|
||||
0, /* 0xde */
|
||||
0, /* 0xdf */
|
||||
0, /* 0xe0 */
|
||||
0, /* 0xe1 */
|
||||
0, /* 0xe2 */
|
||||
0, /* 0xe3 */
|
||||
0, /* 0xe4 */
|
||||
0, /* 0xe5 */
|
||||
0, /* 0xe6 */
|
||||
0, /* 0xe7 */
|
||||
0, /* 0xe8 */
|
||||
0, /* 0xe9 */
|
||||
0, /* 0xea */
|
||||
0, /* 0xeb */
|
||||
0, /* 0xec */
|
||||
0, /* 0xed */
|
||||
0, /* 0xee */
|
||||
0, /* 0xef */
|
||||
0, /* 0xf0 */
|
||||
0, /* 0xf1 */
|
||||
0, /* 0xf2 */
|
||||
0, /* 0xf3 */
|
||||
0, /* 0xf4 */
|
||||
0, /* 0xf5 */
|
||||
0, /* 0xf6 */
|
||||
0, /* 0xf7 */
|
||||
0, /* 0xf8 */
|
||||
0, /* 0xf9 */
|
||||
0, /* 0xfa */
|
||||
0, /* 0xfb */
|
||||
0, /* 0xfc */
|
||||
0, /* 0xfd */
|
||||
0, /* 0xfe */
|
||||
0, /* 0xff */
|
||||
};
|
@@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
unsigned char __dj_ctype_tolower[] = {
|
||||
0x00,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
|
||||
};
|
@@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
unsigned char __dj_ctype_toupper[] = {
|
||||
0x00,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
|
||||
};
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isalnum)(int c)
|
||||
{
|
||||
return isalnum(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isalpha)(int c)
|
||||
{
|
||||
return isalpha(c);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.hd>
|
||||
|
||||
int (isascii)(int c)
|
||||
{
|
||||
return isascii(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (iscntrl)(int c)
|
||||
{
|
||||
return iscntrl(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isdigit)(int c)
|
||||
{
|
||||
return isdigit(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isgraph)(int c)
|
||||
{
|
||||
return isgraph(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (islower)(int c)
|
||||
{
|
||||
return islower(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isprint)(int c)
|
||||
{
|
||||
return isprint(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (ispunct)(int c)
|
||||
{
|
||||
return ispunct(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isspace)(int c)
|
||||
{
|
||||
return isspace(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isupper)(int c)
|
||||
{
|
||||
return isupper(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (isxdigit)(int c)
|
||||
{
|
||||
return isxdigit(c);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.hd>
|
||||
|
||||
int (toascii)(int c)
|
||||
{
|
||||
return toascii(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (tolower)(int c)
|
||||
{
|
||||
return tolower(c);
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <ctype.h>
|
||||
#include <inlines/ctype.ha>
|
||||
|
||||
int (toupper)(int c)
|
||||
{
|
||||
return toupper(c);
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
THIS_SRCS = errno.c
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,6 +0,0 @@
|
||||
int errno;
|
||||
|
||||
int __isatty(int _fd)
|
||||
{
|
||||
return 1;
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
THIS_SRCS = lconv.c mbcurmax.c mblen.c mbstowcs.c mbtowc.c setlocal.c \
|
||||
wcstombs.c wctomb.c
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,32 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <locale.h>
|
||||
#include <limits.h>
|
||||
|
||||
static char ESTR[] = "";
|
||||
static char DSTR[] = ".";
|
||||
|
||||
static struct lconv __lconv_ = {
|
||||
ESTR,
|
||||
DSTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
ESTR,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX
|
||||
};
|
||||
|
||||
struct lconv *localeconv()
|
||||
{
|
||||
return &__lconv_;
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
int __dj_mb_cur_max = 1;
|
@@ -1,15 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
mblen(const char *s, size_t n)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
if (n == 0 || *s == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t
|
||||
mbstowcs(wchar_t *wcs, const char *s, size_t n)
|
||||
{
|
||||
int i;
|
||||
for (i=0; s[i] && (i<n-1); i++)
|
||||
wcs[i] = s[i];
|
||||
wcs[i] = 0;
|
||||
return i;
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
mbtowc(wchar_t *pwc, const char *s, size_t n)
|
||||
{
|
||||
int x = 0;
|
||||
if (s == 0)
|
||||
return 0;
|
||||
if (*s)
|
||||
x = 1;
|
||||
|
||||
if (pwc)
|
||||
*pwc = *s;
|
||||
|
||||
return x;
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
||||
char *setlocale(int category, const char *locale)
|
||||
{
|
||||
static char CLOCALE[] = "C";
|
||||
if (locale == 0)
|
||||
return CLOCALE;
|
||||
if (strcmp(locale, CLOCALE) && strcmp(locale, "POSIX") && locale[0])
|
||||
return 0;
|
||||
return CLOCALE;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
size_t
|
||||
wcstombs(char *s, const wchar_t *wcs, size_t n)
|
||||
{
|
||||
int i;
|
||||
for (i=0; wcs[i] && (i<n-1); i++)
|
||||
s[i] = wcs[i];
|
||||
s[i] = 0;
|
||||
return i;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
wctomb(char *s, wchar_t wchar)
|
||||
{
|
||||
if (s)
|
||||
s[0] = wchar;
|
||||
return 1;
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
THIS_SRCS = acosh.c acos.s asinh.c asin.s atan2.s atanh.c atan.s \
|
||||
ceil.s cosh.c cos.s exp.s fabs.s floor.s fmod.s frexp.c huge_val.c \
|
||||
hypot.c ldexp.c log.s modfl.s modf.s pow10.s pow2.s pow.s sinh.c \
|
||||
sin.s sqrt.s tanh.c tan.s
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,22 +0,0 @@
|
||||
#include<libc/asm.h>
|
||||
|
||||
.text
|
||||
LC0:
|
||||
.double 0d1.00000000000000000000e+00
|
||||
|
||||
MK_C_SYM(acos)
|
||||
fldl 4(%esp)
|
||||
fld1
|
||||
fsubp %st(0),%st(1)
|
||||
fsqrt
|
||||
|
||||
fldl 4(%esp)
|
||||
fld1
|
||||
faddp %st(0),%st(1)
|
||||
fsqrt
|
||||
|
||||
fpatan
|
||||
|
||||
fld %st(0)
|
||||
faddp
|
||||
ret
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
acosh(double x)
|
||||
{
|
||||
return log(x + sqrt(x*x - 1));
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(asin)
|
||||
fldl 4(%esp)
|
||||
fld %st(0)
|
||||
fmulp
|
||||
fld1
|
||||
fsubp
|
||||
fsqrt
|
||||
fldl 4(%esp)
|
||||
fxch %st(1)
|
||||
fpatan
|
||||
ret
|
||||
|
@@ -1,9 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
asinh(double x)
|
||||
{
|
||||
return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x);
|
||||
}
|
||||
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(atan)
|
||||
fldl 4(%esp)
|
||||
fld1
|
||||
fpatan
|
||||
ret
|
||||
|
@@ -1,35 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
|
||||
.data
|
||||
.align 2
|
||||
nan:
|
||||
.long 0xffffffff
|
||||
.byte 0xff
|
||||
.byte 0xff
|
||||
.byte 0xff
|
||||
.byte 0x7f
|
||||
|
||||
.text
|
||||
MK_C_SYM(atan2)
|
||||
fldl 4(%esp)
|
||||
fldl 12(%esp)
|
||||
ftst
|
||||
fnstsw %ax
|
||||
sahf
|
||||
jne doit
|
||||
fxch %st(1)
|
||||
ftst
|
||||
fnstsw %ax
|
||||
sahf
|
||||
je isanan
|
||||
fxch %st(1)
|
||||
doit:
|
||||
fpatan
|
||||
ret
|
||||
isanan:
|
||||
movl $1,C_SYM(errno)
|
||||
fstp %st(0)
|
||||
fstp %st(0)
|
||||
fldl nan
|
||||
ret
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
atanh(double x)
|
||||
{
|
||||
return log((1+x)/(1-x)) / 2.0;
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(ceil)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp)
|
||||
fwait
|
||||
movw -4(%ebp),%ax
|
||||
andw $0xf3ff,%ax
|
||||
orw $0x0800,%ax
|
||||
movw %ax,-2(%ebp)
|
||||
fldcw -2(%ebp)
|
||||
|
||||
fldl 8(%ebp)
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp)
|
||||
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
|
@@ -1,15 +0,0 @@
|
||||
#include<libc/asm.h>
|
||||
L0:
|
||||
.quad 0xffffffffffffffff
|
||||
|
||||
MK_C_SYM(cos)
|
||||
fldl 4(%esp)
|
||||
fcos
|
||||
fstsw
|
||||
sahf
|
||||
jnp L1
|
||||
fstp %st(0)
|
||||
fldl L0
|
||||
L1:
|
||||
ret
|
||||
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double cosh(double x)
|
||||
{
|
||||
const double ebig = exp(fabs(x));
|
||||
return (ebig + 1.0/ebig) / 2.0;
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
#include<libc/asm.h>
|
||||
.data
|
||||
LCW1:
|
||||
.word 0
|
||||
LCW2:
|
||||
.word 0
|
||||
LC0:
|
||||
.double 0d1.0e+00
|
||||
|
||||
.text
|
||||
|
||||
MK_C_SYM(exp)
|
||||
fldl 4(%esp)
|
||||
fldl2e
|
||||
fmulp
|
||||
fstcw LCW1
|
||||
fstcw LCW2
|
||||
fwait
|
||||
andw $0xf3ff,LCW2
|
||||
orw $0x0400,LCW2
|
||||
fldcw LCW2
|
||||
fldl %st(0)
|
||||
frndint
|
||||
fldcw LCW1
|
||||
fxch %st(1)
|
||||
fsub %st(1),%st
|
||||
f2xm1
|
||||
faddl LC0
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
@@ -1,6 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(fabs)
|
||||
fldl 4(%esp)
|
||||
fabs
|
||||
ret
|
@@ -1,24 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(floor)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp)
|
||||
fwait
|
||||
movw -4(%ebp),%ax
|
||||
andw $0xf3ff,%ax
|
||||
orw $0x0400,%ax
|
||||
movw %ax,-2(%ebp)
|
||||
fldcw -2(%ebp)
|
||||
|
||||
fldl 8(%ebp)
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp)
|
||||
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
|
@@ -1,29 +0,0 @@
|
||||
#include<libc/asm.h>
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
.data
|
||||
LCW1:
|
||||
.word 0
|
||||
.align 4
|
||||
|
||||
.text
|
||||
|
||||
MK_C_SYM(fmod)
|
||||
fldl 4(%esp)
|
||||
fldl 12(%esp)
|
||||
ftst
|
||||
fnstsw %ax
|
||||
fxch %st(1)
|
||||
sahf
|
||||
jnz next
|
||||
fstpl %st(0)
|
||||
jmp out
|
||||
next:
|
||||
fprem
|
||||
fnstsw %ax
|
||||
sahf
|
||||
jpe next
|
||||
fstpl %st(1)
|
||||
out:
|
||||
ret
|
||||
|
||||
|
@@ -1,26 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
frexp(double x, int *exptr)
|
||||
{
|
||||
union {
|
||||
double d;
|
||||
unsigned char c[8];
|
||||
} u;
|
||||
|
||||
u.d = x;
|
||||
/*
|
||||
* The format of the number is:
|
||||
* Sign, 12 exponent bits, 51 mantissa bits
|
||||
* The exponent is 1023 biased and there is an implicit zero.
|
||||
* We get the exponent from the upper bits and set the exponent
|
||||
* to 0x3fe (1022).
|
||||
*/
|
||||
*exptr = (int)(((u.c[7] & 0x7f) << 4) | (u.c[6] >> 4)) - 1022;
|
||||
u.c[7] &= 0x80;
|
||||
u.c[7] |= 0x3f;
|
||||
u.c[6] &= 0x0f;
|
||||
u.c[6] |= 0xe0;
|
||||
return u.d;
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/ieee.h>
|
||||
|
||||
double_t __dj_huge_val = { 0x00000, 0x00000, 0x7ff, 0x0 };
|
@@ -1,100 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
/*
|
||||
* hypot() function for DJGPP.
|
||||
*
|
||||
* hypot() computes sqrt(x^2 + y^2). The problem with the obvious
|
||||
* naive implementation is that it might fail for very large or
|
||||
* very small arguments. For instance, for large x or y the result
|
||||
* might overflow even if the value of the function should not,
|
||||
* because squaring a large number might trigger an overflow. For
|
||||
* very small numbers, their square might underflow and will be
|
||||
* silently replaced by zero; this won't cause an exception, but might
|
||||
* have an adverse effect on the accuracy of the result.
|
||||
*
|
||||
* This implementation tries to avoid the above pitfals, without
|
||||
* inflicting too much of a performance hit.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers
|
||||
between these two shouldn't neither overflow nor underflow
|
||||
when squared. */
|
||||
#define __SQRT_DBL_MAX 1.3e+154
|
||||
#define __SQRT_DBL_MIN 2.3e-162
|
||||
|
||||
double
|
||||
hypot(double x, double y)
|
||||
{
|
||||
double abig = fabs(x), asmall = fabs(y);
|
||||
double ratio;
|
||||
|
||||
/* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */
|
||||
if (abig < asmall)
|
||||
{
|
||||
double temp = abig;
|
||||
|
||||
abig = asmall;
|
||||
asmall = temp;
|
||||
}
|
||||
|
||||
/* Trivial case. */
|
||||
if (asmall == 0.)
|
||||
return abig;
|
||||
|
||||
/* Scale the numbers as much as possible by using its ratio.
|
||||
For example, if both ABIG and ASMALL are VERY small, then
|
||||
X^2 + Y^2 might be VERY inaccurate due to loss of
|
||||
significant digits. Dividing ASMALL by ABIG scales them
|
||||
to a certain degree, so that accuracy is better. */
|
||||
|
||||
if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX)
|
||||
return abig * sqrt(1.0 + ratio*ratio);
|
||||
else
|
||||
{
|
||||
/* Slower but safer algorithm due to Moler and Morrison. Never
|
||||
produces any intermediate result greater than roughly the
|
||||
larger of X and Y. Should converge to machine-precision
|
||||
accuracy in 3 iterations. */
|
||||
|
||||
double r = ratio*ratio, t, s, p = abig, q = asmall;
|
||||
|
||||
do {
|
||||
t = 4. + r;
|
||||
if (t == 4.)
|
||||
break;
|
||||
s = r / t;
|
||||
p += 2. * s * p;
|
||||
q *= s;
|
||||
r = (q / p) * (q / p);
|
||||
} while (1);
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("hypot(3, 4) =\t\t\t %25.17e\n", hypot(3., 4.));
|
||||
printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", hypot(3.e+150, 4.e+150));
|
||||
printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", hypot(3.e+306, 4.e+306));
|
||||
printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n",
|
||||
hypot(3.e-320, 4.e-320));
|
||||
printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n",
|
||||
hypot(0.7*DBL_MAX, 0.7*DBL_MAX));
|
||||
printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", hypot(DBL_MAX, 1.0));
|
||||
printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", hypot(1.0, DBL_MAX));
|
||||
printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", hypot(0.0, DBL_MAX));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,32 +0,0 @@
|
||||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
ldexp(double v, int e)
|
||||
{
|
||||
double two = 2.0;
|
||||
|
||||
if (e < 0)
|
||||
{
|
||||
e = -e; /* This just might overflow on two-complement machines. */
|
||||
if (e < 0) return 0.0;
|
||||
while (e > 0)
|
||||
{
|
||||
if (e & 1) v /= two;
|
||||
two *= two;
|
||||
e >>= 1;
|
||||
}
|
||||
}
|
||||
else if (e > 0)
|
||||
{
|
||||
while (e > 0)
|
||||
{
|
||||
if (e & 1) v *= two;
|
||||
two *= two;
|
||||
e >>= 1;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(log)
|
||||
fldln2
|
||||
fldl 4(%esp)
|
||||
fyl2x
|
||||
ret
|
@@ -1,33 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
.text
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(modf)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $16,%esp
|
||||
pushl %ebx
|
||||
fnstcw -4(%ebp)
|
||||
fwait
|
||||
movw -4(%ebp),%ax
|
||||
orw $0x0c3f,%ax
|
||||
movw %ax,-8(%ebp)
|
||||
fldcw -8(%ebp)
|
||||
fwait
|
||||
fldl 8(%ebp)
|
||||
frndint
|
||||
fstpl -16(%ebp)
|
||||
fwait
|
||||
movl -16(%ebp),%edx
|
||||
movl -12(%ebp),%ecx
|
||||
movl 16(%ebp),%ebx
|
||||
movl %edx,(%ebx)
|
||||
movl %ecx,4(%ebx)
|
||||
fldl 8(%ebp)
|
||||
fsubl -16(%ebp)
|
||||
leal -20(%ebp),%esp
|
||||
fclex
|
||||
fldcw -4(%ebp)
|
||||
fwait
|
||||
popl %ebx
|
||||
leave
|
||||
ret
|
@@ -1,21 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(__modfl)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
fldt 8(%ebp)
|
||||
movl 20(%ebp),%eax
|
||||
fnstcw -2(%ebp)
|
||||
movw -2(%ebp),%dx
|
||||
orb $0x0c,%dh
|
||||
movw %dx,-4(%ebp)
|
||||
fldcw -4(%ebp)
|
||||
fld %st(0)
|
||||
frndint
|
||||
fldcw -2(%ebp)
|
||||
fld %st(0)
|
||||
fstpt (%eax)
|
||||
fsubrp %st,%st(1)
|
||||
leave
|
||||
ret
|
@@ -1,86 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
.data
|
||||
yint:
|
||||
.word 0,0
|
||||
LCW1:
|
||||
.word 0
|
||||
LCW2:
|
||||
.word 0
|
||||
|
||||
.text
|
||||
LC0:
|
||||
.double 0d1.0e+00
|
||||
|
||||
frac:
|
||||
fstcw LCW1
|
||||
fstcw LCW2
|
||||
fwait
|
||||
andw $0xf3ff,LCW2
|
||||
orw $0x0400,LCW2
|
||||
fldcw LCW2
|
||||
fldl %st(0)
|
||||
frndint
|
||||
fldcw LCW1
|
||||
fxch %st(1)
|
||||
fsub %st(1),%st
|
||||
ret
|
||||
|
||||
Lpow2:
|
||||
call frac
|
||||
f2xm1
|
||||
faddl LC0
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
MK_C_SYM(pow)
|
||||
fldl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
ftst
|
||||
fnstsw %ax
|
||||
sahf
|
||||
jbe xltez
|
||||
fyl2x
|
||||
jmp Lpow2
|
||||
xltez:
|
||||
jb xltz
|
||||
fstp %st(0)
|
||||
ftst
|
||||
fnstsw %ax
|
||||
sahf
|
||||
ja ygtz
|
||||
jb error
|
||||
fstp %st(0)
|
||||
fld1
|
||||
fchs
|
||||
error:
|
||||
fsqrt
|
||||
ret
|
||||
ygtz:
|
||||
fstp %st(0)
|
||||
fldz
|
||||
ret
|
||||
xltz:
|
||||
fabs
|
||||
fxch %st(1)
|
||||
call frac
|
||||
ftst
|
||||
fnstsw %ax
|
||||
fstp %st(0)
|
||||
sahf
|
||||
je yisint
|
||||
fstp %st(0)
|
||||
fchs
|
||||
jmp error
|
||||
yisint:
|
||||
fistl yint
|
||||
fxch %st(1)
|
||||
fyl2x
|
||||
call Lpow2
|
||||
andl $1,yint
|
||||
jz yeven
|
||||
fchs
|
||||
yeven:
|
||||
ret
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
.data
|
||||
LCW1:
|
||||
.word 0
|
||||
LCW2:
|
||||
.word 0
|
||||
LC0:
|
||||
.double 0d1.0e+00
|
||||
|
||||
.text
|
||||
|
||||
MK_C_SYM(__pow10)
|
||||
fldl 4(%esp)
|
||||
fldl2t
|
||||
fmulp
|
||||
fstcw LCW1
|
||||
fstcw LCW2
|
||||
fwait
|
||||
andw $0xf3ff,LCW2
|
||||
orw $0x0400,LCW2
|
||||
fldcw LCW2
|
||||
fldl %st(0)
|
||||
frndint
|
||||
fldcw LCW1
|
||||
fxch %st(1)
|
||||
fsub %st(1),%st
|
||||
f2xm1
|
||||
faddl LC0
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
@@ -1,30 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
.data
|
||||
LCW1:
|
||||
.word 0
|
||||
LCW2:
|
||||
.word 0
|
||||
LC0:
|
||||
.double 0d1.0e+00
|
||||
|
||||
.text
|
||||
|
||||
MK_C_SYM(__pow2)
|
||||
fldl 4(%esp)
|
||||
fstcw LCW1
|
||||
fstcw LCW2
|
||||
fwait
|
||||
andw $0xf3ff,LCW2
|
||||
orw $0x0400,LCW2
|
||||
fldcw LCW2
|
||||
fldl %st(0)
|
||||
frndint
|
||||
fldcw LCW1
|
||||
fxch %st(1)
|
||||
fsub %st(1),%st
|
||||
f2xm1
|
||||
faddl LC0
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
@@ -1,16 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
L0:
|
||||
.quad 0xffffffffffffffff
|
||||
|
||||
MK_C_SYM(sin)
|
||||
fldl 4(%esp)
|
||||
fsin
|
||||
fstsw
|
||||
sahf
|
||||
jnp L1
|
||||
fstp %st(0)
|
||||
fldl L0
|
||||
L1:
|
||||
ret
|
||||
|
@@ -1,16 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double sinh(double x)
|
||||
{
|
||||
if(x >= 0.0)
|
||||
{
|
||||
const double epos = exp(x);
|
||||
return (epos - 1.0/epos) / 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const double eneg = exp(-x);
|
||||
return (1.0/eneg - eneg) / 2.0;
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(sqrt)
|
||||
fldl 4(%esp)
|
||||
fsqrt
|
||||
ret
|
@@ -1,16 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include<libc/asm.h>
|
||||
L0:
|
||||
.quad 0xffffffffffffffff
|
||||
|
||||
MK_C_SYM(tan)
|
||||
fldl 4(%esp)
|
||||
fptan
|
||||
fstsw
|
||||
fstp %st(0)
|
||||
sahf
|
||||
jnp L1
|
||||
/* fstp %st(0) - if exception, there is nothing on the stack */
|
||||
fldl L0
|
||||
L1:
|
||||
ret
|
@@ -1,17 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <math.h>
|
||||
|
||||
double tanh(double x)
|
||||
{
|
||||
if (x > 50)
|
||||
return 1;
|
||||
else if (x < -50)
|
||||
return -1;
|
||||
else
|
||||
{
|
||||
const double ebig = exp(x);
|
||||
const double esmall = 1.0/ebig;
|
||||
return (ebig - esmall) / (ebig + esmall);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
THIS_SRCS = longjmp.s setjmp.s
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,64 +0,0 @@
|
||||
# 1 "longjmp.s"
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(longjmp)
|
||||
movl 4(%esp),%edi
|
||||
movl 8(%esp),%eax
|
||||
movl %eax,0(%edi)
|
||||
|
||||
movw 46(%edi),%fs
|
||||
movw 48(%edi),%gs
|
||||
movl 4(%edi),%ebx
|
||||
movl 8(%edi),%ecx
|
||||
movl 12(%edi),%edx
|
||||
movl 24(%edi),%ebp
|
||||
|
||||
movw 50(%edi),%es
|
||||
movl 28(%edi),%esi
|
||||
subl $28,%esi
|
||||
|
||||
movl 60(%edi),%eax
|
||||
es
|
||||
movl %eax,(%esi)
|
||||
|
||||
movzwl 42(%edi),%eax
|
||||
es
|
||||
movl %eax,4(%esi)
|
||||
|
||||
movl 20(%edi),%eax
|
||||
es
|
||||
movl %eax,8(%esi)
|
||||
|
||||
movl 16(%edi),%eax
|
||||
es
|
||||
movl %eax,12(%esi)
|
||||
|
||||
movl 32(%edi),%eax
|
||||
es
|
||||
movl %eax,16(%esi)
|
||||
|
||||
movl 40(%edi),%eax
|
||||
es
|
||||
movl %eax,20(%esi)
|
||||
|
||||
movl 36(%edi),%eax
|
||||
es
|
||||
movl %eax,24(%esi)
|
||||
|
||||
movl 0(%edi),%eax
|
||||
movw 44(%edi),%es
|
||||
|
||||
movw 50(%edi),%ss
|
||||
movl %esi,%esp
|
||||
|
||||
popl C_SYM(__djgpp_exception_state_ptr)
|
||||
popl %ds
|
||||
popl %edi
|
||||
popl %esi
|
||||
|
||||
iret
|
||||
|
||||
MK_C_SYM(__djgpp_exception_state_ptr)
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
@@ -1,44 +0,0 @@
|
||||
#include<libc/asm.h>
|
||||
MK_C_SYM(setjmp)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
|
||||
pushl %edi
|
||||
movl 8(%ebp),%edi
|
||||
|
||||
movl %eax, (%edi)
|
||||
movl %ebx,4(%edi)
|
||||
movl %ecx,8(%edi)
|
||||
movl %edx,12(%edi)
|
||||
movl %esi,16(%edi)
|
||||
|
||||
movl -4(%ebp),%eax
|
||||
movl %eax,20(%edi)
|
||||
|
||||
movl (%ebp),%eax
|
||||
movl %eax,24(%edi)
|
||||
|
||||
movl %esp,%eax
|
||||
addl $12,%eax
|
||||
movl %eax,28(%edi)
|
||||
|
||||
movl 4(%ebp),%eax
|
||||
movl %eax,32(%edi)
|
||||
|
||||
pushfl
|
||||
popl 36(%edi)
|
||||
|
||||
movw %cs, 40(%edi)
|
||||
movw %ds, 42(%edi)
|
||||
movw %es, 44(%edi)
|
||||
movw %fs, 46(%edi)
|
||||
movw %gs, 48(%edi)
|
||||
movw %ss, 50(%edi)
|
||||
|
||||
movl C_SYM(__djgpp_exception_state_ptr), %eax
|
||||
movl %eax, 60(%edi)
|
||||
|
||||
popl %edi
|
||||
xorl %eax,%eax
|
||||
popl %ebp
|
||||
ret
|
@@ -1,11 +0,0 @@
|
||||
THIS_SRCS = allocfil.c clearerr.c doprnt.c doscan.c fclose.c feof.c \
|
||||
ferror.c fflush.c fgetc.c fgetpos.c fgets.c filbuf.c flsbuf.c \
|
||||
fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c frlist.c \
|
||||
fscanf.c fseek.c fsetpos.c ftell.c fwalk.c fwrite.c getc.c getchar.c \
|
||||
gets.c getw.c perror.c printf.c putc.c putchar.c puts.c putw.c \
|
||||
remove.c _rename.c rename.c rewind.c scanf.c setbuf.c setbuffe.c \
|
||||
setlineb.c setvbuf.c sprintf.c sscanf.c stdaux.c stderr.c stdin.c \
|
||||
stdiohk.c stdout.c stdprn.c tmpfile.c tmpnam.c ungetc.c vfprintf.c \
|
||||
vprintf.c vsprintf.c
|
||||
|
||||
include $(MENUET_LIBC_TOPDIR)/Make.rules
|
@@ -1,11 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <libc/dosio.h>
|
||||
#include<assert.h>
|
||||
|
||||
int _rename(const char *old, const char *new)
|
||||
{
|
||||
return -1;
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/local.h>
|
||||
#include <libc/stdiohk.h>
|
||||
|
||||
FILE *__alloc_file(void)
|
||||
{
|
||||
__file_rec *fr = __file_rec_list;
|
||||
__file_rec **last_fr = &__file_rec_list;
|
||||
FILE *rv=0;
|
||||
int i;
|
||||
|
||||
/* Try to find an empty slot */
|
||||
while (fr)
|
||||
{
|
||||
last_fr = &(fr->next);
|
||||
|
||||
/* If one of the existing slots is available, return it */
|
||||
for (i=0; i<fr->count; i++)
|
||||
if (fr->files[i]->_flag == 0)
|
||||
return fr->files[i];
|
||||
|
||||
/* If this one is full, go to the next */
|
||||
if (fr->count == __FILE_REC_MAX)
|
||||
fr = fr->next;
|
||||
else
|
||||
/* it isn't full, we can add to it */
|
||||
break;
|
||||
}
|
||||
if (!fr)
|
||||
{
|
||||
/* add another one to the end, make it empty */
|
||||
fr = *last_fr = (__file_rec *)malloc(sizeof(__file_rec));
|
||||
if (fr == 0)
|
||||
return 0;
|
||||
fr->next = 0;
|
||||
fr->count = 0;
|
||||
}
|
||||
/* fr is a pointer to a rec with empty slots in it */
|
||||
rv = fr->files[fr->count] = (FILE *)malloc(sizeof(FILE));
|
||||
if (rv == 0)
|
||||
return 0;
|
||||
memset(rv, 0, sizeof(FILE));
|
||||
fr->count ++;
|
||||
return rv;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
#undef clearerr
|
||||
void
|
||||
clearerr(FILE *f)
|
||||
{
|
||||
f->_flag &= ~(_IOERR|_IOEOF);
|
||||
}
|
@@ -1,840 +0,0 @@
|
||||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/stdiohk.h>
|
||||
#include <libc/local.h>
|
||||
|
||||
static char decimal = '.';
|
||||
|
||||
/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
|
||||
#define MAXEXP 308
|
||||
#define MAXEXPLD 4952 /* this includes subnormal numbers */
|
||||
/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
|
||||
#define MAXFRACT 39
|
||||
|
||||
#define DEFPREC 6
|
||||
#define DEFLPREC 6
|
||||
|
||||
#define BUF (MAXEXPLD+MAXFRACT+1) /* + decimal point */
|
||||
|
||||
#define PUTC(ch) (void) putc(ch, fp)
|
||||
|
||||
#define ARG(basetype) \
|
||||
_ulong = flags&LONGINT ? va_arg(argp, long basetype) : \
|
||||
flags&SHORTINT ? (short basetype)va_arg(argp, int) : \
|
||||
va_arg(argp, int)
|
||||
|
||||
static int nan2 = 0;
|
||||
|
||||
static __inline__ int todigit(char c)
|
||||
{
|
||||
if (c<='0') return 0;
|
||||
if (c>='9') return 9;
|
||||
return c-'0';
|
||||
}
|
||||
static __inline__ char tochar(int n)
|
||||
{
|
||||
if (n>=9) return '9';
|
||||
if (n<=0) return '0';
|
||||
return n+'0';
|
||||
}
|
||||
|
||||
/* have to deal with the negative buffer count kludge */
|
||||
|
||||
#define LONGINT 0x01 /* long integer */
|
||||
#define LONGDBL 0x02 /* long double */
|
||||
#define SHORTINT 0x04 /* short integer */
|
||||
#define ALT 0x08 /* alternate form */
|
||||
#define LADJUST 0x10 /* left adjustment */
|
||||
#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
|
||||
#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
|
||||
|
||||
static cvtl(long double number, int prec, int flags, char *signp,
|
||||
unsigned char fmtch, char *startp, char *endp);
|
||||
static char *roundl(long double fract, int *expv, char *start, char *end,
|
||||
char ch, char *signp);
|
||||
static char *exponentl(char *p, int expv, unsigned char fmtch);
|
||||
static int isspeciall(long double d, char *bufp);
|
||||
|
||||
static char NULL_REP[] = "(null)";
|
||||
|
||||
int
|
||||
_doprnt(const char *fmt0, va_list argp, FILE *fp)
|
||||
{
|
||||
const char *fmt; /* format string */
|
||||
int ch; /* character from fmt */
|
||||
int cnt; /* return value accumulator */
|
||||
int n; /* random handy integer */
|
||||
char *t; /* buffer pointer */
|
||||
long double _ldouble; /* double and long double precision arguments
|
||||
%L.[eEfgG] */
|
||||
unsigned long _ulong; /* integer arguments %[diouxX] */
|
||||
int base; /* base for [diouxX] conversion */
|
||||
int dprec; /* decimal precision in [diouxX] */
|
||||
int fieldsz; /* field size expanded by sign, etc */
|
||||
int flags; /* flags as above */
|
||||
int fpprec; /* `extra' floating precision in [eEfgG] */
|
||||
int prec; /* precision from format (%.3d), or -1 */
|
||||
int realsz; /* field size expanded by decimal precision */
|
||||
int size; /* size of converted field or string */
|
||||
int width; /* width from format (%8d), or 0 */
|
||||
char sign; /* sign prefix (' ', '+', '-', or \0) */
|
||||
char softsign; /* temporary negative sign for floats */
|
||||
const char *digs; /* digits for [diouxX] conversion */
|
||||
char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
|
||||
|
||||
decimal = localeconv()->decimal_point[0];
|
||||
|
||||
if (fp->_flag & _IORW)
|
||||
{
|
||||
fp->_flag |= _IOWRT;
|
||||
fp->_flag &= ~(_IOEOF|_IOREAD);
|
||||
}
|
||||
if ((fp->_flag & _IOWRT) == 0)
|
||||
return (EOF);
|
||||
|
||||
fmt = fmt0;
|
||||
digs = "0123456789abcdef";
|
||||
for (cnt = 0;; ++fmt)
|
||||
{
|
||||
n = fp->_cnt;
|
||||
for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%';
|
||||
++cnt, ++fmt)
|
||||
if ((--n < 0
|
||||
&& (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz))
|
||||
|| (ch == '\n' && fp->_flag & _IOLBF))
|
||||
{
|
||||
fp->_cnt = n;
|
||||
fp->_ptr = t;
|
||||
(void) _flsbuf((unsigned char)ch, fp);
|
||||
n = fp->_cnt;
|
||||
t = (char *)fp->_ptr;
|
||||
}
|
||||
else
|
||||
*t++ = ch;
|
||||
fp->_cnt = n;
|
||||
fp->_ptr = t;
|
||||
if (!ch)
|
||||
return cnt;
|
||||
flags = 0; dprec = 0; fpprec = 0; width = 0;
|
||||
prec = -1;
|
||||
sign = '\0';
|
||||
rflag:
|
||||
switch (*++fmt)
|
||||
{
|
||||
case ' ':
|
||||
/*
|
||||
* ``If the space and + flags both appear, the space
|
||||
* flag will be ignored.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
if (!sign)
|
||||
sign = ' ';
|
||||
goto rflag;
|
||||
case '#':
|
||||
flags |= ALT;
|
||||
goto rflag;
|
||||
case '*':
|
||||
/*
|
||||
* ``A negative field width argument is taken as a
|
||||
* - flag followed by a positive field width.''
|
||||
* -- ANSI X3J11
|
||||
* They don't exclude field widths read from args.
|
||||
*/
|
||||
if ((width = va_arg(argp, int)) >= 0)
|
||||
goto rflag;
|
||||
width = -width;
|
||||
/* FALLTHROUGH */
|
||||
case '-':
|
||||
flags |= LADJUST;
|
||||
goto rflag;
|
||||
case '+':
|
||||
sign = '+';
|
||||
goto rflag;
|
||||
case '.':
|
||||
if (*++fmt == '*')
|
||||
n = va_arg(argp, int);
|
||||
else
|
||||
{
|
||||
n = 0;
|
||||
while (isascii(*fmt) && isdigit(*fmt))
|
||||
n = 10 * n + todigit(*fmt++);
|
||||
--fmt;
|
||||
}
|
||||
prec = n < 0 ? -1 : n;
|
||||
goto rflag;
|
||||
case '0':
|
||||
/*
|
||||
* ``Note that 0 is taken as a flag, not as the
|
||||
* beginning of a field width.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
flags |= ZEROPAD;
|
||||
goto rflag;
|
||||
case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
n = 0;
|
||||
do {
|
||||
n = 10 * n + todigit(*fmt);
|
||||
} while (isascii(*++fmt) && isdigit(*fmt));
|
||||
width = n;
|
||||
--fmt;
|
||||
goto rflag;
|
||||
case 'L':
|
||||
flags |= LONGDBL;
|
||||
goto rflag;
|
||||
case 'h':
|
||||
flags |= SHORTINT;
|
||||
goto rflag;
|
||||
case 'l':
|
||||
flags |= LONGINT;
|
||||
goto rflag;
|
||||
case 'c':
|
||||
*(t = buf) = va_arg(argp, int);
|
||||
size = 1;
|
||||
sign = '\0';
|
||||
goto pforw;
|
||||
case 'D':
|
||||
flags |= LONGINT;
|
||||
/*FALLTHROUGH*/
|
||||
case 'd':
|
||||
case 'i':
|
||||
ARG(int);
|
||||
if ((long)_ulong < 0)
|
||||
{
|
||||
_ulong = -_ulong;
|
||||
sign = '-';
|
||||
}
|
||||
base = 10;
|
||||
goto number;
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (flags & LONGDBL)
|
||||
_ldouble = va_arg(argp, long double);
|
||||
else
|
||||
_ldouble = (long double)va_arg(argp, double);
|
||||
/*
|
||||
* don't do unrealistic precision; just pad it with
|
||||
* zeroes later, so buffer size stays rational.
|
||||
*/
|
||||
if (prec > MAXFRACT)
|
||||
{
|
||||
if (*fmt != 'g' && (*fmt != 'G' || (flags&ALT)))
|
||||
fpprec = prec - MAXFRACT;
|
||||
prec = MAXFRACT;
|
||||
}
|
||||
else if (prec == -1)
|
||||
{
|
||||
if (flags&LONGINT)
|
||||
prec = DEFLPREC;
|
||||
else
|
||||
prec = DEFPREC;
|
||||
}
|
||||
/*
|
||||
* softsign avoids negative 0 if _double is < 0 and
|
||||
* no significant digits will be shown
|
||||
*/
|
||||
if (_ldouble < 0)
|
||||
{
|
||||
softsign = '-';
|
||||
_ldouble = -_ldouble;
|
||||
}
|
||||
else
|
||||
softsign = 0;
|
||||
/*
|
||||
* cvt may have to round up past the "start" of the
|
||||
* buffer, i.e. ``intf("%.2f", (double)9.999);'';
|
||||
* if the first char isn't NULL, it did.
|
||||
*/
|
||||
*buf = NULL;
|
||||
size = cvtl(_ldouble, prec, flags, &softsign, *fmt, buf,
|
||||
buf + sizeof(buf));
|
||||
if (softsign && !nan2)
|
||||
sign = '-';
|
||||
nan2 = 0;
|
||||
t = *buf ? buf : buf + 1;
|
||||
goto pforw;
|
||||
case 'n':
|
||||
if (flags & LONGINT)
|
||||
*va_arg(argp, long *) = cnt;
|
||||
else if (flags & SHORTINT)
|
||||
*va_arg(argp, short *) = cnt;
|
||||
else
|
||||
*va_arg(argp, int *) = cnt;
|
||||
break;
|
||||
case 'O':
|
||||
flags |= LONGINT;
|
||||
/*FALLTHROUGH*/
|
||||
case 'o':
|
||||
ARG(unsigned);
|
||||
base = 8;
|
||||
goto nosign;
|
||||
case 'p':
|
||||
/*
|
||||
* ``The argument shall be a pointer to void. The
|
||||
* value of the pointer is converted to a sequence
|
||||
* of printable characters, in an implementation-
|
||||
* defined manner.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
/* NOSTRICT */
|
||||
_ulong = (unsigned long)va_arg(argp, void *);
|
||||
base = 16;
|
||||
goto nosign;
|
||||
case 's':
|
||||
if (!(t = va_arg(argp, char *)))
|
||||
t = NULL_REP;
|
||||
if (prec >= 0)
|
||||
{
|
||||
/*
|
||||
* can't use strlen; can only look for the
|
||||
* NUL in the first `prec' characters, and
|
||||
* strlen() will go further.
|
||||
*/
|
||||
char *p /*, *memchr() */;
|
||||
|
||||
if ((p = memchr(t, 0, prec)))
|
||||
{
|
||||
size = p - t;
|
||||
if (size > prec)
|
||||
size = prec;
|
||||
}
|
||||
else
|
||||
size = prec;
|
||||
}
|
||||
else
|
||||
size = strlen(t);
|
||||
sign = '\0';
|
||||
goto pforw;
|
||||
case 'U':
|
||||
flags |= LONGINT;
|
||||
/*FALLTHROUGH*/
|
||||
case 'u':
|
||||
ARG(unsigned);
|
||||
base = 10;
|
||||
goto nosign;
|
||||
case 'X':
|
||||
digs = "0123456789ABCDEF";
|
||||
/* FALLTHROUGH */
|
||||
case 'x':
|
||||
ARG(unsigned);
|
||||
base = 16;
|
||||
/* leading 0x/X only if non-zero */
|
||||
if (flags & ALT && _ulong != 0)
|
||||
flags |= HEXPREFIX;
|
||||
|
||||
/* unsigned conversions */
|
||||
nosign: sign = '\0';
|
||||
/*
|
||||
* ``... diouXx conversions ... if a precision is
|
||||
* specified, the 0 flag will be ignored.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
number: if ((dprec = prec) >= 0)
|
||||
flags &= ~ZEROPAD;
|
||||
|
||||
/*
|
||||
* ``The result of converting a zero value with an
|
||||
* explicit precision of zero is no characters.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
t = buf + BUF;
|
||||
if (_ulong != 0 || prec != 0)
|
||||
{
|
||||
do {
|
||||
*--t = digs[_ulong % base];
|
||||
_ulong /= base;
|
||||
} while (_ulong);
|
||||
digs = "0123456789abcdef";
|
||||
if (flags & ALT && base == 8 && *t != '0')
|
||||
*--t = '0'; /* octal leading 0 */
|
||||
}
|
||||
size = buf + BUF - t;
|
||||
|
||||
pforw:
|
||||
/*
|
||||
* All reasonable formats wind up here. At this point,
|
||||
* `t' points to a string which (if not flags&LADJUST)
|
||||
* should be padded out to `width' places. If
|
||||
* flags&ZEROPAD, it should first be prefixed by any
|
||||
* sign or other prefix; otherwise, it should be blank
|
||||
* padded before the prefix is emitted. After any
|
||||
* left-hand padding and prefixing, emit zeroes
|
||||
* required by a decimal [diouxX] precision, then print
|
||||
* the string proper, then emit zeroes required by any
|
||||
* leftover floating precision; finally, if LADJUST,
|
||||
* pad with blanks.
|
||||
*/
|
||||
|
||||
/*
|
||||
* compute actual size, so we know how much to pad
|
||||
* fieldsz excludes decimal prec; realsz includes it
|
||||
*/
|
||||
fieldsz = size + fpprec;
|
||||
realsz = dprec > fieldsz ? dprec : fieldsz;
|
||||
if (sign)
|
||||
realsz++;
|
||||
if (flags & HEXPREFIX)
|
||||
realsz += 2;
|
||||
|
||||
/* right-adjusting blank padding */
|
||||
if ((flags & (LADJUST|ZEROPAD)) == 0 && width)
|
||||
for (n = realsz; n < width; n++)
|
||||
PUTC(' ');
|
||||
/* prefix */
|
||||
if (sign)
|
||||
PUTC(sign);
|
||||
if (flags & HEXPREFIX)
|
||||
{
|
||||
PUTC('0');
|
||||
PUTC((char)*fmt);
|
||||
}
|
||||
/* right-adjusting zero padding */
|
||||
if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
|
||||
for (n = realsz; n < width; n++)
|
||||
PUTC('0');
|
||||
/* leading zeroes from decimal precision */
|
||||
for (n = fieldsz; n < dprec; n++)
|
||||
PUTC('0');
|
||||
|
||||
/* the string or number proper */
|
||||
n = size;
|
||||
if (fp->_cnt - n >= 0 && (fp->_flag & _IOLBF) == 0)
|
||||
{
|
||||
fp->_cnt -= n;
|
||||
memcpy((char *)fp->_ptr, t, n);
|
||||
fp->_ptr += n;
|
||||
}
|
||||
else
|
||||
while (--n >= 0)
|
||||
PUTC(*t++);
|
||||
/* trailing f.p. zeroes */
|
||||
while (--fpprec >= 0)
|
||||
PUTC('0');
|
||||
/* left-adjusting padding (always blank) */
|
||||
if (flags & LADJUST)
|
||||
for (n = realsz; n < width; n++)
|
||||
PUTC(' ');
|
||||
/* finally, adjust cnt */
|
||||
cnt += width > realsz ? width : realsz;
|
||||
break;
|
||||
case '\0': /* "%?" prints ?, unless ? is NULL */
|
||||
return cnt;
|
||||
default:
|
||||
PUTC((char)*fmt);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static long double pten[] =
|
||||
{
|
||||
1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L,
|
||||
1e512L, 1e1024L, 1e2048L, 1e4096L
|
||||
};
|
||||
|
||||
static long double ptenneg[] =
|
||||
{
|
||||
1e-1L, 1e-2L, 1e-4L, 1e-8L, 1e-16L, 1e-32L, 1e-64L, 1e-128L, 1e-256L,
|
||||
1e-512L, 1e-1024L, 1e-2048L, 1e-4096L
|
||||
};
|
||||
|
||||
#define MAXP 4096
|
||||
#define NP 12
|
||||
#define P (4294967296.0L * 4294967296.0L * 2.0L) /* 2^65 */
|
||||
static long double INVPREC = P;
|
||||
static long double PREC = 1.0L/P;
|
||||
#undef P
|
||||
/*
|
||||
* Defining FAST_LDOUBLE_CONVERSION results in a little bit faster
|
||||
* version, which might be less accurate (about 1 bit) for long
|
||||
* double. For 'normal' double it doesn't matter.
|
||||
*/
|
||||
/* #define FAST_LDOUBLE_CONVERSION */
|
||||
|
||||
static int
|
||||
cvtl(long double number, int prec, int flags, char *signp, unsigned char fmtch,
|
||||
char *startp, char *endp)
|
||||
{
|
||||
char *p, *t;
|
||||
long double fract;
|
||||
int dotrim, expcnt, gformat;
|
||||
long double integer, tmp;
|
||||
|
||||
if ((expcnt = isspeciall(number, startp)))
|
||||
return(expcnt);
|
||||
|
||||
dotrim = expcnt = gformat = 0;
|
||||
/* fract = modfl(number, &integer); */
|
||||
integer = number;
|
||||
|
||||
/* get an extra slot for rounding. */
|
||||
t = ++startp;
|
||||
|
||||
p = endp - 1;
|
||||
if (integer)
|
||||
{
|
||||
int i, lp=NP, pt=MAXP;
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
long double oint = integer, dd=1.0L;
|
||||
#endif
|
||||
if (integer > INVPREC)
|
||||
{
|
||||
integer *= PREC;
|
||||
while(lp >= 0) {
|
||||
if (integer >= pten[lp])
|
||||
{
|
||||
expcnt += pt;
|
||||
integer *= ptenneg[lp];
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
dd *= pten[lp];
|
||||
#endif
|
||||
}
|
||||
pt >>= 1;
|
||||
lp--;
|
||||
}
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
integer = oint/dd;
|
||||
#else
|
||||
integer *= INVPREC;
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Do we really need this ?
|
||||
*/
|
||||
for (i = 0; i < expcnt; i++)
|
||||
*p-- = '0';
|
||||
}
|
||||
number = integer;
|
||||
fract = modfl(number, &integer);
|
||||
/*
|
||||
* get integer portion of number; put into the end of the buffer; the
|
||||
* .01 is added for modf(356.0 / 10, &integer) returning .59999999...
|
||||
*/
|
||||
for (; integer; ++expcnt)
|
||||
{
|
||||
tmp = modfl(integer * 0.1L , &integer);
|
||||
*p-- = tochar((int)((tmp + .01L) * 10));
|
||||
}
|
||||
switch(fmtch)
|
||||
{
|
||||
case 'f':
|
||||
/* reverse integer into beginning of buffer */
|
||||
if (expcnt)
|
||||
for (; ++p < endp; *t++ = *p);
|
||||
else
|
||||
*t++ = '0';
|
||||
/*
|
||||
* if precision required or alternate flag set, add in a
|
||||
* decimal point.
|
||||
*/
|
||||
if (prec || flags&ALT)
|
||||
*t++ = decimal;
|
||||
/* if requires more precision and some fraction left */
|
||||
if (fract)
|
||||
{
|
||||
if (prec)
|
||||
do {
|
||||
fract = modfl(fract * 10.0L, &tmp);
|
||||
*t++ = tochar((int)tmp);
|
||||
} while (--prec && fract);
|
||||
if (fract)
|
||||
startp = roundl(fract, (int *)NULL, startp,
|
||||
t - 1, (char)0, signp);
|
||||
}
|
||||
for (; prec--; *t++ = '0');
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
eformat:
|
||||
if (expcnt)
|
||||
{
|
||||
*t++ = *++p;
|
||||
if (prec || flags&ALT)
|
||||
*t++ = decimal;
|
||||
/* if requires more precision and some integer left */
|
||||
for (; prec && ++p < endp; --prec)
|
||||
*t++ = *p;
|
||||
/*
|
||||
* if done precision and more of the integer component,
|
||||
* round using it; adjust fract so we don't re-round
|
||||
* later.
|
||||
*/
|
||||
if (!prec && ++p < endp)
|
||||
{
|
||||
fract = 0;
|
||||
startp = roundl((long double)0.0L, &expcnt,
|
||||
startp, t - 1, *p, signp);
|
||||
}
|
||||
/* adjust expcnt for digit in front of decimal */
|
||||
--expcnt;
|
||||
}
|
||||
/* until first fractional digit, decrement exponent */
|
||||
else if (fract)
|
||||
{
|
||||
int lp=NP, pt=MAXP;
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
long double ofract = fract, dd=1.0L;
|
||||
#endif
|
||||
expcnt = -1;
|
||||
if (fract < PREC)
|
||||
{
|
||||
fract *= INVPREC;
|
||||
while(lp >= 0)
|
||||
{
|
||||
if (fract <= ptenneg[lp])
|
||||
{
|
||||
expcnt -= pt;
|
||||
fract *= pten[lp];
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
dd *= pten[lp];
|
||||
#endif
|
||||
}
|
||||
pt >>= 1;
|
||||
lp--;
|
||||
}
|
||||
#ifndef FAST_LDOUBLE_CONVERSION
|
||||
fract = ofract*dd;
|
||||
#else
|
||||
fract *= PREC;
|
||||
#endif
|
||||
}
|
||||
/* adjust expcnt for digit in front of decimal */
|
||||
for ( /* expcnt = -1 */ ;; --expcnt)
|
||||
{
|
||||
fract = modfl(fract * 10.0L, &tmp);
|
||||
if (tmp)
|
||||
break;
|
||||
}
|
||||
*t++ = tochar((int)tmp);
|
||||
if (prec || flags&ALT)
|
||||
*t++ = decimal;
|
||||
}
|
||||
else
|
||||
{
|
||||
*t++ = '0';
|
||||
if (prec || flags&ALT)
|
||||
*t++ = decimal;
|
||||
}
|
||||
/* if requires more precision and some fraction left */
|
||||
if (fract)
|
||||
{
|
||||
if (prec)
|
||||
do {
|
||||
fract = modfl(fract * 10.0L, &tmp);
|
||||
*t++ = tochar((int)tmp);
|
||||
} while (--prec && fract);
|
||||
if (fract)
|
||||
startp = roundl(fract, &expcnt, startp,
|
||||
t - 1, (char)0, signp);
|
||||
}
|
||||
/* if requires more precision */
|
||||
for (; prec--; *t++ = '0');
|
||||
|
||||
/* unless alternate flag, trim any g/G format trailing 0's */
|
||||
if (gformat && !(flags&ALT))
|
||||
{
|
||||
while (t > startp && *--t == '0');
|
||||
if (*t == decimal)
|
||||
--t;
|
||||
++t;
|
||||
}
|
||||
t = exponentl(t, expcnt, fmtch);
|
||||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
/* a precision of 0 is treated as a precision of 1. */
|
||||
if (!prec)
|
||||
++prec;
|
||||
/*
|
||||
* ``The style used depends on the value converted; style e
|
||||
* will be used only if the exponent resulting from the
|
||||
* conversion is less than -4 or greater than the precision.''
|
||||
* -- ANSI X3J11
|
||||
*/
|
||||
if (expcnt > prec || (!expcnt && fract && fract < .0001))
|
||||
{
|
||||
/*
|
||||
* g/G format counts "significant digits, not digits of
|
||||
* precision; for the e/E format, this just causes an
|
||||
* off-by-one problem, i.e. g/G considers the digit
|
||||
* before the decimal point significant and e/E doesn't
|
||||
* count it as precision.
|
||||
*/
|
||||
--prec;
|
||||
fmtch -= 2; /* G->E, g->e */
|
||||
gformat = 1;
|
||||
goto eformat;
|
||||
}
|
||||
/*
|
||||
* reverse integer into beginning of buffer,
|
||||
* note, decrement precision
|
||||
*/
|
||||
if (expcnt)
|
||||
for (; ++p < endp; *t++ = *p, --prec);
|
||||
else
|
||||
*t++ = '0';
|
||||
/*
|
||||
* if precision required or alternate flag set, add in a
|
||||
* decimal point. If no digits yet, add in leading 0.
|
||||
*/
|
||||
if (prec || flags&ALT)
|
||||
{
|
||||
dotrim = 1;
|
||||
*t++ = decimal;
|
||||
}
|
||||
else
|
||||
dotrim = 0;
|
||||
/* if requires more precision and some fraction left */
|
||||
while (prec && fract)
|
||||
{
|
||||
fract = modfl(fract * 10.0L, &tmp);
|
||||
*t++ = tochar((int)tmp);
|
||||
prec--;
|
||||
}
|
||||
if (fract)
|
||||
startp = roundl(fract, (int *)NULL, startp, t - 1,
|
||||
(char)0, signp);
|
||||
/* alternate format, adds 0's for precision, else trim 0's */
|
||||
if (flags&ALT)
|
||||
for (; prec--; *t++ = '0');
|
||||
else if (dotrim)
|
||||
{
|
||||
while (t > startp && *--t == '0');
|
||||
if (*t != decimal)
|
||||
++t;
|
||||
}
|
||||
}
|
||||
return t - startp;
|
||||
}
|
||||
|
||||
static char *
|
||||
roundl(long double fract, int *expv, char *start, char *end, char ch,
|
||||
char *signp)
|
||||
{
|
||||
long double tmp;
|
||||
|
||||
if (fract)
|
||||
{
|
||||
if (fract == 0.5L)
|
||||
{
|
||||
char *e = end;
|
||||
if (*e == '.')
|
||||
e--;
|
||||
if (*e == '0' || *e == '2' || *e == '4'
|
||||
|| *e == '6' || *e == '8')
|
||||
{
|
||||
tmp = 3.0;
|
||||
goto start;
|
||||
}
|
||||
}
|
||||
(void)modfl(fract * 10.0L, &tmp);
|
||||
}
|
||||
else
|
||||
tmp = todigit(ch);
|
||||
start:
|
||||
if (tmp > 4)
|
||||
for (;; --end)
|
||||
{
|
||||
if (*end == decimal)
|
||||
--end;
|
||||
if (++*end <= '9')
|
||||
break;
|
||||
*end = '0';
|
||||
if (end == start)
|
||||
{
|
||||
if (expv)
|
||||
{ /* e/E; increment exponent */
|
||||
*end = '1';
|
||||
++*expv;
|
||||
}
|
||||
else
|
||||
{ /* f; add extra digit */
|
||||
*--end = '1';
|
||||
--start;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
|
||||
else if (*signp == '-')
|
||||
for (;; --end)
|
||||
{
|
||||
if (*end == decimal)
|
||||
--end;
|
||||
if (*end != '0')
|
||||
break;
|
||||
if (end == start)
|
||||
*signp = 0;
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
static char *
|
||||
exponentl(char *p, int expv, unsigned char fmtch)
|
||||
{
|
||||
char *t;
|
||||
char expbuf[MAXEXPLD];
|
||||
|
||||
*p++ = fmtch;
|
||||
if (expv < 0)
|
||||
{
|
||||
expv = -expv;
|
||||
*p++ = '-';
|
||||
}
|
||||
else
|
||||
*p++ = '+';
|
||||
t = expbuf + MAXEXPLD;
|
||||
if (expv > 9)
|
||||
{
|
||||
do {
|
||||
*--t = tochar(expv % 10);
|
||||
} while ((expv /= 10) > 9);
|
||||
*--t = tochar(expv);
|
||||
for (; t < expbuf + MAXEXPLD; *p++ = *t++);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = '0';
|
||||
*p++ = tochar(expv);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static int
|
||||
isspeciall(long double d, char *bufp)
|
||||
{
|
||||
struct IEEExp {
|
||||
unsigned manl:32;
|
||||
unsigned manh:32;
|
||||
unsigned exp:15;
|
||||
unsigned sign:1;
|
||||
} *ip = (struct IEEExp *)&d;
|
||||
|
||||
nan2 = 0; /* don't assume the static is 0 (emacs) */
|
||||
if (ip->exp != 0x7fff)
|
||||
return(0);
|
||||
if ((ip->manh & 0x7fffffff) || ip->manl)
|
||||
{
|
||||
strcpy(bufp, "NaN");
|
||||
nan2 = 1; /* kludge: we don't need the sign, it's not nice
|
||||
but it should work */
|
||||
}
|
||||
else
|
||||
(void)strcpy(bufp, "Inf");
|
||||
return(3);
|
||||
}
|
||||
|
@@ -1,360 +0,0 @@
|
||||
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/local.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define SPC 01
|
||||
#define STP 02
|
||||
|
||||
#define SHORT 0
|
||||
#define REGULAR 1
|
||||
#define LONG 2
|
||||
#define LONGDOUBLE 4
|
||||
#define INT 0
|
||||
#define FLOAT 1
|
||||
|
||||
static int _innum(void *ptr, int type, int len, int size, FILE *iop,
|
||||
int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *),
|
||||
int *eofptr);
|
||||
static int _instr(char *ptr, int type, int len, FILE *iop,
|
||||
int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *),
|
||||
int *eofptr);
|
||||
static const char *_getccl(const unsigned char *s);
|
||||
|
||||
static char _sctab[256] = {
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,SPC,SPC,SPC,SPC,SPC,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
SPC,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
static int nchars = 0;
|
||||
|
||||
int
|
||||
_doscan(FILE *iop, const char *fmt, va_list argp)
|
||||
{
|
||||
return(_doscan_low(iop, fgetc, ungetc, fmt, argp));
|
||||
}
|
||||
|
||||
int
|
||||
_doscan_low(FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *),
|
||||
const char *fmt, va_list argp)
|
||||
{
|
||||
register int ch;
|
||||
int nmatch, len, ch1;
|
||||
void* ptr;
|
||||
int fileended, size;
|
||||
|
||||
nchars = 0;
|
||||
nmatch = 0;
|
||||
fileended = 0;
|
||||
for (;;) switch (ch = *fmt++) {
|
||||
case '\0':
|
||||
return (nmatch);
|
||||
case '%':
|
||||
if ((ch = *fmt++) == '%')
|
||||
goto def;
|
||||
if (ch == 'n')
|
||||
{
|
||||
int* arg = va_arg(argp, int*);
|
||||
*arg = nchars;
|
||||
break;
|
||||
}
|
||||
if (fileended)
|
||||
return(nmatch? nmatch: -1);
|
||||
ptr = 0;
|
||||
if (ch != '*')
|
||||
ptr = va_arg(argp, void*);
|
||||
else
|
||||
ch = *fmt++;
|
||||
len = 0;
|
||||
size = REGULAR;
|
||||
while (isdigit(ch)) {
|
||||
len = len*10 + ch - '0';
|
||||
ch = *fmt++;
|
||||
}
|
||||
if (len == 0)
|
||||
len = 30000;
|
||||
if (ch=='l') {
|
||||
size = LONG;
|
||||
ch = *fmt++;
|
||||
} else if (ch=='h') {
|
||||
size = SHORT;
|
||||
ch = *fmt++;
|
||||
} else if (ch=='L') {
|
||||
size = LONGDOUBLE;
|
||||
ch = *fmt++;
|
||||
} else if (ch=='[')
|
||||
fmt = _getccl((const unsigned char *)fmt);
|
||||
if (isupper(ch)) {
|
||||
/* ch = tolower(ch);
|
||||
gcc gives warning: ANSI C forbids braced
|
||||
groups within expressions */
|
||||
ch += 'a' - 'A';
|
||||
size = LONG;
|
||||
}
|
||||
if (ch == '\0')
|
||||
return(-1);
|
||||
if (_innum(ptr, ch, len, size, iop, scan_getc, scan_ungetc,
|
||||
&fileended) && ptr)
|
||||
nmatch++;
|
||||
/* breaks %n */
|
||||
/* if (fileended) {
|
||||
return(nmatch? nmatch: -1);
|
||||
} */
|
||||
break;
|
||||
case ' ':
|
||||
case '\n':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\f':
|
||||
case '\v':
|
||||
while (((nchars++, ch1 = scan_getc(iop))!=EOF) && (_sctab[ch1] & SPC))
|
||||
;
|
||||
if (ch1 != EOF)
|
||||
{
|
||||
scan_ungetc(ch1, iop);
|
||||
}
|
||||
nchars--;
|
||||
break;
|
||||
|
||||
default:
|
||||
def:
|
||||
ch1 = scan_getc(iop);
|
||||
if (ch1 != EOF) nchars++;
|
||||
if (ch1 != ch) {
|
||||
if (ch1==EOF)
|
||||
return(-1);
|
||||
scan_ungetc(ch1, iop);
|
||||
nchars--;
|
||||
return(nmatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_innum(void *ptr, int type, int len, int size, FILE *iop,
|
||||
int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr)
|
||||
{
|
||||
register char *np;
|
||||
char numbuf[64];
|
||||
register c, base;
|
||||
int expseen, scale, negflg, c1, ndigit;
|
||||
long lcval;
|
||||
int cpos;
|
||||
|
||||
if (type=='c' || type=='s' || type=='[')
|
||||
return(_instr(ptr, type, len,
|
||||
iop, scan_getc, scan_ungetc, eofptr));
|
||||
lcval = 0;
|
||||
ndigit = 0;
|
||||
scale = INT;
|
||||
if (type=='e'||type=='f'||type=='g')
|
||||
scale = FLOAT;
|
||||
base = 10;
|
||||
if (type=='o')
|
||||
base = 8;
|
||||
else if (type=='x')
|
||||
base = 16;
|
||||
np = numbuf;
|
||||
expseen = 0;
|
||||
negflg = 0;
|
||||
while (((nchars++, c = scan_getc(iop)) != EOF) && (_sctab[c] & SPC))
|
||||
;
|
||||
if (c == EOF) nchars--;
|
||||
if (c=='-') {
|
||||
negflg++;
|
||||
*np++ = c;
|
||||
c = scan_getc(iop);
|
||||
nchars++;
|
||||
len--;
|
||||
} else if (c=='+') {
|
||||
len--;
|
||||
c = scan_getc(iop);
|
||||
nchars++;
|
||||
}
|
||||
cpos = 0;
|
||||
for ( ; --len>=0; *np++ = c, c = scan_getc(iop), nchars++) {
|
||||
cpos++;
|
||||
if (c == '0' && cpos == 1 && type == 'i')
|
||||
base = 8;
|
||||
if ((c == 'x' || c == 'X') && (type == 'i' || type == 'x')
|
||||
&& cpos == 2 && lcval == 0)
|
||||
{
|
||||
base = 16;
|
||||
continue;
|
||||
}
|
||||
if (isdigit(c)
|
||||
|| (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) {
|
||||
ndigit++;
|
||||
if (base==8)
|
||||
lcval <<=3;
|
||||
else if (base==10)
|
||||
lcval = ((lcval<<2) + lcval)<<1;
|
||||
else
|
||||
lcval <<= 4;
|
||||
c1 = c;
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if ('a'<=c && c<='f')
|
||||
c -= 'a'-10;
|
||||
else
|
||||
c -= 'A'-10;
|
||||
lcval += c;
|
||||
c = c1;
|
||||
continue;
|
||||
} else if (c=='.') {
|
||||
if (base!=10 || scale==INT)
|
||||
break;
|
||||
ndigit++;
|
||||
continue;
|
||||
} else if ((c=='e'||c=='E') && expseen==0) {
|
||||
if (base!=10 || scale==INT || ndigit==0)
|
||||
break;
|
||||
expseen++;
|
||||
*np++ = c;
|
||||
c = scan_getc(iop);
|
||||
nchars++;
|
||||
if (c!='+'&&c!='-'&&('0'>c||c>'9'))
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (negflg)
|
||||
lcval = -lcval;
|
||||
if (c != EOF) {
|
||||
scan_ungetc(c, iop);
|
||||
*eofptr = 0;
|
||||
} else
|
||||
*eofptr = 1;
|
||||
nchars--;
|
||||
if (ptr==NULL || np==numbuf || (negflg && np==numbuf+1) ) /* gene dykes*/
|
||||
return(0);
|
||||
*np++ = 0;
|
||||
switch((scale<<4) | size) {
|
||||
|
||||
case (FLOAT<<4) | SHORT:
|
||||
case (FLOAT<<4) | REGULAR:
|
||||
*(float *)ptr = atof(numbuf);
|
||||
break;
|
||||
|
||||
case (FLOAT<<4) | LONG:
|
||||
*(double *)ptr = atof(numbuf);
|
||||
break;
|
||||
|
||||
case (FLOAT<<4) | LONGDOUBLE:
|
||||
*(long double *)ptr = _atold(numbuf);
|
||||
break;
|
||||
|
||||
case (INT<<4) | SHORT:
|
||||
*(short *)ptr = (short)lcval;
|
||||
break;
|
||||
|
||||
case (INT<<4) | REGULAR:
|
||||
*(int *)ptr = (int)lcval;
|
||||
break;
|
||||
|
||||
case (INT<<4) | LONG:
|
||||
case (INT<<4) | LONGDOUBLE:
|
||||
*(long *)ptr = lcval;
|
||||
break;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
static int
|
||||
_instr(char *ptr, int type, int len, FILE *iop,
|
||||
int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr)
|
||||
{
|
||||
register ch;
|
||||
register char *optr;
|
||||
int ignstp;
|
||||
|
||||
*eofptr = 0;
|
||||
optr = ptr;
|
||||
if (type=='c' && len==30000)
|
||||
len = 1;
|
||||
ignstp = 0;
|
||||
if (type=='s')
|
||||
ignstp = SPC;
|
||||
while ((nchars++, ch = scan_getc(iop)) != EOF && _sctab[ch] & ignstp)
|
||||
;
|
||||
ignstp = SPC;
|
||||
if (type=='c')
|
||||
ignstp = 0;
|
||||
else if (type=='[')
|
||||
ignstp = STP;
|
||||
while (ch!=EOF && (_sctab[ch]&ignstp)==0) {
|
||||
if (ptr)
|
||||
*ptr++ = ch;
|
||||
if (--len <= 0)
|
||||
break;
|
||||
ch = scan_getc(iop);
|
||||
nchars++;
|
||||
}
|
||||
if (ch != EOF) {
|
||||
if (len > 0)
|
||||
{
|
||||
scan_ungetc(ch, iop);
|
||||
nchars--;
|
||||
}
|
||||
*eofptr = 0;
|
||||
} else
|
||||
{
|
||||
nchars--;
|
||||
*eofptr = 1;
|
||||
}
|
||||
if (ptr && ptr!=optr) {
|
||||
if (type!='c')
|
||||
*ptr++ = '\0';
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_getccl(const unsigned char *s)
|
||||
{
|
||||
register c, t;
|
||||
|
||||
t = 0;
|
||||
if (*s == '^') {
|
||||
t++;
|
||||
s++;
|
||||
}
|
||||
for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++)
|
||||
if (t)
|
||||
_sctab[c] &= ~STP;
|
||||
else
|
||||
_sctab[c] |= STP;
|
||||
if ((c = *s) == ']' || c == '-') { /* first char is special */
|
||||
if (t)
|
||||
_sctab[c] |= STP;
|
||||
else
|
||||
_sctab[c] &= ~STP;
|
||||
s++;
|
||||
}
|
||||
while ((c = *s++) != ']') {
|
||||
if (c==0)
|
||||
return((const char *)--s);
|
||||
else if (c == '-' && *s != ']' && s[-2] < *s) {
|
||||
for (c = s[-2] + 1; c < *s; c++)
|
||||
if (t)
|
||||
_sctab[c] |= STP;
|
||||
else
|
||||
_sctab[c] &= ~STP;
|
||||
} else if (t)
|
||||
_sctab[c] |= STP;
|
||||
else
|
||||
_sctab[c] &= ~STP;
|
||||
}
|
||||
return((const char *)s);
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int fclose(FILE *f)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = EOF;
|
||||
if (!f)
|
||||
return r;
|
||||
if (f->_flag & (_IOREAD|_IOWRT|_IORW)
|
||||
&& !(f->_flag&_IOSTRG))
|
||||
{
|
||||
r = fflush(f);
|
||||
if (close(fileno(f)) < 0)
|
||||
r = EOF;
|
||||
if (f->_flag&_IOMYBUF)
|
||||
free(f->_base);
|
||||
}
|
||||
if (f->_flag & _IORMONCL && f->_name_to_remove)
|
||||
{
|
||||
remove(f->_name_to_remove);
|
||||
free(f->_name_to_remove);
|
||||
f->_name_to_remove = 0;
|
||||
}
|
||||
f->_cnt = 0;
|
||||
f->_base = 0;
|
||||
f->_ptr = 0;
|
||||
f->_bufsiz = 0;
|
||||
f->_flag = 0;
|
||||
f->_file = -1;
|
||||
return r;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
#undef feof
|
||||
int
|
||||
feof(FILE *stream)
|
||||
{
|
||||
return stream->_flag & _IOEOF;
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
#undef ferror
|
||||
int ferror(FILE *stream)
|
||||
{
|
||||
return stream->_flag & _IOERR;
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int fflush(FILE *f)
|
||||
{
|
||||
char *base;
|
||||
int n, rn;
|
||||
if(!f) return 0;
|
||||
if(f->std_ops && STM_OP(f,flush))
|
||||
return STM_OP(f,flush)(f);
|
||||
if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT
|
||||
&& (base = f->_base) != NULL
|
||||
&& (rn = n = f->_ptr - base) > 0)
|
||||
{
|
||||
f->_ptr = base;
|
||||
f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz;
|
||||
do {
|
||||
n = write(fileno(f), base, rn);
|
||||
if (n <= 0) {
|
||||
f->_flag |= _IOERR;
|
||||
return EOF;
|
||||
}
|
||||
rn -= n;
|
||||
base += n;
|
||||
} while (rn > 0);
|
||||
_dosemu_flush(fileno(f));
|
||||
}
|
||||
if (f->_flag & _IORW)
|
||||
{
|
||||
f->_cnt = 0;
|
||||
f->_flag &= ~(_IOWRT|_IOREAD);
|
||||
f->_ptr = f->_base;
|
||||
}
|
||||
return 0;
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
return __getc(f);
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
int fgetpos(FILE *stream, fpos_t *pos)
|
||||
{
|
||||
if (stream && pos)
|
||||
{
|
||||
*pos = (fpos_t)ftell(stream);
|
||||
return 0;
|
||||
}
|
||||
errno = EFAULT;
|
||||
return 1;
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
char * fgets(char *s, int n, FILE *f)
|
||||
{
|
||||
int c=0;
|
||||
char *cs;
|
||||
cs = s;
|
||||
while (--n>0 && (c = __getc(f)) != EOF)
|
||||
{
|
||||
*cs++ = c;
|
||||
if (c == '\n') break;
|
||||
}
|
||||
if (c == EOF && cs == s) return NULL;
|
||||
*cs++ = '\0';
|
||||
return s;
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/stdiohk.h>
|
||||
|
||||
int _filbuf(FILE *f)
|
||||
{
|
||||
int size;
|
||||
char c;
|
||||
|
||||
if (f->_flag & _IORW)
|
||||
f->_flag |= _IOREAD;
|
||||
|
||||
if ((f->_flag&_IOREAD) == 0)
|
||||
return EOF;
|
||||
if (f->_flag&(_IOSTRG|_IOEOF))
|
||||
return EOF;
|
||||
tryagain:
|
||||
if (f->_base==NULL) {
|
||||
if (f->_flag&_IONBF) {
|
||||
f->_base = &c;
|
||||
goto tryagain;
|
||||
}
|
||||
size = 512;
|
||||
if ((f->_base = malloc(size)) == NULL) {
|
||||
f->_flag |= _IONBF;
|
||||
goto tryagain;
|
||||
}
|
||||
f->_flag |= _IOMYBUF;
|
||||
f->_bufsiz = size;
|
||||
}
|
||||
if (f == stdin) {
|
||||
if (stdout->_flag&_IOLBF)
|
||||
fflush(stdout);
|
||||
if (stderr->_flag&_IOLBF)
|
||||
fflush(stderr);
|
||||
}
|
||||
if(f->std_ops && STM_OP(f,read))
|
||||
{
|
||||
f->_cnt=STM_OP(f,read)(f,f->_base,f->_flag & _IONBF ? 1 : f->_bufsiz);
|
||||
} else {
|
||||
f->_cnt = read(fileno(f), f->_base,f->_flag & _IONBF ? 1 : f->_bufsiz);
|
||||
}
|
||||
f->_ptr = f->_base;
|
||||
if (f->_flag & _IONBF && f->_base == &c)
|
||||
f->_base = NULL;
|
||||
if (--f->_cnt < 0) {
|
||||
if (f->_cnt == -1) {
|
||||
f->_flag |= _IOEOF;
|
||||
if (f->_flag & _IORW)
|
||||
f->_flag &= ~_IOREAD;
|
||||
} else
|
||||
f->_flag |= _IOERR;
|
||||
f->_cnt = 0;
|
||||
return EOF;
|
||||
}
|
||||
return *f->_ptr++ & 0377;
|
||||
}
|
@@ -1,98 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int
|
||||
_flsbuf(int c, FILE *f)
|
||||
{
|
||||
char *base;
|
||||
int n, rn;
|
||||
char c1;
|
||||
int size;
|
||||
|
||||
if (f->_flag & _IORW)
|
||||
{
|
||||
f->_flag |= _IOWRT;
|
||||
f->_flag &= ~(_IOEOF|_IOREAD);
|
||||
}
|
||||
|
||||
if ((f->_flag&_IOWRT)==0)
|
||||
return EOF;
|
||||
|
||||
tryagain:
|
||||
if (f->_flag&_IOLBF)
|
||||
{
|
||||
base = f->_base;
|
||||
*f->_ptr++ = c;
|
||||
if ((rn = f->_ptr - base) >= f->_bufsiz || c == '\n')
|
||||
{
|
||||
f->_ptr = base;
|
||||
f->_cnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we got here because _cnt is wrong, so fix it */
|
||||
f->_cnt = -rn;
|
||||
rn = n = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (f->_flag&_IONBF)
|
||||
{
|
||||
c1 = c;
|
||||
rn = 1;
|
||||
base = &c1;
|
||||
f->_cnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((base=f->_base)==NULL)
|
||||
{
|
||||
size = 512;
|
||||
if ((f->_base=base=malloc(size)) == NULL)
|
||||
{
|
||||
f->_flag |= _IONBF;
|
||||
goto tryagain;
|
||||
}
|
||||
f->_flag |= _IOMYBUF;
|
||||
f->_bufsiz = size;
|
||||
if (f==stdout)
|
||||
{
|
||||
f->_flag |= _IOLBF;
|
||||
f->_ptr = base;
|
||||
goto tryagain;
|
||||
}
|
||||
rn = n = 0;
|
||||
}
|
||||
else
|
||||
rn = f->_ptr - base;
|
||||
f->_ptr = base;
|
||||
f->_cnt = f->_bufsiz;
|
||||
}
|
||||
while (rn > 0)
|
||||
{
|
||||
if(f->std_ops && STM_OP(f,write))
|
||||
{
|
||||
n=STM_OP(f,write)(f,base,rn);
|
||||
} else {
|
||||
n = write(fileno(f), base, rn);
|
||||
}
|
||||
if (n <= 0)
|
||||
{
|
||||
f->_flag |= _IOERR;
|
||||
return EOF;
|
||||
}
|
||||
rn -= n;
|
||||
base += n;
|
||||
}
|
||||
if ((f->_flag&(_IOLBF|_IONBF)) == 0)
|
||||
{
|
||||
f->_cnt--;
|
||||
*f->_ptr++ = c;
|
||||
}
|
||||
return c;
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/local.h>
|
||||
#include <libc/dosio.h>
|
||||
|
||||
FILE * fopen(const char *file, const char *mode)
|
||||
{
|
||||
FILE *f;
|
||||
int fd, rw, oflags = 0;
|
||||
char tbchar;
|
||||
|
||||
if (file == 0)
|
||||
return 0;
|
||||
if (mode == 0)
|
||||
return 0;
|
||||
|
||||
f = __alloc_file();
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
|
||||
rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
|
||||
|
||||
switch (*mode)
|
||||
{
|
||||
case 'a':
|
||||
oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
|
||||
break;
|
||||
case 'r':
|
||||
oflags = rw ? O_RDWR : O_RDONLY;
|
||||
break;
|
||||
case 'w':
|
||||
oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
|
||||
break;
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
if (mode[1] == '+')
|
||||
tbchar = mode[2];
|
||||
else
|
||||
tbchar = mode[1];
|
||||
if (tbchar == 't')
|
||||
oflags |= O_TEXT;
|
||||
else if (tbchar == 'b')
|
||||
oflags |= O_BINARY;
|
||||
else
|
||||
oflags |= (_fmode & (O_TEXT|O_BINARY));
|
||||
|
||||
fd = open(file, oflags, 0666);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
if (*mode == 'a')
|
||||
lseek(fd, 0, SEEK_END);
|
||||
|
||||
f->_cnt = 0;
|
||||
f->_file = fd;
|
||||
f->_bufsiz = 0;
|
||||
if (rw)
|
||||
f->_flag = _IORW;
|
||||
else if (*mode == 'r')
|
||||
f->_flag = _IOREAD;
|
||||
else
|
||||
f->_flag = _IOWRT;
|
||||
|
||||
f->_base = f->_ptr = NULL;
|
||||
f->std_ops=NULL;
|
||||
// __libclog_printf("fopen: return=%x\n",f);
|
||||
return f;
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
fprintf(register FILE *iop, const char *fmt, ...)
|
||||
{
|
||||
int len;
|
||||
char localbuf[BUFSIZ];
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
if (iop->_flag & _IONBF)
|
||||
{
|
||||
iop->_flag &= ~_IONBF;
|
||||
iop->_ptr = iop->_base = localbuf;
|
||||
iop->_bufsiz = BUFSIZ;
|
||||
len = _doprnt(fmt, va, iop);
|
||||
fflush(iop);
|
||||
iop->_flag |= _IONBF;
|
||||
iop->_base = NULL;
|
||||
iop->_bufsiz = NULL;
|
||||
iop->_cnt = 0;
|
||||
}
|
||||
else
|
||||
len = _doprnt(fmt, va, iop);
|
||||
va_end(va);
|
||||
return ferror(iop) ? EOF : len;
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int fputc(int c, FILE *fp)
|
||||
{
|
||||
return __putc(c, fp);
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int
|
||||
fputs(const char *s, FILE *f)
|
||||
{
|
||||
int r = 0;
|
||||
int c;
|
||||
int unbuffered;
|
||||
char localbuf[BUFSIZ];
|
||||
|
||||
unbuffered = f->_flag & _IONBF;
|
||||
if (unbuffered)
|
||||
{
|
||||
f->_flag &= ~_IONBF;
|
||||
f->_ptr = f->_base = localbuf;
|
||||
f->_bufsiz = BUFSIZ;
|
||||
}
|
||||
|
||||
while ((c = *s++))
|
||||
r = __putc(c, f);
|
||||
|
||||
if (unbuffered)
|
||||
{
|
||||
fflush(f);
|
||||
f->_flag |= _IONBF;
|
||||
f->_base = NULL;
|
||||
f->_bufsiz = NULL;
|
||||
f->_cnt = 0;
|
||||
}
|
||||
|
||||
return(r);
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
size_t fread(void *vptr, size_t size, size_t count, FILE *iop)
|
||||
{
|
||||
char *ptr = (char *)vptr;
|
||||
int s;
|
||||
int c;
|
||||
|
||||
// __libclog_printf("fread(%x,%u,%u,%x)\n",vptr,size,count,iop);
|
||||
|
||||
s = size * count;
|
||||
while (s > 0) {
|
||||
if (iop->_cnt < s) {
|
||||
if (iop->_cnt > 0) {
|
||||
memcpy(ptr, iop->_ptr, iop->_cnt);
|
||||
ptr += iop->_cnt;
|
||||
s -= iop->_cnt;
|
||||
}
|
||||
/*
|
||||
* filbuf clobbers _cnt & _ptr,
|
||||
* so don't waste time setting them.
|
||||
*/
|
||||
if ((c = _filbuf(iop)) == EOF)
|
||||
break;
|
||||
*ptr++ = c;
|
||||
s--;
|
||||
}
|
||||
if (iop->_cnt >= s) {
|
||||
memcpy(ptr, iop->_ptr, s);
|
||||
iop->_ptr += s;
|
||||
iop->_cnt -= s;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return size != 0 ? count - ((s + size - 1) / size) : 0;
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/dosio.h>
|
||||
|
||||
FILE *
|
||||
freopen(const char *file, const char *mode, FILE *f)
|
||||
{
|
||||
int fd, rw, oflags=0;
|
||||
char tbchar;
|
||||
|
||||
if (file == 0 || mode == 0 || f == 0)
|
||||
return 0;
|
||||
|
||||
rw = (mode[1] == '+');
|
||||
|
||||
fclose(f);
|
||||
|
||||
switch (*mode) {
|
||||
case 'a':
|
||||
oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
|
||||
break;
|
||||
case 'r':
|
||||
oflags = rw ? O_RDWR : O_RDONLY;
|
||||
break;
|
||||
case 'w':
|
||||
oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
if (mode[1] == '+')
|
||||
tbchar = mode[2];
|
||||
else
|
||||
tbchar = mode[1];
|
||||
if (tbchar == 't')
|
||||
oflags |= O_TEXT;
|
||||
else if (tbchar == 'b')
|
||||
oflags |= O_BINARY;
|
||||
else
|
||||
oflags |= (_fmode & (O_TEXT|O_BINARY));
|
||||
|
||||
fd = open(file, oflags, 0666);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
if (*mode == 'a')
|
||||
lseek(fd, 0, SEEK_END);
|
||||
|
||||
f->_cnt = 0;
|
||||
f->_file = fd;
|
||||
f->_bufsiz = 0;
|
||||
if (rw)
|
||||
f->_flag = _IORW;
|
||||
else if (*mode == 'r')
|
||||
f->_flag = _IOREAD;
|
||||
else
|
||||
f->_flag = _IOWRT;
|
||||
|
||||
f->_base = f->_ptr = NULL;
|
||||
return f;
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/local.h>
|
||||
|
||||
static __file_rec __initial_file_rec = {
|
||||
0,
|
||||
3,
|
||||
{ stdin, stdout, stderr }
|
||||
};
|
||||
|
||||
__file_rec *__file_rec_list = &__initial_file_rec;
|
@@ -1,15 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int
|
||||
fscanf(FILE *f, const char *fmt, ...)
|
||||
{
|
||||
int r;
|
||||
va_list a=0;
|
||||
va_start(a, fmt);
|
||||
r = _doscan(f, fmt, a);
|
||||
va_end(a);
|
||||
return r;
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
#include <fcntl.h>
|
||||
#include <libc/dosio.h>
|
||||
|
||||
int
|
||||
fseek(FILE *f, long offset, int ptrname)
|
||||
{
|
||||
long p = -1; /* can't happen? */
|
||||
if(f && f->std_ops && STM_OP(f,seek))
|
||||
return STM_OP(f,seek)(f,offset,ptrname);
|
||||
f->_flag &= ~_IOEOF;
|
||||
if (f->_flag & _IOREAD)
|
||||
{
|
||||
if ((ptrname == SEEK_CUR) && f->_base && !(f->_flag & _IONBF))
|
||||
{
|
||||
offset += ftell(f);
|
||||
ptrname = SEEK_SET;
|
||||
}
|
||||
|
||||
if (f->_flag & _IORW)
|
||||
{
|
||||
f->_ptr = f->_base;
|
||||
f->_flag &= ~_IOREAD;
|
||||
}
|
||||
p = lseek(fileno(f), offset, ptrname);
|
||||
f->_cnt = 0;
|
||||
f->_ptr = f->_base;
|
||||
}
|
||||
else if (f->_flag & (_IOWRT|_IORW))
|
||||
{
|
||||
p = fflush(f);
|
||||
return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ?
|
||||
-1 : 0;
|
||||
}
|
||||
return p==-1 ? -1 : 0;
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
fsetpos(FILE *stream, const fpos_t *pos)
|
||||
{
|
||||
if (stream && pos)
|
||||
{
|
||||
fseek(stream, (long)(*pos), SEEK_SET);
|
||||
return 0;
|
||||
}
|
||||
errno = EFAULT;
|
||||
return 1;
|
||||
}
|
@@ -1,67 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <libc/stubs.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
#include <fcntl.h>
|
||||
#include <libc/dosio.h>
|
||||
|
||||
long
|
||||
ftell(FILE *f)
|
||||
{
|
||||
long tres;
|
||||
int adjust=0;
|
||||
int idx;
|
||||
|
||||
if (f->_cnt < 0)
|
||||
f->_cnt = 0;
|
||||
if (f->_flag&_IOREAD)
|
||||
{
|
||||
/* When reading files, the file position known by `lseek' is
|
||||
at the end of the buffered portion of the file. So `adjust'
|
||||
is negative (current buf position is BEFORE the one returned
|
||||
by `lseek') and, for TEXT files, it gets decremented (larger
|
||||
in absolute value) for every NL from current pos to the end
|
||||
of the buffer, to account for stripped CR characters. */
|
||||
adjust = - f->_cnt;
|
||||
|
||||
if (__file_handle_modes[f->_file] & O_TEXT) /* if a text file */
|
||||
{
|
||||
if (f->_cnt)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
/* For every char in buf AFTER current pos... */
|
||||
for (cp=f->_ptr + f->_cnt - 1; cp >= f->_ptr; cp--)
|
||||
if (*cp == '\n') /* ...if it's LF... */
|
||||
adjust--; /* ...there was a CR also */
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (f->_flag&(_IOWRT|_IORW))
|
||||
{
|
||||
/* When writing a file, the current file position known by `lseek'
|
||||
is at the beginning of the buffered portion of the file. We
|
||||
have to adjust it by our offset from the beginning of the buffer,
|
||||
and account for the CR characters which will be added by `write'. */
|
||||
if (f->_flag&_IOWRT && f->_base && (f->_flag&_IONBF)==0)
|
||||
{
|
||||
int lastidx = adjust = f->_ptr - f->_base;
|
||||
|
||||
if (__file_handle_modes[f->_file] & O_TEXT)
|
||||
for (idx=0; idx < lastidx; idx++)
|
||||
if (f->_base[idx] == '\n')
|
||||
adjust++;
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
if(f && f->std_ops && STM_OP(f,seek))
|
||||
tres=STM_OP(f,seek)(f,0,1);
|
||||
else
|
||||
tres = lseek(fileno(f), 0L, 1);
|
||||
if (tres<0)
|
||||
return tres;
|
||||
tres += adjust;
|
||||
return tres;
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
#include <libc/local.h>
|
||||
|
||||
void
|
||||
_fwalk(void (*func)(FILE *))
|
||||
{
|
||||
__file_rec *fr;
|
||||
int i;
|
||||
|
||||
for (fr=__file_rec_list; fr; fr=fr->next)
|
||||
for (i=0; i<fr->count; i++)
|
||||
if (fr->files[i]->_flag)
|
||||
func(fr->files[i]);
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
size_t
|
||||
fwrite(const void *vptr, size_t size, size_t count, FILE *f)
|
||||
{
|
||||
const char *ptr = (const char *)vptr;
|
||||
register int s;
|
||||
|
||||
s = size * count;
|
||||
|
||||
// __libclog_printf("fwrite(%x,%u,%u,%u)\n",vptr,size,count,f->_file);
|
||||
|
||||
if (f->_flag & _IOLBF)
|
||||
while (s > 0) {
|
||||
if (--f->_cnt > -f->_bufsiz && *(const char *)ptr != '\n')
|
||||
*f->_ptr++ = *(const char *)ptr++;
|
||||
else if (_flsbuf(*(const char *)ptr++, f) == EOF)
|
||||
break;
|
||||
s--;
|
||||
}
|
||||
else while (s > 0) {
|
||||
if (f->_cnt < s) {
|
||||
if (f->_cnt > 0) {
|
||||
memcpy(f->_ptr, ptr, f->_cnt);
|
||||
ptr += f->_cnt;
|
||||
f->_ptr += f->_cnt;
|
||||
s -= f->_cnt;
|
||||
}
|
||||
if (_flsbuf(*(const unsigned char *)ptr++, f) == EOF)
|
||||
break;
|
||||
s--;
|
||||
}
|
||||
if (f->_cnt >= s) {
|
||||
memcpy(f->_ptr, ptr, s);
|
||||
f->_ptr += s;
|
||||
f->_cnt -= s;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return size != 0 ? count - ((s + size - 1) / size) : 0;
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
int getc(FILE *f)
|
||||
{
|
||||
return fgetc(f);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <stdio.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
#undef getchar
|
||||
int getchar(void)
|
||||
{
|
||||
return fgetc(stdin);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user