diff options
author | Toomas Soome <tsoome@me.com> | 2020-02-08 20:24:21 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-03-18 19:36:25 +0200 |
commit | 97b5374547d500fded52d886ceba8a9962af0527 (patch) | |
tree | 58133eb5538d122ed076707c9abe35530356cc0c /usr/src/lib/libbc/libc/stdio/common | |
parent | 20d3bf629e3e91ea61dee8153d5bc47daeab26b0 (diff) | |
download | illumos-gate-97b5374547d500fded52d886ceba8a9962af0527.tar.gz |
12292 retire libbc
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Reviewed by: Alexander Eremin <aeremin@tintri.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/lib/libbc/libc/stdio/common')
39 files changed, 0 insertions, 4207 deletions
diff --git a/usr/src/lib/libbc/libc/stdio/common/clrerr.c b/usr/src/lib/libbc/libc/stdio/common/clrerr.c deleted file mode 100644 index fcb8f0478e..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/clrerr.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -#include <stdio.h> -#undef clearerr - -void -clearerr(iop) -register FILE *iop; -{ - iop->_flag &= ~(_IOERR | _IOEOF); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/ctermid.c b/usr/src/lib/libbc/libc/stdio/common/ctermid.c deleted file mode 100644 index 23365e3a6a..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/ctermid.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -extern char *strcpy(); -static char res[L_ctermid]; - -char * -ctermid(s) -register char *s; -{ - return (strcpy(s != NULL ? s : res, "/dev/tty")); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/cuserid.c b/usr/src/lib/libbc/libc/stdio/common/cuserid.c deleted file mode 100644 index b33140d0b8..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/cuserid.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -#include <stdio.h> -#include <pwd.h> - -extern char *strcpy(), *getlogin(); -extern int getuid(); -extern struct passwd *getpwuid(); -static char res[L_cuserid]; - -char * -cuserid(s) -char *s; -{ - register struct passwd *pw; - register char *p; - - if (s == NULL) - s = res; - p = getlogin(); - if (p != NULL) - return (strcpy(s, p)); - pw = getpwuid(getuid()); - endpwent(); - if (pw != NULL) - return (strcpy(s, pw->pw_name)); - *s = '\0'; - return (NULL); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/doprnt.c b/usr/src/lib/libbc/libc/stdio/common/doprnt.c deleted file mode 100644 index eb5e3438cd..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/doprnt.c +++ /dev/null @@ -1,1270 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * _doprnt: common code for printf, fprintf, sprintf - * Floating-point code is included or not, depending - * on whether the preprocessor variable FLOAT is 1 or 0. - */ -#define MAXARGS 50 -#ifndef FLOAT -#define FLOAT 1 /* YES! we want floating */ -#endif - -#include <stdio.h> -#include <ctype.h> -#include <stdarg.h> -#include <values.h> -#include <locale.h> -#include "doprnt.h" -#include "stdiom.h" -#include <string.h> /* strchr, strlen, strspn */ - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) - -/* If this symbol is nonzero, allow '0' as a flag */ -/* If this symbol is nonzero, allow '0' as a flag */ -#define FZERO 1 - -#if FLOAT -/* - * libc/gen/common functions for floating-point conversion - */ -#include <floatingpoint.h> -extern void _fourdigitsquick(); -#endif - -#define emitchar(c) { if (--filecnt < 0) { \ - FILE *iop = file; \ - if (((iop->_flag & (_IOLBF|_IONBF)) == 0 \ - || -filecnt >= iop->_bufsiz)) { \ - iop->_ptr = fileptr; \ - if (iop->_flag & _IOSTRG) \ - return iop->_ptr - iop->_base; \ - else \ - (void) _xflsbuf(iop); \ - fileptr = iop->_ptr; \ - filecnt = iop->_cnt; \ - filecnt--; \ - } \ - } \ - *fileptr++ = (unsigned)(c); \ - count++; \ - } - -static char *nullstr = "(null)"; -static char *lowerhex = "0123456789abcdef"; -static char *upperhex = "0123456789ABCDEF"; - -/* stva_list is used to subvert C's restriction that a variable with an - * array type can not appear on the left hand side of an assignment operator. - * By putting the array inside a structure, the functionality of assigning to - * the whole array through a simple assignment is achieved.. -*/ -typedef struct stva_list { - va_list ap; -} stva_list; - -void _mkarglst(char *, stva_list, stva_list []); -void _getarg(char *, stva_list *, int); -static char *_check_dol(char *, int *); - -int -_doprnt(char *format, va_list in_args, FILE *file) -{ - char convertbuffer[1024] ; - - /* Current position in format */ - char *cp; - - /* Starting and ending points for value to be printed */ - char *bp; - char *p; - - /* Pointer and count for I/O buffer */ - unsigned char *fileptr; - int filecnt; - - /* Field width and precision */ - int width; - int prec; - - /* Format code */ - char fcode; - - /* Number of padding zeroes required on the left */ - int lzero; - - /* Flags - nonzero if corresponding character appears in format */ - bool fplus; /* + */ - bool fminus; /* - */ - bool fblank; /* blank */ - bool fsharp; /* # */ -#if FZERO - bool ansi_fzero; /* 0 for ansi-dictated formats */ - bool compat_fzero; /* 0 for backward compatibility */ -#endif - bool Lsize; /* Capital L for size = long double = quadruple */ - - /* Pointer to sign, "0x", "0X", or empty */ - char *prefix; - - /* Scratch */ - int nblank; - -#if FLOAT - /* Exponent or empty */ - char *suffix; - - /* Buffer to create exponent */ - char expbuf[7]; /* "e+xxxx\0" */ - - /* Number of padding zeroes required on the right */ - int rzero; - - /* Length of exponent suffix. */ - int suffixlength; - - /* The value being converted, if real or quadruple */ - double dval; - quadruple qval; - - /* Output values from fconvert and econvert */ - int decpt, sign; - - /* Values are developed in this buffer */ - char buf[1034]; /* Size of convertbuffer, plus some for exponent and sign. */ - - /* Current locale's decimal point */ - char decpt_char = *(localeconv()->decimal_point); - -#else - /* Values are developed in this buffer */ - char buf[MAXDIGS]; -#endif - - - /* The value being converted, if integer */ - unsigned long val; - - /* Work variables */ - int n; - char c; - char radix; - int svswitch = 0; - /* count of output characters */ - int count; - - /* variables for positional parameters */ - char *sformat = format; /* save the beginning of the format */ - int fpos = 1; /* 1 if first positional parameter */ - stva_list args, /* used to step through the argument list */ - args_width, /* for width */ - args_prec, /* for prec */ - sargs; /* used to save the start of the argument list */ - stva_list arglst[MAXARGS];/* array giving the approriate values - * for va_arg() to retrieve the - * corresponding argument: - * arglst[0] is the first argument - * arglst[1] is the second argument, etc. - */ - int index = 0; /* argument placeolder */ - /* Initialize args and sargs to the start of the argument list. - * Note that ANSI guarantees that the address of the first member of - * a structure will be the same as the address of the structure. */ - args_width = args_prec = args = sargs = *(struct stva_list *)&in_args; - - -/* initialize p an bp (starting and ending points) bugid 1141781 */ - - p = bp = NULL; - - cp = format; - if ((c = *cp++) != '\0') { - /* - * We know we're going to write something; make sure - * we can write and set up buffers, etc.. - */ - if (_WRTCHK(file)) - return(EOF); - } else - return(0); /* no fault, no error */ - - count = 0; - fileptr = file->_ptr; - filecnt = file->_cnt; - - /* - * The main loop -- this loop goes through one iteration - * for each ordinary character or format specification. - */ - do { - if (c != '%') { - /* Ordinary (non-%) character */ - emitchar(c); - } else { - /* - * % has been spotted! - * - * First, try the 99% cases. - * then parse the format specification. - * - * Note that this code assumes the Sun - * Workstation environment (all params - * passed as int == long, no interrupts - * for fixed point overflow from negating - * the most negative number). - */ - skipit: - switch(c = *cp++) { - - case 'l': - case 'h': - /* Quickly ignore long & short specifiers */ - goto skipit; - - case 's': - bp = va_arg(args.ap, char *); - if (bp == NULL) - bp = nullstr; - while (c = *bp++) - emitchar(c); - p = bp; - continue; - - case 'c': - c = va_arg(args.ap, int); - emitc: - emitchar(c); - continue; - - case 'i': - case 'd': - case 'D': - val = va_arg(args.ap, int); - if ((long) val < 0) { - emitchar('-'); - val = -val; - } - goto udcommon; - - case 'U': - case 'u': - val = va_arg(args.ap, unsigned); - udcommon: - { - char *stringp = lowerhex; - bp = buf+MAXDIGS; - stringp = lowerhex; - do { - *--bp = stringp[val%10]; - val /= 10; - } while (val); - } - goto intout; - - case 'X': - { - char *stringp = upperhex; - val = va_arg(args.ap, unsigned); - bp = buf + MAXDIGS; - if (val == 0) - goto zero; - while (val) { - *--bp = stringp[val%16]; - val /= 16; - } - } - goto intout; - - case 'x': - case 'p': - { - char *stringp = lowerhex; - val = va_arg(args.ap, unsigned); - bp = buf + MAXDIGS; - if (val == 0) - goto zero; - while (val) { - *--bp = stringp[val%16]; - val /= 16; - } - } - goto intout; - - case 'O': - case 'o': - { - char *stringp = lowerhex; - val = va_arg(args.ap, unsigned); - bp = buf + MAXDIGS; - if (val == 0) - goto zero; - while (val) { - *--bp = stringp[val%8]; - val /= 8; - } - } - /* Common code to output integers */ - intout: - p = buf + MAXDIGS; - while (bp < p) { - c = *bp++; - emitchar(c); - } - continue; - - zero: - c = '0'; - goto emitc; - - default: - /* - * let AT&T deal with it - */ - cp-= 2; - } - - Lsize = 0; /* Not long double unless we say so. */ - /* Scan the <flags> */ - fplus = 0; - fminus = 0; - fblank = 0; - fsharp = 0; -#if FZERO - ansi_fzero = 0; - compat_fzero = 0; -#endif - scan: switch (*++cp) { - case '+': - fplus = 1; - goto scan; - case '-': - fminus = 1; - goto scan; - case ' ': - fblank = 1; - goto scan; - case '#': - fsharp = 1; - goto scan; -#if FZERO - case '0': - ansi_fzero = 1; - compat_fzero = 1; - goto scan; -#endif - } - - /* Scan the field width */ - if (*cp == '*') { - char *p; - int val; - - p = _check_dol(cp+1, &val); - if (p != (char *)NULL) { - /* - * argument re-order - */ - if (fpos) { - _mkarglst(sformat, sargs, arglst); - fpos = 0; - } - if (val <= MAXARGS) { - args_width = arglst[val - 1]; - } else { - args_width = arglst[MAXARGS - 1]; - _getarg(sformat, &args_width, val); - } - width = va_arg(args_width.ap, int); - if (width < 0) { - width = -width; - fminus = 1; - } - cp = p; - } - else { - width = va_arg(args.ap, int); - if (width < 0) { - width = -width; - fminus = 1; - } - cp++; - } - } else { - index = width = 0; - while (isdigit(*cp)) { - n = tonumber(*cp++); - index = width = width * 10 + n; - } - } - - /* Scan the precision */ - if (*cp == '.') { - - /* '*' instead of digits? */ - if (*++cp == '*') { - char *p; - int val; - - p = _check_dol(cp+1, &val); - if (p != (char *)NULL) { - /* - * argument re-order - */ - if (fpos) { - _mkarglst(sformat, sargs, arglst); - fpos = 0; - } - if (val <= MAXARGS) { - args_prec = arglst[val - 1]; - } else { - args_prec = arglst[MAXARGS - 1]; - _getarg(sformat, &args_prec, val); - } - prec = va_arg(args_prec.ap, int); - cp = p; - } - else { - prec = va_arg(args.ap, int); - cp++; - } - } else { - prec = 0; - while (isdigit(*cp)) { - n = tonumber(*cp++); - prec = prec * 10 + n; - } - } - } else - prec = -1; - - if (*cp == '$') { - if (fpos) { - _mkarglst(sformat, sargs, arglst); - fpos = 0; - } - if (index <= MAXARGS) { - args = arglst[index - 1]; - } else { - args = arglst[MAXARGS - 1]; - _getarg(sformat, &args, index); - } - goto scan; - } - /* - * The character addressed by cp must be the - * format letter -- there is nothing left for - * it to be. - * - * The status of the +, -, #, blank, and 0 - * flags are reflected in the variables - * "fplus", "fminus", "fsharp", "fblank", - * and "ansi_fzero"/"compat_fzero", respectively. - * "width" and "prec" contain numbers - * corresponding to the digit strings - * before and after the decimal point, - * respectively. If there was no decimal - * point, "prec" is -1. - * - * The following switch sets things up - * for printing. What ultimately gets - * printed will be padding blanks, a prefix, - * left padding zeroes, a value, right padding - * zeroes, a suffix, and more padding - * blanks. Padding blanks will not appear - * simultaneously on both the left and the - * right. Each case in this switch will - * compute the value, and leave in several - * variables the information necessary to - * construct what is to be printed. - * - * The prefix is a sign, a blank, "0x", "0X", - * or null, and is addressed by "prefix". - * - * The suffix is either null or an exponent, - * and is addressed by "suffix". - * - * The value to be printed starts at "bp" - * and continues up to and not including "p". - * - * "lzero" and "rzero" will contain the number - * of padding zeroes required on the left - * and right, respectively. If either of - * these variables is negative, it will be - * treated as if it were zero. - * - * The number of padding blanks, and whether - * they go on the left or the right, will be - * computed on exit from the switch. - */ - - lzero = 0; - prefix = ""; -#if FLOAT - rzero = 0; - suffix = prefix; -#endif - -#if FZERO - /* if both zero-padding and left-justify flags - * are used, ignore zero-padding, per ansi c - */ - if (ansi_fzero & fminus) { - ansi_fzero = 0; - compat_fzero = 0; - } - - /* if zero-padding and precision are specified, - * ignore zero-padding for ansi-dictated formats, - * per ansi c - */ - if (ansi_fzero & (prec != -1)) ansi_fzero = 0; -#endif - - next: - switch (fcode = *cp++) { - - /* toss the length modifier, if any */ - case 'l': - case 'h': - goto next; - - case 'L': - Lsize = 1; /* Remember long double size. */ - goto next; - - /* - * fixed point representations - * - * "radix" is the radix for the conversion. - * Conversion is unsigned unless fcode is 'd'. - * We assume a 2's complement machine and - * that fixed point overflow (from negating - * the largest negative int) is ignored. - */ - - case 'i': - case 'D': - case 'U': - case 'd': - case 'u': - radix = 10; - goto fixed; - - case 'O': - case 'o': - radix = 8; - goto fixed; - - case 'X': - case 'x': - radix = 16; - - fixed: - /* Establish default precision */ - if (prec < 0) - prec = 1; - - /* Fetch the argument to be printed */ - val = va_arg(args.ap, unsigned); - - /* If signed conversion, establish sign */ - if (fcode == 'd' || fcode == 'D' || fcode == 'i') { - if ((long) val < 0) { - prefix = "-"; - val = -val; - } else if (fplus) - prefix = "+"; - else if (fblank) - prefix = " "; - } - /* Set translate table for digits */ - { - char *stringp; - if (fcode == 'X') - stringp = upperhex; - else - stringp = lowerhex; - - /* Develop the digits of the value */ - bp = buf + MAXDIGS; - switch(radix) { - case 8: /*octal*/ - while (val) { - *--bp = stringp[val%8]; - val /= 8; - } - break; - case 16:/*hex*/ - while (val) { - *--bp = stringp[val%16]; - val /= 16; - } - break; - default: - while (val) { - *--bp = stringp[val%10]; - val /= 10; - } - break; - } /* switch */ - } - - /* Calculate padding zero requirement */ - p = buf + MAXDIGS; - - /* Handle the # flag */ - if (fsharp && bp != p) { - switch (fcode) { - case 'x': - prefix = "0x"; - break; - case 'X': - prefix = "0X"; - break; - } - } -#if FZERO - if (ansi_fzero) { - n = width - strlen(prefix); - if (n > prec) - prec = n; - } -#endif - lzero = bp - p + prec; - - /* Handle the # flag for 'o' */ - if (fsharp && bp != p && fcode == 'o' && - lzero < 1) { - lzero = 1; - } - break; -#if FLOAT - -#if defined(__sparc) -#define GETQVAL /* Sun-4 macro to get a quad q from the argument list, passed as a pointer. */ \ - { qval = *(va_arg(args.ap, quadruple*)) ; } -#else -#define GETQVAL /* Sun-3 macro to get a quad q from the argument list, passed as a value. */ \ - { int iq ; unsigned long * pl = (unsigned long *) (&qval) ; for(iq=0;iq<4;iq++) pl[iq] = (unsigned long) va_arg(args.ap, unsigned long) ; } -#endif - - case 'E': - case 'e': - /* - * E-format. The general strategy - * here is fairly easy: we take - * what econvert gives us and re-format it. - */ - - /* Establish default precision */ - if (prec < 0) - prec = 6; - - /* Fetch the value */ - if (Lsize == 0) { /* Double */ - dval = va_arg(args.ap, double); - bp = econvert(dval, prec + 1, &decpt, &sign, convertbuffer); - } else { /* Long Double = quadruple */ - GETQVAL; - bp = qeconvert(&qval, prec + 1, &decpt, &sign, convertbuffer); - } - - /* Determine the prefix */ - if (sign) - prefix = "-"; - else if (fplus) - prefix = "+"; - else if (fblank) - prefix = " "; - if (convertbuffer[0] > '9') - { /* handle infinity, nan */ - bp = &convertbuffer[0]; - for (p = bp+1 ; *p != 0 ; p++) ; - goto ebreak ; - } - { - char *stringp; - /* Place the first digit in the buffer */ - stringp = &buf[0]; - *stringp++ = *bp != '\0'? *bp++: '0'; - - /* Put in a decimal point if needed */ - if (prec != 0 || fsharp) - *stringp++ = decpt_char; - - /* Create the rest of the mantissa */ - rzero = prec; - while (rzero > 0 && *bp!= '\0') { - --rzero; - *stringp++ = *bp++; - } - p = stringp; - } - - bp = &buf[0]; - - /* Create the exponent */ - if (convertbuffer[0] != '0') - n = decpt - 1; - else - n = 0 ; - if (n < 0) - n = -n; - _fourdigitsquick( (short unsigned) n, &(expbuf[2]) ) ; - expbuf[6] = 0 ; - if (n < 100) - /* - * Normally two digit exponent field, - * three or four if required. - */ - { suffix = &(expbuf[4]) ; suffixlength = 4 ; } - else if (n < 1000) - { suffix = &(expbuf[3]) ; suffixlength = 5 ; } - else - { suffix = &(expbuf[2]) ; suffixlength = 6 ; } - /* Put in the exponent sign */ - *--suffix = (decpt > 0 || convertbuffer[0] == '0' )? '+': '-'; - - /* Put in the e; note kludge in 'g' format */ - *--suffix = fcode; -ebreak: -#if FZERO - if (compat_fzero &! fminus) - /* Calculate padding zero requirement */ - lzero = width - (strlen(prefix) - + (p - buf) + rzero + suffixlength); -#endif - break; - - case 'f': - /* - * F-format floating point. This is - * a good deal less simple than E-format. - * The overall strategy will be to call - * fconvert, reformat its result into buf, - * and calculate how many trailing - * zeroes will be required. There will - * never be any leading zeroes needed. - */ - - /* Establish default precision */ - if (prec < 0) - prec = 6; - - if (Lsize == 0) { - dval = va_arg(args.ap, double); - bp = fconvert(dval, prec, &decpt, &sign, convertbuffer); - } else { - GETQVAL ; - bp = qfconvert(&qval, prec, &decpt, &sign, convertbuffer); - } - - /* Determine the prefix */ - if (sign) - prefix = "-"; - else if (fplus) - prefix = "+"; - else if (fblank) - prefix = " "; - if (convertbuffer[0] > '9') - { /* handle infinity, nan */ - bp = &convertbuffer[0]; - for (p = bp+1 ; *p != 0 ; p++) ; - goto fbreak ; - } - { - char *stringp; - /* Initialize buffer pointer */ - stringp = &buf[0]; - - /* Emit the digits before the decimal point */ - n = decpt; - if (n <= 0) - *stringp++ = '0'; - else - do - if (*bp == '\0' ) - *stringp++ = '0'; - else { - *stringp++ = *bp++; - } - while (--n != 0); - - /* Decide whether we need a decimal point */ - if (fsharp || prec > 0) - *stringp++ = decpt_char; - - /* Digits(if any) after the decimal point */ - n = prec; - rzero = prec - n; - while (--n >= 0) { - if (++decpt <= 0 || *bp == '\0') - *stringp++ = '0'; - else { - *stringp++ = *bp++; - } - } -#if FZERO - if (compat_fzero &! fminus) - /* Calculate padding zero requirement */ - lzero = width - (strlen(prefix) - + (stringp - buf) + rzero); -#endif - p = stringp; - } - - bp = &buf[0]; -fbreak: - break; - - case 'G': - case 'g': - /* - * g-format. We play around a bit - * and then jump into e or f, as needed. - */ - - /* Establish default precision */ - if (prec < 0) - prec = 6; - else if (prec == 0) - prec = 1; - - if (Lsize == 0) { - dval = va_arg(args.ap, double); - bp = gconvert(dval, prec, fsharp, convertbuffer); - } else { - GETQVAL; - bp = qgconvert(&qval, prec, fsharp, convertbuffer); - } - bp = convertbuffer ; - if (convertbuffer[0] == '-') { - prefix = "-" ; - bp++; - } - else if (fplus) - prefix = "+"; - else if (fblank) - prefix = " "; - if (isupper(fcode)) - { /* Put in a big E for small minds. */ - for (p = bp ; (*p != NULL) && (*p != 'e') ; p++) ; - if (*p == 'e') *p = 'E' ; - for (; (*p != NULL) ; p++) ; - /* Find end of string. */ - } - else - for (p = bp ; *p != NULL ; p++) ; - /* Find end of string. */ - rzero = 0; -#if FZERO - if (compat_fzero & !fminus) - /* Calculate padding zero requirement */ - lzero = width - (strlen(prefix) - + (p - bp) + rzero); -#endif - break ; - -#endif - case 'c': - buf[0] = va_arg(args.ap, int); - bp = &buf[0]; - p = bp + 1; - break; - - case 's': - bp = va_arg(args.ap, char *); - if (prec < 0) - prec = MAXINT; - /* avoid *(0) */ - if (bp == NULL) - bp = nullstr; - for (n=0; *bp++ != '\0' && n < prec; n++) - ; -#if FZERO - if (compat_fzero &! fminus) - lzero = width - n; -#endif - p = --bp; - bp -= n; - break; - - case '\0': - /* well, what's the punch line? */ - goto out; - - case 'n': - svswitch = 1; - break; - default: - p = bp = &fcode; - p++; - break; - - } - /* Calculate number of padding blanks */ - nblank = width -#if FLOAT - - (rzero < 0? 0: rzero) - - strlen(suffix) -#endif - - (p - bp) - - (lzero < 0? 0: lzero) - - strlen(prefix); - - /* Blanks on left if required */ - if (!fminus) - while (--nblank >= 0) - emitchar(' '); - - /* Prefix, if any */ - while (*prefix != '\0') { - emitchar(*prefix); - prefix++; - } - - /* Zeroes on the left */ - while (--lzero >= 0) - emitchar('0'); - - /* The value itself */ - while (bp < p) { - emitchar(*bp); - bp++; - } -#if FLOAT - /* Zeroes on the right */ - while (--rzero >= 0) - emitchar('0'); - - /* The suffix */ - while (*suffix != '\0') { - emitchar(*suffix); - suffix++; - } -#endif - /* Blanks on the right if required */ - if (fminus) - while (--nblank >= 0) - emitchar(' '); - /* If %n is seen, save count in argument */ - if (svswitch == 1) { - long *svcount; - svcount = va_arg (args.ap, long *); - *svcount = count; - svswitch = 0; - } - } /* else */ - } while ((c = *cp++) != '\0'); /* do */ -out: - file->_ptr = fileptr; - file->_cnt = filecnt; - if (file->_flag & (_IONBF | _IOLBF) && - (file->_flag & _IONBF || - memchr((char *)file->_base, '\n', fileptr - file->_base) != NULL)) - (void) _xflsbuf(file); - return (ferror(file)? EOF: count); -} - -#if defined(__sparc) -/* - * We use "double *" instead of "quadruple *" to skip over the pointer to - * long double on the argument list since a pointer is a pointer after all. - */ -#define SKIPQVAL { \ - (void) va_arg(args.ap, double *); \ -} -#else /* Sun-3 */ -#define SKIPQVAL { \ - int iq; \ - for (iq = 0; iq < 4; iq++) \ - (void) va_arg(args.ap, unsigned long); \ -} -#endif -/* - * This function initializes arglst, to contain the appropriate va_list values - * for the first MAXARGS arguments. - */ -void -_mkarglst(char *fmt, stva_list args, stva_list arglst[]) -{ - static char *digits = "01234567890", *skips = "# +-.0123456789h$"; - - enum types {INT = 1, LONG, CHAR_PTR, DOUBLE, LONG_DOUBLE, VOID_PTR, - LONG_PTR, INT_PTR}; - enum types typelst[MAXARGS], curtype; - int maxnum, n, curargno, flags; - - /* - * Algorithm 1. set all argument types to zero. - * 2. walk through fmt putting arg types in typelst[]. - * 3. walk through args using va_arg(args.ap, typelst[n]) - * and set arglst[] to the appropriate values. - * Assumptions: Cannot use %*$... to specify variable position. - */ - - (void)memset((void *)typelst, 0, sizeof(typelst)); - maxnum = -1; - curargno = 0; - while ((fmt = strchr(fmt, '%')) != 0) - { - fmt++; /* skip % */ - if (fmt[n = strspn(fmt, digits)] == '$') - { - curargno = atoi(fmt) - 1; /* convert to zero base */ - fmt += n + 1; - } - flags = 0; - again:; - fmt += strspn(fmt, skips); - switch (*fmt++) - { - case '%': /*there is no argument! */ - continue; - case 'l': - flags |= 0x1; - goto again; - case 'L': - flags |= 0x8; - goto again; - case '*': /* int argument used for value */ - flags |= 0x2; - curtype = INT; - break; - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - if (flags & 0x8) - curtype = LONG_DOUBLE; - else - curtype = DOUBLE; - break; - case 's': - curtype = CHAR_PTR; - break; - case 'p': - curtype = VOID_PTR; - break; - case 'n': - if (flags & 0x1) - curtype = LONG_PTR; - else - curtype = INT_PTR; - break; - default: - if (flags & 0x1) - curtype = LONG; - else - curtype = INT; - break; - } - if (curargno >= 0 && curargno < MAXARGS) - { - typelst[curargno] = curtype; - if (maxnum < curargno) - maxnum = curargno; - } - curargno++; /* default to next in list */ - if (flags & 0x2) /* took care of *, keep going */ - { - flags ^= 0x2; - goto again; - } - } - for (n = 0 ; n <= maxnum; n++) - { - arglst[n] = args; - if (typelst[n] == 0) - typelst[n] = INT; - - switch (typelst[n]) - { - case INT: - va_arg(args.ap, int); - break; - case LONG: - va_arg(args.ap, long); - break; - case CHAR_PTR: - va_arg(args.ap, char *); - break; - case DOUBLE: - va_arg(args.ap, double); - break; - case LONG_DOUBLE: - SKIPQVAL - break; - case VOID_PTR: - va_arg(args.ap, void *); - break; - case LONG_PTR: - va_arg(args.ap, long *); - break; - case INT_PTR: - va_arg(args.ap, int *); - break; - } - } -} - -/* - * This function is used to find the va_list value for arguments whose - * position is greater than MAXARGS. This function is slow, so hopefully - * MAXARGS will be big enough so that this function need only be called in - * unusual circumstances. - * pargs is assumed to contain the value of arglst[MAXARGS - 1]. - */ -void -_getarg(char *fmt, stva_list *pargs, int argno) -{ - static char *digits = "01234567890", *skips = "# +-.0123456789h$"; - int i, n, curargno, flags; - char *sfmt = fmt; - int found = 1; - - curargno = i = MAXARGS; - while (found) - { - fmt = sfmt; - found = 0; - while ((i != argno) && (fmt = strchr(fmt, '%')) != 0) - { - fmt++; /* skip % */ - if (fmt[n = strspn(fmt, digits)] == '$') - { - curargno = atoi(fmt); - fmt += n + 1; - } - - /* find conversion specifier for next argument */ - if (i != curargno) - { - curargno++; - continue; - } else - found = 1; - flags = 0; - again:; - fmt += strspn(fmt, skips); - switch (*fmt++) - { - case '%': /*there is no argument! */ - continue; - case 'l': - flags |= 0x1; - goto again; - case 'L': - flags |= 0x8; - goto again; - case '*': /* int argument used for value */ - flags |= 0x2; - (void)va_arg((*pargs).ap, int); - break; - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - if (flags & 0x8) { -#define args (*pargs) - SKIPQVAL -#undef args - } - else - (void)va_arg((*pargs).ap, double); - break; - case 's': - (void)va_arg((*pargs).ap, char *); - break; - case 'p': - (void)va_arg((*pargs).ap, void *); - break; - case 'n': - if (flags & 0x1) - (void)va_arg((*pargs).ap, long *); - else - (void)va_arg((*pargs).ap, int *); - break; - default: - if (flags & 0x1) - (void)va_arg((*pargs).ap, long int); - else - (void)va_arg((*pargs).ap, int); - break; - } - i++; - curargno++; /* default to next in list */ - if (flags & 0x2) /* took care of *, keep going */ - { - flags ^= 0x2; - goto again; - } - } - - /* missing specifier for parameter, assume parameter is an int */ - if (!found && i != argno) { - (void)va_arg((*pargs).ap, int); - i++; - curargno++; - found = 1; - } - } -} - - -/* - * parse a string, mini parse - */ -static char * -_check_dol(char *s, int *val) -{ - char *os; /* save old string */ - int tmp_val = 0; - int flag = 0; - - while (isdigit (*s)) { - ++flag; - tmp_val = tmp_val*10 + *s - '0'; - s++; - } - if (flag == 0) - return ((char *)NULL); - if (*s == '$') { - *val = tmp_val; - return(++s); - } - return ((char *)NULL); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/doprnt.h b/usr/src/lib/libbc/libc/stdio/common/doprnt.h deleted file mode 100644 index 68c4e5d06e..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/doprnt.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* Maximum number of digits in any integer (long) representation */ -#define MAXDIGS 11 - -/* Convert a digit character to the corresponding number */ -#define tonumber(x) ((x)-'0') - -/* Convert a number between 0 and 9 to the corresponding digit */ -#define todigit(x) ((x)+'0') - -/* Data type for flags */ -typedef char bool; diff --git a/usr/src/lib/libbc/libc/stdio/common/doscan.c b/usr/src/lib/libbc/libc/stdio/common/doscan.c deleted file mode 100644 index 08cc3ff215..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/doscan.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> -#include <ctype.h> -#include <stdarg.h> -#include <values.h> -#include <floatingpoint.h> -#include <errno.h> -#include <memory.h> - -#define NCHARS (1 << BITSPERBYTE) -#define locgetc() (chcount+=1,getc(iop)) -#define locungetc(x) (chcount-=1,ungetc(x,iop)) - -static int chcount,flag_eof; - -static int number(int, int, int, int, FILE *, va_list *); -static int string(int, int, int, char *, FILE *, va_list *); -static unsigned char *setup(unsigned char *, char *); - -#ifdef S5EMUL -#define isws(c) isspace(c) -#else -/* - * _sptab[c+1] is 1 iff 'c' is a white space character according to the - * 4.2BSD "scanf" definition - namely, SP, TAB, and NL are the only - * whitespace characters. - */ -static char _sptab[1+256] = { - 0, /* EOF - not a whitespace char */ - 0,0,0,0,0,0,0,0, - 0,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 1,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, - 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,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,0,0, -}; - -#define isws(c) ((_sptab + 1)[c] != 0) -#endif - -int -_doscan(FILE *iop, unsigned char *fmt, va_list va_alist) -{ - char tab[NCHARS]; - int ch; - int nmatch = 0, len, inchar, stow, size; - chcount=0; flag_eof=0; - - /******************************************************* - * Main loop: reads format to determine a pattern, - * and then goes to read input stream - * in attempt to match the pattern. - *******************************************************/ - for ( ; ; ) - { - if ( (ch = *fmt++) == '\0') - return(nmatch); /* end of format */ - if (isws(ch)) - { - if (!flag_eof) - { - while (isws(inchar = locgetc())) - ; - if (inchar == EOF) { - chcount--; - flag_eof = 1; - } - else if (locungetc(inchar) == EOF) - flag_eof = 1; - } - continue; - } - if (ch != '%' || (ch = *fmt++) == '%') - { - if ( (inchar = locgetc()) == ch ) - continue; - if (inchar != EOF) { - if (locungetc(inchar) != EOF) - return(nmatch); /* failed to match input */ - } else { - chcount--; - } - break; - } - if (ch == '*') - { - stow = 0; - ch = *fmt++; - } - else - stow = 1; - - for (len = 0; isdigit(ch); ch = *fmt++) - len = len * 10 + ch - '0'; - if (len == 0) - len = MAXINT; - if ( (size = ch) == 'l' || (size == 'h') || (size == 'L') ) - ch = *fmt++; - if (ch == '\0' || - ch == '[' && (fmt = setup(fmt, tab)) == NULL) - return(EOF); /* unexpected end of format */ - if (isupper(ch)) /* no longer documented */ - { - /* - * The rationale behind excluding the size - * of 'L' is that the 'L' size specifier was - * introduced in ANSI/ISO-C. If the user - * specifies a format of %LG, it can mean - * nothing other than "long double", be the - * code ANSI or not. Mapping it to "double" - * makes no sense. - */ - if (size != 'L') - size = 'l'; -#ifdef S5EMUL - ch = _tolower(ch); -#else - ch = tolower(ch); -#endif - } - switch(ch) - { - case 'c': - case 's': - case '[': - if ((size = string(stow,ch,len,tab,iop,&va_alist)) < 0) - goto out; /* EOF seen, nothing converted */ - break; - case 'n': - if (stow == 0) - continue; - if (size == 'h') - *va_arg(va_alist, short *) = (short) chcount; - else if (size == 'l') - *va_arg(va_alist, long *) = (long) chcount; - else - *va_arg(va_alist, int *) = (int) chcount; - continue; - default: - if ((size = number(stow, ch, len, size, iop, &va_alist)) < 0) - goto out; /* EOF seen, nothing converted */ - break; - } - if (size) - nmatch += stow; - else - return((flag_eof && !nmatch) ? EOF : nmatch); - continue; - } -out: - return (nmatch != 0 ? nmatch : EOF); /* end of input */ -} - -/* - ************************************************************** - * Functions to read the input stream in an attempt to match incoming - * data to the current pattern from the main loop of _doscan(). - ************************************************************** - */ -static int -number(int stow, int type, int len, int size, FILE *iop, va_list *listp) -{ - char numbuf[64], inchar, lookahead; - char *np = numbuf; - int c, base; - int digitseen = 0, floater = 0, negflg = 0; - long lcval = 0; - switch(type) - { - case 'e': - case 'f': - case 'g': - floater++; - case 'd': - case 'u': - case 'i': - base = 10; - break; - case 'o': - base = 8; - break; - case 'x': - base = 16; - break; - default: - return(0); /* unrecognized conversion character */ - } - if (!flag_eof) - { - while (isws(c = locgetc())) - ; - } - else - c = locgetc(); - if (c == EOF) { - chcount--; - return(-1); /* EOF before match */ - } - if (floater != 0) { /* Handle floating point with - * file_to_decimal. */ - decimal_mode dm; - decimal_record dr; - fp_exception_field_type efs; - enum decimal_string_form form; - char *echar; - int nread, ic; - char buffer[1024]; - char *nb = buffer; - - locungetc(c); - if (len > 1024) - len = 1024; - file_to_decimal(&nb, len, 0, &dr, &form, &echar, iop, &nread); - if (stow && (form != invalid_form)) { - dm.rd = fp_direction; - if (size == 'l') { /* double */ - decimal_to_double((double *) va_arg(*listp, double *), &dm, &dr, &efs); - } else if (size == 'L') { /* quad */ - decimal_to_quadruple((quadruple *)va_arg(*listp, double *), &dm, &dr, &efs); - } else {/* single */ - decimal_to_single((float *) va_arg(*listp, float *), &dm, &dr, &efs); - } - if ((efs & (1 << fp_overflow)) != 0) { - errno = ERANGE; - } - if ((efs & (1 << fp_underflow)) != 0) { - errno = ERANGE; - } - } - chcount += nread; /* Count characters read. */ - c = *nb; /* Get first unused character. */ - ic = c; - if (c == NULL) { - ic = locgetc(); - c = ic; - /* - * If null, first unused may have been put back - * already. - */ - } - if (ic == EOF) { - chcount--; - flag_eof = 1; - } else if (locungetc(c) == EOF) - flag_eof = 1; - return ((form == invalid_form) ? 0 : 1); /* successful match if - * non-zero */ - } - switch(c) { - case '-': - negflg++; - if (type == 'u') - break; - case '+': /* fall-through */ - if (--len <= 0) - break; - if ( (c = locgetc()) != '0') - break; - case '0': - if ( (type != 'i') || (len <= 1) ) - break; - if ( ((inchar = locgetc()) == 'x') || (inchar == 'X') ) - { - /* If not using sscanf and * - * at the buffer's end * - * then LOOK ahead */ - - if ( (iop->_flag & _IOSTRG) || (iop->_cnt != 0) ) - lookahead = locgetc(); - else - { - if ( read(fileno(iop),np,1) == 1) - lookahead = *np; - else - lookahead = EOF; - chcount += 1; - } - if ( isxdigit(lookahead) ) - { - base =16; - - if ( len <= 2) - { - locungetc(lookahead); - len -= 1; /* Take into account the 'x'*/ - } - else - { - c = lookahead; - len -= 2; /* Take into account '0x'*/ - } - } - else - { - locungetc(lookahead); - locungetc(inchar); - } - } - else - { - locungetc(inchar); - base = 8; - } - } - if (!negflg || type != 'u') - for (; --len >= 0 ; *np++ = c, c = locgetc()) - { - if (np > numbuf + 62) - { - errno = ERANGE; - return(0); - } - if (isdigit(c)) - { - int digit; - digit = c - '0'; - if (base == 8) - { - if (digit >= 8) - break; - if (stow) - lcval = (lcval<<3) + digit; - } - else - { - if (stow) - { - if (base == 10) - lcval = (((lcval<<2) + lcval)<<1) + digit; - else /* base == 16 */ - lcval = (lcval<<4) + digit; - } - } - digitseen++; - - - continue; - } - else if (base == 16 && isxdigit(c)) - { - int digit; - digit = c - (isupper(c) ? 'A' - 10 : 'a' - 10); - if (stow) - lcval = (lcval<<4) + digit; - digitseen++; - continue; - } - break; - } - - - if (stow && digitseen) - { - /* suppress possible overflow on 2's-comp negation */ - if (negflg && lcval != HIBITL) - lcval = -lcval; - if (size == 'l') - *va_arg(*listp, long *) = lcval; - else if (size == 'h') - *va_arg(*listp, short *) = (short)lcval; - else - *va_arg(*listp, int *) = (int)lcval; - } - if (c == EOF) { - chcount--; - flag_eof=1; - } else if (locungetc(c) == EOF) - flag_eof=1; - return (digitseen); /* successful match if non-zero */ -} - -static int -string(int stow, int type, int len, char *tab, FILE *iop, va_list *listp) -{ - int ch; - char *ptr; - char *start; - - start = ptr = stow ? va_arg(*listp, char *) : NULL; - if (type == 's') - { - if (!flag_eof) - { - while (isws(ch = locgetc())) - ; - } - else - ch = locgetc(); - if (ch == EOF) - return(-1); /* EOF before match */ - while (ch != EOF && !isws(ch)) - { - if (stow) - *ptr = ch; - ptr++; - if (--len <= 0) - break; - ch = locgetc(); - } - } else if (type == 'c') { - if (len == MAXINT) - len = 1; - while ( (ch = locgetc()) != EOF) - { - if (stow) - *ptr = ch; - ptr++; - if (--len <= 0) - break; - } - } else { /* type == '[' */ - while ( (ch = locgetc()) != EOF && !tab[ch]) - { - if (stow) - *ptr = ch; - ptr++; - if (--len <= 0) - break; - } - } - if (ch == EOF ) - { - chcount-=1; - flag_eof = 1; - } - else if (len > 0 && locungetc(ch) == EOF) - flag_eof = 1; - if (ptr == start) - return(0); /* no match */ - if (stow && type != 'c') - *ptr = '\0'; - return (1); /* successful match */ -} - -static unsigned char * -setup(unsigned char *fmt, char *tab) -{ - int b, c, d, t = 0; - - if (*fmt == '^') - { - t++; - fmt++; - } - (void) memset(tab, !t, NCHARS); - if ( (c = *fmt) == ']' || c == '-') /* first char is special */ - { - tab[c] = t; - fmt++; - } - while ( (c = *fmt++) != ']') - { - if (c == '\0') - return(NULL); /* unexpected end of format */ - if (c == '-' && (d = *fmt) != ']' && (b = fmt[-2]) < d) - { - (void) memset(&tab[b], t, d - b + 1); - fmt++; - } - else - tab[c] = t; - } - return (fmt); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fdopen.c b/usr/src/lib/libbc/libc/stdio/common/fdopen.c deleted file mode 100644 index a225c02b45..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fdopen.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.4 */ - -/*LINTLIBRARY*/ -/* - * Unix routine to do an "fopen" on file descriptor - * The mode has to be repeated because you can't query its - * status - */ - -#include <stdio.h> -#include <sys/errno.h> - -extern int errno; -extern long lseek(); -extern FILE *_findiop(); - -FILE * -fdopen(fd, mode) -int fd; -register char *mode; -{ - static int nofile = -1; - register FILE *iop; - - if(nofile < 0) - nofile = getdtablesize(); - - if(fd < 0 || fd >= nofile) { - errno = EINVAL; - return(NULL); - } - - if((iop = _findiop()) == NULL) - return(NULL); - - iop->_cnt = 0; - iop->_file = fd; - iop->_base = iop->_ptr = NULL; - iop->_bufsiz = 0; - switch(*mode) { - - case 'r': - iop->_flag = _IOREAD; - break; - case 'a': - (void) lseek(fd, 0L, 2); - /* No break */ - case 'w': - iop->_flag = _IOWRT; - break; - default: - errno = EINVAL; - return(NULL); - } - - if(mode[1] == '+') - iop->_flag = _IORW; - - return(iop); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/feof.c b/usr/src/lib/libbc/libc/stdio/common/feof.c deleted file mode 100644 index 9bbaeded9b..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/feof.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - - -/*LINTLIBRARY*/ -#include <stdio.h> - -#undef feof -#define __feof__(p) (((p)->_flag&_IOEOF)!=0) - -int -feof(fp) -register FILE *fp; -{ - return (__feof__(fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/ferror.c b/usr/src/lib/libbc/libc/stdio/common/ferror.c deleted file mode 100644 index 4c0b69e3b9..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/ferror.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> - -#undef ferror -#define __ferror__(p) (((p)->_flag&_IOERR)!=0) - -int -ferror(fp) -register FILE *fp; -{ - return (__ferror__(fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fgetc.c b/usr/src/lib/libbc/libc/stdio/common/fgetc.c deleted file mode 100644 index 8ed7c98f0b..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fgetc.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -int -fgetc(fp) -register FILE *fp; -{ - return(getc(fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fgets.c b/usr/src/lib/libbc/libc/stdio/common/fgets.c deleted file mode 100644 index d6cfb55466..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fgets.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 3.3 */ - -/*LINTLIBRARY*/ -/* - * This version reads directly from the buffer rather than looping on getc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - */ -#include <stdio.h> -#include "stdiom.h" - -#define MIN(x, y) (x < y ? x : y) - -extern int _filbuf(); -extern char *memccpy(); - -char * -fgets(ptr, size, iop) -char *ptr; -register int size; -register FILE *iop; -{ - char *p, *ptr0 = ptr; - register int n; - - if ( !(iop->_flag & (_IOREAD|_IORW)) ) { - iop->_flag |= _IOERR; - return (NULL); - } - - for (size--; size > 0; size -= n) { - if (iop->_cnt <= 0) { /* empty buffer */ - if (_filbuf(iop) == EOF) { - if (ptr0 == ptr) - return (NULL); - break; /* no more data */ - } - iop->_ptr--; - iop->_cnt++; - } - n = MIN(size, iop->_cnt); - if ((p = memccpy(ptr, (char *) iop->_ptr, '\n', n)) != NULL) - n = p - ptr; - ptr += n; - iop->_cnt -= n; - iop->_ptr += n; - _BUFSYNC(iop); - if (p != NULL) - break; /* found '\n' in buffer */ - } - *ptr = '\0'; - return (ptr0); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fileno.c b/usr/src/lib/libbc/libc/stdio/common/fileno.c deleted file mode 100644 index 5d91655a26..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fileno.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> - -int -fileno(fp) -register FILE *fp; -{ - return (fp->_file); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/findiop.c b/usr/src/lib/libbc/libc/stdio/common/findiop.c deleted file mode 100644 index b038b0bc8d..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/findiop.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1987 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> -#include <errno.h> -#include <malloc.h> -#include "iob.h" - -#define active(iop) ((iop)->_flag & (_IOREAD|_IOWRT|_IORW)) - -static unsigned char sbuf[NSTATIC][_SBFSIZ]; -unsigned char (*_smbuf)[_SBFSIZ] = sbuf; -static FILE **iobglue; -static FILE **endglue; - -/* - * Find a free FILE for fopen et al. - * We have a fixed static array of entries, and in addition - * may allocate additional entries dynamically, up to the kernel - * limit on the number of open files. - * At first just check for a free slot in the fixed static array. - * If none are available, then we allocate a structure to glue together - * the old and new FILE entries, which are then no longer contiguous. - */ -FILE * -_findiop(void) -{ - FILE **iov, *iop; - FILE *fp; - - if(iobglue == NULL) { - for(iop = _iob; iop < _iob + NSTATIC; iop++) - if(!active(iop)) - return(iop); - - if(_f_morefiles() == 0) { - errno = ENOMEM; - return(NULL); - } - } - - iov = iobglue; - while(*iov != NULL && active(*iov)) - if (++iov >= endglue) { - errno = EMFILE; - return(NULL); - } - - if(*iov == NULL) - *iov = (FILE *)calloc(1, sizeof **iov); - - return(*iov); -} - -int -_f_morefiles(void) -{ - FILE **iov; - FILE *fp; - unsigned char *cp; - int nfiles; - - nfiles = getdtablesize(); - - iobglue = (FILE **)calloc(nfiles, sizeof *iobglue); - if(iobglue == NULL) - return(0); - - if((_smbuf = (unsigned char (*)[_SBFSIZ])malloc(nfiles * sizeof *_smbuf)) == NULL) { - free((char *)iobglue); - iobglue = NULL; - return(0); - } - - endglue = iobglue + nfiles; - - for(fp = _iob, iov = iobglue; fp < &_iob[NSTATIC]; /* void */) - *iov++ = fp++; - - return(1); -} - -void -f_prealloc(void) -{ - FILE **iov; - FILE *fp; - - if(iobglue == NULL && _f_morefiles() == 0) - return; - - for(iov = iobglue; iov < endglue; iov++) - if(*iov == NULL) - *iov = (FILE *)calloc(1, sizeof **iov); -} - -void -_fwalk(int (*function)(FILE *)) -{ - FILE **iov; - FILE *fp; - - if(function == NULL) - return; - - if(iobglue == NULL) { - for(fp = _iob; fp < &_iob[NSTATIC]; fp++) - if(active(fp)) - (*function)(fp); - } else { - for(iov = iobglue; iov < endglue; iov++) - if(*iov && active(*iov)) - (*function)(*iov); - } -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fputc.c b/usr/src/lib/libbc/libc/stdio/common/fputc.c deleted file mode 100644 index 54ceb3220b..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fputc.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -int -fputc(c, fp) -int c; -register FILE *fp; -{ - return(putc(c, fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fputs.c b/usr/src/lib/libbc/libc/stdio/common/fputs.c deleted file mode 100644 index c91c890f85..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fputs.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1995 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - - -/*LINTLIBRARY*/ -/* - * This version writes directly to the buffer rather than looping on putc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - */ -#include <stdio.h> -#include "stdiom.h" -#include <errno.h> -#include <memory.h> - -static char *memnulccpy(char *, char *, int, int); - -int -fputs(char *ptr, FILE *iop) -{ - int ndone = 0, n; - unsigned char *cptr, *bufend; - char *p; - char c; - - if (_WRTCHK(iop)) { - iop->_flag |= _IOERR; -#ifdef POSIX - errno = EBADF; -#endif /* POSIX */ - return (EOF); - } - bufend = iop->_base + iop->_bufsiz; - - if ((iop->_flag & _IONBF) == 0) { - if (iop->_flag & _IOLBF) { - for ( ; ; ptr += n) { - while ((n = bufend - (cptr = iop->_ptr)) <= 0) - /* full buf */ - if (_xflsbuf(iop) == EOF) - return(EOF); - if ((p = memnulccpy((char *) cptr, ptr, '\n', n)) != NULL) { - /* - * Copy terminated either because we - * saw a newline or we saw a NUL (end - * of string). - */ - c = *(p - 1); /* last character moved */ - if (c == '\0') - p--; /* didn't write '\0' */ - n = p - (char *) cptr; - } - iop->_cnt -= n; - iop->_ptr += n; - _BUFSYNC(iop); - ndone += n; - if (p != NULL) { - /* - * We found either a newline or a NUL. - * If we found a newline, flush the - * buffer. - * If we found a NUL, we're done. - */ - if (c == '\n') { - if (_xflsbuf(iop) == EOF) - return(EOF); - } else { - /* done */ - return(ndone); - } - } - } - } else { - for ( ; ; ptr += n) { - while ((n = bufend - (cptr = iop->_ptr)) <= 0) - /* full buf */ - if (_xflsbuf(iop) == EOF) - return(EOF); - if ((p = memccpy((char *) cptr, ptr, '\0', n)) != NULL) - n = (p - (char *) cptr) - 1; - iop->_cnt -= n; - iop->_ptr += n; - _BUFSYNC(iop); - ndone += n; - if (p != NULL) { - /* done */ - return(ndone); - } - } - } - } else { - /* write out to an unbuffered file */ - return (write(iop->_file, ptr, strlen(ptr))); - } -} - -/* - * Copy s2 to s1, stopping if character c or a NUL is copied. - * Copy no more than n bytes. - * Return a pointer to the byte after character c or NUL in the copy, - * or NULL if c or NUL is not found in the first n bytes. - */ -static char * -memnulccpy(char *s1, char *s2, int c, int n) -{ - int cmoved; - - while (--n >= 0) { - cmoved = *s2++; - if ((*s1++ = cmoved) == '\0' || cmoved == c) - return (s1); - } - return (0); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fread.c b/usr/src/lib/libbc/libc/stdio/common/fread.c deleted file mode 100644 index 0a0aeea727..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fread.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -/* - * This version reads directly from the buffer rather than looping on getc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - */ -#include <stdio.h> -#include "stdiom.h" -#include <memory.h> - -#define MIN(x, y) (x < y ? x : y) - -extern int _filbuf(); - -int -fread(char *ptr, int size, int count, FILE *iop) -{ - unsigned int nleft; - int n; - - if (size <= 0 || count <= 0) return 0; - nleft = count * size; - - /* Put characters in the buffer */ - /* note that the meaning of n when just starting this loop is - irrelevant. It is defined in the loop */ - for ( ; ; ) { - if (iop->_cnt <= 0) { /* empty buffer */ - if (_filbuf(iop) == EOF) - return (count - (nleft + size - 1)/size); - iop->_ptr--; - iop->_cnt++; - } - n = MIN(nleft, iop->_cnt); - ptr = memcpy(ptr, (char *) iop->_ptr, n) + n; - iop->_cnt -= n; - iop->_ptr += n; - _BUFSYNC(iop); - if ((nleft -= n) == 0) - return (count); - } -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fseek.c b/usr/src/lib/libbc/libc/stdio/common/fseek.c deleted file mode 100644 index 348f11302d..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fseek.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -/* - * Seek for standard library. Coordinates with buffering. - */ -#include <stdio.h> - -extern long lseek(); -extern int fflush(); - -int -fseek(iop, offset, ptrname) -register FILE *iop; -long offset; -int ptrname; -{ - register int resync, c; - long p = -1; /* can't happen? */ - - iop->_flag &= ~_IOEOF; - if(iop->_flag & _IOREAD) { - if(ptrname < 2 && iop->_base && !(iop->_flag&_IONBF)) { - c = iop->_cnt; - p = offset; - if(ptrname == 0) { - long curpos = lseek(fileno(iop), 0L, 1); - if (curpos == -1) - return (-1); - p += c - curpos; - resync = offset&01; - } else { - offset -= (long)c; - resync = 0; - } - if(!(iop->_flag&_IORW) && c > 0 && p <= c && - p >= iop->_base - iop->_ptr) { - iop->_ptr += (int)p; - iop->_cnt -= (int)p; - return(0); - } - } else - resync = 0; - if(iop->_flag & _IORW) { - iop->_ptr = iop->_base; - iop->_flag &= ~_IOREAD; - resync = 0; - } - p = lseek(fileno(iop), offset-resync, ptrname); - iop->_cnt = 0; - if (resync && p != -1) - if (getc(iop) == EOF) - p = -1; - } else if(iop->_flag & (_IOWRT | _IORW)) { - p = fflush(iop); - iop->_cnt = 0; - if(iop->_flag & _IORW) { - iop->_flag &= ~_IOWRT; - iop->_ptr = iop->_base; - } - return(lseek(fileno(iop), offset, ptrname) == -1 || p == EOF ? - -1 : 0); - } - return((p == -1)? -1: 0); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/ftell.c b/usr/src/lib/libbc/libc/stdio/common/ftell.c deleted file mode 100644 index 85659bb764..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/ftell.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -/* - * Return file offset. - * Coordinates with buffering. - */ -#include <stdio.h> - -extern long lseek(); - -long -ftell(iop) -register FILE *iop; -{ - register long tres; - register int adjust; - - if(iop->_cnt < 0) - iop->_cnt = 0; - if(iop->_flag & _IOREAD) - adjust = - iop->_cnt; - else if(iop->_flag & (_IOWRT | _IORW)) { - adjust = 0; - if(iop->_flag & _IOWRT && iop->_base && - (iop->_flag & _IONBF) == 0) - adjust = iop->_ptr - iop->_base; - } else - return(-1); - tres = lseek(fileno(iop), 0L, 1); - if(tres >= 0) - tres += (long)adjust; - return(tres); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/fwrite.c b/usr/src/lib/libbc/libc/stdio/common/fwrite.c deleted file mode 100644 index c68412ed52..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/fwrite.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 3.6 */ - -/*LINTLIBRARY*/ -/* - * This version writes directly to the buffer rather than looping on putc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - * - * This version does buffered writes larger than BUFSIZ directly, when - * the buffer is empty. - */ -#include <stdio.h> -#include "stdiom.h" - -#define MIN(x, y) (x < y ? x : y) - -extern char *memcpy(); - -int -fwrite(ptr, size, count, iop) -char *ptr; -int size, count; -register FILE *iop; -{ - register unsigned nleft; - register int n; - register unsigned char *cptr, *bufend; - register unsigned char *prev_ptr; - - if (size <= 0 || count <= 0 || _WRTCHK(iop)) - return (0); - - bufend = iop->_base + iop->_bufsiz; - nleft = count*size; - - /* if the file is unbuffered, or if the iop->ptr = iop->base, and there - is > BUFSZ chars to write, we can do a direct write */ - prev_ptr = iop->_ptr; - if (iop->_base >= iop->_ptr) { /*this covers the unbuffered case, too*/ - if (((iop->_flag & _IONBF) != 0) || (nleft >= BUFSIZ)) { - if ((n=write(fileno(iop),ptr,nleft)) != nleft) - { - iop->_flag |= _IOERR; - n = (n >= 0) ? n : 0; - } - return n/size; - } - } - /* Put characters in the buffer */ - /* note that the meaning of n when just starting this loop is - irrelevant. It is defined in the loop */ - for (; ; ptr += n) { - while ((n = bufend - (cptr = iop->_ptr)) <= 0) /* full buf */ - if (_xflsbuf(iop) == EOF) - return (count - (nleft + size - 1)/size); - n = MIN(nleft, n); - (void) memcpy((char *) cptr, ptr, n); - iop->_cnt -= n; - iop->_ptr += n; - _BUFSYNC(iop); - /* done; flush if linebuffered with a newline */ - if ((nleft -= n) == 0) { - if (iop->_flag & (_IOLBF | _IONBF)) { - if ((iop->_flag & _IONBF) || (memchr(prev_ptr, - '\n',iop->_ptr - prev_ptr) != NULL)) { - (void) _xflsbuf(iop); - } - } - return (count); - } - } -} diff --git a/usr/src/lib/libbc/libc/stdio/common/getc.c b/usr/src/lib/libbc/libc/stdio/common/getc.c deleted file mode 100644 index 617c18be80..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/getc.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> - -#undef getc -#define __getc__(p) (--(p)->_cnt>=0? ((int)*(p)->_ptr++):_filbuf(p)) - -int -getc(fp) -register FILE *fp; -{ - return (__getc__(fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/getchar.c b/usr/src/lib/libbc/libc/stdio/common/getchar.c deleted file mode 100644 index db8a18821b..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/getchar.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -/* - * A subroutine version of the macro getchar. - */ -#include <stdio.h> -#undef getchar - -int -getchar() -{ - return(getc(stdin)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/gets.c b/usr/src/lib/libbc/libc/stdio/common/gets.c deleted file mode 100644 index a78346dbab..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/gets.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -/* - * This version reads directly from the buffer rather than looping on getc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - */ -#include <stdio.h> -#include "stdiom.h" -#include <memory.h> - -extern int _filbuf(); - -char * -gets(char *ptr) -{ - char *p, *ptr0 = ptr; - int n; - - for ( ; ; ) { - if (stdin->_cnt <= 0) { /* empty buffer */ - if (_filbuf(stdin) == EOF) { - if (ptr0 == ptr) - return (NULL); - break; /* no more data */ - } - stdin->_ptr--; - stdin->_cnt++; - } - n = stdin->_cnt; - if ((p = memccpy(ptr, (char *) stdin->_ptr, '\n', n)) != NULL) - n = p - ptr; - ptr += n; - stdin->_cnt -= n; - stdin->_ptr += n; - _BUFSYNC(stdin); - if (p != NULL) { /* found '\n' in buffer */ - ptr--; /* step back over '\n' */ - break; - } - } - *ptr = '\0'; - return (ptr0); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/getw.c b/usr/src/lib/libbc/libc/stdio/common/getw.c deleted file mode 100644 index 97df767bce..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/getw.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -/* - * The intent here is to provide a means to make the order of - * bytes in an io-stream correspond to the order of the bytes - * in the memory while doing the io a `word' at a time. - */ -#include <stdio.h> - -int -getw(stream) -register FILE *stream; -{ - int w; - register char *s = (char *)&w; - register int i = sizeof(int); - - while (--i >= 0) - *s++ = getc(stream); - return (feof(stream) || ferror(stream) ? EOF : w); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/iob.c b/usr/src/lib/libbc/libc/stdio/common/iob.c deleted file mode 100644 index df2e0846d3..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/iob.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1988 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from Sun */ - -#include <stdio.h> -#include "iob.h" - -FILE _iob[NSTATIC] = { -#if pdp11 - { NULL, 0, NULL, 0, _IOREAD, 0 }, /* stdin */ - { NULL, 0, NULL, 0, _IOWRT, 1 }, /* stdout */ - { NULL, 0, NULL, 0, _IOWRT|_IONBF, 2 }, /* stderr */ -#else -#if u370 - { NULL, 0, NULL, 0, _IOREAD, 0 }, /* stdin */ - { NULL, 0, NULL, 0, _IOWRT, 1 }, /* stdout */ - { NULL, 0, NULL, 0, _IOWRT|_IONBF, 2 }, /* stderr */ -#else /* just about every other UNIX system in existence */ - { 0, NULL, NULL, 0, _IOREAD, 0 }, /* stdin */ - { 0, NULL, NULL, 0, _IOWRT, 1 }, /* stdout */ - { 0, NULL, NULL, 0, _IOWRT|_IONBF, 2 }, /* stderr */ -#endif -#endif -}; diff --git a/usr/src/lib/libbc/libc/stdio/common/iob.h b/usr/src/lib/libbc/libc/stdio/common/iob.h deleted file mode 100644 index 644dfecf46..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/iob.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1987 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#define NSTATIC 32 diff --git a/usr/src/lib/libbc/libc/stdio/common/putc.c b/usr/src/lib/libbc/libc/stdio/common/putc.c deleted file mode 100644 index 9cf2d6dae6..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/putc.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> - -#undef putc -#define __putc__(x, p) (--(p)->_cnt >= 0 ?\ - (int)(*(p)->_ptr++ = (unsigned char)(x)) :\ - (((p)->_flag & _IOLBF) && -(p)->_cnt < (p)->_bufsiz ?\ - ((*(p)->_ptr = (unsigned char)(x)) != '\n' ?\ - (int)(*(p)->_ptr++) :\ - _flsbuf(*(unsigned char *)(p)->_ptr, p)) :\ - _flsbuf((unsigned char)(x), p))) - -int -putc(c, fp) -register char c; -register FILE *fp; -{ - return (__putc__(c, fp)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/putchar.c b/usr/src/lib/libbc/libc/stdio/common/putchar.c deleted file mode 100644 index 7a8fb3b9b5..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/putchar.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -/* - * A subroutine version of the macro putchar - */ -#include <stdio.h> -#undef putchar - -int -putchar(c) -register char c; -{ - return(putc(c, stdout)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/puts.c b/usr/src/lib/libbc/libc/stdio/common/puts.c deleted file mode 100644 index ed6297474c..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/puts.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 3.3 */ - -/*LINTLIBRARY*/ -/* - * This version writes directly to the buffer rather than looping on putc. - * Ptr args aren't checked for NULL because the program would be a - * catastrophic mess anyway. Better to abort than just to return NULL. - */ -#include <stdio.h> -#include "stdiom.h" - -extern char *memccpy(); - -int -puts(ptr) -char *ptr; -{ - char *p; - register int ndone = 0, n; - register unsigned char *cptr, *bufend; - - if (_WRTCHK(stdout)) - return (EOF); - - bufend = stdout->_base + stdout->_bufsiz; - - for ( ; ; ptr += n) { - while ((n = bufend - (cptr = stdout->_ptr)) <= 0) /* full buf */ - if (_xflsbuf(stdout) == EOF) - return(EOF); - if ((p = memccpy((char *) cptr, ptr, '\0', n)) != NULL) - n = p - (char *) cptr; - stdout->_cnt -= n; - stdout->_ptr += n; - _BUFSYNC(stdout); - ndone += n; - if (p != NULL) { - stdout->_ptr[-1] = '\n'; /* overwrite '\0' with '\n' */ - if (stdout->_flag & (_IONBF | _IOLBF)) /* flush line */ - if (_xflsbuf(stdout) == EOF) - return(EOF); - return(ndone); - } - } -} diff --git a/usr/src/lib/libbc/libc/stdio/common/putw.c b/usr/src/lib/libbc/libc/stdio/common/putw.c deleted file mode 100644 index db34b3aed4..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/putw.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -/* - * The intent here is to provide a means to make the order of - * bytes in an io-stream correspond to the order of the bytes - * in the memory while doing the io a `word' at a time. - */ -#include <stdio.h> - -int -putw(w, stream) -int w; -register FILE *stream; -{ - register char *s = (char *)&w; - register int i = sizeof(int); - - while (--i >= 0) - (void) putc(*s++, stream); - return (ferror(stream)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/remove.c b/usr/src/lib/libbc/libc/stdio/common/remove.c deleted file mode 100644 index d886a73306..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/remove.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> - -#undef remove - -int -remove(fname) -register char *fname; -{ - return (unlink(fname)); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/rew.c b/usr/src/lib/libbc/libc/stdio/common/rew.c deleted file mode 100644 index d56416aed2..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/rew.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -extern int fflush(); -extern long lseek(); - -void -rewind(iop) -register FILE *iop; -{ - (void) fflush(iop); - (void) lseek(fileno(iop), 0L, 0); - iop->_cnt = 0; - iop->_ptr = iop->_base; - iop->_flag &= ~(_IOERR | _IOEOF); - if(iop->_flag & _IORW) - iop->_flag &= ~(_IOREAD | _IOWRT); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/scanf.c b/usr/src/lib/libbc/libc/stdio/common/scanf.c deleted file mode 100644 index e024fb7c4f..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/scanf.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/*LINTLIBRARY*/ -#include <stdio.h> -#include <ctype.h> -#include <stdarg.h> -#include <errno.h> -#include <string.h> -#include <malloc.h> - -#define ON 1 -#define OFF 0 - -#define ARGMAX 64 -static unsigned char newap[ARGMAX * sizeof(double)]; -static unsigned char newform[256]; - -extern int _doscan(); - -static int format_arg(unsigned char *, unsigned char *, unsigned char *); - -int -scanf(char *fmt, ...) -{ - va_list ap; - char *nf; - int ret_val; - - - va_start(ap, fmt); - if (strlen(fmt) >= sizeof(newform)) { - nf = malloc(strlen(fmt)+1); - if (format_arg((unsigned char *)strcpy(nf, fmt), ap, newap) - == ON) { - va_end(ap); - ret_val = _doscan(stdin, nf, newap); - free(nf); - return(ret_val); - } - free(nf); - } else if (format_arg((unsigned char *)strcpy(newform, fmt), ap, newap) - == ON) { - va_end(ap); - return(_doscan(stdin, newform, newap)); - } - ret_val = _doscan(stdin, fmt, ap); - va_end(ap); - return (ret_val); -} - -int -fscanf(FILE *iop, char *fmt, ...) -{ - va_list ap; - char *nf; - int ret_val; - -#ifdef POSIX - if ( !(iop->_flag & (_IOREAD|_IORW)) ) { - iop->_flag |= _IOERR; - errno = EBADF; - return (EOF); - } -#endif /* POSIX */ - va_start(ap, fmt); - if (strlen(fmt) >= sizeof(newform)) { - nf = malloc(strlen(fmt)+1); - if (format_arg((unsigned char *)strcpy(nf, fmt), ap, newap) - == ON) { - va_end(ap); - ret_val = _doscan(stdin, nf, newap); - free(nf); - return(ret_val); - } - free(nf); - } else if (format_arg((unsigned char *)strcpy(newform, fmt), ap, newap) - == ON) { - va_end(ap); - return(_doscan(iop, newform, newap)); - } - ret_val = _doscan(iop, fmt, ap); - va_end(ap); - return (ret_val); -} - -int -sscanf(char *str, char *fmt, ...) -{ - va_list ap; - FILE strbuf; - char *nf; - int ret_val; - - va_start(ap, fmt); - strbuf._flag = _IOREAD|_IOSTRG; - strbuf._ptr = strbuf._base = (unsigned char*)str; - strbuf._cnt = strlen(str); - strbuf._bufsiz = strbuf._cnt; - if (strlen(fmt) >= sizeof(newform)) { - nf = malloc(strlen(fmt)+1); - if (format_arg((unsigned char *)strcpy(nf, fmt), ap, newap) - == ON) { - va_end(ap); - ret_val = _doscan(stdin, nf, newap); - free(nf); - return(ret_val); - } - free(nf); - } else if (format_arg((unsigned char *)strcpy(newform, fmt), ap, newap) - == ON) { - va_end(ap); - return(_doscan(&strbuf, newform, newap)); - } - ret_val = _doscan(&strbuf, fmt, ap); - va_end(ap); - return (ret_val); -} - -/* - * This function reorganises the format string and argument list. - */ - - -#ifndef NL_ARGMAX -#define NL_ARGMAX 9 -#endif - -struct al { - int a_num; /* arg # specified at this position */ - unsigned char *a_start; /* ptr to 'n' part of '%n$' in format str */ - unsigned char *a_end; /* ptr to '$'+1 part of '%n$' in format str */ - int *a_val; /* pointers to arguments */ -}; - -static int -format_arg(unsigned char *format, unsigned char *list, unsigned char *newlist) -{ - unsigned char *aptr, *bptr, *cptr; - int i, fcode, nl_fmt, num, length, j; - unsigned char *fmtsav; - struct al args[ARGMAX + 1]; - -#ifdef VTEST - { - int fd; - fd = creat("/tmp/SCANF", 0666); - } -#endif - for (i = 0; i <= ARGMAX; args[i++].a_num = 0); - nl_fmt = 0; - i = j = 1; - while (*format) { - while ((fcode = *format++) != '\0' && fcode != '%') ; - if (!fcode || i > ARGMAX) - break; - charswitch: - switch (fcode = *format++) { - case 'l': - case 'h': - goto charswitch; - case '0': case '1': case '2': - case '3': case '4': case '5': - case '6': case '7': case '8': - case '9': - num = fcode - '0'; - fmtsav = format; - while (isdigit(fcode = *format)) { - num = num * 10 + fcode - '0'; - format++; - } - if (*format == '$') { - nl_fmt++; - args[i].a_start = fmtsav - 1; - args[i].a_end = ++format; - if (num > NL_ARGMAX) - num = num; - args[i].a_num = num; - } - goto charswitch; - /* now have arg type only to parse */ - case 'd': case 'u': case 'o': - case 'x': case 'e': case 'f': - case 'g': case 'c': case '[': - case 's': - if (nl_fmt == 0) - return(OFF); - if (!args[i].a_num) { - args[i].a_start = args[i].a_end = format - 1; - args[i].a_num = j++; - } - i++; - break; - case '*': - case '%': - break; - default: - format--; - break; - } - } - length = i; - if (nl_fmt == 0) - return (OFF); - for (i = 1; i < length && args[i].a_num == 0; i++); - - /* - * Reformat the format string - */ - cptr = aptr = args[i].a_start; - do { - bptr = args[i++].a_end; - for (; i < length && args[i].a_num == 0; i++); - if (i == length) - while (*cptr++); - else - cptr = args[i].a_start; - for (; bptr != cptr; *aptr++ = *bptr++); - } while (i < length); - - /* - * Create arglist - * assuming that pointer to all variable type have - * same size. - */ - for (i = 1; i < length; i++) - args[i].a_val = ((int **)(list += sizeof(int *)))[-1]; - - for (i = 1; i < length; i++) { - int **ptr; - ptr = (int **)newlist; - *ptr = args[args[i].a_num].a_val; - newlist += sizeof(int *); - } - return(ON); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/setbuffer.c b/usr/src/lib/libbc/libc/stdio/common/setbuffer.c deleted file mode 100644 index dd1afa49d9..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/setbuffer.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * University Copyright- Copyright (c) 1982, 1986, 1988 - * The Regents of the University of California - * All Rights Reserved - * - * University Acknowledgment- Portions of this document are derived from - * software developed by the University of California, Berkeley, and its - * contributors. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <malloc.h> -#include <unistd.h> - -extern unsigned char (*_smbuf)[_SBFSIZ]; - -void -setbuffer(FILE *iop, char *buf, int size) -{ - int fno = fileno(iop); /* file number */ - - if (iop->_base != NULL && iop->_flag&_IOMYBUF) - free((char *)iop->_base); - iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); - if ((iop->_base = (unsigned char *)buf) == NULL) { - iop->_flag |= _IONBF; /* file unbuffered except in fastio */ - /* use small buffers reserved for this */ - iop->_base = _smbuf[fno]; - iop->_bufsiz = _SBFSIZ; - } else { - /* regular buffered I/O, specified buffer size */ - if (size <= 0) - return; - iop->_bufsiz = size; - } - iop->_ptr = iop->_base; - iop->_cnt = 0; -} - -/* - * set line buffering - */ -int -setlinebuf(FILE *iop) -{ - char *buf; - - fflush(iop); - setbuffer(iop, NULL, 0); - buf = (char *)malloc(128); - if (buf != NULL) { - setbuffer(iop, buf, 128); - iop->_flag |= _IOLBF|_IOMYBUF; - } - return (0); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/setvbuf.c b/usr/src/lib/libbc/libc/stdio/common/setvbuf.c deleted file mode 100644 index 3721c52147..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/setvbuf.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1986 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -extern void free(); -extern unsigned char (*_smbuf)[_SBFSIZ]; -extern char *malloc(); -extern void _getsmbuf(); - -int -setvbuf(iop, buf, type, size) -register FILE *iop; -register char *buf; -register int type; -register int size; -{ - register int fno = fileno(iop); /* file number */ - - if(iop->_base != NULL && iop->_flag & _IOMYBUF) - free((char*)iop->_base); - iop->_flag &= ~(_IOMYBUF | _IONBF | _IOLBF); - switch (type) { - /*note that the flags are the same as the possible values for type*/ - case _IONBF: - /* file is unbuffered except in fastio */ - iop->_flag |= _IONBF; - /* use small buffers reserved for this */ - iop->_base = _smbuf[fno]; - iop->_bufsiz = _SBFSIZ; - break; - case _IOLBF: - case _IOFBF: - if (size < 0) - return -1; - iop->_flag |= type; - size = (size == 0) ? BUFSIZ : size; - /* - * need eight characters beyond bufend for stdio slop - */ - if (size <= 8) { - size = BUFSIZ; - buf = NULL; - } - if (buf == NULL) { - size += 8; - buf = malloc((unsigned)size); - iop->_flag |= _IOMYBUF; - } - iop->_base = (unsigned char *)buf; - iop->_bufsiz = size - 8; - break; - default: - return -1; - } - iop->_ptr = iop->_base; - iop->_cnt = 0; - return 0; -} diff --git a/usr/src/lib/libbc/libc/stdio/common/stdiom.h b/usr/src/lib/libbc/libc/stdio/common/stdiom.h deleted file mode 100644 index cac8d3c0b5..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/stdiom.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* The following macros improve performance of the stdio by reducing the - number of calls to _bufsync and _wrtchk. _BUFSYNC has the same - effect as _bufsync, and _WRTCHK has the same effect as _wrtchk, - but often these functions have no effect, and in those cases the - macros avoid the expense of calling the functions. */ - -#define _BUFSYNC(iop) if ((iop->_base + iop->_bufsiz) - iop->_ptr < \ - ( iop->_cnt < 0 ? 0 : iop->_cnt ) ) \ - _bufsync(iop) -#define _WRTCHK(iop) ((((iop->_flag & (_IOWRT | _IOEOF)) != _IOWRT) \ - || (iop->_base == NULL) \ - || (iop->_ptr == iop->_base && iop->_cnt == 0 \ - && !(iop->_flag & (_IONBF | _IOLBF)))) \ - ? _wrtchk(iop) : 0 ) diff --git a/usr/src/lib/libbc/libc/stdio/common/tempnam.c b/usr/src/lib/libbc/libc/stdio/common/tempnam.c deleted file mode 100644 index 53631b1c7a..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/tempnam.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1993 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */ - -/*LINTLIBRARY*/ -#include <stdio.h> -#include <string.h> - -#define max(A,B) (((A)<(B))?(B):(A)) - -extern char *malloc(), *getenv(), *mktemp(); -extern int access(); - -static char *pcopy(); -static char seed[4]; - -char * -tempnam(dir, pfx) -char *dir; /* use this directory please (if non-NULL) */ -char *pfx; /* use this (if non-NULL) as filename prefix */ -{ - register char *p, *q, *tdir; - int x=0, y=0, z; - - if (seed[0] == 0) - seed[0] = seed[1] = seed[2] = 'A'; - z=strlen(P_tmpdir); - if((tdir = getenv("TMPDIR")) != NULL) { - x = strlen(tdir); - } - if(dir != NULL) { - y=strlen(dir); - } - if((p=malloc((unsigned)(max(max(x,y),z)+16))) == NULL) - return(NULL); - if(x > 0 && access(pcopy(p, tdir), 3) == 0) - goto OK; - if(y > 0 && access(pcopy(p, dir), 3) == 0) - goto OK; - if(access(pcopy(p, P_tmpdir), 3) == 0) - goto OK; - if(access(pcopy(p, "/tmp"), 3) != 0) - return(NULL); -OK: - (void)strcat(p, "/"); - if(pfx) { - *(p+strlen(p)+5) = '\0'; - (void)strncat(p, pfx, 5); - } - (void)strcat(p, seed); - (void)strcat(p, "XXXXXX"); - q = seed; - while(*q == 'Z') - *q++ = 'A'; - ++*q; - if(*mktemp(p) == '\0') - return(NULL); - return(p); -} - -static char* -pcopy(space, arg) -char *space, *arg; -{ - char *p; - - if(arg) { - (void)strcpy(space, arg); - p = space-1+strlen(space); - if(*p == '/') - *p = '\0'; - } - return(space); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/tmpfile.c b/usr/src/lib/libbc/libc/stdio/common/tmpfile.c deleted file mode 100644 index 5981194b75..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/tmpfile.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */ - -/*LINTLIBRARY*/ -/* - * tmpfile - return a pointer to an update file that can be - * used for scratch. The file will automatically - * go away if the program using it terminates. - */ -#include <stdio.h> - -extern FILE *fopen(); -extern int unlink(); -extern char *tmpnam(); -extern void perror(); - -FILE * -tmpfile() -{ - char tfname[L_tmpnam]; - register FILE *p; - - (void) tmpnam(tfname); - if((p = fopen(tfname, "w+")) == NULL) - return NULL; - else - (void) unlink(tfname); - return(p); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/tmpnam.c b/usr/src/lib/libbc/libc/stdio/common/tmpnam.c deleted file mode 100644 index ed20714514..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/tmpnam.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -extern char *mktemp(), *strcpy(), *strcat(); -static char str[L_tmpnam], seed[] = { 'a', 'a', 'a', '\0' }; - -char * -tmpnam(s) -char *s; -{ - register char *p, *q; - register int cnt = 0; - - p = (s == NULL)? str: s; - (void) strcpy(p, P_tmpdir); - (void) strcat(p, seed); - (void) strcat(p, "XXXXXX"); - - q = seed; - while(*q == 'z') { - *q++ = 'a'; - cnt++; - } - if (cnt < 3) - ++*q; - - (void) mktemp(p); - return(p); -} diff --git a/usr/src/lib/libbc/libc/stdio/common/ungetc.c b/usr/src/lib/libbc/libc/stdio/common/ungetc.c deleted file mode 100644 index f6c5f8b8f4..0000000000 --- a/usr/src/lib/libbc/libc/stdio/common/ungetc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1988 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.1 */ - -/*LINTLIBRARY*/ -#include <stdio.h> - -int -ungetc(c, iop) -int c; -register FILE *iop; -{ - if(c == EOF) - return(EOF); - if((iop->_flag & (_IOREAD|_IORW)) == 0) - return(EOF); - - if (iop->_base == NULL) /* get buffer if we don't have one */ - _findbuf(iop); - - if((iop->_flag & _IOREAD) == 0 || iop->_ptr <= iop->_base) - if(iop->_ptr == iop->_base && iop->_cnt == 0) - ++iop->_ptr; - else - return(EOF); - if (*--iop->_ptr != c) *iop->_ptr = c; /* was *--iop->_ptr = c; */ - ++iop->_cnt; - return(c); -} |