📄 lib.txt
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/ext_fmt.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00000 struct mantissa {
00001 unsigned long h_32;
00002 unsigned long l_32;
00003 };
00004
00005 struct EXTEND {
00006 short sign;
00007 short exp;
00008 struct mantissa mantissa;
00009 #define m1 mantissa.h_32
00010 #define m2 mantissa.l_32
00011 };
00012
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/loc_time.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00100 /*
00101 * loc_time.h - some local definitions
00102 */
00103 /* $Header: loc_time.h,v 1.1 91/04/22 13:19:51 ceriel Exp $ */
00104
00105 #define YEAR0 1900 /* the first year */
00106 #define EPOCH_YR 1970 /* EPOCH = Jan 1 1970 00:00:00 */
00107 #define SECS_DAY (24L * 60L * 60L)
00108 #define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400)))
00109 #define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
00110 #define FIRSTSUNDAY(timp) (((timp)->tm_yday - (timp)->tm_wday + 420) % 7)
00111 #define FIRSTDAYOF(timp) (((timp)->tm_wday - (timp)->tm_yday + 420) % 7)
00112 #define TIME_MAX ULONG_MAX
00113 #define ABB_LEN 3
00114
00115 extern const int _ytab[2][12];
00116 extern const char *_days[];
00117 extern const char *_months[];
00118
00119 void _tzset(void);
00120 unsigned _dstget(struct tm *timep);
00121
00122 extern long _timezone;
00123 extern long _dst_off;
00124 extern int _daylight;
00125 extern char *_tzname[2];
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/abort.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00200 /*
00201 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00202 * See the copyright notice in the ACK home directory, in the file "Copyright".
00203 */
00204 /* $Header: abort.c,v 1.3 90/11/22 13:59:37 eck Exp $ */
00205
00206 #if defined(_POSIX_SOURCE)
00207 #include <sys/types.h>
00208 #endif
00209 #include <signal.h>
00210 #include <stdlib.h>
00211
00212 extern void (*_clean)(void);
00213
00214 void
00215 abort(void)
00216 {
00217 if (_clean) _clean(); /* flush all output files */
00218 raise(SIGABRT);
00219 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/abs.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00300 /*
00301 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00302 * See the copyright notice in the ACK home directory, in the file "Copyright".
00303 */
00304 /* $Header: abs.c,v 1.1 89/05/16 13:06:59 eck Exp $ */
00305
00306 #include <stdlib.h>
00307
00308 int
00309 abs(register int i)
00310 {
00311 return i >= 0 ? i : -i;
00312 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/asctime.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00400 /*
00401 * asctime - print a date
00402 */
00403 /* $Header: asctime.c,v 1.3 91/04/22 13:20:15 ceriel Exp $ */
00404
00405 #include <string.h>
00406 #include <time.h>
00407 #include "loc_time.h"
00408
00409 #define DATE_STR "??? ??? ?? ??:??:?? ????\n"
00410
00411 static char *
00412 two_digits(register char *pb, int i, int nospace)
00413 {
00414 *pb = (i / 10) % 10 + '0';
00415 if (!nospace && *pb == '0') *pb = ' ';
00416 pb++;
00417 *pb++ = (i % 10) + '0';
00418 return ++pb;
00419 }
00421 static char *
00422 four_digits(register char *pb, int i)
00423 {
00424 i %= 10000;
00425 *pb++ = (i / 1000) + '0';
00426 i %= 1000;
00427 *pb++ = (i / 100) + '0';
00428 i %= 100;
00429 *pb++ = (i / 10) + '0';
00430 *pb++ = (i % 10) + '0';
00431 return ++pb;
00432 }
00434 char *asctime(const struct tm *timeptr)
00435 {
00436 static char buf[26];
00437 register char *pb = buf;
00438 register const char *ps;
00439 register int n;
00440
00441 strcpy(pb, DATE_STR);
00442 ps = _days[timeptr->tm_wday];
00443 n = ABB_LEN;
00444 while(--n >= 0) *pb++ = *ps++;
00445 pb++;
00446 ps = _months[timeptr->tm_mon];
00447 n = ABB_LEN;
00448 while(--n >= 0) *pb++ = *ps++;
00449 pb++;
00450 pb = two_digits(
00451 two_digits(
00452 two_digits(two_digits(pb, timeptr->tm_mday, 0)
00453 , timeptr->tm_hour, 1)
00454 , timeptr->tm_min, 1)
00455 , timeptr->tm_sec, 1);
00456
00457 four_digits(pb, timeptr->tm_year + 1900);
00458 return buf;
00459 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/assert.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00500 /*
00501 * assert.c - diagnostics
00502 */
00503 /* $Header: assert.c,v 1.3 90/04/03 15:01:58 eck Exp $ */
00504
00505 #include <assert.h>
00506 #include <stdio.h>
00507 #include <stdlib.h>
00508
00509 void __bad_assertion(const char *mess) {
00510
00511 fputs(mess, stderr);
00512 abort();
00513 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/atexit.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00600 /* $Header: atexit.c,v 1.1 89/12/18 15:11:09 eck Exp $ */
00601
00602 #include <stdlib.h>
00603
00604 #define NEXITS 32
00605
00606 extern void (*__functab[NEXITS])(void);
00607 extern int __funccnt;
00608
00609 int
00610 atexit(void (*func)(void))
00611 {
00612 if (__funccnt >= NEXITS)
00613 return 1;
00614 __functab[__funccnt++] = func;
00615 return 0;
00616 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/atof.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00700 /*
00701 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00702 * See the copyright notice in the ACK home directory, in the file "Copyright".
00703 */
00704 /* $Header: atof.c,v 1.2 89/12/18 15:11:50 eck Exp $ */
00705
00706 #include <stdlib.h>
00707 #include <errno.h>
00708
00709 double
00710 atof(const char *nptr)
00711 {
00712 double d;
00713 int e = errno;
00714
00715 d = strtod(nptr, (char **) NULL);
00716 errno = e;
00717 return d;
00718 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/atoi.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00800 /*
00801 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00802 * See the copyright notice in the ACK home directory, in the file "Copyright".
00803 */
00804 /* $Header: atoi.c,v 1.4 90/05/22 12:22:25 ceriel Exp $ */
00805
00806 #include <ctype.h>
00807 #include <stdlib.h>
00808
00809 /* We do not use strtol here for backwards compatibility in behaviour on
00810 overflow.
00811 */
00812 int
00813 atoi(register const char *nptr)
00814 {
00815 int total = 0;
00816 int minus = 0;
00817
00818 while (isspace(*nptr)) nptr++;
00819 if (*nptr == '+') nptr++;
00820 else if (*nptr == '-') {
00821 minus = 1;
00822 nptr++;
00823 }
00824 while (isdigit(*nptr)) {
00825 total *= 10;
00826 total += (*nptr++ - '0');
00827 }
00828 return minus ? -total : total;
00829 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/atol.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00900 /*
00901 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
00902 * See the copyright notice in the ACK home directory, in the file "Copyright".
00903 */
00904 /* $Header: atol.c,v 1.3 90/05/22 10:48:12 ceriel Exp $ */
00905
00906 #include <ctype.h>
00907 #include <stdlib.h>
00908
00909 /* We do not use strtol here for backwards compatibility in behaviour on
00910 overflow.
00911 */
00912 long
00913 atol(register const char *nptr)
00914 {
00915 long total = 0;
00916 int minus = 0;
00917
00918 while (isspace(*nptr)) nptr++;
00919 if (*nptr == '+') nptr++;
00920 else if (*nptr == '-') {
00921 minus = 1;
00922 nptr++;
00923 }
00924 while (isdigit(*nptr)) {
00925 total *= 10;
00926 total += (*nptr++ - '0');
00927 }
00928 return minus ? -total : total;
00929 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/bsearch.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01000 /*
01001 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
01002 * See the copyright notice in the ACK home directory, in the file "Copyright".
01003 */
01004 /* $Header: bsearch.c,v 1.2 89/12/18 15:12:21 eck Exp $ */
01005
01006 #include <stdlib.h>
01007
01008 void *
01009 bsearch(register const void *key, register const void *base,
01010 register size_t nmemb, register size_t size,
01011 int (*compar)(const void *, const void *))
01012 {
01013 register const void *mid_point;
01014 register int cmp;
01015
01016 while (nmemb > 0) {
01017 mid_point = (char *)base + size * (nmemb >> 1);
01018 if ((cmp = (*compar)(key, mid_point)) == 0)
01019 return (void *)mid_point;
01020 if (cmp >= 0) {
01021 base = (char *)mid_point + size;
01022 nmemb = (nmemb - 1) >> 1;
01023 } else
01024 nmemb >>= 1;
01025 }
01026 return (void *)NULL;
01027 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/calloc.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01100 /* $Header$ */
01101 #include <stdlib.h>
01102
01103 #define ALIGN(x) (((x) + (sizeof(size_t) - 1)) & ~(sizeof(size_t) - 1))
01104
01105 void *
01106 calloc(size_t nelem, size_t elsize)
01107 {
01108 register char *p;
01109 register size_t *q;
01110 size_t size = ALIGN(nelem * elsize);
01111
01112 p = malloc(size);
01113 if (p == NULL) return NULL;
01114 q = (size_t *) (p + size);
01115 while ((char *) q > p) *--q = 0;
01116 return p;
01117 }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lib/ansi/chartab.c
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01200 #include <ctype.h>
01201
01202 char __ctype[] = {
01203 0,
01204 _C,
01205 _C,
01206 _C,
01207 _C,
01208 _C,
01209 _C,
01210 _C,
01211 _C,
01212 _C,
01213 _C|_S,
01214 _C|_S,
01215 _C|_S,
01216 _C|_S,
01217 _C|_S,
01218 _C,
01219 _C,
01220 _C,
01221 _C,
01222 _C,
01223 _C,
01224 _C,
01225 _C,
01226 _C,
01227 _C,
01228 _C,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -