/programs/develop/libraries/menuetlibc/src/libc/ansi/Makefile |
---|
0,0 → 1,40 |
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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/Makefile |
---|
0,0 → 1,3 |
THIS_SRCS = assert.c unimplemented.c debug.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/assert.c |
---|
0,0 → 1,11 |
#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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/debug.c |
---|
0,0 → 1,45 |
#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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/unimplemented.c |
---|
0,0 → 1,9 |
#include<assert.h> |
#include<menuet/os.h> |
void __dj_unimp(const char *fn) |
{ |
__libclog_printf(fn); |
exit(-1); |
for(;;); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/Makefile |
---|
0,0 → 1,5 |
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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_flags.c |
---|
0,0 → 1,263 |
/* 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 */ |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_lower.c |
---|
0,0 → 1,39 |
/* 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 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_upper.c |
---|
0,0 → 1,39 |
/* 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 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalnum.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isalnum)(int c) |
{ |
return isalnum(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalpha.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isalpha)(int c) |
{ |
return isalpha(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isascii.c |
---|
0,0 → 1,9 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/iscntrl.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (iscntrl)(int c) |
{ |
return iscntrl(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isdigit.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isdigit)(int c) |
{ |
return isdigit(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isgraph.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isgraph)(int c) |
{ |
return isgraph(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/islower.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (islower)(int c) |
{ |
return islower(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isprint.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isprint)(int c) |
{ |
return isprint(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ispunct.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (ispunct)(int c) |
{ |
return ispunct(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isspace.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isspace)(int c) |
{ |
return isspace(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isupper.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isupper)(int c) |
{ |
return isupper(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isxdigit.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (isxdigit)(int c) |
{ |
return isxdigit(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toascii.c |
---|
0,0 → 1,9 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/tolower.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (tolower)(int c) |
{ |
return tolower(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toupper.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <ctype.h> |
#include <inlines/ctype.ha> |
int (toupper)(int c) |
{ |
return toupper(c); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/Makefile |
---|
0,0 → 1,3 |
THIS_SRCS = errno.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/errno.c |
---|
0,0 → 1,6 |
int errno; |
int __isatty(int _fd) |
{ |
return 1; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/Makefile |
---|
0,0 → 1,4 |
THIS_SRCS = lconv.c mbcurmax.c mblen.c mbstowcs.c mbtowc.c setlocal.c \ |
wcstombs.c wctomb.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/lconv.c |
---|
0,0 → 1,32 |
/* 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_; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbcurmax.c |
---|
0,0 → 1,4 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
int __dj_mb_cur_max = 1; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mblen.c |
---|
0,0 → 1,15 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbstowcs.c |
---|
0,0 → 1,12 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbtowc.c |
---|
0,0 → 1,17 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/setlocal.c |
---|
0,0 → 1,13 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/wcstombs.c |
---|
0,0 → 1,12 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/wctomb.c |
---|
0,0 → 1,10 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/Makefile |
---|
0,0 → 1,6 |
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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acos.s |
---|
0,0 → 1,22 |
#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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acosh.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
double |
acosh(double x) |
{ |
return log(x + sqrt(x*x - 1)); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asin.s |
---|
0,0 → 1,14 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asinh.c |
---|
0,0 → 1,9 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan.s |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include<libc/asm.h> |
MK_C_SYM(atan) |
fldl 4(%esp) |
fld1 |
fpatan |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan2.s |
---|
0,0 → 1,35 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atanh.c |
---|
0,0 → 1,8 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ceil.s |
---|
0,0 → 1,24 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cos.s |
---|
0,0 → 1,15 |
#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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cosh.c |
---|
0,0 → 1,8 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/exp.s |
---|
0,0 → 1,31 |
#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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fabs.s |
---|
0,0 → 1,6 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include<libc/asm.h> |
MK_C_SYM(fabs) |
fldl 4(%esp) |
fabs |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/floor.s |
---|
0,0 → 1,24 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fmod.s |
---|
0,0 → 1,29 |
#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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/frexp.c |
---|
0,0 → 1,26 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/huge_val.c |
---|
0,0 → 1,4 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/ieee.h> |
double_t __dj_huge_val = { 0x00000, 0x00000, 0x7ff, 0x0 }; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/hypot.c |
---|
0,0 → 1,100 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ldexp.c |
---|
0,0 → 1,32 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/log.s |
---|
0,0 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include<libc/asm.h> |
MK_C_SYM(log) |
fldln2 |
fldl 4(%esp) |
fyl2x |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modf.s |
---|
0,0 → 1,33 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modfl.s |
---|
0,0 → 1,21 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow.s |
---|
0,0 → 1,86 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow10.s |
---|
0,0 → 1,32 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow2.s |
---|
0,0 → 1,30 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sin.s |
---|
0,0 → 1,16 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sinh.c |
---|
0,0 → 1,16 |
/* 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; |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sqrt.s |
---|
0,0 → 1,6 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include<libc/asm.h> |
MK_C_SYM(sqrt) |
fldl 4(%esp) |
fsqrt |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tan.s |
---|
0,0 → 1,16 |
/* 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tanh.c |
---|
0,0 → 1,17 |
/* 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); |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/Makefile |
---|
0,0 → 1,3 |
THIS_SRCS = longjmp.s setjmp.s |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/longjmp.s |
---|
0,0 → 1,64 |
# 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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/setjmp.s |
---|
0,0 → 1,44 |
#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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/Makefile |
---|
0,0 → 1,11 |
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 |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/_rename.c |
---|
0,0 → 1,11 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/allocfil.c |
---|
0,0 → 1,49 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/clearerr.c |
---|
0,0 → 1,10 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doprnt.c |
---|
0,0 → 1,840 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doscan.c |
---|
0,0 → 1,360 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fclose.c |
---|
0,0 → 1,39 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/feof.c |
---|
0,0 → 1,10 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ferror.c |
---|
0,0 → 1,9 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fflush.c |
---|
0,0 → 1,41 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetc.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int fgetc(FILE *f) |
{ |
return __getc(f); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetpos.c |
---|
0,0 → 1,14 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgets.c |
---|
0,0 → 1,18 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/filbuf.c |
---|
0,0 → 1,62 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/flsbuf.c |
---|
0,0 → 1,98 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fopen.c |
---|
0,0 → 1,74 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fprintf.c |
---|
0,0 → 1,28 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputc.c |
---|
0,0 → 1,8 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputs.c |
---|
0,0 → 1,34 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fread.c |
---|
0,0 → 1,39 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/freopen.c |
---|
0,0 → 1,66 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/frlist.c |
---|
0,0 → 1,11 |
/* 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; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fscanf.c |
---|
0,0 → 1,15 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fseek.c |
---|
0,0 → 1,40 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fsetpos.c |
---|
0,0 → 1,15 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ftell.c |
---|
0,0 → 1,67 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwalk.c |
---|
0,0 → 1,16 |
/* 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]); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwrite.c |
---|
0,0 → 1,45 |
/* 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; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getc.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int getc(FILE *f) |
{ |
return fgetc(f); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getchar.c |
---|
0,0 → 1,9 |
/* 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); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/gets.c |
---|
0,0 → 1,17 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
char * |
gets(char *s) |
{ |
int c; |
char *cs; |
cs = s; |
while ((c = getchar()) != '\n' && c != EOF) |
*cs++ = c; |
if (c == EOF && cs==s) |
return NULL; |
*cs++ = '\0'; |
return s; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getw.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int |
getw(FILE *f) |
{ |
int i; |
char *p; |
int w; |
p = (char *)&w; |
for (i=sizeof(int); --i>=0;) |
*p++ = getc(f); |
if (feof(f)) |
return EOF; |
return w; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/perror.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <string.h> |
#include <errno.h> |
void |
perror(const char *s) |
{ |
fprintf(stderr, "%s: %s\n", s, strerror(errno)); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/printf.c |
---|
0,0 → 1,15 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int |
printf(const char *fmt, ...) |
{ |
int len; |
va_list va; |
va_start(va, fmt); |
len = _doprnt(fmt, va, stdout); |
va_end(va); |
return ferror(stdout) ? EOF : len; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putc.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int putc(int c, FILE *fp) |
{ |
return fputc(c, fp); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putchar.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#undef putchar |
int |
putchar(int c) |
{ |
return fputc(c, stdout); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/puts.c |
---|
0,0 → 1,12 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
int |
puts(const char *s) |
{ |
int c; |
while ((c = *s++)) |
putchar(c); |
return putchar('\n'); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putw.c |
---|
0,0 → 1,15 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int |
putw(int w, FILE *f) |
{ |
char *p; |
int i; |
p = (char *)&w; |
for (i=sizeof(int); --i>=0;) |
putc(*p++, f); |
return ferror(f); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/remove.c |
---|
0,0 → 1,22 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <io.h> |
#include <stdio.h> |
#include <errno.h> |
#include <libc/dosio.h> |
#include <menuet/os.h> |
int remove(const char *fn) |
{ |
struct systree_info2 inf; |
int res; |
_fixpath(fn,inf.name); |
inf.command = 8; |
inf.file_offset_low = inf.file_offset_high = 0; |
inf.size = inf.data_pointer = 0; |
res = __kolibri__system_tree_access2(&inf); |
if (res == 0) return 0; |
if (res == 5) errno = ENOENT; |
else errno = EACCES; |
return -1; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rename.c |
---|
0,0 → 1,74 |
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
/* ------------------------- rename() for DJGPP -------------------------- */ |
/* |
* An implementation of rename() which can move both files AND |
* directories on the same filesystem (in the DOS world this means |
* the same logical drive). Most cases are simply passed to the |
* DOS Int 21h/AH=56h function. Special treatment is required for |
* renaming (moving) directories which don't share their parent |
* directory, because DOS won't allow this. This is called ``Prune |
* and graft'' operation. Most of the code below handles this |
* special case. It recursively creates subdirectories at the |
* target path, moves regular files there, then deletes the (empty) |
* directories at the source. |
* |
* An alternative (and much faster) implementation would be to access |
* the parent directories of the source and the target at the disk |
* sector level and rewrite them with BIOS calls. However, this won't |
* work for networked drives and will leave the file system in an |
* inconsistent state, should the machine crash before the operation |
* is completed. (A hybrid approach which uses the fast method when |
* possible and the slow one otherwise, is left as an exercise for the |
* ambitious readers. ;-) |
*/ |
#include <libc/stubs.h> |
#include <libc/bss.h> |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
#include <ctype.h> |
#include <errno.h> |
#include <io.h> |
#include <sys/stat.h> |
#include <dir.h> |
#include <fcntl.h> |
// \begin{diamond}[23.02.2007] |
// this is the only solution allowed by existing Kolibri system functions |
// it is better than nothing :) |
// But renaming of large files will be time-consuming operation... |
// and renaming of directories is impossible... |
int rename(const char *old, const char *new) |
{ |
int f1,f2; |
char* data; |
int bytes; |
f1 = dosemu_open(old,O_RDONLY); |
if (f1 < 0) {errno = ENOENT; return -1;} |
f2 = dosemu_open(new,O_WRONLY|O_CREAT|O_EXCL); |
if (f2 < 0) {dosemu_close(f1); errno = EACCES; return -1;} |
data = malloc(32768); |
if (!data) {dosemu_close(f2); dosemu_close(f1); errno = ENOMEM; return -1;} |
do |
{ |
bytes = dosemu_read(f1, data, 32768); |
if (bytes >= 0) |
bytes = dosemu_write(f2, data, bytes); |
} while (bytes == 32768); |
free(data); |
dosemu_close(f2); |
dosemu_close(f1); |
if (bytes == -1) |
{ |
errno = EACCES; |
return -1; |
} |
remove(old); |
return 0; |
} |
// \end{diamond}[23.02.2007] |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rewind.c |
---|
0,0 → 1,16 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <libc/file.h> |
void rewind(FILE *f) |
{ |
fflush(f); |
lseek(fileno(f), 0L, SEEK_SET); |
f->_cnt = 0; |
f->_ptr = f->_base; |
f->_flag &= ~(_IOERR|_IOEOF); |
if (f->_flag & _IORW) |
f->_flag &= ~(_IOREAD|_IOWRT); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/scanf.c |
---|
0,0 → 1,15 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdarg.h> |
#include <libc/file.h> |
int |
scanf(const char *fmt, ...) |
{ |
int r; |
va_list a=0; |
va_start(a, fmt); |
r = _doscan(stdin, fmt, a); |
va_end(a); |
return r; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuf.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdlib.h> |
#include <libc/file.h> |
void |
setbuf(FILE *f, char *buf) |
{ |
if (buf) |
setvbuf(f, buf, _IOFBF, BUFSIZ); |
else |
setvbuf(f, 0, _IONBF, BUFSIZ); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuffe.c |
---|
0,0 → 1,12 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <stdio.h> |
#include <stdlib.h> |
void setbuffer(FILE *f, void *buf, int size) |
{ |
if (buf) |
setvbuf(f, buf, _IOFBF, size); |
else |
setvbuf(f, 0, _IONBF, 0); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setlineb.c |
---|
0,0 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
void setlinebuf(FILE *f) |
{ |
setvbuf(f, 0, _IOLBF, BUFSIZ); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setvbuf.c |
---|
0,0 → 1,48 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdlib.h> |
#include <libc/file.h> |
int setvbuf(FILE *f, char *buf, int type, size_t len) |
{ |
int mine=0; |
if (!f) |
return -1; |
fflush(f); |
switch (type) |
{ |
case _IOFBF: |
case _IOLBF: |
if (len <= 0) |
return -1; |
if (buf == 0) |
{ |
buf = (char *)malloc(len); |
if (buf == 0) |
return -1; |
mine = 1; |
} |
case _IONBF: |
if (f->_base != NULL && f->_flag & _IOMYBUF) |
free(f->_base); |
f->_cnt = 0; |
f->_flag &= ~(_IONBF|_IOFBF|_IOLBF); |
f->_flag |= type; |
if (type != _IONBF) |
{ |
if (mine) |
f->_flag |= _IOMYBUF; |
f->_ptr = f->_base = buf; |
f->_bufsiz = len; |
} |
else |
{ |
f->_base = 0; |
f->_bufsiz = 0; |
} |
return 0; |
default: |
return -1; |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c |
---|
0,0 → 1,21 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <limits.h> |
#include <libc/file.h> |
int |
sprintf(char *str, const char *fmt, ...) |
{ |
FILE _strbuf; |
int len; |
va_list va; |
va_start(va, fmt); |
_strbuf._flag = _IOWRT|_IOSTRG; |
_strbuf._ptr = str; |
_strbuf._cnt = INT_MAX; |
len = _doprnt(fmt, va, &_strbuf); |
va_end(va); |
*_strbuf._ptr = 0; |
return len; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sscanf.c |
---|
0,0 → 1,25 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdarg.h> |
#include <libc/file.h> |
#include <libc/unconst.h> |
int |
sscanf(const char *str, const char *fmt, ...) |
{ |
int r; |
va_list a=0; |
FILE _strbuf; |
va_start(a, fmt); |
_strbuf._flag = _IOREAD|_IOSTRG; |
_strbuf._ptr = _strbuf._base = unconst(str, char *); |
_strbuf._cnt = 0; |
while (*str++) |
_strbuf._cnt++; |
_strbuf._bufsiz = _strbuf._cnt; |
r = _doscan(&_strbuf, fmt, a); |
va_end(a); |
return r; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdaux.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/stdiohk.h> |
FILE __dj_stdaux = { |
0, 0, 0, 0, |
_IORW | _IONBF, |
4 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stderr.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/stdiohk.h> |
FILE __dj_stderr = { |
0, 0, 0, 0, |
_IOWRT | _IONBF, |
2 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdin.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/stdiohk.h> |
FILE __dj_stdin = { |
0, 0, 0, 0, |
_IOREAD | _IOLBF, |
0 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdiohk.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/local.h> |
static void fcloseall_helper(FILE *f) |
{ |
fflush(f); |
if (fileno(f) > 2) |
fclose(f); |
} |
void __stdio_cleanup_proc(void) |
{ |
_fwalk(fcloseall_helper); |
} |
void (*__stdio_cleanup_hook)(void) = __stdio_cleanup_proc; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdout.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/stdiohk.h> |
FILE __dj_stdout = { |
0, 0, 0, 0, |
_IOWRT | _IOFBF, |
1 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdprn.c |
---|
0,0 → 1,10 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
#include <libc/stdiohk.h> |
FILE __dj_stdprn = { |
0, 0, 0, 0, |
_IOWRT | _IOLBF, |
3 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpfile.c |
---|
0,0 → 1,32 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
#include <fcntl.h> |
#include <libc/file.h> |
FILE * |
tmpfile(void) |
{ |
FILE *f; |
char *temp_name; |
char *n_t_r; |
temp_name = tmpnam(0); |
if (temp_name == 0) |
return 0; |
n_t_r = (char *)malloc(strlen(temp_name)+1); |
if (!n_t_r) |
return 0; |
f = fopen(temp_name, (_fmode & O_TEXT) ? "wt+" : "wb+"); |
if (f) |
{ |
f->_flag |= _IORMONCL; |
f->_name_to_remove = n_t_r; |
strcpy(f->_name_to_remove, temp_name); |
} |
return f; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpnam.c |
---|
0,0 → 1,71 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <string.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <errno.h> |
#include <libc/bss.h> |
static char *tmp_dir; |
static int tmp_len; |
static int tmp_bss_count = -1; |
static void |
try(const char *var) |
{ |
static char buf[L_tmpnam]; |
char *t = getenv(var); |
if (t == 0) |
return; |
tmp_len = strlen(t); |
strcpy(buf, t); |
if (buf[tmp_len - 1] != '/' && buf[tmp_len - 1] != '\\') |
buf[tmp_len++] = '/', buf[tmp_len] = 0; |
if (access(buf, D_OK)) |
return; |
tmp_dir = buf; |
} |
char * |
tmpnam(char *s) |
{ |
static char static_buf[L_tmpnam]; |
static char tmpcount[] = "dj000000"; |
int i; |
if (tmp_bss_count != __bss_count) |
{ |
tmp_bss_count = __bss_count; |
if (tmp_dir == 0) try("TMPDIR"); |
if (tmp_dir == 0) try("TEMP"); |
if (tmp_dir == 0) try("TMP"); |
if (tmp_dir == 0) |
{ |
static char def[] = "c:/"; |
tmp_dir = def; |
tmp_len = 3; |
} |
} |
if (!s) |
s = static_buf; |
strcpy(s, tmp_dir); |
do { |
/* increment the "count" starting at the first digit (backwards order) */ |
for (i=2; tmpcount[i] == '9' && i < 8; tmpcount[i] = '0', i++); |
if (i < 8) |
tmpcount[i]++; |
strcpy(s+tmp_len, tmpcount); |
} while (access(s, F_OK)==0); /* until file doesn't exist */ |
return s; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ungetc.c |
---|
0,0 → 1,26 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <libc/file.h> |
int |
ungetc(int c, FILE *f) |
{ |
if (c == EOF |
|| (f->_flag & (_IOREAD|_IORW)) == 0 |
|| f->_ptr == NULL |
|| f->_base == NULL) |
return EOF; |
if (f->_ptr == f->_base) |
{ |
if (f->_cnt == 0) |
f->_ptr++; |
else |
return EOF; |
} |
f->_cnt++; |
*--f->_ptr = c; |
return c; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vfprintf.c |
---|
0,0 → 1,27 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdarg.h> |
#include <libc/file.h> |
int |
vfprintf(FILE *f, const char *fmt, va_list ap) |
{ |
int len; |
char localbuf[BUFSIZ]; |
if (f->_flag & _IONBF) |
{ |
f->_flag &= ~_IONBF; |
f->_ptr = f->_base = localbuf; |
f->_bufsiz = BUFSIZ; |
len = _doprnt(fmt, ap, f); |
(void)fflush(f); |
f->_flag |= _IONBF; |
f->_base = NULL; |
f->_bufsiz = 0; |
f->_cnt = 0; |
} |
else |
len = _doprnt(fmt, ap, f); |
return (ferror(f) ? EOF : len); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vprintf.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdarg.h> |
#include <libc/file.h> |
int |
vprintf(const char *fmt, va_list ap) |
{ |
int len; |
len = _doprnt(fmt, ap, stdout); |
return (ferror(stdout) ? EOF : len); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vsprintf.c |
---|
0,0 → 1,19 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <stdarg.h> |
#include <limits.h> |
#include <libc/file.h> |
int |
vsprintf(char *str, const char *fmt, va_list ap) |
{ |
FILE f; |
int len; |
f._flag = _IOWRT|_IOSTRG; |
f._ptr = str; |
f._cnt = INT_MAX; |
len = _doprnt(fmt, ap, &f); |
*f._ptr = 0; |
return len; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/Makefile |
---|
0,0 → 1,5 |
THIS_SRCS = abort.c abs.c atexit.c atof.c atoi.c atol.c atold.c bsearch.c \ |
calloc.c div.c exit.c getenv.c labs.c ldiv.c malloc.c qsort.c \ |
rand.c strtod.c strtol.c strtold.c strtoul.c system.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abort.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <unistd.h> |
#include <io.h> |
#include <assert.h> |
static char msg[] = "Abort!\n"; |
void abort() |
{ |
__libclog_printf(msg); |
exit(-1); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abs.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
int |
abs(int j) |
{ |
return j<0 ? -j : j; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atexit.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <libc/atexit.h> |
int |
atexit(void (*a)(void)) |
{ |
struct __atexit *ap; |
if (a == 0) |
return -1; |
ap = (struct __atexit *)malloc(sizeof(struct __atexit)); |
if (!ap) |
return -1; |
ap->__next = __atexit_ptr; |
ap->__function = a; |
__atexit_ptr = ap; |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atof.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
double |
atof(const char *ascii) |
{ |
return strtod(ascii, 0); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atoi.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
int |
atoi(const char *str) |
{ |
return (int)strtol(str, 0, 10); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atol.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
long |
atol(const char *str) |
{ |
return strtol(str, 0, 10); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atold.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
long double |
_atold(const char *ascii) |
{ |
return _strtold(ascii, 0); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/bsearch.c |
---|
0,0 → 1,26 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <libc/unconst.h> |
void * |
bsearch(const void *key, const void *base0, size_t nelem, |
size_t size, int (*cmp)(const void *ck, const void *ce)) |
{ |
char *base = unconst(base0, char *); |
int lim, cmpval; |
void *p; |
for (lim = nelem; lim != 0; lim >>= 1) |
{ |
p = base + (lim >> 1) * size; |
cmpval = (*cmp)(key, p); |
if (cmpval == 0) |
return p; |
if (cmpval > 0) |
{ /* key > p: move right */ |
base = (char *)p + size; |
lim--; |
} /* else move left */ |
} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/calloc.c |
---|
0,0 → 1,12 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <string.h> |
void * |
calloc(size_t size, size_t nelem) |
{ |
void *rv = malloc(size*nelem); |
if (rv) |
memset(rv, 0, size*nelem); |
return rv; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/div.c |
---|
0,0 → 1,24 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
div_t |
div(int num, int denom) |
{ |
div_t r; |
if (num > 0 && denom < 0) { |
num = -num; |
denom = -denom; |
} |
r.quot = num / denom; |
r.rem = num % denom; |
if (num < 0 && denom > 0) |
{ |
if (r.rem > 0) |
{ |
r.quot++; |
r.rem -= denom; |
} |
} |
return r; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/exit.c |
---|
0,0 → 1,37 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <libc/stubs.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <dos.h> |
#include <io.h> |
#include <libc/atexit.h> |
struct __atexit *__atexit_ptr = 0; |
extern void (*__stdio_cleanup_hook)(void); |
/* typedef void (*FUNC)(void); |
extern FUNC djgpp_first_dtor[] __asm__("djgpp_first_dtor"); |
extern FUNC djgpp_last_dtor[] __asm__("djgpp_last_dtor"); */ |
int keypress_at_exit=0; |
void exit(int status) |
{ |
int i; |
struct __atexit *a = __atexit_ptr; |
// dosemu_atexit(); // <- this function is already in atexit list |
// (see crt1.c). - diamond |
/* if(keypress_at_exit) while(!__menuet__getkey()); */ |
while (a) |
{ |
(a->__function)(); |
a = a->__next; |
} |
/* if (__stdio_cleanup_hook) |
__stdio_cleanup_hook(); |
for (i=0; i<djgpp_last_dtor-djgpp_first_dtor; i++) |
djgpp_first_dtor[i]();*/ |
_exit(status); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/getenv.c |
---|
0,0 → 1,9 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <string.h> |
extern char * __libc_getenv(const char *name); // from crt0/env.c |
char * getenv(const char *name) |
{ |
return __libc_getenv(name); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/labs.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
long |
labs(long j) |
{ |
return j<0 ? -j : j; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/ldiv.c |
---|
0,0 → 1,25 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
ldiv_t |
ldiv(long num, long denom) |
{ |
ldiv_t r; |
if (num > 0 && denom < 0) |
{ |
num = -num; |
denom = -denom; |
} |
r.quot = num / denom; |
r.rem = num % denom; |
if (num < 0 && denom > 0) |
{ |
if (r.rem > 0) |
{ |
r.quot++; |
r.rem -= denom; |
} |
} |
return r; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/malloc.c |
---|
0,0 → 1,358 |
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <string.h> |
#include <unistd.h> |
#include <menuet/sem.h> |
typedef struct BLOCK { |
size_t size; |
struct BLOCK *next; |
int bucket; |
} BLOCK; |
#define BEFORE(bp) ((BLOCK *)((char *)bp - *(int *)((char *)bp - 4) - 8)) |
#define BEFSZ(bp) (*(size_t *)((char *)bp - 4)) |
#define ENDSZ(bp) (*(size_t *)((char *)bp + bp->size + 4)) |
#define AFTER(bp) ((BLOCK *)((char *)bp + bp->size + 8)) |
#define DATA(bp) ((char *)&(bp->next)) |
#define NUMSMALL 0 |
#define ALIGN 8 |
#define SMALL (NUMSMALL*ALIGN) |
DECLARE_STATIC_SEM(malloc_mutex) |
static BLOCK *slop = 0; |
static BLOCK *freelist[30]; |
#if NUMSMALL |
static BLOCK *smallblocks[NUMSMALL]; |
#endif |
static inline void malloc_lock(void) |
{ |
sem_lock(&malloc_mutex); |
} |
static inline void malloc_unlock(void) |
{ |
sem_unlock(&malloc_mutex); |
} |
#define MIN_SAVE_EXTRA 64 |
#define BIG_BLOCK 4096 |
#define DEBUG 0 |
#if DEBUG |
static void |
check(BLOCK *b) |
{ |
printf("check %08x %d %08x %d\n", b, b->size, &(ENDSZ(b)), ENDSZ(b)); |
} |
#define CHECK(p) do { check(p); assert(p->size == ENDSZ(p)); consistency(); } while (0) |
#define CHECK1(p) do { check(p); assert(p->size == ENDSZ(p)); } while (0) |
static void |
consistency() |
{ |
#if 0 |
int b; |
BLOCK *bl; |
if (slop) |
CHECK1(slop); |
for (b=0; b<32; b++) |
for (bl=freelist[b]; bl; bl=bl->next) |
CHECK1(bl); |
#endif |
} |
#else |
#define CHECK(p) |
#endif |
static inline int |
size2bucket(size_t size) |
{ |
int rv=0; |
size>>=2; |
while (size) |
{ |
rv++; |
size>>=1; |
} |
return rv; |
} |
static inline int |
b2bucket(BLOCK *b) |
{ |
if (b->bucket == -1) |
b->bucket = size2bucket(b->size); |
return b->bucket; |
} |
static inline BLOCK * |
split_block(BLOCK *b, size_t size) |
{ |
BLOCK *rv = (BLOCK *)((char *)b + size+8); |
#if DEBUG |
printf(" split %u/%08x to %u/%08x, %u/%08x\n", |
b->size, b, size, b, b->size - size - 8, rv); |
#endif |
rv->size = b->size - size - 8; |
rv->bucket = -1; |
b->size = size; |
ENDSZ(b) = b->size; |
ENDSZ(rv) = rv->size; |
CHECK(b); |
CHECK(rv); |
return rv; |
} |
#define RET(rv) CHECK(rv); ENDSZ(rv) |= 1; rv->size |= 1; return DATA(rv) |
void * malloc(size_t size) |
{ |
int b, chunk_size; |
BLOCK *rv, **prev; |
static BLOCK *expected_sbrk = 0; |
if (size<ALIGN) size = ALIGN; |
size = (size+(ALIGN-1))&~(ALIGN-1); |
#if DEBUG |
printf("malloc(%u)\n", size); |
#endif |
#if NUMSMALL |
if (size < SMALL) |
{ |
rv = smallblocks[size/ALIGN]; |
if (rv) |
{ |
smallblocks[size/ALIGN] = rv->next; |
return DATA(rv); |
} |
} |
#endif |
if (slop && slop->size >= size) |
{ |
rv = slop; |
#if DEBUG |
printf(" using slop %u/%08x\n", slop->size, slop); |
#endif |
if (slop->size >= size+MIN_SAVE_EXTRA) |
{ |
slop = split_block(slop, size); |
#if DEBUG |
printf(" remaining slop %u/%08x\n", slop->size, slop); |
#endif |
} |
else |
slop = 0; |
RET(rv); |
} |
b = size2bucket(size); |
prev = &(freelist[b]); |
for (rv=freelist[b]; rv; prev=&(rv->next), rv=rv->next) |
{ |
if (rv->size >= size && rv->size < size+size/4) |
{ |
*prev = rv->next; |
RET(rv); |
} |
} |
while (b < 30) |
{ |
prev = &(freelist[b]); |
#if DEBUG |
printf(" checking bucket %d\n", b); |
#endif |
for (rv=freelist[b]; rv; prev=&(rv->next), rv=rv->next) |
if (rv->size >= size) |
{ |
#if DEBUG |
printf(" found size %d/%08x\n", rv->size, rv); |
#endif |
*prev = rv->next; |
if (rv->size >= size+MIN_SAVE_EXTRA) |
{ |
#if DEBUG |
printf(" enough to save\n"); |
#endif |
if (slop) |
{ |
b = b2bucket(slop); |
#if DEBUG |
printf(" putting old slop %u/%08x on free list %d\n", |
slop->size, slop, b); |
#endif |
slop->next = freelist[b]; |
freelist[b] = slop; |
} |
slop = split_block(rv, size); |
#if DEBUG |
printf(" slop size %u/%08x\n", slop->size, slop); |
#endif |
} |
RET(rv); |
} |
b++; |
} |
chunk_size = size+16; /* two ends plus two placeholders */ |
rv = (BLOCK *)sbrk(chunk_size); |
if (rv == (BLOCK *)(-1)) |
return 0; |
#if DEBUG |
printf("sbrk(%d) -> %08x, expected %08x\n", chunk_size, rv, expected_sbrk); |
#endif |
if (rv == expected_sbrk) |
{ |
expected_sbrk = (BLOCK *)((char *)rv + chunk_size); |
/* absorb old end-block-marker */ |
#if DEBUG |
printf(" got expected sbrk\n"); |
#endif |
rv = (BLOCK *)((char *)rv - 4); |
} |
else |
{ |
expected_sbrk = (BLOCK *)((char *)rv + chunk_size); |
#if DEBUG |
printf(" disconnected sbrk\n"); |
#endif |
/* build start-block-marker */ |
rv->size = 1; |
rv = (BLOCK *)((char *)rv + 4); |
chunk_size -= 8; |
} |
rv->size = chunk_size - 8; |
ENDSZ(rv) = rv->size; |
AFTER(rv)->size = 1; |
CHECK(rv); |
RET(rv); |
} |
static inline BLOCK * |
merge(BLOCK *a, BLOCK *b, BLOCK *c) |
{ |
int bu; |
BLOCK *bp, **bpp; |
#if DEBUG |
printf(" merge %u/%08x + %u/%08x = %u\n", |
a->size, a, b->size, b, a->size+b->size+8); |
#endif |
CHECK(a); |
CHECK(b); |
CHECK(c); |
if (c == slop) |
{ |
#if DEBUG |
printf(" snipping slop %u/%08x\n", slop->size, slop); |
#endif |
slop = 0; |
} |
bu = b2bucket(c); |
#if DEBUG |
printf("bucket for %u/%08x is %d\n", c->size, c, bu); |
#endif |
bpp = freelist+bu; |
for (bp=freelist[bu]; bp; bpp=&(bp->next), bp=bp->next) |
{ |
#if DEBUG |
printf(" %08x", bp); |
#endif |
if (bp == c) |
{ |
#if DEBUG |
printf("\n snipping %u/%08x from freelist[%d]\n", bp->size, bp, bu); |
#endif |
*bpp = bp->next; |
break; |
} |
} |
CHECK(c); |
a->size += b->size + 8; |
a->bucket = -1; |
ENDSZ(a) = a->size; |
CHECK(a); |
return a; |
} |
void |
free(void *ptr) |
{ |
int b; |
BLOCK *block; |
if (ptr == 0) |
return; |
block = (BLOCK *)((char *)ptr-4); |
#if NUMSMALL |
if (block->size < SMALL) |
{ |
block->next = smallblocks[block->size/ALIGN]; |
smallblocks[block->size/ALIGN] = block; |
return; |
} |
#endif |
block->size &= ~1; |
ENDSZ(block) &= ~1; |
block->bucket = -1; |
#if DEBUG |
printf("free(%u/%08x)\n", block->size, block); |
#endif |
CHECK(block); |
if (! (AFTER(block)->size & 1)) |
{ |
CHECK(AFTER(block)); |
} |
if (! (BEFSZ(block) & 1)) |
{ |
CHECK(BEFORE(block)); |
block = merge(BEFORE(block), block, BEFORE(block)); |
} |
CHECK(block); |
if (! (AFTER(block)->size & 1)) |
{ |
CHECK(AFTER(block)); |
block = merge(block, AFTER(block), AFTER(block)); |
} |
CHECK(block); |
b = b2bucket(block); |
block->next = freelist[b]; |
freelist[b] = block; |
CHECK(block); |
} |
void * realloc(void *ptr, size_t size) |
{ |
BLOCK *b; |
char *newptr; |
size_t copysize; |
if (ptr == 0) return malloc(size); |
b = (BLOCK *)((char *)ptr-4); |
copysize = b->size & ~1; |
if (size <= copysize) |
{ |
return ptr; |
copysize = size; |
} |
newptr = (char *)malloc(size); |
if (!newptr) return NULL; |
memcpy(newptr, ptr, copysize); |
free(ptr); |
return newptr; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/qsort.c |
---|
0,0 → 1,238 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
/*- |
* Copyright (c) 1980, 1983 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that: (1) source distributions retain this entire copyright |
* notice and comment, and (2) distributions including binaries display |
* the following acknowledgement: ``This product includes software |
* developed by the University of California, Berkeley and its contributors'' |
* in the documentation or other materials provided with the distribution |
* and in all advertising materials mentioning features or use of this |
* software. Neither the name of the University nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
* qsort.c: |
* Our own version of the system qsort routine which is faster by an average |
* of 25%, with lows and highs of 10% and 50%. |
* The THRESHold below is the insertion sort threshold, and has been adjusted |
* for records of size 48 bytes. |
* The MTHREShold is where we stop finding a better median. |
*/ |
#define THRESH 4 /* threshold for insertion */ |
#define MTHRESH 6 /* threshold for median */ |
static int (*qcmp)(const void *, const void *); /* the comparison routine */ |
static int qsz; /* size of each record */ |
static int thresh; /* THRESHold in chars */ |
static int mthresh; /* MTHRESHold in chars */ |
/* |
* qst: |
* Do a quicksort |
* First, find the median element, and put that one in the first place as the |
* discriminator. (This "median" is just the median of the first, last and |
* middle elements). (Using this median instead of the first element is a big |
* win). Then, the usual partitioning/swapping, followed by moving the |
* discriminator into the right place. Then, figure out the sizes of the two |
* partions, do the smaller one recursively and the larger one via a repeat of |
* this code. Stopping when there are less than THRESH elements in a partition |
* and cleaning up with an insertion sort (in our caller) is a huge win. |
* All data swaps are done in-line, which is space-losing but time-saving. |
* (And there are only three places where this is done). |
*/ |
static void |
qst(char *base, char *max) |
{ |
char c, *i, *j, *jj; |
int ii; |
char *mid, *tmp; |
int lo, hi; |
/* |
* At the top here, lo is the number of characters of elements in the |
* current partition. (Which should be max - base). |
* Find the median of the first, last, and middle element and make |
* that the middle element. Set j to largest of first and middle. |
* If max is larger than that guy, then it's that guy, else compare |
* max with loser of first and take larger. Things are set up to |
* prefer the middle, then the first in case of ties. |
*/ |
lo = max - base; /* number of elements as chars */ |
do { |
mid = i = base + qsz * ((lo / qsz) >> 1); |
if (lo >= mthresh) |
{ |
j = (qcmp((jj = base), i) > 0 ? jj : i); |
if (qcmp(j, (tmp = max - qsz)) > 0) |
{ |
/* switch to first loser */ |
j = (j == jj ? i : jj); |
if (qcmp(j, tmp) < 0) |
j = tmp; |
} |
if (j != i) |
{ |
ii = qsz; |
do { |
c = *i; |
*i++ = *j; |
*j++ = c; |
} while (--ii); |
} |
} |
/* |
* Semi-standard quicksort partitioning/swapping |
*/ |
for (i = base, j = max - qsz; ; ) |
{ |
while (i < mid && qcmp(i, mid) <= 0) |
i += qsz; |
while (j > mid) |
{ |
if (qcmp(mid, j) <= 0) |
{ |
j -= qsz; |
continue; |
} |
tmp = i + qsz; /* value of i after swap */ |
if (i == mid) |
{ |
/* j <-> mid, new mid is j */ |
mid = jj = j; |
} |
else |
{ |
/* i <-> j */ |
jj = j; |
j -= qsz; |
} |
goto swap; |
} |
if (i == mid) |
{ |
break; |
} |
else |
{ |
/* i <-> mid, new mid is i */ |
jj = mid; |
tmp = mid = i; /* value of i after swap */ |
j -= qsz; |
} |
swap: |
ii = qsz; |
do { |
c = *i; |
*i++ = *jj; |
*jj++ = c; |
} while (--ii); |
i = tmp; |
} |
/* |
* Look at sizes of the two partitions, do the smaller |
* one first by recursion, then do the larger one by |
* making sure lo is its size, base and max are update |
* correctly, and branching back. But only repeat |
* (recursively or by branching) if the partition is |
* of at least size THRESH. |
*/ |
i = (j = mid) + qsz; |
if ((lo = j - base) <= (hi = max - i)) |
{ |
if (lo >= thresh) |
qst(base, j); |
base = i; |
lo = hi; |
} |
else |
{ |
if (hi >= thresh) |
qst(i, max); |
max = j; |
} |
} while (lo >= thresh); |
} |
/* |
* qsort: |
* First, set up some global parameters for qst to share. Then, quicksort |
* with qst(), and then a cleanup insertion sort ourselves. Sound simple? |
* It's not... |
*/ |
void |
qsort(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *)) |
{ |
char *base = (char *)base0; |
char c, *i, *j, *lo, *hi; |
char *min, *max; |
if (n <= 1) |
return; |
qsz = size; |
qcmp = compar; |
thresh = qsz * THRESH; |
mthresh = qsz * MTHRESH; |
max = base + n * qsz; |
if (n >= THRESH) |
{ |
qst(base, max); |
hi = base + thresh; |
} |
else |
{ |
hi = max; |
} |
/* |
* First put smallest element, which must be in the first THRESH, in |
* the first position as a sentinel. This is done just by searching |
* the first THRESH elements (or the first n if n < THRESH), finding |
* the min, and swapping it into the first position. |
*/ |
for (j = lo = base; (lo += qsz) < hi; ) |
if (qcmp(j, lo) > 0) |
j = lo; |
if (j != base) |
{ |
/* swap j into place */ |
for (i = base, hi = base + qsz; i < hi; ) |
{ |
c = *j; |
*j++ = *i; |
*i++ = c; |
} |
} |
/* |
* With our sentinel in place, we now run the following hyper-fast |
* insertion sort. For each remaining element, min, from [1] to [n-1], |
* set hi to the index of the element AFTER which this one goes. |
* Then, do the standard insertion sort shift on a character at a time |
* basis for each element in the frob. |
*/ |
for (min = base; (hi = min += qsz) < max; ) |
{ |
while (qcmp(hi -= qsz, min) > 0) |
/* void */; |
if ((hi += qsz) != min) { |
for (lo = min + qsz; --lo >= min; ) |
{ |
c = *lo; |
for (i = j = lo; (j -= qsz) >= hi; i = j) |
*i = *j; |
*i = c; |
} |
} |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/rand.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
static unsigned long long next = 0; |
int |
rand(void) |
{ |
next = next * 1103515245L + 12345; |
next = (next<<15) ^ (next >> 27); |
return (int)((next >> 4) & RAND_MAX); |
} |
void |
srand(unsigned seed) |
{ |
next = seed; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtod.c |
---|
0,0 → 1,96 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <math.h> |
#include <stdlib.h> |
#include <libc/unconst.h> |
double |
strtod(const char *s, char **sret) |
{ |
long double r; /* result */ |
int e; /* exponent */ |
long double d; /* scale */ |
int sign; /* +- 1.0 */ |
int esign; |
int i; |
int flags=0; |
r = 0.0; |
sign = 1.0; |
e = 0; |
esign = 1; |
while ((*s == ' ') || (*s == '\t')) |
s++; |
if (*s == '+') |
s++; |
else if (*s == '-') |
{ |
sign = -1; |
s++; |
} |
while ((*s >= '0') && (*s <= '9')) |
{ |
flags |= 1; |
r *= 10.0; |
r += *s - '0'; |
s++; |
} |
if (*s == '.') |
{ |
d = 0.1L; |
s++; |
while ((*s >= '0') && (*s <= '9')) |
{ |
flags |= 2; |
r += d * (*s - '0'); |
s++; |
d *= 0.1L; |
} |
} |
if (flags == 0) |
{ |
if (sret) |
*sret = unconst(s, char *); |
return 0; |
} |
if ((*s == 'e') || (*s == 'E')) |
{ |
s++; |
if (*s == '+') |
s++; |
else if (*s == '-') |
{ |
s++; |
esign = -1; |
} |
if ((*s < '0') || (*s > '9')) |
{ |
if (sret) |
*sret = unconst(s, char *); |
return r; |
} |
while ((*s >= '0') && (*s <= '9')) |
{ |
e *= 10; |
e += *s - '0'; |
s++; |
} |
} |
if (esign < 0) |
for (i = 1; i <= e; i++) |
r *= 0.1L; |
else |
for (i = 1; i <= e; i++) |
r *= 10.0; |
if (sret) |
*sret = unconst(s, char *); |
return r * sign; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtol.c |
---|
0,0 → 1,91 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <libc/unconst.h> |
long |
strtol(const char *nptr, char **endptr, int base) |
{ |
const char *s = nptr; |
unsigned long acc; |
int c; |
unsigned long cutoff; |
int neg = 0, any, cutlim; |
/* |
* Skip white space and pick up leading +/- sign if any. |
* If base is 0, allow 0x for hex and 0 for octal, else |
* assume decimal; if base is already 16, allow 0x. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') |
{ |
neg = 1; |
c = *s++; |
} |
else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) |
{ |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
/* |
* Compute the cutoff value between legal numbers and illegal |
* numbers. That is the largest legal value, divided by the |
* base. An input number that is greater than this value, if |
* followed by a legal input character, is too big. One that |
* is equal to this value may be valid or not; the limit |
* between valid and invalid numbers is then based on the last |
* digit. For instance, if the range for longs is |
* [-2147483648..2147483647] and the input base is 10, |
* cutoff will be set to 214748364 and cutlim to either |
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated |
* a value > 214748364, or equal but the next digit is > 7 (or 8), |
* the number is too big, and we will return a range error. |
* |
* Set any if any `digits' consumed; make it negative to indicate |
* overflow. |
*/ |
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; |
cutlim = cutoff % (unsigned long)base; |
cutoff /= (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) |
{ |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else |
{ |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) |
{ |
acc = neg ? LONG_MIN : LONG_MAX; |
errno = ERANGE; |
} |
else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); |
return acc; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtold.c |
---|
0,0 → 1,120 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <stdlib.h> |
#include <ctype.h> |
#include <libc/unconst.h> |
static long double powten[] = |
{ |
1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L, |
1e512L, 1e1024L, 1e2048L, 1e4096L |
}; |
long double |
_strtold(const char *s, char **sret) |
{ |
long double r; /* result */ |
int e, ne; /* exponent */ |
int sign; /* +- 1.0 */ |
int esign; |
int flags=0; |
int l2powm1; |
r = 0.0L; |
sign = 1; |
e = ne = 0; |
esign = 1; |
while(*s && isspace(*s)) |
s++; |
if (*s == '+') |
s++; |
else if (*s == '-') |
{ |
sign = -1; |
s++; |
} |
while ((*s >= '0') && (*s <= '9')) |
{ |
flags |= 1; |
r *= 10.0L; |
r += *s - '0'; |
s++; |
} |
if (*s == '.') |
{ |
s++; |
while ((*s >= '0') && (*s <= '9')) |
{ |
flags |= 2; |
r *= 10.0L; |
r += *s - '0'; |
s++; |
ne++; |
} |
} |
if (flags == 0) |
{ |
if (sret) |
*sret = unconst(s, char *); |
return 0.0L; |
} |
if ((*s == 'e') || (*s == 'E')) |
{ |
s++; |
if (*s == '+') |
s++; |
else if (*s == '-') |
{ |
s++; |
esign = -1; |
} |
while ((*s >= '0') && (*s <= '9')) |
{ |
e *= 10; |
e += *s - '0'; |
s++; |
} |
} |
if (esign < 0) |
{ |
esign = -esign; |
e = -e; |
} |
e = e - ne; |
if (e < -4096) |
{ |
/* possibly subnormal number, 10^e would overflow */ |
r *= 1.0e-2048L; |
e += 2048; |
} |
if (e < 0) |
{ |
e = -e; |
esign = -esign; |
} |
if (e >= 8192) |
e = 8191; |
if (e) |
{ |
long double d = 1.0L; |
l2powm1 = 0; |
while (e) |
{ |
if (e & 1) |
d *= powten[l2powm1]; |
e >>= 1; |
l2powm1++; |
} |
if (esign > 0) |
r *= d; |
else |
r /= d; |
} |
if (sret) |
*sret = unconst(s, char *); |
return r * sign; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtoul.c |
---|
0,0 → 1,75 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <libc/unconst.h> |
/* |
* Convert a string to an unsigned long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
unsigned long |
strtoul(const char *nptr, char **endptr, int base) |
{ |
const char *s = nptr; |
unsigned long acc; |
int c; |
unsigned long cutoff; |
int neg = 0, any, cutlim; |
/* |
* See strtol for comments as to the logic used. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') |
{ |
neg = 1; |
c = *s++; |
} |
else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) |
{ |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; |
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) |
{ |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) |
{ |
acc = ULONG_MAX; |
errno = ERANGE; |
} |
else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); |
return acc; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/system.c |
---|
0,0 → 1,18 |
#include <libc/stubs.h> |
#include <fcntl.h> |
#include <sys/stat.h> |
#include <unistd.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <ctype.h> |
#include <errno.h> |
#include <process.h> |
#include <libc/dosexec.h> |
#include <libc/unconst.h> |
#include <assert.h> |
int system (const char *cmdline) |
{ |
unimpl(); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/Makefile |
---|
0,0 → 1,6 |
THIS_SRCS = memchr.c memcmp.c memcpy.c memmove.s memset.s strcat.c \ |
strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strerror.c \ |
strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c \ |
strspn.c strstr.c strtok.c strxfrm.c syserr1.c syserr2.c syserr3.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memchr.c |
---|
0,0 → 1,18 |
#include<string.h> |
#include<libc/unconst.h> |
#include<assert.h> |
void * memchr(const void *s, int c, size_t n) |
{ |
int d0; |
register void * __res; |
if (!n) return NULL; |
__asm__ __volatile__( |
"repne\n\t" |
"scasb\n\t" |
"je 1f\n\t" |
"movl $1,%0\n" |
"1:\tdecl %0" |
:"=D" (__res), "=&c" (d0) : "a" (c),"0" (s),"1" (n)); |
return __res; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcmp.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
#include <assert.h> |
int |
memcmp(const void *s1, const void *s2, size_t n) |
{ |
if (n != 0) |
{ |
const unsigned char *p1 = s1, *p2 = s2; |
do { |
if (*p1++ != *p2++) |
return (*--p1 - *--p2); |
} while (--n != 0); |
} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcpy.c |
---|
0,0 → 1,23 |
#include<stdio.h> |
#include<stdlib.h> |
#include<string.h> |
void * memcpy(void * _dest, const void *_src, size_t _n) |
{ |
int d0, d1, d2; |
__asm__ __volatile__( |
"jcxz 1f\n\t" |
"rep ; movsl\n\t" |
"1:\t" |
"testb $2,%b4\n\t" |
"je 1f\n\t" |
"movsw\n" |
"1:\ttestb $1,%b4\n\t" |
"je 2f\n\t" |
"movsb\n" |
"2:" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
:"0" (_n/4), "q" (_n),"1" ((long)_dest),"2" ((long)_src) |
: "memory"); |
return (_dest); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memmove.s |
---|
0,0 → 1,33 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
.file "memmove.s" |
#include<libc/asm.h> |
MK_C_SYM(memmove) |
pushl %ebp |
movl %esp,%ebp |
pushl %esi |
pushl %edi |
movl 8(%ebp),%edi |
movl 12(%ebp),%esi |
movl 16(%ebp),%ecx |
jecxz L2 |
cld |
cmpl %esi,%edi |
jb L3 |
std |
addl %ecx,%esi |
addl %ecx,%edi |
decl %esi |
decl %edi |
L3: |
rep |
movsb |
L2: |
cld |
popl %edi |
popl %esi |
movl 8(%ebp),%eax |
leave |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memset.s |
---|
0,0 → 1,51 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include<libc/asm.h> |
.file "memset.s" |
.text |
.align 4 |
MK_C_SYM(memset) |
pushl %ebp |
movl %esp,%ebp |
pushl %edi |
movl 8(%ebp),%edi |
movl 12(%ebp),%eax |
movl 16(%ebp),%ecx |
cld |
# We will handle memsets of <= 15 bytes one byte at a time. |
# This avoids some extra overhead for small memsets, and |
# knowing we are setting > 15 bytes eliminates some annoying |
# checks in the "long move" case. |
cmpl $15,%ecx |
jle L3 |
# Otherwise, tile the byte value out into %eax. |
# 0x41 -> 0x41414141, etc. |
movb %al,%ah |
movl %eax,%edx |
sall $16,%eax |
movw %dx,%ax |
jmp L2 |
# Handle any cruft necessary to get %edi long-aligned. |
L1: stosb |
decl %ecx |
L2: testl $3,%edi |
jnz L1 |
# Now slam out all of the longs. |
movl %ecx,%edx |
shrl $2,%ecx |
rep |
stosl |
# Finally, handle any trailing cruft. We know the high three bytes |
# of %ecx must be zero, so just put the "slop count" in the low byte. |
movb %dl,%cl |
andb $3,%cl |
L3: rep |
stosb |
popl %edi |
movl 8(%ebp),%eax |
leave |
ret |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcat.c |
---|
0,0 → 1,17 |
#include <string.h> |
char * strcat(char *s, const char *append) |
{ |
int d0, d1, d2, d3; |
__asm__ __volatile__( |
"repne\n\t" |
"scasb\n\t" |
"decl %1\n" |
"1:\tlodsb\n\t" |
"stosb\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b" |
: "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) |
: "0" (append),"1"(s),"2"(0),"3" (0xffffffff):"memory"); |
return s; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strchr.c |
---|
0,0 → 1,20 |
#include <string.h> |
#include <libc/unconst.h> |
char * strchr(const char *s, int c) |
{ |
int d0; |
register char * __res; |
__asm__ __volatile__( |
"movb %%al,%%ah\n" |
"1:\tlodsb\n\t" |
"cmpb %%ah,%%al\n\t" |
"je 2f\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b\n\t" |
"movl $1,%1\n" |
"2:\tmovl %1,%0\n\t" |
"decl %0" |
:"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); |
return __res; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcmp.c |
---|
0,0 → 1,21 |
#include <string.h> |
int strcmp(const char *s1, const char *s2) |
{ |
int d0, d1; |
register int __res; |
__asm__ __volatile__( |
"1:\tlodsb\n\t" |
"scasb\n\t" |
"jne 2f\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b\n\t" |
"xorl %%eax,%%eax\n\t" |
"jmp 3f\n" |
"2:\tsbbl %%eax,%%eax\n\t" |
"orb $1,%%al\n" |
"3:" |
:"=a" (__res), "=&S" (d0), "=&D" (d1) |
:"1" (s1),"2" (s2)); |
return __res; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcoll.c |
---|
0,0 → 1,8 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
int |
strcoll(const char *s1, const char *s2) |
{ |
return strcmp(s1, s2); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcpy.c |
---|
0,0 → 1,15 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
char * strcpy(char *to, const char *from) |
{ |
int d0, d1, d2; |
__asm__ __volatile__( |
"1:\tlodsb\n\t" |
"stosb\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b" |
: "=&S" (d0), "=&D" (d1), "=&a" (d2) |
:"0" (from),"1" (to) : "memory"); |
return to; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcspn.c |
---|
0,0 → 1,20 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
size_t |
strcspn(const char *s1, const char *s2) |
{ |
const char *p, *spanp; |
char c, sc; |
for (p = s1;;) |
{ |
c = *p++; |
spanp = s2; |
do { |
if ((sc = *spanp++) == c) |
return p - 1 - s1; |
} while (sc != 0); |
} |
/* NOTREACHED */ |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strerror.c |
---|
0,0 → 1,37 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <stdio.h> |
#include <string.h> |
#include <errno.h> |
#include <libc/unconst.h> |
char * |
strerror(int errnum) |
{ |
static char ebuf[40]; /* 64-bit number + slop */ |
char *cp; |
int v=1000000, lz=0; |
if (errnum >= 0 && errnum < __sys_nerr) |
return(unconst(__sys_errlist[errnum], char *)); |
strcpy(ebuf, "Unknown error: "); |
cp = ebuf + 15; |
if (errnum < 0) |
{ |
*cp++ = '-'; |
errnum = -errnum; |
} |
while (v) |
{ |
int d = errnum / v; |
if (d || lz || (v == 1)) |
{ |
*cp++ = d+'0'; |
lz = 1; |
} |
errnum %= v; |
v /= 10; |
} |
return ebuf; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strlen.c |
---|
0,0 → 1,15 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
size_t strlen(const char *str) |
{ |
int d0; |
register int __res; |
__asm__ __volatile__( |
"repne\n\t" |
"scasb\n\t" |
"notl %0\n\t" |
"decl %0" |
:"=c" (__res), "=&D" (d0) :"1" (str),"a" (0), "0" (0xffffffff)); |
return __res; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncat.c |
---|
0,0 → 1,24 |
#include <string.h> |
char * |
strncat(char *dst, const char *src, size_t n) |
{ |
int d0, d1, d2, d3; |
__asm__ __volatile__( |
"repne\n\t" |
"scasb\n\t" |
"decl %1\n\t" |
"movl %8,%3\n" |
"1:\tdecl %3\n\t" |
"js 2f\n\t" |
"lodsb\n\t" |
"stosb\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b\n" |
"2:\txorl %2,%2\n\t" |
"stosb" |
: "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) |
: "0" (src),"1" (dst),"2" (0),"3" (0xffffffff), "g" (n) |
: "memory"); |
return dst; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncmp.c |
---|
0,0 → 1,24 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
int strncmp(const char *s1, const char *s2, size_t n) |
{ |
register int __res; |
int d0, d1, d2; |
__asm__ __volatile__( |
"1:\tdecl %3\n\t" |
"js 2f\n\t" |
"lodsb\n\t" |
"scasb\n\t" |
"jne 3f\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b\n" |
"2:\txorl %%eax,%%eax\n\t" |
"jmp 4f\n" |
"3:\tsbbl %%eax,%%eax\n\t" |
"orb $1,%%al\n" |
"4:" |
:"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) |
:"1" (s1),"2" (s2),"3" (n)); |
return __res; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncpy.c |
---|
0,0 → 1,20 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
char * strncpy(char *dst, const char *src, size_t n) |
{ |
int d0, d1, d2, d3; |
__asm__ __volatile__( |
"1:\tdecl %2\n\t" |
"js 2f\n\t" |
"lodsb\n\t" |
"stosb\n\t" |
"testb %%al,%%al\n\t" |
"jne 1b\n\t" |
"rep\n\t" |
"stosb\n" |
"2:" |
: "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) |
:"0" (src),"1" (dst),"2" (n) : "memory"); |
return dst; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strpbrk.c |
---|
0,0 → 1,18 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
#include <libc/unconst.h> |
char * |
strpbrk(const char *s1, const char *s2) |
{ |
const char *scanp; |
int c, sc; |
while ((c = *s1++) != 0) |
{ |
for (scanp = s2; (sc = *scanp++) != 0;) |
if (sc == c) |
return unconst(s1 - 1, char *); |
} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strrchr.c |
---|
0,0 → 1,21 |
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
#include <libc/unconst.h> |
char * |
strrchr(const char *s, int c) |
{ |
char cc = c; |
const char *sp=(char *)0; |
while (*s) |
{ |
if (*s == cc) |
sp = s; |
s++; |
} |
if (cc == 0) |
sp = s; |
return unconst(sp, char *); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strspn.c |
---|
0,0 → 1,16 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
size_t |
strspn(const char *s1, const char *s2) |
{ |
const char *p = s1, *spanp; |
char c, sc; |
cont: |
c = *p++; |
for (spanp = s2; (sc = *spanp++) != 0;) |
if (sc == c) |
goto cont; |
return (p - 1 - s1); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strstr.c |
---|
0,0 → 1,23 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
#include <libc/unconst.h> |
char * |
strstr(const char *s, const char *find) |
{ |
char c, sc; |
size_t len; |
if ((c = *find++) != 0) |
{ |
len = strlen(find); |
do { |
do { |
if ((sc = *s++) == 0) |
return 0; |
} while (sc != c); |
} while (strncmp(s, find, len) != 0); |
s--; |
} |
return unconst(s, char *); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strtok.c |
---|
0,0 → 1,51 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
char * |
strtok(char *s, const char *delim) |
{ |
const char *spanp; |
int c, sc; |
char *tok; |
static char *last; |
if (s == NULL && (s = last) == NULL) |
return (NULL); |
/* |
* Skip (span) leading delimiters (s += strspn(s, delim), sort of). |
*/ |
cont: |
c = *s++; |
for (spanp = delim; (sc = *spanp++) != 0;) { |
if (c == sc) |
goto cont; |
} |
if (c == 0) { /* no non-delimiter characters */ |
last = NULL; |
return (NULL); |
} |
tok = s - 1; |
/* |
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of). |
* Note that delim must have one NUL; we stop if we see that, too. |
*/ |
for (;;) { |
c = *s++; |
spanp = delim; |
do { |
if ((sc = *spanp++) == c) { |
if (c == 0) |
s = NULL; |
else |
s[-1] = 0; |
last = s; |
return (tok); |
} |
} while (sc != 0); |
} |
/* NOTREACHED */ |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strxfrm.c |
---|
0,0 → 1,28 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
size_t |
strxfrm(dst, src, n) |
char *dst; |
const char *src; |
size_t n; |
{ |
size_t r = 0; |
int c; |
if (n != 0) { |
while ((c = *src++) != 0) |
{ |
r++; |
if (--n == 0) |
{ |
while (*src++ != 0) |
r++; |
break; |
} |
*dst++ = c; |
} |
*dst = 0; |
} |
return r; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.c |
---|
0,0 → 1,42 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include "syserr1.h" |
char __syserr00[] = "No Error"; |
char __syserr01[] = "Input to function out of range (EDOM)"; |
char __syserr02[] = "Output of function out of range (ERANGE)"; |
char __syserr03[] = "Argument list too long (E2BIG)"; |
char __syserr04[] = "Permission denied (EACCES)"; |
char __syserr05[] = "Resource temporarily unavailable (EAGAIN)"; |
char __syserr06[] = "Bad file descriptor (EBADF)"; |
char __syserr07[] = "Resource busy (EBUSY)"; |
char __syserr08[] = "No child processes (ECHILD)"; |
char __syserr09[] = "Resource deadlock avoided (EDEADLK)"; |
char __syserr10[] = "File exists (EEXIST)"; |
char __syserr11[] = "Bad address (EFAULT)"; |
char __syserr12[] = "File too large (EFBIG)"; |
char __syserr13[] = "Interrupted system call (EINTR)"; |
char __syserr14[] = "Invalid argument (EINVAL)"; |
char __syserr15[] = "Input or output error (EIO)"; |
char __syserr16[] = "Is a directory (EISDIR)"; |
char __syserr17[] = "Too many open files (EMFILE)"; |
char __syserr18[] = "Too many links (EMLINK)"; |
char __syserr19[] = "File name too long (ENAMETOOLONG)"; |
char __syserr20[] = "Too many open files in system (ENFILE)"; |
char __syserr21[] = "No such device (ENODEV)"; |
char __syserr22[] = "No such file or directory (ENOENT)"; |
char __syserr23[] = "Unable to execute file (ENOEXEC)"; |
char __syserr24[] = "No locks available (ENOLCK)"; |
char __syserr25[] = "Not enough memory (ENOMEM)"; |
char __syserr26[] = "No space left on drive (ENOSPC)"; |
char __syserr27[] = "Function not implemented (ENOSYS)"; |
char __syserr28[] = "Not a directory (ENOTDIR)"; |
char __syserr29[] = "Directory not empty (ENOTEMPTY)"; |
char __syserr30[] = "Inappropriate I/O control operation (ENOTTY)"; |
char __syserr31[] = "No such device or address (ENXIO)"; |
char __syserr32[] = "Operation not permitted (EPERM)"; |
char __syserr33[] = "Broken pipe (EPIPE)"; |
char __syserr34[] = "Read-only file system (EROFS)"; |
char __syserr35[] = "Invalid seek (ESPIPE)"; |
char __syserr36[] = "No such process (ESRCH)"; |
char __syserr37[] = "Improper link (EXDEV)"; |
char __syserr38[] = "No more files (ENMFILE)"; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.h |
---|
0,0 → 1,40 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
extern char __syserr00[]; |
extern char __syserr01[]; |
extern char __syserr02[]; |
extern char __syserr03[]; |
extern char __syserr04[]; |
extern char __syserr05[]; |
extern char __syserr06[]; |
extern char __syserr07[]; |
extern char __syserr08[]; |
extern char __syserr09[]; |
extern char __syserr10[]; |
extern char __syserr11[]; |
extern char __syserr12[]; |
extern char __syserr13[]; |
extern char __syserr14[]; |
extern char __syserr15[]; |
extern char __syserr16[]; |
extern char __syserr17[]; |
extern char __syserr18[]; |
extern char __syserr19[]; |
extern char __syserr20[]; |
extern char __syserr21[]; |
extern char __syserr22[]; |
extern char __syserr23[]; |
extern char __syserr24[]; |
extern char __syserr25[]; |
extern char __syserr26[]; |
extern char __syserr27[]; |
extern char __syserr28[]; |
extern char __syserr29[]; |
extern char __syserr30[]; |
extern char __syserr31[]; |
extern char __syserr32[]; |
extern char __syserr33[]; |
extern char __syserr34[]; |
extern char __syserr35[]; |
extern char __syserr36[]; |
extern char __syserr37[]; |
extern char __syserr38[]; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr2.c |
---|
0,0 → 1,16 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <errno.h> |
#include "syserr1.h" |
const char *__sys_errlist[] = { |
__syserr00, __syserr01, __syserr02, __syserr03, __syserr04, |
__syserr05, __syserr06, __syserr07, __syserr08, __syserr09, |
__syserr10, __syserr11, __syserr12, __syserr13, __syserr14, |
__syserr15, __syserr16, __syserr17, __syserr18, __syserr19, |
__syserr20, __syserr21, __syserr22, __syserr23, __syserr24, |
__syserr25, __syserr26, __syserr27, __syserr28, __syserr29, |
__syserr30, __syserr31, __syserr32, __syserr33, __syserr34, |
__syserr35, __syserr36, __syserr37, __syserr38 |
}; |
int __sys_nerr = sizeof(__sys_errlist) / sizeof(__sys_errlist[0]); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr3.c |
---|
0,0 → 1,16 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <errno.h> |
#include "syserr1.h" |
char *sys_errlist[] = { |
__syserr00, __syserr01, __syserr02, __syserr03, __syserr04, |
__syserr05, __syserr06, __syserr07, __syserr08, __syserr09, |
__syserr10, __syserr11, __syserr12, __syserr13, __syserr14, |
__syserr15, __syserr16, __syserr17, __syserr18, __syserr19, |
__syserr20, __syserr21, __syserr22, __syserr23, __syserr24, |
__syserr25, __syserr26, __syserr27, __syserr28, __syserr29, |
__syserr30, __syserr31, __syserr32, __syserr33, __syserr34, |
__syserr35, __syserr36, __syserr37, __syserr38 |
}; |
int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/Makefile |
---|
0,0 → 1,4 |
THIS_SRCS = ctime.c difftime.c strftime.c time.c |
include $(MENUET_LIBC_TOPDIR)/Make.rules |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/ctime.c |
---|
0,0 → 1,1197 |
#include <libc/stubs.h> |
#include <fcntl.h> |
#include <time.h> |
#include <string.h> |
#include <ctype.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <tzfile.h> |
#include <libc/unconst.h> |
#include "posixrul.h" |
#define P(s) s |
#define alloc_size_t size_t |
#define qsort_size_t size_t |
#define fread_size_t size_t |
#define fwrite_size_t size_t |
#define ACCESS_MODE O_RDONLY|O_BINARY |
#define OPEN_MODE O_RDONLY|O_BINARY |
static char WILDABBR[] = " "; |
#ifndef TRUE |
#define TRUE 1 |
#define FALSE 0 |
#endif /* !defined TRUE */ |
static const char GMT[] = "GMT"; |
struct ttinfo { /* time type information */ |
long tt_gmtoff; /* GMT offset in seconds */ |
int tt_isdst; /* used to set tm_isdst */ |
int tt_abbrind; /* abbreviation list index */ |
int tt_ttisstd; /* TRUE if transition is std time */ |
}; |
struct lsinfo { /* leap second information */ |
time_t ls_trans; /* transition time */ |
long ls_corr; /* correction to apply */ |
}; |
struct state { |
int leapcnt; |
int timecnt; |
int typecnt; |
int charcnt; |
time_t ats[TZ_MAX_TIMES]; |
unsigned char types[TZ_MAX_TIMES]; |
struct ttinfo ttis[TZ_MAX_TYPES]; |
char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? TZ_MAX_CHARS + 1 : sizeof GMT]; |
struct lsinfo lsis[TZ_MAX_LEAPS]; |
}; |
struct rule { |
int r_type; /* type of rule--see below */ |
int r_day; /* day number of rule */ |
int r_week; /* week number of rule */ |
int r_mon; /* month number of rule */ |
long r_time; /* transition time of rule */ |
}; |
#define JULIAN_DAY 0 /* Jn - Julian day */ |
#define DAY_OF_YEAR 1 /* n - day of year */ |
#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ |
/* |
** Prototypes for static functions. |
*/ |
static long detzcode P((const char * codep)); |
static const char * getzname P((const char * strp)); |
static const char * getnum P((const char * strp, int * nump, int min, |
int max)); |
static const char * getsecs P((const char * strp, long * secsp)); |
static const char * getoffset P((const char * strp, long * offsetp)); |
static const char * getrule P((const char * strp, struct rule * rulep)); |
static void gmtload P((struct state * sp)); |
static void gmtsub P((const time_t * timep, long offset, |
struct tm * tmp)); |
static void localsub P((const time_t * timep, long offset, |
struct tm * tmp)); |
static void normalize P((int * tensptr, int * unitsptr, int base)); |
static void settzname P((void)); |
static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * const, const long, struct tm * const), |
long offset)); |
static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * const, const long, struct tm * const), |
long offset, int * okayp)); |
static void timesub P((const time_t * timep, long offset, |
const struct state * sp, struct tm * tmp)); |
static int tmcomp P((const struct tm * atmp, |
const struct tm * btmp)); |
static time_t transtime P((time_t janfirst, int year, |
const struct rule * rulep, long offset)); |
static int tzparse P((const char * name, struct state * sp, |
int lastditch)); |
//static void tzsetwall(void); |
#ifdef ALL_STATE |
static struct state *lclptr; |
static struct state *gmtptr; |
#endif /* defined ALL_STATE */ |
#ifndef ALL_STATE |
static struct state lclmem; |
static struct state gmtmem; |
#define lclptr (&lclmem) |
#define gmtptr (&gmtmem) |
#endif /* State Farm */ |
static int lcl_is_set; |
static int gmt_is_set; |
char * tzname[2] = { |
WILDABBR, |
WILDABBR |
}; |
static long |
detzcode(const char * const codep) |
{ |
long result; |
int i; |
result = 0; |
for (i = 0; i < 4; ++i) |
result = (result << 8) | (codep[i] & 0xff); |
return result; |
} |
static void |
settzname(void) |
{ |
const struct state * const sp = lclptr; |
int i; |
tzname[0] = WILDABBR; |
tzname[1] = WILDABBR; |
#ifdef ALL_STATE |
if (sp == NULL) |
{ |
tzname[0] = tzname[1] = GMT; |
return; |
} |
#endif /* defined ALL_STATE */ |
for (i = 0; i < sp->typecnt; ++i) |
{ |
register const struct ttinfo * const ttisp = &sp->ttis[i]; |
tzname[ttisp->tt_isdst] = |
unconst(&sp->chars[ttisp->tt_abbrind], char *); |
#if 0 |
if (ttisp->tt_isdst) |
_daylight = 1; |
if (i == 0 || !ttisp->tt_isdst) |
_timezone = -(ttisp->tt_gmtoff); |
if (i == 0 || ttisp->tt_isdst) |
_altzone = -(ttisp->tt_gmtoff); |
#endif |
} |
/* |
** And to get the latest zone names into tzname. . . |
*/ |
for (i = 0; i < sp->timecnt; ++i) |
{ |
const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]]; |
tzname[ttisp->tt_isdst] = unconst(&sp->chars[ttisp->tt_abbrind], char *); |
} |
} |
static const int mon_lengths[2][MONSPERYEAR] = { |
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, |
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } |
}; |
static const int year_lengths[2] = { |
DAYSPERNYEAR, DAYSPERLYEAR |
}; |
/* |
** Given a pointer into a time zone string, scan until a character that is not |
** a valid character in a zone name is found. Return a pointer to that |
** character. |
*/ |
static const char * |
getzname(const char *strp) |
{ |
char c; |
while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && |
c != '+') |
++strp; |
return strp; |
} |
/* |
** Given a pointer into a time zone string, extract a number from that string. |
** Check that the number is within a specified range; if it is not, return |
** NULL. |
** Otherwise, return a pointer to the first character not part of the number. |
*/ |
static const char * |
getnum(const char *strp, int * const nump, const int min, const int max) |
{ |
char c; |
int num; |
if (strp == NULL || !isdigit(*strp)) |
return NULL; |
num = 0; |
while ((c = *strp) != '\0' && isdigit(c)) |
{ |
num = num * 10 + (c - '0'); |
if (num > max) |
return NULL; |
++strp; |
} |
if (num < min) |
return NULL; |
*nump = num; |
return strp; |
} |
/* |
** Given a pointer into a time zone string, extract a number of seconds, |
** in hh[:mm[:ss]] form, from the string. |
** If any error occurs, return NULL. |
** Otherwise, return a pointer to the first character not part of the number |
** of seconds. |
*/ |
static const char * |
getsecs(const char *strp, long * const secsp) |
{ |
int num; |
strp = getnum(strp, &num, 0, HOURSPERDAY); |
if (strp == NULL) |
return NULL; |
*secsp = num * SECSPERHOUR; |
if (*strp == ':') |
{ |
++strp; |
strp = getnum(strp, &num, 0, MINSPERHOUR - 1); |
if (strp == NULL) |
return NULL; |
*secsp += num * SECSPERMIN; |
if (*strp == ':') |
{ |
++strp; |
strp = getnum(strp, &num, 0, SECSPERMIN - 1); |
if (strp == NULL) |
return NULL; |
*secsp += num; |
} |
} |
return strp; |
} |
/* |
** Given a pointer into a time zone string, extract an offset, in |
** [+-]hh[:mm[:ss]] form, from the string. |
** If any error occurs, return NULL. |
** Otherwise, return a pointer to the first character not part of the time. |
*/ |
static const char * |
getoffset(const char *strp, long * const offsetp) |
{ |
int neg; |
if (*strp == '-') |
{ |
neg = 1; |
++strp; |
} |
else if (isdigit(*strp) || *strp++ == '+') |
neg = 0; |
else |
return NULL; /* illegal offset */ |
strp = getsecs(strp, offsetp); |
if (strp == NULL) |
return NULL; /* illegal time */ |
if (neg) |
*offsetp = -*offsetp; |
return strp; |
} |
/* |
** Given a pointer into a time zone string, extract a rule in the form |
** date[/time]. See POSIX section 8 for the format of "date" and "time". |
** If a valid rule is not found, return NULL. |
** Otherwise, return a pointer to the first character not part of the rule. |
*/ |
static const char * |
getrule(const char *strp, struct rule * const rulep) |
{ |
if (*strp == 'J') |
{ |
/* |
** Julian day. |
*/ |
rulep->r_type = JULIAN_DAY; |
++strp; |
strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); |
} |
else if (*strp == 'M') |
{ |
/* |
** Month, week, day. |
*/ |
rulep->r_type = MONTH_NTH_DAY_OF_WEEK; |
++strp; |
strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); |
if (strp == NULL) |
return NULL; |
if (*strp++ != '.') |
return NULL; |
strp = getnum(strp, &rulep->r_week, 1, 5); |
if (strp == NULL) |
return NULL; |
if (*strp++ != '.') |
return NULL; |
strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); |
} |
else if (isdigit(*strp)) |
{ |
/* |
** Day of year. |
*/ |
rulep->r_type = DAY_OF_YEAR; |
strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); |
} |
else |
return NULL; /* invalid format */ |
if (strp == NULL) |
return NULL; |
if (*strp == '/') |
{ |
/* |
** Time specified. |
*/ |
++strp; |
strp = getsecs(strp, &rulep->r_time); |
} |
else |
rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ |
return strp; |
} |
/* |
** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the |
** year, a rule, and the offset from GMT at the time that rule takes effect, |
** calculate the Epoch-relative time that rule takes effect. |
*/ |
static time_t |
transtime(const time_t janfirst, const int year, const struct rule * const rulep, const long offset) |
{ |
int leapyear; |
time_t value=0; |
int i; |
int d, m1, yy0, yy1, yy2, dow; |
leapyear = isleap(year); |
switch (rulep->r_type) |
{ |
case JULIAN_DAY: |
/* |
** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap |
** years. |
** In non-leap years, or if the day number is 59 or less, just |
** add SECSPERDAY times the day number-1 to the time of |
** January 1, midnight, to get the day. |
*/ |
value = janfirst + (rulep->r_day - 1) * SECSPERDAY; |
if (leapyear && rulep->r_day >= 60) |
value += SECSPERDAY; |
break; |
case DAY_OF_YEAR: |
/* |
** n - day of year. |
** Just add SECSPERDAY times the day number to the time of |
** January 1, midnight, to get the day. |
*/ |
value = janfirst + rulep->r_day * SECSPERDAY; |
break; |
case MONTH_NTH_DAY_OF_WEEK: |
/* |
** Mm.n.d - nth "dth day" of month m. |
*/ |
value = janfirst; |
for (i = 0; i < rulep->r_mon - 1; ++i) |
value += mon_lengths[leapyear][i] * SECSPERDAY; |
/* |
** Use Zeller's Congruence to get day-of-week of first day of |
** month. |
*/ |
m1 = (rulep->r_mon + 9) % 12 + 1; |
yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; |
yy1 = yy0 / 100; |
yy2 = yy0 % 100; |
dow = ((26 * m1 - 2) / 10 + |
1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; |
if (dow < 0) |
dow += DAYSPERWEEK; |
/* |
** "dow" is the day-of-week of the first day of the month. Get |
** the day-of-month (zero-origin) of the first "dow" day of the |
** month. |
*/ |
d = rulep->r_day - dow; |
if (d < 0) |
d += DAYSPERWEEK; |
for (i = 1; i < rulep->r_week; ++i) |
{ |
if (d + DAYSPERWEEK >= |
mon_lengths[leapyear][rulep->r_mon - 1]) |
break; |
d += DAYSPERWEEK; |
} |
/* |
** "d" is the day-of-month (zero-origin) of the day we want. |
*/ |
value += d * SECSPERDAY; |
break; |
} |
/* |
** "value" is the Epoch-relative time of 00:00:00 GMT on the day in |
** question. To get the Epoch-relative time of the specified local |
** time on that day, add the transition time and the current offset |
** from GMT. |
*/ |
return value + rulep->r_time + offset; |
} |
/* |
** Given a POSIX section 8-style TZ string, fill in the rule tables as |
** appropriate. |
*/ |
static int tzload (const char * name, struct state * sp) |
{ |
return -1; |
} |
static int |
tzparse(const char *name, struct state * const sp, const int lastditch) |
{ |
const char * stdname; |
const char * dstname=0; |
int stdlen; |
int dstlen; |
long stdoffset; |
long dstoffset; |
time_t * atp; |
unsigned char * typep; |
char * cp; |
int load_result; |
stdname = name; |
if (lastditch) |
{ |
stdlen = strlen(name); /* length of standard zone name */ |
name += stdlen; |
if (stdlen >= sizeof sp->chars) |
stdlen = (sizeof sp->chars) - 1; |
} |
else |
{ |
name = getzname(name); |
stdlen = name - stdname; |
if (stdlen < 3) |
return -1; |
} |
if (*name == '\0') |
return -1; |
else |
{ |
name = getoffset(name, &stdoffset); |
if (name == NULL) |
return -1; |
} |
load_result = tzload(TZDEFRULES, sp); |
if (load_result != 0) |
sp->leapcnt = 0; /* so, we're off a little */ |
if (*name != '\0') |
{ |
dstname = name; |
name = getzname(name); |
dstlen = name - dstname; /* length of DST zone name */ |
if (dstlen < 3) |
return -1; |
if (*name != '\0' && *name != ',' && *name != ';') |
{ |
name = getoffset(name, &dstoffset); |
if (name == NULL) |
return -1; |
} |
else |
dstoffset = stdoffset - SECSPERHOUR; |
if (*name == ',' || *name == ';') |
{ |
struct rule start; |
struct rule end; |
int year; |
time_t janfirst; |
time_t starttime; |
time_t endtime; |
++name; |
if ((name = getrule(name, &start)) == NULL) |
return -1; |
if (*name++ != ',') |
return -1; |
if ((name = getrule(name, &end)) == NULL) |
return -1; |
if (*name != '\0') |
return -1; |
sp->typecnt = 2; /* standard time and DST */ |
/* |
** Two transitions per year, from EPOCH_YEAR to 2037. |
*/ |
sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); |
if (sp->timecnt > TZ_MAX_TIMES) |
return -1; |
sp->ttis[0].tt_gmtoff = -dstoffset; |
sp->ttis[0].tt_isdst = 1; |
sp->ttis[0].tt_abbrind = stdlen + 1; |
sp->ttis[1].tt_gmtoff = -stdoffset; |
sp->ttis[1].tt_isdst = 0; |
sp->ttis[1].tt_abbrind = 0; |
atp = sp->ats; |
typep = sp->types; |
janfirst = 0; |
for (year = EPOCH_YEAR; year <= 2037; ++year) |
{ |
starttime = transtime(janfirst, year, &start, |
stdoffset); |
endtime = transtime(janfirst, year, &end, |
dstoffset); |
if (starttime > endtime) |
{ |
*atp++ = endtime; |
*typep++ = 1; /* DST ends */ |
*atp++ = starttime; |
*typep++ = 0; /* DST begins */ |
} |
else |
{ |
*atp++ = starttime; |
*typep++ = 0; /* DST begins */ |
*atp++ = endtime; |
*typep++ = 1; /* DST ends */ |
} |
janfirst += |
year_lengths[isleap(year)] * SECSPERDAY; |
} |
} |
else |
{ |
int sawstd; |
int sawdst; |
long stdfix; |
long dstfix; |
long oldfix; |
int isdst; |
int i; |
if (*name != '\0') |
return -1; |
if (load_result != 0) |
return -1; |
/* |
** Compute the difference between the real and |
** prototype standard and summer time offsets |
** from GMT, and put the real standard and summer |
** time offsets into the rules in place of the |
** prototype offsets. |
*/ |
sawstd = FALSE; |
sawdst = FALSE; |
stdfix = 0; |
dstfix = 0; |
for (i = 0; i < sp->typecnt; ++i) |
{ |
if (sp->ttis[i].tt_isdst) |
{ |
oldfix = dstfix; |
dstfix = |
sp->ttis[i].tt_gmtoff + dstoffset; |
if (sawdst && (oldfix != dstfix)) |
return -1; |
sp->ttis[i].tt_gmtoff = -dstoffset; |
sp->ttis[i].tt_abbrind = stdlen + 1; |
sawdst = TRUE; |
} |
else |
{ |
oldfix = stdfix; |
stdfix = |
sp->ttis[i].tt_gmtoff + stdoffset; |
if (sawstd && (oldfix != stdfix)) |
return -1; |
sp->ttis[i].tt_gmtoff = -stdoffset; |
sp->ttis[i].tt_abbrind = 0; |
sawstd = TRUE; |
} |
} |
/* |
** Make sure we have both standard and summer time. |
*/ |
if (!sawdst || !sawstd) |
return -1; |
/* |
** Now correct the transition times by shifting |
** them by the difference between the real and |
** prototype offsets. Note that this difference |
** can be different in standard and summer time; |
** the prototype probably has a 1-hour difference |
** between standard and summer time, but a different |
** difference can be specified in TZ. |
*/ |
isdst = FALSE; /* we start in standard time */ |
for (i = 0; i < sp->timecnt; ++i) |
{ |
const struct ttinfo * ttisp; |
/* |
** If summer time is in effect, and the |
** transition time was not specified as |
** standard time, add the summer time |
** offset to the transition time; |
** otherwise, add the standard time offset |
** to the transition time. |
*/ |
ttisp = &sp->ttis[sp->types[i]]; |
sp->ats[i] += |
(isdst && !ttisp->tt_ttisstd) ? |
dstfix : stdfix; |
isdst = ttisp->tt_isdst; |
} |
} |
} |
else |
{ |
dstlen = 0; |
sp->typecnt = 1; /* only standard time */ |
sp->timecnt = 0; |
sp->ttis[0].tt_gmtoff = -stdoffset; |
sp->ttis[0].tt_isdst = 0; |
sp->ttis[0].tt_abbrind = 0; |
} |
sp->charcnt = stdlen + 1; |
if (dstlen != 0) |
sp->charcnt += dstlen + 1; |
if (sp->charcnt > sizeof sp->chars) |
return -1; |
cp = sp->chars; |
(void) strncpy(cp, stdname, stdlen); |
cp += stdlen; |
*cp++ = '\0'; |
if (dstlen != 0) |
{ |
(void) strncpy(cp, dstname, dstlen); |
*(cp + dstlen) = '\0'; |
} |
return 0; |
} |
static void |
gmtload(struct state * const sp) |
{ |
if (tzload(GMT, sp) != 0) |
(void) tzparse(GMT, sp, TRUE); |
} |
void |
tzset(void) |
{ |
const char * name; |
name = getenv("TZ"); |
if (name == NULL) |
{ |
tzsetwall(); |
return; |
} |
lcl_is_set = TRUE; |
#ifdef ALL_STATE |
if (lclptr == NULL) |
{ |
lclptr = (struct state *) malloc(sizeof *lclptr); |
if (lclptr == NULL) |
{ |
settzname(); /* all we can do */ |
return; |
} |
} |
#endif /* defined ALL_STATE */ |
if (*name == '\0') |
{ |
/* |
** User wants it fast rather than right. |
*/ |
lclptr->leapcnt = 0; /* so, we're off a little */ |
lclptr->timecnt = 0; |
lclptr->ttis[0].tt_gmtoff = 0; |
lclptr->ttis[0].tt_abbrind = 0; |
(void) strcpy(lclptr->chars, GMT); |
} |
else if (tzload(name, lclptr) != 0) |
if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) |
gmtload(lclptr); |
settzname(); |
} |
void |
tzsetwall(void) |
{ |
lcl_is_set = TRUE; |
#ifdef ALL_STATE |
if (lclptr == NULL) |
{ |
lclptr = (struct state *) malloc(sizeof *lclptr); |
if (lclptr == NULL) |
{ |
settzname(); /* all we can do */ |
return; |
} |
} |
#endif /* defined ALL_STATE */ |
if (tzload((char *) NULL, lclptr) != 0) |
gmtload(lclptr); |
settzname(); |
} |
/* |
** The easy way to behave "as if no library function calls" localtime |
** is to not call it--so we drop its guts into "localsub", which can be |
** freely called. (And no, the PANS doesn't require the above behavior-- |
** but it *is* desirable.) |
** |
** The unused offset argument is for the benefit of mktime variants. |
*/ |
/*ARGSUSED*/ |
static void |
localsub(const time_t * const timep, const long offset, struct tm * const tmp) |
{ |
const struct state * sp; |
const struct ttinfo * ttisp; |
int i; |
const time_t t = *timep; |
if (!lcl_is_set) |
tzset(); |
sp = lclptr; |
#ifdef ALL_STATE |
if (sp == NULL) |
{ |
gmtsub(timep, offset, tmp); |
return; |
} |
#endif /* defined ALL_STATE */ |
if (sp->timecnt == 0 || t < sp->ats[0]) |
{ |
i = 0; |
while (sp->ttis[i].tt_isdst) |
if (++i >= sp->typecnt) |
{ |
i = 0; |
break; |
} |
} |
else |
{ |
for (i = 1; i < sp->timecnt; ++i) |
if (t < sp->ats[i]) |
break; |
i = sp->types[i - 1]; |
} |
ttisp = &sp->ttis[i]; |
/* |
** To get (wrong) behavior that's compatible with System V Release 2.0 |
** you'd replace the statement below with |
** t += ttisp->tt_gmtoff; |
** timesub(&t, 0L, sp, tmp); |
*/ |
timesub(&t, ttisp->tt_gmtoff, sp, tmp); |
tmp->tm_isdst = ttisp->tt_isdst; |
tzname[tmp->tm_isdst] = unconst(&sp->chars[ttisp->tt_abbrind], char *); |
tmp->tm_zone = unconst(&sp->chars[ttisp->tt_abbrind], char *); |
} |
struct tm * |
localtime(const time_t * const timep) |
{ |
static struct tm tm; |
localsub(timep, 0L, &tm); |
return &tm; |
} |
/* |
** gmtsub is to gmtime as localsub is to localtime. |
*/ |
static void |
gmtsub(const time_t * const timep, const long offset, struct tm * const tmp) |
{ |
if (!gmt_is_set) |
{ |
gmt_is_set = TRUE; |
#ifdef ALL_STATE |
gmtptr = (struct state *) malloc(sizeof *gmtptr); |
if (gmtptr != NULL) |
#endif /* defined ALL_STATE */ |
gmtload(gmtptr); |
} |
timesub(timep, offset, gmtptr, tmp); |
/* |
** Could get fancy here and deliver something such as |
** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, |
** but this is no time for a treasure hunt. |
*/ |
if (offset != 0) |
tmp->tm_zone = WILDABBR; |
else |
{ |
#ifdef ALL_STATE |
if (gmtptr == NULL) |
tmp->TM_ZONE = GMT; |
else |
tmp->TM_ZONE = gmtptr->chars; |
#endif /* defined ALL_STATE */ |
#ifndef ALL_STATE |
tmp->tm_zone = gmtptr->chars; |
#endif /* State Farm */ |
} |
} |
struct tm * |
gmtime(const time_t * const timep) |
{ |
static struct tm tm; |
gmtsub(timep, 0L, &tm); |
return &tm; |
} |
static void |
timesub(const time_t * const timep, const long offset, const struct state * const sp, struct tm * const tmp) |
{ |
const struct lsinfo * lp; |
long days; |
long rem; |
int y; |
int yleap; |
const int * ip; |
long corr; |
int hit; |
int i; |
corr = 0; |
hit = FALSE; |
#ifdef ALL_STATE |
i = (sp == NULL) ? 0 : sp->leapcnt; |
#endif /* defined ALL_STATE */ |
#ifndef ALL_STATE |
i = sp->leapcnt; |
#endif /* State Farm */ |
while (--i >= 0) |
{ |
lp = &sp->lsis[i]; |
if (*timep >= lp->ls_trans) |
{ |
if (*timep == lp->ls_trans) |
hit = ((i == 0 && lp->ls_corr > 0) || |
lp->ls_corr > sp->lsis[i - 1].ls_corr); |
corr = lp->ls_corr; |
break; |
} |
} |
days = *timep / SECSPERDAY; |
rem = *timep % SECSPERDAY; |
#ifdef mc68k |
if (*timep == 0x80000000) |
{ |
/* |
** A 3B1 muffs the division on the most negative number. |
*/ |
days = -24855; |
rem = -11648; |
} |
#endif /* mc68k */ |
rem += (offset - corr); |
while (rem < 0) |
{ |
rem += SECSPERDAY; |
--days; |
} |
while (rem >= SECSPERDAY) |
{ |
rem -= SECSPERDAY; |
++days; |
} |
tmp->tm_hour = (int) (rem / SECSPERHOUR); |
rem = rem % SECSPERHOUR; |
tmp->tm_min = (int) (rem / SECSPERMIN); |
tmp->tm_sec = (int) (rem % SECSPERMIN); |
if (hit) |
/* |
** A positive leap second requires a special |
** representation. This uses "... ??:59:60". |
*/ |
++(tmp->tm_sec); |
tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); |
if (tmp->tm_wday < 0) |
tmp->tm_wday += DAYSPERWEEK; |
y = EPOCH_YEAR; |
if (days >= 0) |
for ( ; ; ) |
{ |
yleap = isleap(y); |
if (days < (long) year_lengths[yleap]) |
break; |
++y; |
days = days - (long) year_lengths[yleap]; |
} |
else |
do { |
--y; |
yleap = isleap(y); |
days = days + (long) year_lengths[yleap]; |
} while (days < 0); |
tmp->tm_year = y - TM_YEAR_BASE; |
tmp->tm_yday = (int) days; |
ip = mon_lengths[yleap]; |
for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) |
days = days - (long) ip[tmp->tm_mon]; |
tmp->tm_mday = (int) (days + 1); |
tmp->tm_isdst = 0; |
tmp->tm_gmtoff = offset; |
} |
/* |
** A la X3J11 |
*/ |
char * |
asctime(const struct tm *timeptr) |
{ |
static const char wday_name[DAYSPERWEEK][3] = { |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" |
}; |
static const char mon_name[MONSPERYEAR][3] = { |
"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" |
}; |
static char result[26]; |
(void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", |
wday_name[timeptr->tm_wday], |
mon_name[timeptr->tm_mon], |
timeptr->tm_mday, timeptr->tm_hour, |
timeptr->tm_min, timeptr->tm_sec, |
TM_YEAR_BASE + timeptr->tm_year); |
return result; |
} |
char * |
ctime(const time_t * const timep) |
{ |
return asctime(localtime(timep)); |
} |
/* |
** Adapted from code provided by Robert Elz, who writes: |
** The "best" way to do mktime I think is based on an idea of Bob |
** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). |
** It does a binary search of the time_t space. Since time_t's are |
** just 32 bits, its a max of 32 iterations (even at 64 bits it |
** would still be very reasonable). |
*/ |
#ifndef WRONG |
#define WRONG (-1) |
#endif /* !defined WRONG */ |
static void |
normalize(int * const tensptr, int * const unitsptr, const int base) |
{ |
if (*unitsptr >= base) |
{ |
*tensptr += *unitsptr / base; |
*unitsptr %= base; |
} |
else if (*unitsptr < 0) |
{ |
--*tensptr; |
*unitsptr += base; |
if (*unitsptr < 0) |
{ |
*tensptr -= 1 + (-*unitsptr) / base; |
*unitsptr = base - (-*unitsptr) % base; |
} |
} |
} |
static int |
tmcomp(const struct tm * const atmp, const struct tm * const btmp) |
{ |
int result; |
if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && |
(result = (atmp->tm_mon - btmp->tm_mon)) == 0 && |
(result = (atmp->tm_mday - btmp->tm_mday)) == 0 && |
(result = (atmp->tm_hour - btmp->tm_hour)) == 0 && |
(result = (atmp->tm_min - btmp->tm_min)) == 0) |
result = atmp->tm_sec - btmp->tm_sec; |
return result; |
} |
static time_t |
time2(struct tm *tmp, void (*const funcp)(const time_t *const,const long,struct tm *), const long offset, int * const okayp) |
{ |
const struct state * sp; |
int dir; |
int bits; |
int i, j ; |
int saved_seconds; |
time_t newt; |
time_t t; |
struct tm yourtm, mytm; |
*okayp = FALSE; |
yourtm = *tmp; |
if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) |
normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); |
normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); |
normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); |
normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); |
while (yourtm.tm_mday <= 0) |
{ |
--yourtm.tm_year; |
yourtm.tm_mday += |
year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; |
} |
for ( ; ; ) |
{ |
i = mon_lengths[isleap(yourtm.tm_year + |
TM_YEAR_BASE)][yourtm.tm_mon]; |
if (yourtm.tm_mday <= i) |
break; |
yourtm.tm_mday -= i; |
if (++yourtm.tm_mon >= MONSPERYEAR) |
{ |
yourtm.tm_mon = 0; |
++yourtm.tm_year; |
} |
} |
saved_seconds = yourtm.tm_sec; |
yourtm.tm_sec = 0; |
/* |
** Calculate the number of magnitude bits in a time_t |
** (this works regardless of whether time_t is |
** signed or unsigned, though lint complains if unsigned). |
*/ |
for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) |
; |
/* |
** If time_t is signed, then 0 is the median value, |
** if time_t is unsigned, then 1 << bits is median. |
*/ |
t = (time_t) 1 << bits; |
for ( ; ; ) |
{ |
(*funcp)(&t, offset, &mytm); |
dir = tmcomp(&mytm, &yourtm); |
if (dir != 0) |
{ |
if (bits-- < 0) |
return WRONG; |
if (bits < 0) |
--t; |
else if (dir > 0) |
t -= (time_t) 1 << bits; |
else t += (time_t) 1 << bits; |
continue; |
} |
if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) |
break; |
/* |
** Right time, wrong type. |
** Hunt for right time, right type. |
** It's okay to guess wrong since the guess |
** gets checked. |
*/ |
sp = (const struct state *) |
((funcp == localsub) ? lclptr : gmtptr); |
#ifdef ALL_STATE |
if (sp == NULL) |
return WRONG; |
#endif /* defined ALL_STATE */ |
for (i = 0; i < sp->typecnt; ++i) |
{ |
if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) |
continue; |
for (j = 0; j < sp->typecnt; ++j) |
{ |
if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) |
continue; |
newt = t + sp->ttis[j].tt_gmtoff - |
sp->ttis[i].tt_gmtoff; |
(*funcp)(&newt, offset, &mytm); |
if (tmcomp(&mytm, &yourtm) != 0) |
continue; |
if (mytm.tm_isdst != yourtm.tm_isdst) |
continue; |
/* |
** We have a match. |
*/ |
t = newt; |
goto label; |
} |
} |
return WRONG; |
} |
label: |
t += saved_seconds; |
(*funcp)(&t, offset, tmp); |
*okayp = TRUE; |
return t; |
} |
static time_t |
time1(struct tm * const tmp, void (*const funcp)(const time_t * const, const long, struct tm *), const long offset) |
{ |
time_t t; |
const struct state * sp; |
int samei, otheri; |
int okay; |
if (tmp->tm_isdst > 1) |
tmp->tm_isdst = 1; |
t = time2(tmp, funcp, offset, &okay); |
if (okay || tmp->tm_isdst < 0) |
return t; |
/* |
** We're supposed to assume that somebody took a time of one type |
** and did some math on it that yielded a "struct tm" that's bad. |
** We try to divine the type they started from and adjust to the |
** type they need. |
*/ |
sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); |
#ifdef ALL_STATE |
if (sp == NULL) |
return WRONG; |
#endif /* defined ALL_STATE */ |
for (samei = 0; samei < sp->typecnt; ++samei) |
{ |
if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) |
continue; |
for (otheri = 0; otheri < sp->typecnt; ++otheri) |
{ |
if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) |
continue; |
tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - |
sp->ttis[samei].tt_gmtoff; |
tmp->tm_isdst = !tmp->tm_isdst; |
t = time2(tmp, funcp, offset, &okay); |
if (okay) |
return t; |
tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - |
sp->ttis[samei].tt_gmtoff; |
tmp->tm_isdst = !tmp->tm_isdst; |
} |
} |
return WRONG; |
} |
time_t |
mktime(struct tm * tmp) |
{ |
return time1(tmp, localsub, 0L); |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/difftime.c |
---|
0,0 → 1,7 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <time.h> |
double difftime(time_t time1, time_t time0) |
{ |
return time1-time0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/posixrul.h |
---|
0,0 → 1,49 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
/* generated with bin2h from DJGPP/zoneinfo/posixrules */ |
unsigned char _posixrules_data[] = { |
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,2,0,0,0,0,0, |
0,1,16,0,0,0,2,0,0,0,8,0,151,254,240,1,135,225,224,2,119,224,240,3,112,254,96,4,96,253,112,5,80, |
224,96,6,64,223,112,7,48,194,96,7,141,25,112,9,16,164,96,9,173,148,240,10,240,134,96,11,224,133,112,12,217,162, |
224,13,192,103,112,14,185,132,224,15,169,131,240,16,153,102,224,17,137,101,240,18,121,72,224,19,105,71,240,20,89,42,224, |
21,73,41,240,22,57,12,224,23,41,11,240,24,34,41,96,25,8,237,240,26,2,11,96,26,242,10,112,27,225,237,96,28, |
209,236,112,29,193,207,96,30,177,206,112,31,161,177,96,32,118,0,240,33,129,147,96,34,85,226,240,35,106,175,224,36,53, |
196,240,37,74,145,224,38,21,166,240,39,42,115,224,39,254,195,112,41,10,85,224,41,222,165,112,42,234,55,224,43,190,135, |
112,44,211,84,96,45,158,105,112,46,179,54,96,47,126,75,112,48,147,24,96,49,103,103,240,50,114,250,96,51,71,73,240, |
52,82,220,96,53,39,43,240,54,50,190,96,55,7,13,240,56,27,218,224,56,230,239,240,57,251,188,224,58,198,209,240,59, |
219,158,224,60,175,238,112,61,187,128,224,62,143,208,112,63,155,98,224,64,111,178,112,65,132,127,96,66,79,148,112,67,100, |
97,96,68,47,118,112,69,68,67,96,70,15,88,112,71,36,37,96,71,248,116,240,73,4,7,96,73,216,86,240,74,227,233, |
96,75,184,56,240,76,205,5,224,77,152,26,240,78,172,231,224,79,119,252,240,80,140,201,224,81,97,25,112,82,108,171,224, |
83,64,251,112,84,76,141,224,85,32,221,112,86,44,111,224,87,0,191,112,88,21,140,96,88,224,161,112,89,245,110,96,90, |
192,131,112,91,213,80,96,92,169,159,240,93,181,50,96,94,137,129,240,95,149,20,96,96,105,99,240,97,126,48,224,98,73, |
69,240,99,94,18,224,100,41,39,240,101,61,244,224,102,18,68,112,103,29,214,224,103,242,38,112,104,253,184,224,105,210,8, |
112,106,221,154,224,107,177,234,112,108,198,183,96,109,145,204,112,110,166,153,96,111,113,174,112,112,134,123,96,113,90,202,240, |
114,102,93,96,115,58,172,240,116,70,63,96,117,26,142,240,118,47,91,224,118,250,112,240,120,15,61,224,120,218,82,240,121, |
239,31,224,122,186,52,240,123,207,1,224,124,163,81,112,125,174,227,224,126,131,51,112,127,142,197,224,128,99,21,112,129,119, |
226,96,130,66,247,112,131,87,196,96,132,34,217,112,133,55,166,96,134,11,245,240,135,23,136,96,135,235,215,240,136,247,106, |
96,137,203,185,240,138,215,76,96,139,171,155,240,140,192,104,224,141,139,125,240,142,160,74,224,143,107,95,240,144,128,44,224, |
145,84,124,112,146,96,14,224,147,52,94,112,148,63,240,224,149,20,64,112,150,41,13,96,150,244,34,112,152,8,239,96,152, |
212,4,112,153,232,209,96,154,189,32,240,155,200,179,96,156,157,2,240,157,168,149,96,158,124,228,240,159,136,119,96,160,92, |
198,240,161,113,147,224,162,60,168,240,163,81,117,224,164,28,138,240,165,49,87,224,166,5,167,112,167,17,57,224,167,229,137, |
112,168,241,27,224,169,197,107,112,170,218,56,96,171,165,77,112,172,186,26,96,173,133,47,112,174,153,252,96,175,101,17,112, |
176,121,222,96,177,78,45,240,178,89,192,96,179,46,15,240,180,57,162,96,181,13,241,240,182,34,190,224,182,237,211,240,184, |
2,160,224,184,205,181,240,185,226,130,224,186,182,210,112,187,194,100,224,188,150,180,112,189,162,70,224,190,118,150,112,191,130, |
40,224,192,86,120,112,193,107,69,96,194,54,90,112,195,75,39,96,196,22,60,112,197,43,9,96,197,255,88,240,199,10,235, |
96,199,223,58,240,200,234,205,96,201,191,28,240,202,211,233,224,203,158,254,240,204,179,203,224,205,126,224,240,206,147,173,224, |
207,103,253,112,208,115,143,224,209,71,223,112,210,83,113,224,211,39,193,112,212,51,83,224,213,7,163,112,214,28,112,96,214, |
231,133,112,215,252,82,96,216,199,103,112,217,220,52,96,218,176,131,240,219,188,22,96,220,144,101,240,221,155,248,96,222,112, |
71,240,223,133,20,224,224,80,41,240,225,100,246,224,226,48,11,240,227,68,216,224,228,15,237,240,229,36,186,224,229,249,10, |
112,231,4,156,224,231,216,236,112,232,228,126,224,233,184,206,112,234,205,155,96,235,152,176,112,236,173,125,96,237,120,146,112, |
238,141,95,96,239,97,174,240,240,109,65,96,241,65,144,240,242,77,35,96,243,33,114,240,244,45,5,96,245,1,84,240,246, |
22,33,224,246,225,54,240,247,246,3,224,248,193,24,240,249,213,229,224,250,160,250,240,251,181,199,224,252,138,23,112,253,149, |
169,224,254,105,249,112,255,117,139,224,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, |
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, |
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, |
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, |
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, |
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, |
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, |
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, |
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,255,255,199,192,1,0,255,255,185,176,0,4,69,68,84, |
0,69,83,84,0,0,0 |
}; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/strftime.c |
---|
0,0 → 1,226 |
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
#include <string.h> |
#include <time.h> |
#define TM_YEAR_BASE 1900 |
static const char *afmt[] = { |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", |
}; |
static const char *Afmt[] = { |
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", |
"Saturday", |
}; |
static const char *bfmt[] = { |
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", |
"Oct", "Nov", "Dec", |
}; |
static const char *Bfmt[] = { |
"January", "February", "March", "April", "May", "June", "July", |
"August", "September", "October", "November", "December", |
}; |
static size_t gsize; |
static char *pt; |
static int |
_add(const char *str) |
{ |
for (;; ++pt, --gsize) |
{ |
if (!gsize) |
return 0; |
if (!(*pt = *str++)) |
return 1; |
} |
} |
static int |
_conv(int n, int digits, char pad) |
{ |
static char buf[10]; |
char *p; |
for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) |
*p-- = n % 10 + '0'; |
while (p > buf && digits-- > 0) |
*p-- = pad; |
return _add(++p); |
} |
static size_t |
_fmt(const char *format, const struct tm *t) |
{ |
for (; *format; ++format) |
{ |
if (*format == '%') |
switch(*++format) |
{ |
case '\0': |
--format; |
break; |
case 'A': |
if (t->tm_wday < 0 || t->tm_wday > 6) |
return 0; |
if (!_add(Afmt[t->tm_wday])) |
return 0; |
continue; |
case 'a': |
if (t->tm_wday < 0 || t->tm_wday > 6) |
return 0; |
if (!_add(afmt[t->tm_wday])) |
return 0; |
continue; |
case 'B': |
if (t->tm_mon < 0 || t->tm_mon > 11) |
return 0; |
if (!_add(Bfmt[t->tm_mon])) |
return 0; |
continue; |
case 'b': |
case 'h': |
if (t->tm_mon < 0 || t->tm_mon > 11) |
return 0; |
if (!_add(bfmt[t->tm_mon])) |
return 0; |
continue; |
case 'C': |
if (!_fmt("%a %b %e %H:%M:%S %Y", t)) |
return 0; |
continue; |
case 'c': |
if (!_fmt("%m/%d/%y %H:%M:%S", t)) |
return 0; |
continue; |
case 'e': |
if (!_conv(t->tm_mday, 2, ' ')) |
return 0; |
continue; |
case 'D': |
if (!_fmt("%m/%d/%y", t)) |
return 0; |
continue; |
case 'd': |
if (!_conv(t->tm_mday, 2, '0')) |
return 0; |
continue; |
case 'H': |
if (!_conv(t->tm_hour, 2, '0')) |
return 0; |
continue; |
case 'I': |
if (!_conv(t->tm_hour % 12 ? |
t->tm_hour % 12 : 12, 2, '0')) |
return 0; |
continue; |
case 'j': |
if (!_conv(t->tm_yday + 1, 3, '0')) |
return 0; |
continue; |
case 'k': |
if (!_conv(t->tm_hour, 2, ' ')) |
return 0; |
continue; |
case 'l': |
if (!_conv(t->tm_hour % 12 ? |
t->tm_hour % 12 : 12, 2, ' ')) |
return 0; |
continue; |
case 'M': |
if (!_conv(t->tm_min, 2, '0')) |
return 0; |
continue; |
case 'm': |
if (!_conv(t->tm_mon + 1, 2, '0')) |
return 0; |
continue; |
case 'n': |
if (!_add("\n")) |
return 0; |
continue; |
case 'p': |
if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) |
return 0; |
continue; |
case 'R': |
if (!_fmt("%H:%M", t)) |
return 0; |
continue; |
case 'r': |
if (!_fmt("%I:%M:%S %p", t)) |
return 0; |
continue; |
case 'S': |
if (!_conv(t->tm_sec, 2, '0')) |
return 0; |
continue; |
case 'T': |
case 'X': |
if (!_fmt("%H:%M:%S", t)) |
return 0; |
continue; |
case 't': |
if (!_add("\t")) |
return 0; |
continue; |
case 'U': |
if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, |
2, '0')) |
return 0; |
continue; |
case 'W': |
if (!_conv((t->tm_yday + 7 - |
(t->tm_wday ? (t->tm_wday - 1) : 6)) |
/ 7, 2, '0')) |
return 0; |
continue; |
case 'w': |
if (!_conv(t->tm_wday, 1, '0')) |
return 0; |
continue; |
case 'x': |
if (!_fmt("%m/%d/%y", t)) |
return 0; |
continue; |
case 'y': |
if (!_conv((t->tm_year + TM_YEAR_BASE) |
% 100, 2, '0')) |
return 0; |
continue; |
case 'Y': |
if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) |
return 0; |
continue; |
case 'Z': |
if (!t->tm_zone || !_add(t->tm_zone)) |
return 0; |
continue; |
case '%': |
/* |
* X311J/88-090 (4.12.3.5): if conversion char is |
* undefined, behavior is undefined. Print out the |
* character itself as printf(3) does. |
*/ |
default: |
break; |
} |
if (!gsize--) |
return 0; |
*pt++ = *format; |
} |
return gsize; |
} |
size_t |
strftime(char *s, size_t maxsize, const char *format, const struct tm *t) |
{ |
pt = s; |
if ((gsize = maxsize) < 1) |
return 0; |
if (_fmt(format, t)) |
{ |
*pt = '\0'; |
return maxsize - gsize; |
} |
return 0; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/libraries/menuetlibc/src/libc/ansi/time/time.c |
---|
0,0 → 1,13 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#include <time.h> |
time_t time(time_t *t) |
{ |
struct timeval tt; |
if (gettimeofday(&tt, 0) < 0) |
return(-1); |
if (t) |
*t = tt.tv_sec; |
return tt.tv_sec; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |