Run libcc.ansi through clang-format.
This commit is contained in:
		
							parent
							
								
									60b7d8de6e
								
							
						
					
					
						commit
						93f39e4bbf
					
				
					 157 changed files with 3836 additions and 3121 deletions
				
			
		| 
						 | 
				
			
			@ -3,11 +3,12 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<assert.h>
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
void __bad_assertion(const char *mess) {
 | 
			
		||||
void __bad_assertion(const char* mess)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	fputs(mess, stderr);
 | 
			
		||||
	abort();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
#include	<ctype.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
 | 
			
		||||
int tolower(int c) {
 | 
			
		||||
	return isupper(c) ? c - 'A' + 'a' : c ;
 | 
			
		||||
int tolower(int c)
 | 
			
		||||
{
 | 
			
		||||
	return isupper(c) ? c - 'A' + 'a' : c;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
#include	<ctype.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
 | 
			
		||||
int toupper(int c) {
 | 
			
		||||
	return islower(c) ? c - 'a' + 'A' : c ;
 | 
			
		||||
int toupper(int c)
 | 
			
		||||
{
 | 
			
		||||
	return islower(c) ? c - 'a' + 'A' : c;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,44 +4,44 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
const char *_sys_errlist[] = {
 | 
			
		||||
        "Error 0",
 | 
			
		||||
        "Not owner",
 | 
			
		||||
        "No such file or directory",
 | 
			
		||||
        "No such process",
 | 
			
		||||
        "Interrupted system call",
 | 
			
		||||
        "I/O error",
 | 
			
		||||
        "No such device or address",
 | 
			
		||||
        "Arg list too long",
 | 
			
		||||
        "Exec format error",
 | 
			
		||||
        "Bad file number",
 | 
			
		||||
        "No children",
 | 
			
		||||
        "No more processes",
 | 
			
		||||
        "Not enough core",
 | 
			
		||||
        "Permission denied",
 | 
			
		||||
        "Bad address",
 | 
			
		||||
        "Block device required",
 | 
			
		||||
        "Mount device busy",
 | 
			
		||||
        "File exists",
 | 
			
		||||
        "Cross-device link",
 | 
			
		||||
        "No such device",
 | 
			
		||||
        "Not a directory",
 | 
			
		||||
        "Is a directory",
 | 
			
		||||
        "Invalid argument",
 | 
			
		||||
        "File table overflow",
 | 
			
		||||
        "Too many open files",
 | 
			
		||||
        "Not a typewriter",
 | 
			
		||||
        "Text file busy",
 | 
			
		||||
        "File too large",
 | 
			
		||||
        "No space left on device",
 | 
			
		||||
        "Illegal seek",
 | 
			
		||||
        "Read-only file system",
 | 
			
		||||
        "Too many links",
 | 
			
		||||
        "Broken pipe",
 | 
			
		||||
        "Math argument",
 | 
			
		||||
        "Result too large"
 | 
			
		||||
const char* _sys_errlist[] = {
 | 
			
		||||
	"Error 0",
 | 
			
		||||
	"Not owner",
 | 
			
		||||
	"No such file or directory",
 | 
			
		||||
	"No such process",
 | 
			
		||||
	"Interrupted system call",
 | 
			
		||||
	"I/O error",
 | 
			
		||||
	"No such device or address",
 | 
			
		||||
	"Arg list too long",
 | 
			
		||||
	"Exec format error",
 | 
			
		||||
	"Bad file number",
 | 
			
		||||
	"No children",
 | 
			
		||||
	"No more processes",
 | 
			
		||||
	"Not enough core",
 | 
			
		||||
	"Permission denied",
 | 
			
		||||
	"Bad address",
 | 
			
		||||
	"Block device required",
 | 
			
		||||
	"Mount device busy",
 | 
			
		||||
	"File exists",
 | 
			
		||||
	"Cross-device link",
 | 
			
		||||
	"No such device",
 | 
			
		||||
	"Not a directory",
 | 
			
		||||
	"Is a directory",
 | 
			
		||||
	"Invalid argument",
 | 
			
		||||
	"File table overflow",
 | 
			
		||||
	"Too many open files",
 | 
			
		||||
	"Not a typewriter",
 | 
			
		||||
	"Text file busy",
 | 
			
		||||
	"File too large",
 | 
			
		||||
	"No space left on device",
 | 
			
		||||
	"Illegal seek",
 | 
			
		||||
	"Read-only file system",
 | 
			
		||||
	"Too many links",
 | 
			
		||||
	"Broken pipe",
 | 
			
		||||
	"Math argument",
 | 
			
		||||
	"Result too large"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const int _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,15 +3,15 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<limits.h>
 | 
			
		||||
#include	<locale.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#include <locale.h>
 | 
			
		||||
 | 
			
		||||
extern struct lconv _lc;
 | 
			
		||||
 | 
			
		||||
struct lconv *
 | 
			
		||||
struct lconv*
 | 
			
		||||
localeconv(void)
 | 
			
		||||
{
 | 
			
		||||
	register struct lconv *lcp = &_lc;
 | 
			
		||||
	register struct lconv* lcp = &_lc;
 | 
			
		||||
 | 
			
		||||
	lcp->decimal_point = ".";
 | 
			
		||||
	lcp->thousands_sep = "";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,26 +3,28 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<locale.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include <locale.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
struct lconv _lc;
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
setlocale(int category, const char *locale)
 | 
			
		||||
char* setlocale(int category, const char* locale)
 | 
			
		||||
{
 | 
			
		||||
	if (!locale) return "C";
 | 
			
		||||
	if (*locale && strcmp(locale, "C")) return (char *)NULL;
 | 
			
		||||
	
 | 
			
		||||
	switch(category) {
 | 
			
		||||
	case LC_ALL:
 | 
			
		||||
	case LC_CTYPE:
 | 
			
		||||
	case LC_COLLATE:
 | 
			
		||||
	case LC_TIME:
 | 
			
		||||
	case LC_NUMERIC:
 | 
			
		||||
	case LC_MONETARY:
 | 
			
		||||
		return *locale ? (char *)locale : "C";
 | 
			
		||||
	default:
 | 
			
		||||
		return (char *)NULL;
 | 
			
		||||
	if (!locale)
 | 
			
		||||
		return "C";
 | 
			
		||||
	if (*locale && strcmp(locale, "C"))
 | 
			
		||||
		return (char*)NULL;
 | 
			
		||||
 | 
			
		||||
	switch (category)
 | 
			
		||||
	{
 | 
			
		||||
		case LC_ALL:
 | 
			
		||||
		case LC_CTYPE:
 | 
			
		||||
		case LC_COLLATE:
 | 
			
		||||
		case LC_TIME:
 | 
			
		||||
		case LC_NUMERIC:
 | 
			
		||||
		case LC_MONETARY:
 | 
			
		||||
			return *locale ? (char*)locale : "C";
 | 
			
		||||
		default:
 | 
			
		||||
			return (char*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,20 +4,20 @@
 | 
			
		|||
 | 
			
		||||
void* calloc(size_t nmemb, size_t size)
 | 
			
		||||
{
 | 
			
		||||
    size_t bytes = nmemb * size;
 | 
			
		||||
    void* ptr;
 | 
			
		||||
    
 | 
			
		||||
    /* Test for overflow.
 | 
			
		||||
	size_t bytes = nmemb * size;
 | 
			
		||||
	void* ptr;
 | 
			
		||||
 | 
			
		||||
	/* Test for overflow.
 | 
			
		||||
     * See http://stackoverflow.com/questions/1815367/multiplication-of-large-numbers-how-to-catch-overflow
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    if ((nmemb == 0) || (size == 0) || (nmemb > (SIZE_MAX / size)))
 | 
			
		||||
        return NULL;
 | 
			
		||||
    
 | 
			
		||||
    ptr = malloc(bytes);
 | 
			
		||||
    if (!ptr)
 | 
			
		||||
        return NULL;
 | 
			
		||||
	if ((nmemb == 0) || (size == 0) || (nmemb > (SIZE_MAX / size)))
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
    memset(ptr, 0, bytes);
 | 
			
		||||
    return ptr;
 | 
			
		||||
	ptr = malloc(bytes);
 | 
			
		||||
	if (!ptr)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	memset(ptr, 0, bytes);
 | 
			
		||||
	return ptr;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "malloc.h"
 | 
			
		||||
 | 
			
		||||
block_t __mem_root = {&__mem_root, 0};
 | 
			
		||||
block_t __mem_root = { &__mem_root, 0 };
 | 
			
		||||
block_t* __mem_freelist = &__mem_root;
 | 
			
		||||
 | 
			
		||||
/* Pulls more memory from the system. */
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ void* malloc(size_t size)
 | 
			
		|||
			 * The size field is already set. */
 | 
			
		||||
			prev->next = p->next;
 | 
			
		||||
			__mem_freelist = prev;
 | 
			
		||||
			return (void*) (p+1);
 | 
			
		||||
			return (void*)(p + 1);
 | 
			
		||||
		}
 | 
			
		||||
		else if (p->size > nblocks)
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ void* malloc(size_t size)
 | 
			
		|||
			p += p->size; /* p now points at our new block */
 | 
			
		||||
			p->size = nblocks;
 | 
			
		||||
			__mem_freelist = prev;
 | 
			
		||||
			return (void*) (p+1);
 | 
			
		||||
			return (void*)(p + 1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (p == __mem_freelist)
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ void* malloc(size_t size)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void free(void *ptr)
 | 
			
		||||
void free(void* ptr)
 | 
			
		||||
{
 | 
			
		||||
	block_t* h = BLOCKOF(ptr);
 | 
			
		||||
	block_t* p;
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ void free(void *ptr)
 | 
			
		|||
 | 
			
		||||
		p = p->next;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/* If we can, merge the next block onto the end of h. */
 | 
			
		||||
 | 
			
		||||
	if ((h + h->size) == p->next)
 | 
			
		||||
| 
						 | 
				
			
			@ -148,4 +148,3 @@ void free(void *ptr)
 | 
			
		|||
	/* ...and update the ring pointer. */
 | 
			
		||||
	__mem_freelist = p;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include "malloc.h"
 | 
			
		||||
 | 
			
		||||
void* realloc(void *ptr, size_t size)
 | 
			
		||||
void* realloc(void* ptr, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	block_t* h;
 | 
			
		||||
	size_t nblocks;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ void* realloc(void *ptr, size_t size)
 | 
			
		|||
	/* Overflow check. */
 | 
			
		||||
	if (nblocks < size)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/* Shrinking the block? Don't bother doing anything (it's never worth it). */
 | 
			
		||||
	if (nblocks <= h->size)
 | 
			
		||||
		return ptr;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,66 +6,76 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
static double
 | 
			
		||||
asin_acos(double x, int cosfl)
 | 
			
		||||
{
 | 
			
		||||
	int negative = x < 0;
 | 
			
		||||
	int     i;
 | 
			
		||||
	double  g;
 | 
			
		||||
	int i;
 | 
			
		||||
	double g;
 | 
			
		||||
	static double p[] = {
 | 
			
		||||
		-0.27368494524164255994e+2,
 | 
			
		||||
		 0.57208227877891731407e+2,
 | 
			
		||||
		0.57208227877891731407e+2,
 | 
			
		||||
		-0.39688862997540877339e+2,
 | 
			
		||||
		 0.10152522233806463645e+2,
 | 
			
		||||
		0.10152522233806463645e+2,
 | 
			
		||||
		-0.69674573447350646411e+0
 | 
			
		||||
	};
 | 
			
		||||
	static double q[] = {
 | 
			
		||||
		-0.16421096714498560795e+3,
 | 
			
		||||
		 0.41714430248260412556e+3,
 | 
			
		||||
		0.41714430248260412556e+3,
 | 
			
		||||
		-0.38186303361750149284e+3,
 | 
			
		||||
		 0.15095270841030604719e+3,
 | 
			
		||||
		0.15095270841030604719e+3,
 | 
			
		||||
		-0.23823859153670238830e+2,
 | 
			
		||||
		 1.0
 | 
			
		||||
		1.0
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (negative) {
 | 
			
		||||
	if (negative)
 | 
			
		||||
	{
 | 
			
		||||
		x = -x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x > 0.5) {
 | 
			
		||||
	if (x > 0.5)
 | 
			
		||||
	{
 | 
			
		||||
		i = 1;
 | 
			
		||||
		if (x > 1) {
 | 
			
		||||
		if (x > 1)
 | 
			
		||||
		{
 | 
			
		||||
			errno = EDOM;
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		g = 0.5 - 0.5 * x;
 | 
			
		||||
		x = - sqrt(g);
 | 
			
		||||
		x = -sqrt(g);
 | 
			
		||||
		x += x;
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		/* ??? avoid underflow ??? */
 | 
			
		||||
		i = 0;
 | 
			
		||||
		g = x * x;
 | 
			
		||||
	}
 | 
			
		||||
	x += x * g * POLYNOM4(g, p) / POLYNOM5(g, q);
 | 
			
		||||
	if (cosfl) {
 | 
			
		||||
		if (! negative) x = -x;
 | 
			
		||||
	if (cosfl)
 | 
			
		||||
	{
 | 
			
		||||
		if (!negative)
 | 
			
		||||
			x = -x;
 | 
			
		||||
	}
 | 
			
		||||
	if ((cosfl == 0) == (i == 1)) {
 | 
			
		||||
	if ((cosfl == 0) == (i == 1))
 | 
			
		||||
	{
 | 
			
		||||
		x = (x + M_PI_4) + M_PI_4;
 | 
			
		||||
	}
 | 
			
		||||
	else if (cosfl && negative && i == 1) {
 | 
			
		||||
	else if (cosfl && negative && i == 1)
 | 
			
		||||
	{
 | 
			
		||||
		x = (x + M_PI_2) + M_PI_2;
 | 
			
		||||
	}
 | 
			
		||||
	if (! cosfl && negative) x = -x;
 | 
			
		||||
	if (!cosfl && negative)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	return x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
atan(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -26,47 +26,52 @@ atan(double x)
 | 
			
		|||
		-0.83758299368150059274e+0
 | 
			
		||||
	};
 | 
			
		||||
	static double q[] = {
 | 
			
		||||
		 0.41066306682575781263e+2,
 | 
			
		||||
		 0.86157349597130242515e+2,
 | 
			
		||||
		 0.59578436142597344465e+2,
 | 
			
		||||
		 0.15024001160028576121e+2,
 | 
			
		||||
		 1.0
 | 
			
		||||
		0.41066306682575781263e+2,
 | 
			
		||||
		0.86157349597130242515e+2,
 | 
			
		||||
		0.59578436142597344465e+2,
 | 
			
		||||
		0.15024001160028576121e+2,
 | 
			
		||||
		1.0
 | 
			
		||||
	};
 | 
			
		||||
	static double a[] = {
 | 
			
		||||
		0.0,
 | 
			
		||||
		0.52359877559829887307710723554658381,  /* pi/6 */
 | 
			
		||||
		0.52359877559829887307710723554658381, /* pi/6 */
 | 
			
		||||
		M_PI_2,
 | 
			
		||||
		1.04719755119659774615421446109316763   /* pi/3 */
 | 
			
		||||
		1.04719755119659774615421446109316763 /* pi/3 */
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	int     neg = x < 0;
 | 
			
		||||
	int     n;
 | 
			
		||||
	double  g;
 | 
			
		||||
	int neg = x < 0;
 | 
			
		||||
	int n;
 | 
			
		||||
	double g;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (neg) {
 | 
			
		||||
	if (neg)
 | 
			
		||||
	{
 | 
			
		||||
		x = -x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x > 1.0) {
 | 
			
		||||
		x = 1.0/x;
 | 
			
		||||
	if (x > 1.0)
 | 
			
		||||
	{
 | 
			
		||||
		x = 1.0 / x;
 | 
			
		||||
		n = 2;
 | 
			
		||||
	}
 | 
			
		||||
	else    n = 0;
 | 
			
		||||
	else
 | 
			
		||||
		n = 0;
 | 
			
		||||
 | 
			
		||||
	if (x > 0.26794919243112270647) {       /* 2-sqtr(3) */
 | 
			
		||||
	if (x > 0.26794919243112270647)
 | 
			
		||||
	{ /* 2-sqtr(3) */
 | 
			
		||||
		n = n + 1;
 | 
			
		||||
		x = (((0.73205080756887729353*x-0.5)-0.5)+x)/
 | 
			
		||||
			(1.73205080756887729353+x);
 | 
			
		||||
		x = (((0.73205080756887729353 * x - 0.5) - 0.5) + x) / (1.73205080756887729353 + x);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* ??? avoid underflow ??? */
 | 
			
		||||
 | 
			
		||||
	g = x * x;
 | 
			
		||||
	x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q);
 | 
			
		||||
	if (n > 1) x = -x;
 | 
			
		||||
	if (n > 1)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	x += a[n];
 | 
			
		||||
	return neg ? -x : x;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,35 +6,41 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
atan2(double y, double x)
 | 
			
		||||
{
 | 
			
		||||
	double absx, absy, val;
 | 
			
		||||
 | 
			
		||||
	if (x == 0 && y == 0) {
 | 
			
		||||
	if (x == 0 && y == 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	absy = y < 0 ? -y : y;
 | 
			
		||||
	absx = x < 0 ? -x : x;
 | 
			
		||||
	if (absy - absx == absy) {
 | 
			
		||||
	if (absy - absx == absy)
 | 
			
		||||
	{
 | 
			
		||||
		/* x negligible compared to y */
 | 
			
		||||
		return y < 0 ? -M_PI_2 : M_PI_2;
 | 
			
		||||
	}
 | 
			
		||||
	if (absx - absy == absx) {
 | 
			
		||||
	if (absx - absy == absx)
 | 
			
		||||
	{
 | 
			
		||||
		/* y negligible compared to x */
 | 
			
		||||
		val = 0.0;
 | 
			
		||||
	}
 | 
			
		||||
	else	val = atan(y/x);
 | 
			
		||||
	if (x > 0) {
 | 
			
		||||
	else
 | 
			
		||||
		val = atan(y / x);
 | 
			
		||||
	if (x > 0)
 | 
			
		||||
	{
 | 
			
		||||
		/* first or fourth quadrant; already correct */
 | 
			
		||||
		return val;
 | 
			
		||||
	}
 | 
			
		||||
	if (y < 0) {
 | 
			
		||||
	if (y < 0)
 | 
			
		||||
	{
 | 
			
		||||
		/* third quadrant */
 | 
			
		||||
		return val - M_PI;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,14 +6,14 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
ceil(double x)
 | 
			
		||||
{
 | 
			
		||||
	double val;
 | 
			
		||||
 | 
			
		||||
	return modf(x, &val) > 0 ? val + 1.0 : val ;
 | 
			
		||||
	return modf(x, &val) > 0 ? val + 1.0 : val;
 | 
			
		||||
	/*	this also works if modf always returns a positive
 | 
			
		||||
		fractional part
 | 
			
		||||
	*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,11 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
exp(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -32,41 +31,46 @@ exp(double x)
 | 
			
		|||
		0.63121894374398503557e-3,
 | 
			
		||||
		0.75104028399870046114e-6
 | 
			
		||||
	};
 | 
			
		||||
	double	xn, g;
 | 
			
		||||
	int	n;
 | 
			
		||||
	int	negative = x < 0;
 | 
			
		||||
	double xn, g;
 | 
			
		||||
	int n;
 | 
			
		||||
	int negative = x < 0;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x < M_LN_MIN_D) {
 | 
			
		||||
	if (x < M_LN_MIN_D)
 | 
			
		||||
	{
 | 
			
		||||
		errno = ERANGE;
 | 
			
		||||
		return 0.0;
 | 
			
		||||
	}
 | 
			
		||||
	if (x > M_LN_MAX_D) {
 | 
			
		||||
	if (x > M_LN_MAX_D)
 | 
			
		||||
	{
 | 
			
		||||
		errno = ERANGE;
 | 
			
		||||
		return HUGE_VAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (negative) x = -x;
 | 
			
		||||
 
 | 
			
		||||
	if (negative)
 | 
			
		||||
		x = -x;
 | 
			
		||||
 | 
			
		||||
	/* ??? avoid underflow ??? */
 | 
			
		||||
 | 
			
		||||
	n = x * M_LOG2E + 0.5;	/* 1/ln(2) = log2(e), 0.5 added for rounding */
 | 
			
		||||
	n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */
 | 
			
		||||
	xn = n;
 | 
			
		||||
	{
 | 
			
		||||
		double	x1 = (long) x;
 | 
			
		||||
		double	x2 = x - x1;
 | 
			
		||||
		double x1 = (long)x;
 | 
			
		||||
		double x2 = x - x1;
 | 
			
		||||
 | 
			
		||||
		g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4);
 | 
			
		||||
		g = ((x1 - xn * 0.693359375) + x2) - xn * (-2.1219444005469058277e-4);
 | 
			
		||||
	}
 | 
			
		||||
	if (negative) {
 | 
			
		||||
	if (negative)
 | 
			
		||||
	{
 | 
			
		||||
		g = -g;
 | 
			
		||||
		n = -n;
 | 
			
		||||
	}
 | 
			
		||||
	xn = g * g;
 | 
			
		||||
	x = g * POLYNOM2(xn, p);
 | 
			
		||||
	n += 1;
 | 
			
		||||
	return (ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n));
 | 
			
		||||
	return (ldexp(0.5 + x / (POLYNOM3(xn, q) - x), n));
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,5 +9,5 @@
 | 
			
		|||
double
 | 
			
		||||
fabs(double x)
 | 
			
		||||
{
 | 
			
		||||
	return  x < 0 ? -x : x;
 | 
			
		||||
	return x < 0 ? -x : x;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,14 +6,14 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
floor(double x)
 | 
			
		||||
{
 | 
			
		||||
	double val;
 | 
			
		||||
 | 
			
		||||
	return modf(x, &val) < 0 ? val - 1.0 : val ;
 | 
			
		||||
	return modf(x, &val) < 0 ? val - 1.0 : val;
 | 
			
		||||
	/*	this also works if modf always returns a positive
 | 
			
		||||
		fractional part
 | 
			
		||||
	*/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,29 +6,34 @@
 | 
			
		|||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
(fmod)(double x, double y)
 | 
			
		||||
{				/* compute fmod(x, y) */
 | 
			
		||||
double(fmod)(double x, double y)
 | 
			
		||||
{ /* compute fmod(x, y) */
 | 
			
		||||
	double t;
 | 
			
		||||
	int n, neg;
 | 
			
		||||
	int ychar, xchar;
 | 
			
		||||
 | 
			
		||||
    	if (y == 0.0) {
 | 
			
		||||
	if (y == 0.0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return 0.0;
 | 
			
		||||
    	}
 | 
			
		||||
    				/* fmod(finite, finite) */
 | 
			
		||||
	if (y < 0.0) y = -y;
 | 
			
		||||
	if (x < 0.0) x = -x, neg = 1;
 | 
			
		||||
	else neg = 0;
 | 
			
		||||
	}
 | 
			
		||||
	/* fmod(finite, finite) */
 | 
			
		||||
	if (y < 0.0)
 | 
			
		||||
		y = -y;
 | 
			
		||||
	if (x < 0.0)
 | 
			
		||||
		x = -x, neg = 1;
 | 
			
		||||
	else
 | 
			
		||||
		neg = 0;
 | 
			
		||||
	t = frexp(y, &ychar);
 | 
			
		||||
				/* substract |y| until |x| < |y| */
 | 
			
		||||
	/* substract |y| until |x| < |y| */
 | 
			
		||||
 | 
			
		||||
	t = frexp(x, &xchar);
 | 
			
		||||
	for (n = xchar - ychar; 0 <= n; --n) {
 | 
			
		||||
				/* try to substract |y|*2^n */
 | 
			
		||||
	    t = ldexp(y, n);
 | 
			
		||||
	    if (t <= x) x -= t;
 | 
			
		||||
	for (n = xchar - ychar; 0 <= n; --n)
 | 
			
		||||
	{
 | 
			
		||||
		/* try to substract |y|*2^n */
 | 
			
		||||
		t = ldexp(y, n);
 | 
			
		||||
		if (t <= x)
 | 
			
		||||
			x -= t;
 | 
			
		||||
	}
 | 
			
		||||
	return (neg ? -x : x);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,25 +10,30 @@
 | 
			
		|||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
hypot(double x,double y)
 | 
			
		||||
hypot(double x, double y)
 | 
			
		||||
{
 | 
			
		||||
	/*	Computes sqrt(x*x+y*y), avoiding overflow */
 | 
			
		||||
 | 
			
		||||
	if (x < 0) x = -x;
 | 
			
		||||
	if (y < 0) y = -y;
 | 
			
		||||
	if (x > y) {
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	if (y < 0)
 | 
			
		||||
		y = -y;
 | 
			
		||||
	if (x > y)
 | 
			
		||||
	{
 | 
			
		||||
		double t = y;
 | 
			
		||||
		y = x;
 | 
			
		||||
		x = t;
 | 
			
		||||
	}
 | 
			
		||||
	/* sqrt(x*x+y*y) = sqrt(y*y*(x*x/(y*y)+1.0)) = y*sqrt(x*x/(y*y)+1.0) */
 | 
			
		||||
	if (y == 0.0) return 0.0;
 | 
			
		||||
	if (y == 0.0)
 | 
			
		||||
		return 0.0;
 | 
			
		||||
	x /= y;
 | 
			
		||||
	return y*sqrt(x*x+1.0);
 | 
			
		||||
	return y * sqrt(x * x + 1.0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct complex {
 | 
			
		||||
	double r,i;
 | 
			
		||||
struct complex
 | 
			
		||||
{
 | 
			
		||||
	double r, i;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,8 +4,8 @@ __IsNan(double d)
 | 
			
		|||
#else
 | 
			
		||||
	float f = d;
 | 
			
		||||
 | 
			
		||||
	if ((*((long *) &f) & 0x7f800000) == 0x7f800000 &&
 | 
			
		||||
	    (*((long *) &f) & 0x007fffff) != 0) return 1;
 | 
			
		||||
	if ((*((long*)&f) & 0x7f800000) == 0x7f800000 && (*((long*)&f) & 0x007fffff) != 0)
 | 
			
		||||
		return 1;
 | 
			
		||||
#endif
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
ldexp(double fl, int exp)
 | 
			
		||||
| 
						 | 
				
			
			@ -14,42 +14,52 @@ ldexp(double fl, int exp)
 | 
			
		|||
	int sign = 1;
 | 
			
		||||
	int currexp;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(fl)) {
 | 
			
		||||
	if (__IsNan(fl))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return fl;
 | 
			
		||||
	}
 | 
			
		||||
	if (fl == 0.0) return 0.0;
 | 
			
		||||
	if (fl<0) {
 | 
			
		||||
	if (fl == 0.0)
 | 
			
		||||
		return 0.0;
 | 
			
		||||
	if (fl < 0)
 | 
			
		||||
	{
 | 
			
		||||
		fl = -fl;
 | 
			
		||||
		sign = -1;
 | 
			
		||||
	}
 | 
			
		||||
	if (fl > DBL_MAX) {		/* for infinity */
 | 
			
		||||
	if (fl > DBL_MAX)
 | 
			
		||||
	{ /* for infinity */
 | 
			
		||||
		errno = ERANGE;
 | 
			
		||||
		return sign * fl;
 | 
			
		||||
	}
 | 
			
		||||
	fl = frexp(fl,&currexp);
 | 
			
		||||
	fl = frexp(fl, &currexp);
 | 
			
		||||
	exp += currexp;
 | 
			
		||||
	if (exp > 0) {
 | 
			
		||||
		if (exp > DBL_MAX_EXP) {
 | 
			
		||||
	if (exp > 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (exp > DBL_MAX_EXP)
 | 
			
		||||
		{
 | 
			
		||||
			errno = ERANGE;
 | 
			
		||||
			return sign * HUGE_VAL;
 | 
			
		||||
		}
 | 
			
		||||
		while (exp>30) {
 | 
			
		||||
			fl *= (double) (1L << 30);
 | 
			
		||||
		while (exp > 30)
 | 
			
		||||
		{
 | 
			
		||||
			fl *= (double)(1L << 30);
 | 
			
		||||
			exp -= 30;
 | 
			
		||||
		}
 | 
			
		||||
		fl *= (double) (1L << exp);
 | 
			
		||||
		fl *= (double)(1L << exp);
 | 
			
		||||
	}
 | 
			
		||||
	else	{
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		/* number need not be normalized */
 | 
			
		||||
		if (exp < DBL_MIN_EXP - DBL_MANT_DIG) {
 | 
			
		||||
		if (exp < DBL_MIN_EXP - DBL_MANT_DIG)
 | 
			
		||||
		{
 | 
			
		||||
			return 0.0;
 | 
			
		||||
		}
 | 
			
		||||
		while (exp<-30) {
 | 
			
		||||
			fl /= (double) (1L << 30);
 | 
			
		||||
		while (exp < -30)
 | 
			
		||||
		{
 | 
			
		||||
			fl /= (double)(1L << 30);
 | 
			
		||||
			exp += 30;
 | 
			
		||||
		}
 | 
			
		||||
		fl /= (double) (1L << -exp);
 | 
			
		||||
		fl /= (double)(1L << -exp);
 | 
			
		||||
	}
 | 
			
		||||
	return sign * fl;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
log(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -20,47 +20,55 @@ log(double x)
 | 
			
		|||
	*/
 | 
			
		||||
	static double a[] = {
 | 
			
		||||
		-0.64124943423745581147e2,
 | 
			
		||||
		 0.16383943563021534222e2,
 | 
			
		||||
		0.16383943563021534222e2,
 | 
			
		||||
		-0.78956112887491257267e0
 | 
			
		||||
	};
 | 
			
		||||
	static double b[] = {
 | 
			
		||||
		-0.76949932108494879777e3,
 | 
			
		||||
		 0.31203222091924532844e3,
 | 
			
		||||
		0.31203222091924532844e3,
 | 
			
		||||
		-0.35667977739034646171e2,
 | 
			
		||||
		 1.0
 | 
			
		||||
		1.0
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	double	znum, zden, z, w;
 | 
			
		||||
	int	exponent;
 | 
			
		||||
	double znum, zden, z, w;
 | 
			
		||||
	int exponent;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x < 0) {
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return -HUGE_VAL;
 | 
			
		||||
	}
 | 
			
		||||
	else if (x == 0) {
 | 
			
		||||
	else if (x == 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = ERANGE;
 | 
			
		||||
		return -HUGE_VAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (x <= DBL_MAX) {
 | 
			
		||||
	if (x <= DBL_MAX)
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	else return x;	/* for infinity and Nan */
 | 
			
		||||
	else
 | 
			
		||||
		return x; /* for infinity and Nan */
 | 
			
		||||
	x = frexp(x, &exponent);
 | 
			
		||||
	if (x > M_1_SQRT2) {
 | 
			
		||||
	if (x > M_1_SQRT2)
 | 
			
		||||
	{
 | 
			
		||||
		znum = (x - 0.5) - 0.5;
 | 
			
		||||
		zden = x * 0.5 + 0.5;
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		znum = x - 0.5;
 | 
			
		||||
		zden = znum * 0.5 + 0.5;
 | 
			
		||||
		exponent--;
 | 
			
		||||
	}
 | 
			
		||||
	z = znum/zden; w = z * z;
 | 
			
		||||
	x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b));
 | 
			
		||||
	z = znum / zden;
 | 
			
		||||
	w = z * z;
 | 
			
		||||
	x = z + z * w * (POLYNOM2(w, a) / POLYNOM3(w, b));
 | 
			
		||||
	z = exponent;
 | 
			
		||||
	x += z * (-2.121944400546905827679e-4);
 | 
			
		||||
	return x + z * 0.693359375;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,22 +6,25 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
log10(double x)
 | 
			
		||||
{
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x < 0) {
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return -HUGE_VAL;
 | 
			
		||||
	}
 | 
			
		||||
	else if (x == 0) {
 | 
			
		||||
	else if (x == 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = ERANGE;
 | 
			
		||||
		return -HUGE_VAL;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,94 +6,116 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<limits.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
pow(double x, double y)
 | 
			
		||||
{
 | 
			
		||||
	double	y_intpart, y_fractpart, fp;
 | 
			
		||||
	int	negexp, negx;
 | 
			
		||||
	int	ex, newexp;
 | 
			
		||||
	double y_intpart, y_fractpart, fp;
 | 
			
		||||
	int negexp, negx;
 | 
			
		||||
	int ex, newexp;
 | 
			
		||||
	unsigned long yi;
 | 
			
		||||
 | 
			
		||||
	if (x == 1.0) return x;
 | 
			
		||||
	if (x == 1.0)
 | 
			
		||||
		return x;
 | 
			
		||||
 | 
			
		||||
	if (x == 0 && y <= 0) {
 | 
			
		||||
	if (x == 0 && y <= 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (y == 0) return 1.0;
 | 
			
		||||
	if (y == 0)
 | 
			
		||||
		return 1.0;
 | 
			
		||||
 | 
			
		||||
	if (y < 0) {
 | 
			
		||||
	if (y < 0)
 | 
			
		||||
	{
 | 
			
		||||
		y = -y;
 | 
			
		||||
		negexp = 1;
 | 
			
		||||
	}
 | 
			
		||||
	else	negexp = 0;
 | 
			
		||||
	else
 | 
			
		||||
		negexp = 0;
 | 
			
		||||
 | 
			
		||||
	y_fractpart = modf(y, &y_intpart);
 | 
			
		||||
 | 
			
		||||
	if (y_fractpart != 0) {
 | 
			
		||||
		if (x < 0) {
 | 
			
		||||
	if (y_fractpart != 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (x < 0)
 | 
			
		||||
		{
 | 
			
		||||
			errno = EDOM;
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	negx = 0;
 | 
			
		||||
	if (x < 0) {
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
	{
 | 
			
		||||
		x = -x;
 | 
			
		||||
		negx = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (y_intpart > ULONG_MAX) {
 | 
			
		||||
		if (negx && modf(y_intpart/2.0, &y_fractpart) == 0) {
 | 
			
		||||
	if (y_intpart > ULONG_MAX)
 | 
			
		||||
	{
 | 
			
		||||
		if (negx && modf(y_intpart / 2.0, &y_fractpart) == 0)
 | 
			
		||||
		{
 | 
			
		||||
			negx = 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		x = log(x);
 | 
			
		||||
 | 
			
		||||
		/* Beware of overflow in the multiplication */
 | 
			
		||||
		if (x > 1.0 && y > DBL_MAX/x) {
 | 
			
		||||
		if (x > 1.0 && y > DBL_MAX / x)
 | 
			
		||||
		{
 | 
			
		||||
			errno = ERANGE;
 | 
			
		||||
			return HUGE_VAL;
 | 
			
		||||
		}
 | 
			
		||||
		if (negexp) y = -y;
 | 
			
		||||
		if (negexp)
 | 
			
		||||
			y = -y;
 | 
			
		||||
 | 
			
		||||
		if (negx) return -exp(x*y);
 | 
			
		||||
		if (negx)
 | 
			
		||||
			return -exp(x * y);
 | 
			
		||||
		return exp(x * y);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (y_fractpart != 0) {
 | 
			
		||||
	if (y_fractpart != 0)
 | 
			
		||||
	{
 | 
			
		||||
		fp = exp(y_fractpart * log(x));
 | 
			
		||||
	}
 | 
			
		||||
	else	fp = 1.0;
 | 
			
		||||
	else
 | 
			
		||||
		fp = 1.0;
 | 
			
		||||
	yi = y_intpart;
 | 
			
		||||
	if (! (yi & 1)) negx = 0;
 | 
			
		||||
	if (!(yi & 1))
 | 
			
		||||
		negx = 0;
 | 
			
		||||
	x = frexp(x, &ex);
 | 
			
		||||
	newexp = 0;
 | 
			
		||||
	for (;;) {
 | 
			
		||||
		if (yi & 1) {
 | 
			
		||||
	for (;;)
 | 
			
		||||
	{
 | 
			
		||||
		if (yi & 1)
 | 
			
		||||
		{
 | 
			
		||||
			fp *= x;
 | 
			
		||||
			newexp += ex;
 | 
			
		||||
		}
 | 
			
		||||
		yi >>= 1;
 | 
			
		||||
		if (yi == 0) break;
 | 
			
		||||
		if (yi == 0)
 | 
			
		||||
			break;
 | 
			
		||||
		x *= x;
 | 
			
		||||
		ex <<= 1;
 | 
			
		||||
		if (x < 0.5) {
 | 
			
		||||
		if (x < 0.5)
 | 
			
		||||
		{
 | 
			
		||||
			x += x;
 | 
			
		||||
			ex -= 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (negexp) {
 | 
			
		||||
		fp = 1.0/fp;
 | 
			
		||||
	if (negexp)
 | 
			
		||||
	{
 | 
			
		||||
		fp = 1.0 / fp;
 | 
			
		||||
		newexp = -newexp;
 | 
			
		||||
	}
 | 
			
		||||
	if (negx) {
 | 
			
		||||
	if (negx)
 | 
			
		||||
	{
 | 
			
		||||
		return -ldexp(fp, newexp);
 | 
			
		||||
	}
 | 
			
		||||
	return ldexp(fp, newexp);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
static double
 | 
			
		||||
sinus(double x, int cos_flag)
 | 
			
		||||
| 
						 | 
				
			
			@ -21,39 +21,44 @@ sinus(double x, int cos_flag)
 | 
			
		|||
 | 
			
		||||
	static double r[] = {
 | 
			
		||||
		-0.16666666666666665052e+0,
 | 
			
		||||
		 0.83333333333331650314e-2,
 | 
			
		||||
		0.83333333333331650314e-2,
 | 
			
		||||
		-0.19841269841201840457e-3,
 | 
			
		||||
		 0.27557319210152756119e-5,
 | 
			
		||||
		0.27557319210152756119e-5,
 | 
			
		||||
		-0.25052106798274584544e-7,
 | 
			
		||||
		 0.16058936490371589114e-9,
 | 
			
		||||
		0.16058936490371589114e-9,
 | 
			
		||||
		-0.76429178068910467734e-12,
 | 
			
		||||
		 0.27204790957888846175e-14
 | 
			
		||||
		0.27204790957888846175e-14
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	double  y;
 | 
			
		||||
	int     neg = 1;
 | 
			
		||||
	double y;
 | 
			
		||||
	int neg = 1;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x < 0) {
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
	{
 | 
			
		||||
		x = -x;
 | 
			
		||||
		neg = -1;
 | 
			
		||||
	}
 | 
			
		||||
	if (cos_flag) {
 | 
			
		||||
	if (cos_flag)
 | 
			
		||||
	{
 | 
			
		||||
		neg = 1;
 | 
			
		||||
		y = M_PI_2 + x;
 | 
			
		||||
	}
 | 
			
		||||
	else    y = x;
 | 
			
		||||
	else
 | 
			
		||||
		y = x;
 | 
			
		||||
 | 
			
		||||
	/* ??? avoid loss of significance, if y is too large, error ??? */
 | 
			
		||||
 | 
			
		||||
	y = y * M_1_PI + 0.5;
 | 
			
		||||
 | 
			
		||||
	if (y >= DBL_MAX/M_PI) return 0.0;
 | 
			
		||||
	if (y >= DBL_MAX / M_PI)
 | 
			
		||||
		return 0.0;
 | 
			
		||||
 | 
			
		||||
	/*      Use extended precision to calculate reduced argument.
 | 
			
		||||
/*      Use extended precision to calculate reduced argument.
 | 
			
		||||
		Here we used 12 bits of the mantissa for a1.
 | 
			
		||||
		Also split x in integer part x1 and fraction part x2.
 | 
			
		||||
	*/
 | 
			
		||||
| 
						 | 
				
			
			@ -63,8 +68,10 @@ sinus(double x, int cos_flag)
 | 
			
		|||
		double x1, x2;
 | 
			
		||||
 | 
			
		||||
		modf(y, &y);
 | 
			
		||||
		if (modf(0.5*y, &x1)) neg = -neg;
 | 
			
		||||
		if (cos_flag) y -= 0.5;
 | 
			
		||||
		if (modf(0.5 * y, &x1))
 | 
			
		||||
			neg = -neg;
 | 
			
		||||
		if (cos_flag)
 | 
			
		||||
			y -= 0.5;
 | 
			
		||||
		x2 = modf(x, &x1);
 | 
			
		||||
		x = x1 - y * A1;
 | 
			
		||||
		x += x2;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,8 +79,9 @@ sinus(double x, int cos_flag)
 | 
			
		|||
#undef A1
 | 
			
		||||
#undef A2
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
	if (x < 0) {
 | 
			
		||||
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
	{
 | 
			
		||||
		neg = -neg;
 | 
			
		||||
		x = -x;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +90,7 @@ sinus(double x, int cos_flag)
 | 
			
		|||
 | 
			
		||||
	y = x * x;
 | 
			
		||||
	x += x * y * POLYNOM7(y, r);
 | 
			
		||||
	return neg==-1 ? -x : x;
 | 
			
		||||
	return neg == -1 ? -x : x;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
| 
						 | 
				
			
			@ -94,6 +102,7 @@ sin(double x)
 | 
			
		|||
double
 | 
			
		||||
cos(double x)
 | 
			
		||||
{
 | 
			
		||||
	if (x < 0) x = -x;
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	return sinus(x, 1);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
static double
 | 
			
		||||
sinh_cosh(double x, int cosh_flag)
 | 
			
		||||
| 
						 | 
				
			
			@ -27,42 +27,48 @@ sinh_cosh(double x, int cosh_flag)
 | 
			
		|||
	};
 | 
			
		||||
	static double q[] = {
 | 
			
		||||
		-0.21108770058106271242e+7,
 | 
			
		||||
		 0.36162723109421836460e+5,
 | 
			
		||||
		0.36162723109421836460e+5,
 | 
			
		||||
		-0.27773523119650701167e+3,
 | 
			
		||||
		 1.0
 | 
			
		||||
		1.0
 | 
			
		||||
	};
 | 
			
		||||
	int	negative = x < 0;
 | 
			
		||||
	double	y = negative ? -x : x;
 | 
			
		||||
	int negative = x < 0;
 | 
			
		||||
	double y = negative ? -x : x;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (! cosh_flag && y <= 1.0) {
 | 
			
		||||
	if (!cosh_flag && y <= 1.0)
 | 
			
		||||
	{
 | 
			
		||||
		/* ??? check for underflow ??? */
 | 
			
		||||
		y = y * y;
 | 
			
		||||
		return x + x * y * POLYNOM3(y, p)/POLYNOM3(y,q);
 | 
			
		||||
		return x + x * y * POLYNOM3(y, p) / POLYNOM3(y, q);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (y >= M_LN_MAX_D) {
 | 
			
		||||
		/* exp(y) would cause overflow */
 | 
			
		||||
#define LNV	0.69316101074218750000e+0
 | 
			
		||||
#define VD2M1	0.52820835025874852469e-4
 | 
			
		||||
		double	w = y - LNV;
 | 
			
		||||
		
 | 
			
		||||
		if (w < M_LN_MAX_D+M_LN2-LNV) {
 | 
			
		||||
	if (y >= M_LN_MAX_D)
 | 
			
		||||
	{
 | 
			
		||||
/* exp(y) would cause overflow */
 | 
			
		||||
#define LNV 0.69316101074218750000e+0
 | 
			
		||||
#define VD2M1 0.52820835025874852469e-4
 | 
			
		||||
		double w = y - LNV;
 | 
			
		||||
 | 
			
		||||
		if (w < M_LN_MAX_D + M_LN2 - LNV)
 | 
			
		||||
		{
 | 
			
		||||
			x = exp(w);
 | 
			
		||||
			x += VD2M1 * x;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			errno = ERANGE;
 | 
			
		||||
			x = HUGE_VAL;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		double	z = exp(y);
 | 
			
		||||
		
 | 
			
		||||
		x = 0.5 * (z + (cosh_flag ? 1.0 : -1.0)/z);
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		double z = exp(y);
 | 
			
		||||
 | 
			
		||||
		x = 0.5 * (z + (cosh_flag ? 1.0 : -1.0) / z);
 | 
			
		||||
	}
 | 
			
		||||
	return negative ? -x : x;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -76,6 +82,7 @@ sinh(double x)
 | 
			
		|||
double
 | 
			
		||||
cosh(double x)
 | 
			
		||||
{
 | 
			
		||||
	if (x < 0) x = -x;
 | 
			
		||||
	if (x < 0)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	return sinh_cosh(x, 1);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,11 +6,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
#define NITER	5
 | 
			
		||||
#define NITER 5
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
sqrt(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -18,25 +18,31 @@ sqrt(double x)
 | 
			
		|||
	int exponent;
 | 
			
		||||
	double val;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (x <= 0) {
 | 
			
		||||
		if (x < 0) errno = EDOM;
 | 
			
		||||
	if (x <= 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (x < 0)
 | 
			
		||||
			errno = EDOM;
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (x > DBL_MAX) return x;	/* for infinity */
 | 
			
		||||
	if (x > DBL_MAX)
 | 
			
		||||
		return x; /* for infinity */
 | 
			
		||||
 | 
			
		||||
	val = frexp(x, &exponent);
 | 
			
		||||
	if (exponent & 1) {
 | 
			
		||||
	if (exponent & 1)
 | 
			
		||||
	{
 | 
			
		||||
		exponent--;
 | 
			
		||||
		val *= 2;
 | 
			
		||||
	}
 | 
			
		||||
	val = ldexp(val + 1.0, exponent/2 - 1);
 | 
			
		||||
	val = ldexp(val + 1.0, exponent / 2 - 1);
 | 
			
		||||
	/* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */
 | 
			
		||||
	for (exponent = NITER - 1; exponent >= 0; exponent--) {
 | 
			
		||||
	for (exponent = NITER - 1; exponent >= 0; exponent--)
 | 
			
		||||
	{
 | 
			
		||||
		val = (val + x / val) / 2.0;
 | 
			
		||||
	}
 | 
			
		||||
	return val;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
tan(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -21,56 +21,61 @@ tan(double x)
 | 
			
		|||
 | 
			
		||||
	int negative = x < 0;
 | 
			
		||||
	int invert = 0;
 | 
			
		||||
	double  y;
 | 
			
		||||
	static double   p[] = {
 | 
			
		||||
		 1.0,
 | 
			
		||||
	double y;
 | 
			
		||||
	static double p[] = {
 | 
			
		||||
		1.0,
 | 
			
		||||
		-0.13338350006421960681e+0,
 | 
			
		||||
		 0.34248878235890589960e-2,
 | 
			
		||||
		0.34248878235890589960e-2,
 | 
			
		||||
		-0.17861707342254426711e-4
 | 
			
		||||
	};
 | 
			
		||||
	static double   q[] = {
 | 
			
		||||
		 1.0,
 | 
			
		||||
	static double q[] = {
 | 
			
		||||
		1.0,
 | 
			
		||||
		-0.46671683339755294240e+0,
 | 
			
		||||
		 0.25663832289440112864e-1,
 | 
			
		||||
		0.25663832289440112864e-1,
 | 
			
		||||
		-0.31181531907010027307e-3,
 | 
			
		||||
		 0.49819433993786512270e-6
 | 
			
		||||
		0.49819433993786512270e-6
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (negative) x = -x;
 | 
			
		||||
 
 | 
			
		||||
	if (negative)
 | 
			
		||||
		x = -x;
 | 
			
		||||
 | 
			
		||||
	/* ??? avoid loss of significance, error if x is too large ??? */
 | 
			
		||||
 | 
			
		||||
	y = x * M_2_PI + 0.5;
 | 
			
		||||
 | 
			
		||||
	if (y >= DBL_MAX/M_PI_2) return 0.0;
 | 
			
		||||
	if (y >= DBL_MAX / M_PI_2)
 | 
			
		||||
		return 0.0;
 | 
			
		||||
 | 
			
		||||
	/*      Use extended precision to calculate reduced argument.
 | 
			
		||||
/*      Use extended precision to calculate reduced argument.
 | 
			
		||||
		Here we used 12 bits of the mantissa for a1.
 | 
			
		||||
		Also split x in integer part x1 and fraction part x2.
 | 
			
		||||
	*/
 | 
			
		||||
    #define A1 1.57080078125
 | 
			
		||||
    #define A2 -4.454455103380768678308e-6
 | 
			
		||||
#define A1 1.57080078125
 | 
			
		||||
#define A2 -4.454455103380768678308e-6
 | 
			
		||||
	{
 | 
			
		||||
		double x1, x2;
 | 
			
		||||
 | 
			
		||||
		modf(y, &y);
 | 
			
		||||
		if (modf(0.5*y, &x1)) invert = 1;
 | 
			
		||||
		if (modf(0.5 * y, &x1))
 | 
			
		||||
			invert = 1;
 | 
			
		||||
		x2 = modf(x, &x1);
 | 
			
		||||
		x = x1 - y * A1;
 | 
			
		||||
		x += x2;
 | 
			
		||||
		x -= y * A2;
 | 
			
		||||
    #undef A1
 | 
			
		||||
    #undef A2
 | 
			
		||||
#undef A1
 | 
			
		||||
#undef A2
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* ??? avoid underflow ??? */
 | 
			
		||||
	y = x * x;
 | 
			
		||||
	x += x * y * POLYNOM2(y, p+1);
 | 
			
		||||
	x += x * y * POLYNOM2(y, p + 1);
 | 
			
		||||
	y = POLYNOM4(y, q);
 | 
			
		||||
	if (negative) x = -x;
 | 
			
		||||
	return invert ? -y/x : x/y;
 | 
			
		||||
	if (negative)
 | 
			
		||||
		x = -x;
 | 
			
		||||
	return invert ? -y / x : x / y;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<float.h>
 | 
			
		||||
#include	<math.h>
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	"localmath.h"
 | 
			
		||||
#include <float.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include "localmath.h"
 | 
			
		||||
 | 
			
		||||
double
 | 
			
		||||
tanh(double x)
 | 
			
		||||
| 
						 | 
				
			
			@ -25,31 +25,36 @@ tanh(double x)
 | 
			
		|||
		-0.96437492777225469787e+0
 | 
			
		||||
	};
 | 
			
		||||
	static double q[] = {
 | 
			
		||||
		 0.48402357071988688686e+4,
 | 
			
		||||
		 0.22337720718962312926e+4,
 | 
			
		||||
		 0.11274474380534949335e+3,
 | 
			
		||||
		 1.0
 | 
			
		||||
		0.48402357071988688686e+4,
 | 
			
		||||
		0.22337720718962312926e+4,
 | 
			
		||||
		0.11274474380534949335e+3,
 | 
			
		||||
		1.0
 | 
			
		||||
	};
 | 
			
		||||
	int 	negative = x < 0;
 | 
			
		||||
	int negative = x < 0;
 | 
			
		||||
 | 
			
		||||
	if (__IsNan(x)) {
 | 
			
		||||
	if (__IsNan(x))
 | 
			
		||||
	{
 | 
			
		||||
		errno = EDOM;
 | 
			
		||||
		return x;
 | 
			
		||||
	}
 | 
			
		||||
	if (negative) x = -x;
 | 
			
		||||
	if (negative)
 | 
			
		||||
		x = -x;
 | 
			
		||||
 | 
			
		||||
	if (x >= 0.5*M_LN_MAX_D) {
 | 
			
		||||
	if (x >= 0.5 * M_LN_MAX_D)
 | 
			
		||||
	{
 | 
			
		||||
		x = 1.0;
 | 
			
		||||
	}
 | 
			
		||||
#define LN3D2	0.54930614433405484570e+0	/* ln(3)/2 */
 | 
			
		||||
	else if (x > LN3D2) {
 | 
			
		||||
		x = 0.5 - 1.0/(exp(x+x)+1.0);
 | 
			
		||||
#define LN3D2 0.54930614433405484570e+0 /* ln(3)/2 */
 | 
			
		||||
	else if (x > LN3D2)
 | 
			
		||||
	{
 | 
			
		||||
		x = 0.5 - 1.0 / (exp(x + x) + 1.0);
 | 
			
		||||
		x += x;
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		/* ??? avoid underflow ??? */
 | 
			
		||||
		double g = x*x;
 | 
			
		||||
		x += x * g * POLYNOM2(g, p)/POLYNOM3(g, q);
 | 
			
		||||
		double g = x * x;
 | 
			
		||||
		x += x * g * POLYNOM2(g, p) / POLYNOM3(g, q);
 | 
			
		||||
	}
 | 
			
		||||
	return negative ? -x : x;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,33 +4,32 @@
 | 
			
		|||
	last edit:	11-Nov-1988	D A Gwyn
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
typedef void	*pointer;		/* (void *) if you have it */
 | 
			
		||||
typedef void* pointer; /* (void *) if you have it */
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int _close(int d);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
closedir(register DIR *dirp)		/* stream from opendir */
 | 
			
		||||
int closedir(register DIR* dirp) /* stream from opendir */
 | 
			
		||||
{
 | 
			
		||||
	register int	fd;
 | 
			
		||||
	register int fd;
 | 
			
		||||
 | 
			
		||||
	if ( dirp == NULL || dirp->dd_buf == NULL )
 | 
			
		||||
		{
 | 
			
		||||
	if (dirp == NULL || dirp->dd_buf == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT;
 | 
			
		||||
		return -1;		/* invalid pointer */
 | 
			
		||||
		}
 | 
			
		||||
		return -1; /* invalid pointer */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fd = dirp->dd_fd;		/* bug fix thanks to R. Salz */
 | 
			
		||||
	free( (pointer)dirp->dd_buf );
 | 
			
		||||
	free( (pointer)dirp );
 | 
			
		||||
	return _close( fd );
 | 
			
		||||
	fd = dirp->dd_fd; /* bug fix thanks to R. Salz */
 | 
			
		||||
	free((pointer)dirp->dd_buf);
 | 
			
		||||
	free((pointer)dirp);
 | 
			
		||||
	return _close(fd);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,91 +29,92 @@
 | 
			
		|||
	to always work, you shouldn't be using this source file at all.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#ifdef BSD_SYSV
 | 
			
		||||
#include	<sys/_dir.h>		/* BSD flavor, not System V */
 | 
			
		||||
#include <sys/_dir.h> /* BSD flavor, not System V */
 | 
			
		||||
#else
 | 
			
		||||
#if	defined(UFS)
 | 
			
		||||
#define	DIRSIZ		14		/* 14 char filename in Version 7 */
 | 
			
		||||
#if defined(UFS)
 | 
			
		||||
#define DIRSIZ 14 /* 14 char filename in Version 7 */
 | 
			
		||||
#endif
 | 
			
		||||
#define	MAXNAMLEN	255
 | 
			
		||||
struct  direct {
 | 
			
		||||
	off_t	d_off;			/* offset of next disk directory entry */
 | 
			
		||||
	u_long	d_fileno;		/* file number of entry */
 | 
			
		||||
	u_short	d_reclen;		/* length of this record */
 | 
			
		||||
	u_short	d_namlen;		/* length of string in d_name */
 | 
			
		||||
	char	d_name[MAXNAMLEN + 1];	/* name (up to MAXNAMLEN + 1) */
 | 
			
		||||
#define MAXNAMLEN 255
 | 
			
		||||
struct direct
 | 
			
		||||
{
 | 
			
		||||
	off_t d_off; /* offset of next disk directory entry */
 | 
			
		||||
	u_long d_fileno; /* file number of entry */
 | 
			
		||||
	u_short d_reclen; /* length of this record */
 | 
			
		||||
	u_short d_namlen; /* length of string in d_name */
 | 
			
		||||
	char d_name[MAXNAMLEN + 1]; /* name (up to MAXNAMLEN + 1) */
 | 
			
		||||
};
 | 
			
		||||
#undef	MAXNAMLEN			/* avoid conflict with SVR3 */
 | 
			
		||||
#undef MAXNAMLEN /* avoid conflict with SVR3 */
 | 
			
		||||
 | 
			
		||||
#define	d_ino	d_fileno		/* compatability */
 | 
			
		||||
#define d_ino d_fileno /* compatability */
 | 
			
		||||
 | 
			
		||||
#ifdef d_ino				/* 4.3BSD/NFS using d_fileno */
 | 
			
		||||
#undef	d_ino				/* (not absolutely necessary) */
 | 
			
		||||
#ifdef d_ino /* 4.3BSD/NFS using d_fileno */
 | 
			
		||||
#undef d_ino /* (not absolutely necessary) */
 | 
			
		||||
#else
 | 
			
		||||
#define	d_fileno	d_ino		/* (struct direct) member */
 | 
			
		||||
#define d_fileno d_ino /* (struct direct) member */
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
#include	<sys/dirent.h>
 | 
			
		||||
#include	<sys/stat.h>
 | 
			
		||||
#include <sys/dirent.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#ifdef UNK
 | 
			
		||||
#ifndef UFS
 | 
			
		||||
#error	UNK applies only to UFS
 | 
			
		||||
#error UNK applies only to UFS
 | 
			
		||||
/* One could do something similar for getdirentries(), but I didn't bother. */
 | 
			
		||||
#endif
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if	defined(UFS) + defined(BFS) + defined(NFS) != 1	/* sanity check */
 | 
			
		||||
#error	exactly one of UFS, BFS, or NFS must be defined
 | 
			
		||||
#if defined(UFS) + defined(BFS) + defined(NFS) != 1 /* sanity check */
 | 
			
		||||
#error exactly one of UFS, BFS, or NFS must be defined
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef UFS
 | 
			
		||||
#define	RecLen( dp )	(sizeof(struct direct))	/* fixed-length entries */
 | 
			
		||||
#else	/* BFS || NFS */
 | 
			
		||||
#define	RecLen( dp )	((dp)->d_reclen)	/* variable-length entries */
 | 
			
		||||
#define RecLen(dp) (sizeof(struct direct)) /* fixed-length entries */
 | 
			
		||||
#else /* BFS || NFS */
 | 
			
		||||
#define RecLen(dp) ((dp)->d_reclen) /* variable-length entries */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef NFS
 | 
			
		||||
#ifdef BSD_SYSV
 | 
			
		||||
#define	getdirentries	_getdirentries	/* package hides this system call */
 | 
			
		||||
#define getdirentries _getdirentries /* package hides this system call */
 | 
			
		||||
#endif
 | 
			
		||||
extern int	getdirentries(int fd, char *buf, int nbytes, long *basep);
 | 
			
		||||
static long	dummy;			/* getdirentries() needs basep */
 | 
			
		||||
#define	GetBlock( fd, buf, n )	getdirentries( fd, buf, (unsigned)n, &dummy )
 | 
			
		||||
#else	/* UFS || BFS */
 | 
			
		||||
extern int getdirentries(int fd, char* buf, int nbytes, long* basep);
 | 
			
		||||
static long dummy; /* getdirentries() needs basep */
 | 
			
		||||
#define GetBlock(fd, buf, n) getdirentries(fd, buf, (unsigned)n, &dummy)
 | 
			
		||||
#else /* UFS || BFS */
 | 
			
		||||
#ifdef BSD_SYSV
 | 
			
		||||
#define read	_read			/* avoid emulation overhead */
 | 
			
		||||
#define read _read /* avoid emulation overhead */
 | 
			
		||||
#endif
 | 
			
		||||
extern int	read();
 | 
			
		||||
#define	GetBlock( fd, buf, n )	read( fd, buf, (unsigned)n )
 | 
			
		||||
extern int read();
 | 
			
		||||
#define GetBlock(fd, buf, n) read(fd, buf, (unsigned)n)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef UNK
 | 
			
		||||
extern int	_getdents();		/* actual system call */
 | 
			
		||||
extern int _getdents(); /* actual system call */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
extern int	_fstat(int fd, struct stat *buf);
 | 
			
		||||
extern off_t	_lseek(int d, int offset, int whence);
 | 
			
		||||
extern int _fstat(int fd, struct stat* buf);
 | 
			
		||||
extern off_t _lseek(int d, int offset, int whence);
 | 
			
		||||
 | 
			
		||||
#ifndef DIRBLKSIZ
 | 
			
		||||
#define	DIRBLKSIZ	4096		/* directory file read buffer size */
 | 
			
		||||
#define DIRBLKSIZ 4096 /* directory file read buffer size */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef SEEK_CUR
 | 
			
		||||
#define	SEEK_CUR	1
 | 
			
		||||
#define SEEK_CUR 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef S_ISDIR				/* macro to test for directory file */
 | 
			
		||||
#define	S_ISDIR( mode )		(((mode) & S_IFMT) == S_IFDIR)
 | 
			
		||||
#ifndef S_ISDIR /* macro to test for directory file */
 | 
			
		||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef UFS
 | 
			
		||||
| 
						 | 
				
			
			@ -124,166 +125,168 @@ extern off_t	_lseek(int d, int offset, int whence);
 | 
			
		|||
*/
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
NameLen( char name[] )				/* return # chars in embedded name */
 | 
			
		||||
		/* -> name embedded in struct direct */
 | 
			
		||||
NameLen(char name[]) /* return # chars in embedded name */
 | 
			
		||||
/* -> name embedded in struct direct */
 | 
			
		||||
{
 | 
			
		||||
	register char	*s;		/* -> name[.] */
 | 
			
		||||
	register char	*stop = &name[DIRSIZ];	/* -> past end of name field */
 | 
			
		||||
	register char* s; /* -> name[.] */
 | 
			
		||||
	register char* stop = &name[DIRSIZ]; /* -> past end of name field */
 | 
			
		||||
 | 
			
		||||
	for ( s = &name[1];		/* (empty names are impossible) */
 | 
			
		||||
	      *s != '\0'		/* not NUL terminator */
 | 
			
		||||
	   && ++s < stop;		/* < DIRSIZ characters scanned */
 | 
			
		||||
	for (s = &name[1]; /* (empty names are impossible) */
 | 
			
		||||
	     *s != '\0' /* not NUL terminator */
 | 
			
		||||
	     && ++s < stop; /* < DIRSIZ characters scanned */
 | 
			
		||||
	    )
 | 
			
		||||
		;
 | 
			
		||||
 | 
			
		||||
	return s - name;		/* # valid characters in name */
 | 
			
		||||
	return s - name; /* # valid characters in name */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else	/* BFS || NFS */
 | 
			
		||||
#else /* BFS || NFS */
 | 
			
		||||
 | 
			
		||||
#define	NameLen( name )	strlen( name )	/* names are always NUL-terminated */
 | 
			
		||||
#define NameLen(name) strlen(name) /* names are always NUL-terminated */
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef UNK
 | 
			
		||||
static enum	{ maybe, no, yes }	state = maybe;
 | 
			
		||||
					/* does _getdents() work? */
 | 
			
		||||
static enum { maybe,
 | 
			
		||||
	no,
 | 
			
		||||
	yes } state
 | 
			
		||||
    = maybe;
 | 
			
		||||
/* does _getdents() work? */
 | 
			
		||||
 | 
			
		||||
/*ARGSUSED*/
 | 
			
		||||
static void
 | 
			
		||||
sig_catch(int sig)			/* sig must be SIGSYS */
 | 
			
		||||
sig_catch(int sig) /* sig must be SIGSYS */
 | 
			
		||||
{
 | 
			
		||||
	state = no;			/* attempted _getdents() faulted */
 | 
			
		||||
	state = no; /* attempted _getdents() faulted */
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
getdents(int fildes, char *buf, unsigned nbyte)	/* returns # bytes read;
 | 
			
		||||
int getdents(int fildes, char* buf, unsigned nbyte) /* returns # bytes read;
 | 
			
		||||
						    0 on EOF, -1 on error */
 | 
			
		||||
/* fildes == directory file descriptor */
 | 
			
		||||
/* *buf == where to put the (struct dirent)s */
 | 
			
		||||
/* nbyte == size of buf[] */
 | 
			
		||||
{
 | 
			
		||||
	int			serrno;	/* entry errno */
 | 
			
		||||
	off_t			offset;	/* initial directory file offset */
 | 
			
		||||
	struct stat		statb;	/* fstat() info */
 | 
			
		||||
	union	{
 | 
			
		||||
		char		dblk[DIRBLKSIZ];
 | 
			
		||||
					/* directory file block buffer */
 | 
			
		||||
		struct direct	dummy;	/* just for alignment */
 | 
			
		||||
		}	u;		/* (avoids having to malloc()) */
 | 
			
		||||
	register struct direct	*dp;	/* -> u.dblk[.] */
 | 
			
		||||
	register struct dirent	*bp;	/* -> buf[.] */
 | 
			
		||||
	int serrno; /* entry errno */
 | 
			
		||||
	off_t offset; /* initial directory file offset */
 | 
			
		||||
	struct stat statb; /* fstat() info */
 | 
			
		||||
	union {
 | 
			
		||||
		char dblk[DIRBLKSIZ];
 | 
			
		||||
		/* directory file block buffer */
 | 
			
		||||
		struct direct dummy; /* just for alignment */
 | 
			
		||||
	} u; /* (avoids having to malloc()) */
 | 
			
		||||
	register struct direct* dp; /* -> u.dblk[.] */
 | 
			
		||||
	register struct dirent* bp; /* -> buf[.] */
 | 
			
		||||
 | 
			
		||||
#ifdef UNK
 | 
			
		||||
	switch ( state )
 | 
			
		||||
		{
 | 
			
		||||
		void		(*shdlr)();	/* entry SIGSYS handler */
 | 
			
		||||
		register int	retval;	/* return from _getdents() if any */
 | 
			
		||||
	switch (state)
 | 
			
		||||
	{
 | 
			
		||||
		void (*shdlr)(); /* entry SIGSYS handler */
 | 
			
		||||
		register int retval; /* return from _getdents() if any */
 | 
			
		||||
 | 
			
		||||
	case yes:			/* _getdents() is known to work */
 | 
			
		||||
		return _getdents( fildes, buf, nbyte );
 | 
			
		||||
		case yes: /* _getdents() is known to work */
 | 
			
		||||
			return _getdents(fildes, buf, nbyte);
 | 
			
		||||
 | 
			
		||||
	case maybe:			/* first time only */
 | 
			
		||||
		shdlr = signal( SIGSYS, sig_catch );
 | 
			
		||||
		retval = _getdents( fildes, buf, nbyte );	/* try it */
 | 
			
		||||
		(void)signal( SIGSYS, shdlr );
 | 
			
		||||
		case maybe: /* first time only */
 | 
			
		||||
			shdlr = signal(SIGSYS, sig_catch);
 | 
			
		||||
			retval = _getdents(fildes, buf, nbyte); /* try it */
 | 
			
		||||
			(void)signal(SIGSYS, shdlr);
 | 
			
		||||
 | 
			
		||||
		if ( state == maybe )	/* SIGSYS did not occur */
 | 
			
		||||
			if (state == maybe) /* SIGSYS did not occur */
 | 
			
		||||
			{
 | 
			
		||||
			state = yes;	/* so _getdents() must have worked */
 | 
			
		||||
			return retval;
 | 
			
		||||
				state = yes; /* so _getdents() must have worked */
 | 
			
		||||
				return retval;
 | 
			
		||||
			}
 | 
			
		||||
		/* else fall through into emulation */
 | 
			
		||||
			/* else fall through into emulation */
 | 
			
		||||
 | 
			
		||||
/*	case no:*/	/* fall through into emulation */
 | 
			
		||||
		}
 | 
			
		||||
			/*	case no:*/ /* fall through into emulation */
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if ( buf == NULL
 | 
			
		||||
	if (buf == NULL
 | 
			
		||||
#ifdef ATT_SPEC
 | 
			
		||||
	  || (unsigned long)buf % sizeof(long) != 0	/* ugh */
 | 
			
		||||
	    || (unsigned long)buf % sizeof(long) != 0 /* ugh */
 | 
			
		||||
#endif
 | 
			
		||||
	   )	{
 | 
			
		||||
		errno = EFAULT;		/* invalid pointer */
 | 
			
		||||
	    )
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT; /* invalid pointer */
 | 
			
		||||
		return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( _fstat( fildes, &statb ) != 0 )
 | 
			
		||||
		return -1;		/* errno set by fstat() */
 | 
			
		||||
	if (_fstat(fildes, &statb) != 0)
 | 
			
		||||
		return -1; /* errno set by fstat() */
 | 
			
		||||
 | 
			
		||||
	if ( !S_ISDIR( statb.st_mode ) )
 | 
			
		||||
		{
 | 
			
		||||
		errno = ENOTDIR;	/* not a directory */
 | 
			
		||||
	if (!S_ISDIR(statb.st_mode))
 | 
			
		||||
	{
 | 
			
		||||
		errno = ENOTDIR; /* not a directory */
 | 
			
		||||
		return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( (offset = _lseek( fildes, (off_t)0, SEEK_CUR )) < 0 )
 | 
			
		||||
		return -1;		/* errno set by lseek() */
 | 
			
		||||
	if ((offset = _lseek(fildes, (off_t)0, SEEK_CUR)) < 0)
 | 
			
		||||
		return -1; /* errno set by lseek() */
 | 
			
		||||
 | 
			
		||||
#ifdef BFS				/* no telling what remote hosts do */
 | 
			
		||||
	if ( (unsigned long)offset % DIRBLKSIZ != 0 )
 | 
			
		||||
		{
 | 
			
		||||
		errno = ENOENT;		/* file pointer probably misaligned */
 | 
			
		||||
#ifdef BFS /* no telling what remote hosts do */
 | 
			
		||||
	if ((unsigned long)offset % DIRBLKSIZ != 0)
 | 
			
		||||
	{
 | 
			
		||||
		errno = ENOENT; /* file pointer probably misaligned */
 | 
			
		||||
		return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	serrno = errno;			/* save entry errno */
 | 
			
		||||
	serrno = errno; /* save entry errno */
 | 
			
		||||
 | 
			
		||||
	for ( bp = (struct dirent *)buf; bp == (struct dirent *)buf; )
 | 
			
		||||
		{			/* convert next directory block */
 | 
			
		||||
		int	size;
 | 
			
		||||
	for (bp = (struct dirent*)buf; bp == (struct dirent*)buf;)
 | 
			
		||||
	{ /* convert next directory block */
 | 
			
		||||
		int size;
 | 
			
		||||
 | 
			
		||||
		do	size = GetBlock( fildes, u.dblk, DIRBLKSIZ );
 | 
			
		||||
		while ( size == -1 && errno == EINTR );
 | 
			
		||||
		do
 | 
			
		||||
			size = GetBlock(fildes, u.dblk, DIRBLKSIZ);
 | 
			
		||||
		while (size == -1 && errno == EINTR);
 | 
			
		||||
 | 
			
		||||
		if ( size <= 0 )
 | 
			
		||||
			return size;	/* EOF or error (EBADF) */
 | 
			
		||||
		if (size <= 0)
 | 
			
		||||
			return size; /* EOF or error (EBADF) */
 | 
			
		||||
 | 
			
		||||
		for ( dp = (struct direct *)u.dblk;
 | 
			
		||||
		      (char *)dp < &u.dblk[size];
 | 
			
		||||
		      dp = (struct direct *)((char *)dp + RecLen( dp ))
 | 
			
		||||
		    )	{
 | 
			
		||||
		for (dp = (struct direct*)u.dblk;
 | 
			
		||||
		     (char*)dp < &u.dblk[size];
 | 
			
		||||
		     dp = (struct direct*)((char*)dp + RecLen(dp)))
 | 
			
		||||
		{
 | 
			
		||||
#ifndef UFS
 | 
			
		||||
			if ( dp->d_reclen <= 0 )
 | 
			
		||||
				{
 | 
			
		||||
				errno = EIO;	/* corrupted directory */
 | 
			
		||||
			if (dp->d_reclen <= 0)
 | 
			
		||||
			{
 | 
			
		||||
				errno = EIO; /* corrupted directory */
 | 
			
		||||
				return -1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
			if ( dp->d_fileno != 0 )
 | 
			
		||||
				{	/* non-empty; copy to user buffer */
 | 
			
		||||
				register int	reclen =
 | 
			
		||||
					DIRENTSIZ( NameLen( dp->d_name ) );
 | 
			
		||||
			if (dp->d_fileno != 0)
 | 
			
		||||
			{ /* non-empty; copy to user buffer */
 | 
			
		||||
				register int reclen = DIRENTSIZ(NameLen(dp->d_name));
 | 
			
		||||
 | 
			
		||||
				if ( (char *)bp + reclen > &buf[nbyte] )
 | 
			
		||||
					{
 | 
			
		||||
				if ((char*)bp + reclen > &buf[nbyte])
 | 
			
		||||
				{
 | 
			
		||||
					errno = EINVAL;
 | 
			
		||||
					return -1;	/* buf too small */
 | 
			
		||||
					}
 | 
			
		||||
					return -1; /* buf too small */
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				bp->d_ino = dp->d_fileno;
 | 
			
		||||
				bp->d_off = offset + ((char *)dp - u.dblk);
 | 
			
		||||
				bp->d_off = offset + ((char*)dp - u.dblk);
 | 
			
		||||
				bp->d_reclen = reclen;
 | 
			
		||||
				(void)strncpy( bp->d_name, dp->d_name,
 | 
			
		||||
					       reclen - DIRENTBASESIZ
 | 
			
		||||
					     );	/* adds NUL padding */
 | 
			
		||||
				(void)strncpy(bp->d_name, dp->d_name,
 | 
			
		||||
				    reclen - DIRENTBASESIZ); /* adds NUL padding */
 | 
			
		||||
 | 
			
		||||
				bp = (struct dirent *)((char *)bp + reclen);
 | 
			
		||||
				}
 | 
			
		||||
				bp = (struct dirent*)((char*)bp + reclen);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
#ifndef BFS	/* 4.2BSD screwed up; fixed in 4.3BSD */
 | 
			
		||||
		if ( (char *)dp > &u.dblk[size] )
 | 
			
		||||
			{
 | 
			
		||||
			errno = EIO;	/* corrupted directory */
 | 
			
		||||
			return -1;
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	errno = serrno;			/* restore entry errno */
 | 
			
		||||
	return (char *)bp - buf;	/* return # bytes read */
 | 
			
		||||
#ifndef BFS /* 4.2BSD screwed up; fixed in 4.3BSD */
 | 
			
		||||
		if ((char*)dp > &u.dblk[size])
 | 
			
		||||
		{
 | 
			
		||||
			errno = EIO; /* corrupted directory */
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	errno = serrno; /* restore entry errno */
 | 
			
		||||
	return (char*)bp - buf; /* return # bytes read */
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,131 +5,130 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	<grp.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <grp.h>
 | 
			
		||||
 | 
			
		||||
#define	O_RDONLY	0
 | 
			
		||||
#define O_RDONLY 0
 | 
			
		||||
 | 
			
		||||
int open(const char *path, int flags);
 | 
			
		||||
int open(const char* path, int flags);
 | 
			
		||||
 | 
			
		||||
#if	defined(__BSD4_2)
 | 
			
		||||
typedef int off_t;                              /* see lseek(2) */
 | 
			
		||||
#if defined(__BSD4_2)
 | 
			
		||||
typedef int off_t; /* see lseek(2) */
 | 
			
		||||
#else
 | 
			
		||||
typedef long off_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
off_t _lseek(int d, off_t offset, int whence);
 | 
			
		||||
int _read(int d, char *buf, int nbytes);
 | 
			
		||||
int _read(int d, char* buf, int nbytes);
 | 
			
		||||
int _close(int d);
 | 
			
		||||
 | 
			
		||||
#define	RBUFSIZE	1024
 | 
			
		||||
#define RBUFSIZE 1024
 | 
			
		||||
static char _gr_file[] = "/etc/group";
 | 
			
		||||
static char _grbuf[256];
 | 
			
		||||
static char _buffer[RBUFSIZE];
 | 
			
		||||
static char *_pnt;
 | 
			
		||||
static char *_buf;
 | 
			
		||||
static int  _gfd = -1;
 | 
			
		||||
static int  _bufcnt;
 | 
			
		||||
static char* _pnt;
 | 
			
		||||
static char* _buf;
 | 
			
		||||
static int _gfd = -1;
 | 
			
		||||
static int _bufcnt;
 | 
			
		||||
static struct group grp;
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
setgrent(void)
 | 
			
		||||
int setgrent(void)
 | 
			
		||||
{
 | 
			
		||||
        if (_gfd >= 0)
 | 
			
		||||
	        _lseek(_gfd, 0L, 0);
 | 
			
		||||
        else
 | 
			
		||||
	        _gfd = open(_gr_file, O_RDONLY);
 | 
			
		||||
	if (_gfd >= 0)
 | 
			
		||||
		_lseek(_gfd, 0L, 0);
 | 
			
		||||
	else
 | 
			
		||||
		_gfd = open(_gr_file, O_RDONLY);
 | 
			
		||||
 | 
			
		||||
        _bufcnt = 0;
 | 
			
		||||
        return _gfd;
 | 
			
		||||
	_bufcnt = 0;
 | 
			
		||||
	return _gfd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
endgrent(void) 
 | 
			
		||||
void endgrent(void)
 | 
			
		||||
{
 | 
			
		||||
        if (_gfd >= 0)
 | 
			
		||||
	        _close(_gfd);
 | 
			
		||||
	if (_gfd >= 0)
 | 
			
		||||
		_close(_gfd);
 | 
			
		||||
 | 
			
		||||
        _gfd = -1;
 | 
			
		||||
        _bufcnt = 0;
 | 
			
		||||
	_gfd = -1;
 | 
			
		||||
	_bufcnt = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
getline(void) 
 | 
			
		||||
getline(void)
 | 
			
		||||
{
 | 
			
		||||
        if (_gfd < 0 && setgrent() < 0)
 | 
			
		||||
	        return 0;
 | 
			
		||||
	if (_gfd < 0 && setgrent() < 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
        _buf = _grbuf;
 | 
			
		||||
        do {
 | 
			
		||||
	        if (--_bufcnt <= 0){
 | 
			
		||||
	                if ((_bufcnt = _read(_gfd, _buffer, RBUFSIZE)) <= 0)
 | 
			
		||||
		                return 0;
 | 
			
		||||
	                else
 | 
			
		||||
		                _pnt = _buffer;
 | 
			
		||||
	_buf = _grbuf;
 | 
			
		||||
	do
 | 
			
		||||
	{
 | 
			
		||||
		if (--_bufcnt <= 0)
 | 
			
		||||
		{
 | 
			
		||||
			if ((_bufcnt = _read(_gfd, _buffer, RBUFSIZE)) <= 0)
 | 
			
		||||
				return 0;
 | 
			
		||||
			else
 | 
			
		||||
				_pnt = _buffer;
 | 
			
		||||
		}
 | 
			
		||||
	        *_buf++ = *_pnt++;
 | 
			
		||||
        } while (*_pnt != '\n');
 | 
			
		||||
        _pnt++;
 | 
			
		||||
        _bufcnt--;
 | 
			
		||||
        *_buf = 0;
 | 
			
		||||
        _buf = _grbuf;
 | 
			
		||||
        return 1;
 | 
			
		||||
		*_buf++ = *_pnt++;
 | 
			
		||||
	} while (*_pnt != '\n');
 | 
			
		||||
	_pnt++;
 | 
			
		||||
	_bufcnt--;
 | 
			
		||||
	*_buf = 0;
 | 
			
		||||
	_buf = _grbuf;
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
skip_period(void) 
 | 
			
		||||
skip_period(void)
 | 
			
		||||
{
 | 
			
		||||
        while (*_buf && *_buf != ':')
 | 
			
		||||
	        _buf++;
 | 
			
		||||
        *_buf++ = '\0';
 | 
			
		||||
	while (*_buf && *_buf != ':')
 | 
			
		||||
		_buf++;
 | 
			
		||||
	*_buf++ = '\0';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct group *
 | 
			
		||||
getgrent(void) 
 | 
			
		||||
struct group*
 | 
			
		||||
getgrent(void)
 | 
			
		||||
{
 | 
			
		||||
        if (getline() == 0)
 | 
			
		||||
               return 0;
 | 
			
		||||
	if (getline() == 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
        grp.gr_name = _buf;
 | 
			
		||||
        skip_period();
 | 
			
		||||
        grp.gr_passwd = _buf;
 | 
			
		||||
        skip_period();
 | 
			
		||||
        grp.gr_gid = atoi(_buf);
 | 
			
		||||
        skip_period();
 | 
			
		||||
        return &grp;
 | 
			
		||||
	grp.gr_name = _buf;
 | 
			
		||||
	skip_period();
 | 
			
		||||
	grp.gr_passwd = _buf;
 | 
			
		||||
	skip_period();
 | 
			
		||||
	grp.gr_gid = atoi(_buf);
 | 
			
		||||
	skip_period();
 | 
			
		||||
	return &grp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct group *
 | 
			
		||||
getgrnam(const char *name)
 | 
			
		||||
struct group*
 | 
			
		||||
getgrnam(const char* name)
 | 
			
		||||
{
 | 
			
		||||
        struct group *g;
 | 
			
		||||
	struct group* g;
 | 
			
		||||
 | 
			
		||||
        setgrent();
 | 
			
		||||
        while ((g = getgrent()) != 0)
 | 
			
		||||
	        if (!strcmp(g -> gr_name, name))
 | 
			
		||||
	                break;
 | 
			
		||||
        endgrent();
 | 
			
		||||
        if (g != 0)
 | 
			
		||||
	        return g;
 | 
			
		||||
        else
 | 
			
		||||
	        return 0;
 | 
			
		||||
	setgrent();
 | 
			
		||||
	while ((g = getgrent()) != 0)
 | 
			
		||||
		if (!strcmp(g->gr_name, name))
 | 
			
		||||
			break;
 | 
			
		||||
	endgrent();
 | 
			
		||||
	if (g != 0)
 | 
			
		||||
		return g;
 | 
			
		||||
	else
 | 
			
		||||
		return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct group *
 | 
			
		||||
struct group*
 | 
			
		||||
getgrgid(int gid)
 | 
			
		||||
{
 | 
			
		||||
        struct group   *g;
 | 
			
		||||
	struct group* g;
 | 
			
		||||
 | 
			
		||||
        setgrent();
 | 
			
		||||
        while ((g = getgrent()) != 0)
 | 
			
		||||
	        if (g -> gr_gid == gid)
 | 
			
		||||
	                break;
 | 
			
		||||
        endgrent();
 | 
			
		||||
        if (g != 0)
 | 
			
		||||
	        return g;
 | 
			
		||||
        else
 | 
			
		||||
	        return 0;
 | 
			
		||||
	setgrent();
 | 
			
		||||
	while ((g = getgrent()) != 0)
 | 
			
		||||
		if (g->gr_gid == gid)
 | 
			
		||||
			break;
 | 
			
		||||
	endgrent();
 | 
			
		||||
	if (g != 0)
 | 
			
		||||
		return g;
 | 
			
		||||
	else
 | 
			
		||||
		return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,56 +3,66 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#define ERR(s, c)       if(opterr){\
 | 
			
		||||
	fputs(argv[0], stderr);\
 | 
			
		||||
	fputs(s, stderr);\
 | 
			
		||||
	fputc(c, stderr);\
 | 
			
		||||
	fputc('\n', stderr);}
 | 
			
		||||
#define ERR(s, c)               \
 | 
			
		||||
	if (opterr)                 \
 | 
			
		||||
	{                           \
 | 
			
		||||
		fputs(argv[0], stderr); \
 | 
			
		||||
		fputs(s, stderr);       \
 | 
			
		||||
		fputc(c, stderr);       \
 | 
			
		||||
		fputc('\n', stderr);    \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
int     opterr = 1;
 | 
			
		||||
int     optind = 1;
 | 
			
		||||
int	optopt;
 | 
			
		||||
char    *optarg;
 | 
			
		||||
int opterr = 1;
 | 
			
		||||
int optind = 1;
 | 
			
		||||
int optopt;
 | 
			
		||||
char* optarg;
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
getopt(int argc, char **argv, char *opts)
 | 
			
		||||
int getopt(int argc, char** argv, char* opts)
 | 
			
		||||
{
 | 
			
		||||
	static int sp = 1;
 | 
			
		||||
	register c;
 | 
			
		||||
	register char *cp;
 | 
			
		||||
	register char* cp;
 | 
			
		||||
 | 
			
		||||
	if (sp == 1)
 | 
			
		||||
		if (optind >= argc ||
 | 
			
		||||
		   argv[optind][0] != '-' || argv[optind][1] == '\0')
 | 
			
		||||
		if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
 | 
			
		||||
			return EOF;
 | 
			
		||||
		else if (!strcmp(argv[optind], "--")) {
 | 
			
		||||
		else if (!strcmp(argv[optind], "--"))
 | 
			
		||||
		{
 | 
			
		||||
			optind++;
 | 
			
		||||
			return EOF;
 | 
			
		||||
		}
 | 
			
		||||
	optopt = c = argv[optind][sp];
 | 
			
		||||
	if (c == ':' || (cp=strchr(opts, c)) == NULL) {
 | 
			
		||||
		ERR (": illegal option -- ", c);
 | 
			
		||||
		if (argv[optind][++sp] == '\0') {
 | 
			
		||||
	if (c == ':' || (cp = strchr(opts, c)) == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		ERR(": illegal option -- ", c);
 | 
			
		||||
		if (argv[optind][++sp] == '\0')
 | 
			
		||||
		{
 | 
			
		||||
			optind++;
 | 
			
		||||
			sp = 1;
 | 
			
		||||
		}
 | 
			
		||||
		return '?';
 | 
			
		||||
	}
 | 
			
		||||
	if (*++cp == ':') {
 | 
			
		||||
		if (argv[optind][sp+1] != '\0')
 | 
			
		||||
			optarg = &argv[optind++][sp+1];
 | 
			
		||||
		else if (++optind >= argc) {
 | 
			
		||||
			ERR (": option requires an argument -- ", c);
 | 
			
		||||
	if (*++cp == ':')
 | 
			
		||||
	{
 | 
			
		||||
		if (argv[optind][sp + 1] != '\0')
 | 
			
		||||
			optarg = &argv[optind++][sp + 1];
 | 
			
		||||
		else if (++optind >= argc)
 | 
			
		||||
		{
 | 
			
		||||
			ERR(": option requires an argument -- ", c);
 | 
			
		||||
			sp = 1;
 | 
			
		||||
			return '?';
 | 
			
		||||
		} else
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			optarg = argv[optind++];
 | 
			
		||||
		sp = 1;
 | 
			
		||||
	} else {
 | 
			
		||||
		if (argv[optind][++sp] == '\0') {
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (argv[optind][++sp] == '\0')
 | 
			
		||||
		{
 | 
			
		||||
			sp = 1;
 | 
			
		||||
			optind++;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,22 +3,21 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include    <stdlib.h>
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	<sgtty.h>
 | 
			
		||||
#include    <fcntl.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sgtty.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
 | 
			
		||||
int _open(const char *path, int flags);
 | 
			
		||||
int _write(int d, const char *buf, int nbytes);
 | 
			
		||||
int _read(int d, char *buf, int nbytes);
 | 
			
		||||
int _open(const char* path, int flags);
 | 
			
		||||
int _write(int d, const char* buf, int nbytes);
 | 
			
		||||
int _read(int d, char* buf, int nbytes);
 | 
			
		||||
int _close(int d);
 | 
			
		||||
 | 
			
		||||
int _stty(int, struct sgttyb *);
 | 
			
		||||
int _gtty(int, struct sgttyb *);
 | 
			
		||||
int _stty(int, struct sgttyb*);
 | 
			
		||||
int _gtty(int, struct sgttyb*);
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
getpass(const char *prompt)
 | 
			
		||||
char* getpass(const char* prompt)
 | 
			
		||||
{
 | 
			
		||||
	int i = 0;
 | 
			
		||||
	struct sgttyb tty, ttysave;
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +25,8 @@ getpass(const char *prompt)
 | 
			
		|||
	int fd;
 | 
			
		||||
	void (*savesig)(int);
 | 
			
		||||
 | 
			
		||||
	if ((fd = _open("/dev/tty", O_RDONLY)) < 0) fd = 0;
 | 
			
		||||
	if ((fd = _open("/dev/tty", O_RDONLY)) < 0)
 | 
			
		||||
		fd = 0;
 | 
			
		||||
	savesig = signal(SIGINT, SIG_IGN);
 | 
			
		||||
	_write(2, prompt, strlen(prompt));
 | 
			
		||||
	_gtty(fd, &tty);
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +39,8 @@ getpass(const char *prompt)
 | 
			
		|||
	pwdbuf[i - 1] = '\0';
 | 
			
		||||
	_stty(fd, &ttysave);
 | 
			
		||||
	_write(2, "\n", 1);
 | 
			
		||||
	if (fd != 0) _close(fd);
 | 
			
		||||
	if (fd != 0)
 | 
			
		||||
		_close(fd);
 | 
			
		||||
	signal(SIGINT, savesig);
 | 
			
		||||
	return(pwdbuf);
 | 
			
		||||
	return (pwdbuf);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,17 +3,19 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int getw(register FILE *stream)
 | 
			
		||||
int getw(register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register int cnt = sizeof(int);
 | 
			
		||||
	int w;
 | 
			
		||||
	register char *p = (char *) &w;
 | 
			
		||||
	register char* p = (char*)&w;
 | 
			
		||||
 | 
			
		||||
	while (cnt--) {
 | 
			
		||||
	while (cnt--)
 | 
			
		||||
	{
 | 
			
		||||
		*p++ = getc(stream);
 | 
			
		||||
	}
 | 
			
		||||
	if (feof(stream) || ferror(stream)) return EOF;
 | 
			
		||||
	if (feof(stream) || ferror(stream))
 | 
			
		||||
		return EOF;
 | 
			
		||||
	return w;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,28 +3,32 @@
 | 
			
		|||
/* no _-protected system-calls? */
 | 
			
		||||
 | 
			
		||||
unsigned int getpid(void);
 | 
			
		||||
int access(char *, int);
 | 
			
		||||
int access(char*, int);
 | 
			
		||||
 | 
			
		||||
char *mktemp(char *template)
 | 
			
		||||
char* mktemp(char* template)
 | 
			
		||||
{
 | 
			
		||||
  register int pid, k;
 | 
			
		||||
  register char *p;
 | 
			
		||||
	register int pid, k;
 | 
			
		||||
	register char* p;
 | 
			
		||||
 | 
			
		||||
  pid = getpid();		/* get process id as semi-unique number */
 | 
			
		||||
  p = template;
 | 
			
		||||
  while (*p) p++;		/* find end of string */
 | 
			
		||||
	pid = getpid(); /* get process id as semi-unique number */
 | 
			
		||||
	p = template;
 | 
			
		||||
	while (*p)
 | 
			
		||||
		p++; /* find end of string */
 | 
			
		||||
 | 
			
		||||
  /* Replace XXXXXX at end of template with pid. */
 | 
			
		||||
  while (*--p == 'X') {
 | 
			
		||||
	*p = '0' + (pid % 10);
 | 
			
		||||
	pid /= 10;
 | 
			
		||||
  }
 | 
			
		||||
  p++;
 | 
			
		||||
  for (k = 'a'; k <= 'z'; k++) {
 | 
			
		||||
	*p = k;
 | 
			
		||||
	if (access(template, 0) < 0) {
 | 
			
		||||
		return template;
 | 
			
		||||
	/* Replace XXXXXX at end of template with pid. */
 | 
			
		||||
	while (*--p == 'X')
 | 
			
		||||
	{
 | 
			
		||||
		*p = '0' + (pid % 10);
 | 
			
		||||
		pid /= 10;
 | 
			
		||||
	}
 | 
			
		||||
  }
 | 
			
		||||
  return("/");
 | 
			
		||||
	p++;
 | 
			
		||||
	for (k = 'a'; k <= 'z'; k++)
 | 
			
		||||
	{
 | 
			
		||||
		*p = k;
 | 
			
		||||
		if (access(template, 0) < 0)
 | 
			
		||||
		{
 | 
			
		||||
			return template;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return ("/");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,64 +4,63 @@
 | 
			
		|||
	last edit:	16-Jun-1987	D A Gwyn
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<sys/stat.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
typedef void	*pointer;		/* (void *) if you have it */
 | 
			
		||||
typedef void* pointer; /* (void *) if you have it */
 | 
			
		||||
 | 
			
		||||
extern int _open(const char *path, int flags, int mode);
 | 
			
		||||
extern int _open(const char* path, int flags, int mode);
 | 
			
		||||
extern int _close(int d);
 | 
			
		||||
extern int _fstat(int fd, struct stat *buf);
 | 
			
		||||
extern int _fstat(int fd, struct stat* buf);
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef O_RDONLY
 | 
			
		||||
#define	O_RDONLY	0
 | 
			
		||||
#define O_RDONLY 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef S_ISDIR				/* macro to test for directory file */
 | 
			
		||||
#define	S_ISDIR( mode )		(((mode) & S_IFMT) == S_IFDIR)
 | 
			
		||||
#ifndef S_ISDIR /* macro to test for directory file */
 | 
			
		||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
DIR *
 | 
			
		||||
opendir(const char *dirname)		/* name of directory */
 | 
			
		||||
DIR* opendir(const char* dirname) /* name of directory */
 | 
			
		||||
{
 | 
			
		||||
	register DIR	*dirp;		/* -> malloc'ed storage */
 | 
			
		||||
	register int	fd;		/* file descriptor for read */
 | 
			
		||||
	struct stat	sbuf;		/* result of fstat() */
 | 
			
		||||
	register DIR* dirp; /* -> malloc'ed storage */
 | 
			
		||||
	register int fd; /* file descriptor for read */
 | 
			
		||||
	struct stat sbuf; /* result of fstat() */
 | 
			
		||||
 | 
			
		||||
	if ( (fd = _open( dirname, O_RDONLY, 0 )) < 0 )
 | 
			
		||||
		return NULL;		/* errno set by open() */
 | 
			
		||||
	if ((fd = _open(dirname, O_RDONLY, 0)) < 0)
 | 
			
		||||
		return NULL; /* errno set by open() */
 | 
			
		||||
 | 
			
		||||
	if ( _fstat( fd, &sbuf ) != 0 || !S_ISDIR( sbuf.st_mode ) )
 | 
			
		||||
		{
 | 
			
		||||
		(void)_close( fd );
 | 
			
		||||
	if (_fstat(fd, &sbuf) != 0 || !S_ISDIR(sbuf.st_mode))
 | 
			
		||||
	{
 | 
			
		||||
		(void)_close(fd);
 | 
			
		||||
		errno = ENOTDIR;
 | 
			
		||||
		return NULL;		/* not a directory */
 | 
			
		||||
		}
 | 
			
		||||
		return NULL; /* not a directory */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( (dirp = (DIR *)malloc( sizeof(DIR) )) == NULL
 | 
			
		||||
	  || (dirp->dd_buf = (char *)malloc( (unsigned)DIRBUF )) == NULL
 | 
			
		||||
	   )	{
 | 
			
		||||
		register int	serrno = errno;
 | 
			
		||||
					/* errno set to ENOMEM by sbrk() */
 | 
			
		||||
	if ((dirp = (DIR*)malloc(sizeof(DIR))) == NULL
 | 
			
		||||
	    || (dirp->dd_buf = (char*)malloc((unsigned)DIRBUF)) == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		register int serrno = errno;
 | 
			
		||||
		/* errno set to ENOMEM by sbrk() */
 | 
			
		||||
 | 
			
		||||
		if ( dirp != NULL )
 | 
			
		||||
			free( (pointer)dirp );
 | 
			
		||||
		if (dirp != NULL)
 | 
			
		||||
			free((pointer)dirp);
 | 
			
		||||
 | 
			
		||||
		(void)_close( fd );
 | 
			
		||||
		(void)_close(fd);
 | 
			
		||||
		errno = serrno;
 | 
			
		||||
		return NULL;		/* not enough memory */
 | 
			
		||||
		}
 | 
			
		||||
		return NULL; /* not enough memory */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dirp->dd_fd = fd;
 | 
			
		||||
	dirp->dd_loc = dirp->dd_size = 0;	/* refill needed */
 | 
			
		||||
	dirp->dd_loc = dirp->dd_size = 0; /* refill needed */
 | 
			
		||||
 | 
			
		||||
	return dirp;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,55 +3,57 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#if	defined(__BSD4_2)
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#if defined(__BSD4_2)
 | 
			
		||||
union wait {
 | 
			
		||||
	int	w_status;
 | 
			
		||||
	int w_status;
 | 
			
		||||
};
 | 
			
		||||
typedef union wait wait_arg;
 | 
			
		||||
#else
 | 
			
		||||
typedef int wait_arg;
 | 
			
		||||
#endif	/* __BSD4_2 */
 | 
			
		||||
#include	"../stdio/loc_incl.h"
 | 
			
		||||
#endif /* __BSD4_2 */
 | 
			
		||||
#include "../stdio/loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int _close(int d);
 | 
			
		||||
#if defined(__USG)
 | 
			
		||||
static
 | 
			
		||||
#endif
 | 
			
		||||
int _dup2(int oldd, int newd);		/* not present in System 5 */
 | 
			
		||||
int _execl(const char *name, ... );
 | 
			
		||||
    int
 | 
			
		||||
    _dup2(int oldd, int newd); /* not present in System 5 */
 | 
			
		||||
int _execl(const char* name, ...);
 | 
			
		||||
int _fork(void);
 | 
			
		||||
int _pipe(int fildes[2]);
 | 
			
		||||
int _wait(wait_arg *status);
 | 
			
		||||
int _wait(wait_arg* status);
 | 
			
		||||
void _exit(int status);
 | 
			
		||||
 | 
			
		||||
static int pids[FOPEN_MAX];
 | 
			
		||||
 | 
			
		||||
FILE *
 | 
			
		||||
popen(const char *command, const char *type)
 | 
			
		||||
FILE* popen(const char* command, const char* type)
 | 
			
		||||
{
 | 
			
		||||
	int piped[2];
 | 
			
		||||
	int Xtype = *type == 'r' ? 0 : *type == 'w' ? 1 : 2;
 | 
			
		||||
	int pid;
 | 
			
		||||
 | 
			
		||||
	if (Xtype == 2 ||
 | 
			
		||||
	    _pipe(piped) < 0 ||
 | 
			
		||||
	    (pid = _fork()) < 0) return 0;
 | 
			
		||||
	
 | 
			
		||||
	if (pid == 0) {
 | 
			
		||||
		/* child */
 | 
			
		||||
		register int *p;
 | 
			
		||||
	if (Xtype == 2 || _pipe(piped) < 0 || (pid = _fork()) < 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
		for (p = pids; p < &pids[ FOPEN_MAX]; p++) {
 | 
			
		||||
			if (*p) _close(p - pids);
 | 
			
		||||
	if (pid == 0)
 | 
			
		||||
	{
 | 
			
		||||
		/* child */
 | 
			
		||||
		register int* p;
 | 
			
		||||
 | 
			
		||||
		for (p = pids; p < &pids[FOPEN_MAX]; p++)
 | 
			
		||||
		{
 | 
			
		||||
			if (*p)
 | 
			
		||||
				_close(p - pids);
 | 
			
		||||
		}
 | 
			
		||||
		_close(piped[Xtype]);
 | 
			
		||||
		_dup2(piped[!Xtype], !Xtype);
 | 
			
		||||
		_close(piped[!Xtype]);
 | 
			
		||||
		_execl("/bin/sh", "sh", "-c", command, (char *) 0);
 | 
			
		||||
		_exit(127);	/* like system() ??? */
 | 
			
		||||
		_execl("/bin/sh", "sh", "-c", command, (char*)0);
 | 
			
		||||
		_exit(127); /* like system() ??? */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pids[piped[Xtype]] = pid;
 | 
			
		||||
| 
						 | 
				
			
			@ -59,14 +61,13 @@ popen(const char *command, const char *type)
 | 
			
		|||
	return fdopen(piped[Xtype], type);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if	defined(__BSD4_2)
 | 
			
		||||
#define	ret_val	status.w_status
 | 
			
		||||
#if defined(__BSD4_2)
 | 
			
		||||
#define ret_val status.w_status
 | 
			
		||||
#else
 | 
			
		||||
#define	ret_val	status
 | 
			
		||||
#define ret_val status
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
pclose(FILE *stream)
 | 
			
		||||
int pclose(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	int fd = fileno(stream);
 | 
			
		||||
	wait_arg status;
 | 
			
		||||
| 
						 | 
				
			
			@ -75,17 +76,20 @@ pclose(FILE *stream)
 | 
			
		|||
	void (*quitsave)(int) = signal(SIGQUIT, SIG_IGN);
 | 
			
		||||
 | 
			
		||||
	fclose(stream);
 | 
			
		||||
	while ((wret = _wait(&status)) != -1) {
 | 
			
		||||
		if (wret == pids[fd]) break;
 | 
			
		||||
	while ((wret = _wait(&status)) != -1)
 | 
			
		||||
	{
 | 
			
		||||
		if (wret == pids[fd])
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	if (wret == -1) ret_val = -1;
 | 
			
		||||
	if (wret == -1)
 | 
			
		||||
		ret_val = -1;
 | 
			
		||||
	signal(SIGINT, intsave);
 | 
			
		||||
	signal(SIGQUIT, quitsave);
 | 
			
		||||
	pids[fd] = 0;
 | 
			
		||||
	return ret_val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if	defined(__USG)
 | 
			
		||||
#if defined(__USG)
 | 
			
		||||
int _dup(int fildes);
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
| 
						 | 
				
			
			@ -95,16 +99,21 @@ _dup2(int oldd, int newd)
 | 
			
		|||
	int fdbuf[FOPEN_MAX];
 | 
			
		||||
 | 
			
		||||
	/* ignore the error on the close() */
 | 
			
		||||
	tmp = errno; (void) _close(newd); errno = tmp;
 | 
			
		||||
	while ((fd = _dup(oldd)) != newd) {
 | 
			
		||||
		if (fd == -1) break;
 | 
			
		||||
	tmp = errno;
 | 
			
		||||
	(void)_close(newd);
 | 
			
		||||
	errno = tmp;
 | 
			
		||||
	while ((fd = _dup(oldd)) != newd)
 | 
			
		||||
	{
 | 
			
		||||
		if (fd == -1)
 | 
			
		||||
			break;
 | 
			
		||||
		fdbuf[i++] = fd;
 | 
			
		||||
	}
 | 
			
		||||
	tmp = errno;
 | 
			
		||||
	while (--i >= 0) {
 | 
			
		||||
	while (--i >= 0)
 | 
			
		||||
	{
 | 
			
		||||
		_close(fdbuf[i]);
 | 
			
		||||
	}
 | 
			
		||||
	errno = tmp;
 | 
			
		||||
	return -(fd == -1);
 | 
			
		||||
}
 | 
			
		||||
#endif	/* __USG */
 | 
			
		||||
#endif /* __USG */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,17 +3,18 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
putw(int w, register FILE *stream)
 | 
			
		||||
int putw(int w, register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register int cnt = sizeof(int);
 | 
			
		||||
	register char *p = (char *) &w;
 | 
			
		||||
	register char* p = (char*)&w;
 | 
			
		||||
 | 
			
		||||
	while (cnt--) {
 | 
			
		||||
	while (cnt--)
 | 
			
		||||
	{
 | 
			
		||||
		putc(*p++, stream);
 | 
			
		||||
	}
 | 
			
		||||
	if (ferror(stream)) return EOF;
 | 
			
		||||
	if (ferror(stream))
 | 
			
		||||
		return EOF;
 | 
			
		||||
	return w;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,44 +4,41 @@
 | 
			
		|||
	last edit:	25-Apr-1987	D A Gwyn
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
/* SVR3 system call, or emulation for getdents() */
 | 
			
		||||
extern int getdents(int fildes, char *buf, unsigned nbyte);
 | 
			
		||||
extern int getdents(int fildes, char* buf, unsigned nbyte);
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct dirent *
 | 
			
		||||
readdir(register DIR *dirp)
 | 
			
		||||
struct dirent*
 | 
			
		||||
readdir(register DIR* dirp)
 | 
			
		||||
{
 | 
			
		||||
	register struct dirent	*dp;	/* -> directory data */
 | 
			
		||||
	register struct dirent* dp; /* -> directory data */
 | 
			
		||||
 | 
			
		||||
	if ( dirp == NULL || dirp->dd_buf == NULL )
 | 
			
		||||
		{
 | 
			
		||||
	if (dirp == NULL || dirp->dd_buf == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT;
 | 
			
		||||
		return NULL;		/* invalid pointer */
 | 
			
		||||
		}
 | 
			
		||||
		return NULL; /* invalid pointer */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	do	{
 | 
			
		||||
		if ( dirp->dd_loc >= dirp->dd_size )	/* empty or obsolete */
 | 
			
		||||
	do
 | 
			
		||||
	{
 | 
			
		||||
		if (dirp->dd_loc >= dirp->dd_size) /* empty or obsolete */
 | 
			
		||||
			dirp->dd_loc = dirp->dd_size = 0;
 | 
			
		||||
 | 
			
		||||
		if ( dirp->dd_size == 0	/* need to refill buffer */
 | 
			
		||||
		  && (dirp->dd_size =
 | 
			
		||||
			getdents( dirp->dd_fd, dirp->dd_buf, (unsigned)DIRBUF )
 | 
			
		||||
		     ) <= 0
 | 
			
		||||
		   )
 | 
			
		||||
			return NULL;	/* EOF or error */
 | 
			
		||||
		if (dirp->dd_size == 0 /* need to refill buffer */
 | 
			
		||||
		    && (dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, (unsigned)DIRBUF)) <= 0)
 | 
			
		||||
			return NULL; /* EOF or error */
 | 
			
		||||
 | 
			
		||||
		dp = (struct dirent *)&dirp->dd_buf[dirp->dd_loc];
 | 
			
		||||
		dp = (struct dirent*)&dirp->dd_buf[dirp->dd_loc];
 | 
			
		||||
		dirp->dd_loc += dp->d_reclen;
 | 
			
		||||
		}
 | 
			
		||||
	while ( dp->d_ino == 0L );	/* don't rely on getdents() */
 | 
			
		||||
	} while (dp->d_ino == 0L); /* don't rely on getdents() */
 | 
			
		||||
 | 
			
		||||
	return dp;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,30 +8,29 @@
 | 
			
		|||
	rewinddir() to forget about buffered data.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
extern off_t	_lseek(int d, int offset, int whence);
 | 
			
		||||
extern off_t _lseek(int d, int offset, int whence);
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef SEEK_SET
 | 
			
		||||
#define	SEEK_SET	0
 | 
			
		||||
#define SEEK_SET 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
rewinddir(register DIR *dirp)
 | 
			
		||||
void rewinddir(register DIR* dirp)
 | 
			
		||||
{
 | 
			
		||||
	if ( dirp == NULL || dirp->dd_buf == NULL )
 | 
			
		||||
		{
 | 
			
		||||
	if (dirp == NULL || dirp->dd_buf == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT;
 | 
			
		||||
		return;			/* invalid pointer */
 | 
			
		||||
		}
 | 
			
		||||
		return; /* invalid pointer */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dirp->dd_loc = dirp->dd_size = 0;	/* invalidate buffer */
 | 
			
		||||
	(void)_lseek( dirp->dd_fd, (off_t)0, SEEK_SET );	/* may set errno */
 | 
			
		||||
	dirp->dd_loc = dirp->dd_size = 0; /* invalidate buffer */
 | 
			
		||||
	(void)_lseek(dirp->dd_fd, (off_t)0, SEEK_SET); /* may set errno */
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,36 +10,35 @@
 | 
			
		|||
		practically impossible to do right.  Avoid using them!
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
extern off_t _lseek(int d, int offset, int whence);
 | 
			
		||||
 | 
			
		||||
#ifndef NULL
 | 
			
		||||
#define	NULL	0
 | 
			
		||||
#define NULL 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef SEEK_SET
 | 
			
		||||
#define	SEEK_SET	0
 | 
			
		||||
#define SEEK_SET 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef int	bool;			/* Boolean data type */
 | 
			
		||||
#define	false	0
 | 
			
		||||
#define	true	1
 | 
			
		||||
typedef int bool; /* Boolean data type */
 | 
			
		||||
#define false 0
 | 
			
		||||
#define true 1
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
seekdir(register DIR *dirp, register off_t loc)
 | 
			
		||||
void seekdir(register DIR* dirp, register off_t loc)
 | 
			
		||||
/* loc == position from telldir() */
 | 
			
		||||
{
 | 
			
		||||
	register bool	rewind;		/* "start over when stymied" flag */
 | 
			
		||||
	register bool rewind; /* "start over when stymied" flag */
 | 
			
		||||
 | 
			
		||||
	if ( dirp == NULL || dirp->dd_buf == NULL )
 | 
			
		||||
		{
 | 
			
		||||
	if (dirp == NULL || dirp->dd_buf == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT;
 | 
			
		||||
		return;			/* invalid pointer */
 | 
			
		||||
		}
 | 
			
		||||
		return; /* invalid pointer */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* A (struct dirent)'s d_off is an invented quantity on 4.nBSD
 | 
			
		||||
	   NFS-supporting systems, so it is not safe to lseek() to it. */
 | 
			
		||||
| 
						 | 
				
			
			@ -52,58 +51,57 @@ seekdir(register DIR *dirp, register off_t loc)
 | 
			
		|||
	   or even to use binary search on the directory blocks.  I
 | 
			
		||||
	   doubt that the extra code for that would be worthwhile. */
 | 
			
		||||
 | 
			
		||||
	if ( dirp->dd_loc >= dirp->dd_size	/* invalid index */
 | 
			
		||||
	  || ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off > loc
 | 
			
		||||
					/* too far along in buffer */
 | 
			
		||||
	   )
 | 
			
		||||
		dirp->dd_loc = 0;	/* reset to beginning of buffer */
 | 
			
		||||
	if (dirp->dd_loc >= dirp->dd_size /* invalid index */
 | 
			
		||||
	    || ((struct dirent*)&dirp->dd_buf[dirp->dd_loc])->d_off > loc
 | 
			
		||||
	    /* too far along in buffer */
 | 
			
		||||
	    )
 | 
			
		||||
		dirp->dd_loc = 0; /* reset to beginning of buffer */
 | 
			
		||||
	/* else save time by starting at current dirp->dd_loc */
 | 
			
		||||
 | 
			
		||||
	for ( rewind = true; ; )
 | 
			
		||||
		{
 | 
			
		||||
		register struct dirent	*dp;
 | 
			
		||||
	for (rewind = true;;)
 | 
			
		||||
	{
 | 
			
		||||
		register struct dirent* dp;
 | 
			
		||||
 | 
			
		||||
		/* See whether the matching entry is in the current buffer. */
 | 
			
		||||
 | 
			
		||||
		if ( (dirp->dd_loc < dirp->dd_size	/* valid index */
 | 
			
		||||
		   || readdir( dirp ) != NULL	/* next buffer read */
 | 
			
		||||
		   && (dirp->dd_loc = 0, true)	/* beginning of buffer set */
 | 
			
		||||
		     )
 | 
			
		||||
		  && (dp = (struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off
 | 
			
		||||
			<= loc		/* match possible in this buffer */
 | 
			
		||||
		   )	{
 | 
			
		||||
			for ( /* dp initialized above */ ;
 | 
			
		||||
			      (char *)dp < &dirp->dd_buf[dirp->dd_size];
 | 
			
		||||
			      dp = (struct dirent *)((char *)dp + dp->d_reclen)
 | 
			
		||||
			    )
 | 
			
		||||
				if ( dp->d_off == loc )
 | 
			
		||||
					{	/* found it! */
 | 
			
		||||
					dirp->dd_loc =
 | 
			
		||||
						(char *)dp - dirp->dd_buf;
 | 
			
		||||
		if ((dirp->dd_loc < dirp->dd_size /* valid index */
 | 
			
		||||
		        || readdir(dirp) != NULL /* next buffer read */
 | 
			
		||||
		            && (dirp->dd_loc = 0, true) /* beginning of buffer set */
 | 
			
		||||
		        )
 | 
			
		||||
		    && (dp = (struct dirent*)&dirp->dd_buf[dirp->dd_loc])->d_off
 | 
			
		||||
		        <= loc /* match possible in this buffer */
 | 
			
		||||
		    )
 | 
			
		||||
		{
 | 
			
		||||
			for (/* dp initialized above */;
 | 
			
		||||
			     (char*)dp < &dirp->dd_buf[dirp->dd_size];
 | 
			
		||||
			     dp = (struct dirent*)((char*)dp + dp->d_reclen))
 | 
			
		||||
				if (dp->d_off == loc)
 | 
			
		||||
				{ /* found it! */
 | 
			
		||||
					dirp->dd_loc = (char*)dp - dirp->dd_buf;
 | 
			
		||||
					return;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
			rewind = false;	/* no point in backing up later */
 | 
			
		||||
			dirp->dd_loc = dirp->dd_size;	/* set end of buffer */
 | 
			
		||||
			}
 | 
			
		||||
		else			/* whole buffer past matching entry */
 | 
			
		||||
			if ( !rewind )
 | 
			
		||||
				{	/* no point in searching further */
 | 
			
		||||
				errno = EINVAL;
 | 
			
		||||
				return;	/* no entry at specified loc */
 | 
			
		||||
				}
 | 
			
		||||
			else	{	/* rewind directory and start over */
 | 
			
		||||
				rewind = false;	/* but only once! */
 | 
			
		||||
 | 
			
		||||
				dirp->dd_loc = dirp->dd_size = 0;
 | 
			
		||||
 | 
			
		||||
				if ( _lseek( dirp->dd_fd, (off_t)0, SEEK_SET )
 | 
			
		||||
					!= 0
 | 
			
		||||
				   )
 | 
			
		||||
					return;	/* errno already set (EBADF) */
 | 
			
		||||
 | 
			
		||||
				if ( loc == 0 )
 | 
			
		||||
					return; /* save time */
 | 
			
		||||
				}
 | 
			
		||||
			rewind = false; /* no point in backing up later */
 | 
			
		||||
			dirp->dd_loc = dirp->dd_size; /* set end of buffer */
 | 
			
		||||
		}
 | 
			
		||||
		else /* whole buffer past matching entry */
 | 
			
		||||
		    if (!rewind)
 | 
			
		||||
		{ /* no point in searching further */
 | 
			
		||||
			errno = EINVAL;
 | 
			
		||||
			return; /* no entry at specified loc */
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{ /* rewind directory and start over */
 | 
			
		||||
			rewind = false; /* but only once! */
 | 
			
		||||
 | 
			
		||||
			dirp->dd_loc = dirp->dd_size = 0;
 | 
			
		||||
 | 
			
		||||
			if (_lseek(dirp->dd_fd, (off_t)0, SEEK_SET)
 | 
			
		||||
			    != 0)
 | 
			
		||||
				return; /* errno already set (EBADF) */
 | 
			
		||||
 | 
			
		||||
			if (loc == 0)
 | 
			
		||||
				return; /* save time */
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,44 +3,48 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#include	<setjmp.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <setjmp.h>
 | 
			
		||||
 | 
			
		||||
int _alarm(int n);
 | 
			
		||||
void _pause(void);
 | 
			
		||||
 | 
			
		||||
static jmp_buf	setjmpbuf;
 | 
			
		||||
static jmp_buf setjmpbuf;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
alfun(int sig)
 | 
			
		||||
{
 | 
			
		||||
	longjmp(setjmpbuf, 1);
 | 
			
		||||
}		/* used with sleep() below */
 | 
			
		||||
} /* used with sleep() below */
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
sleep(int n)
 | 
			
		||||
void sleep(int n)
 | 
			
		||||
{
 | 
			
		||||
/* sleep(n) pauses for 'n' seconds by scheduling an alarm interrupt. */
 | 
			
		||||
	/* sleep(n) pauses for 'n' seconds by scheduling an alarm interrupt. */
 | 
			
		||||
	unsigned oldalarm = 0;
 | 
			
		||||
	void (*oldsig)(int) = 0;
 | 
			
		||||
 | 
			
		||||
	if (n <= 0) return;
 | 
			
		||||
	if (setjmp(setjmpbuf)) {
 | 
			
		||||
	if (n <= 0)
 | 
			
		||||
		return;
 | 
			
		||||
	if (setjmp(setjmpbuf))
 | 
			
		||||
	{
 | 
			
		||||
		signal(SIGALRM, oldsig);
 | 
			
		||||
		_alarm(oldalarm);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	oldalarm = _alarm(5000);	/* Who cares how long, as long
 | 
			
		||||
	oldalarm = _alarm(5000); /* Who cares how long, as long
 | 
			
		||||
					 * as it is long enough
 | 
			
		||||
					 */
 | 
			
		||||
	if (oldalarm > n) oldalarm -= n;
 | 
			
		||||
	else if (oldalarm) {
 | 
			
		||||
	if (oldalarm > n)
 | 
			
		||||
		oldalarm -= n;
 | 
			
		||||
	else if (oldalarm)
 | 
			
		||||
	{
 | 
			
		||||
		n = oldalarm;
 | 
			
		||||
		oldalarm = 1;
 | 
			
		||||
	}
 | 
			
		||||
	oldsig = signal(SIGALRM, alfun);
 | 
			
		||||
	_alarm(n);
 | 
			
		||||
	for (;;)  {
 | 
			
		||||
	for (;;)
 | 
			
		||||
	{
 | 
			
		||||
		/* allow for other handlers ... */
 | 
			
		||||
		_pause();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,28 +7,27 @@
 | 
			
		|||
		practically impossible to do right.  Avoid using them!
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<sys/errno.h>
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<dirent.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <dirent.h>
 | 
			
		||||
 | 
			
		||||
extern off_t _lseek(int d, int offset, int whence);
 | 
			
		||||
 | 
			
		||||
#ifndef SEEK_CUR
 | 
			
		||||
#define	SEEK_CUR	1
 | 
			
		||||
#define SEEK_CUR 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
off_t
 | 
			
		||||
telldir(register DIR *dirp)		/* return offset of next entry */
 | 
			
		||||
off_t telldir(register DIR* dirp) /* return offset of next entry */
 | 
			
		||||
{
 | 
			
		||||
	if ( dirp == NULL || dirp->dd_buf == NULL )
 | 
			
		||||
		{
 | 
			
		||||
	if (dirp == NULL || dirp->dd_buf == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		errno = EFAULT;
 | 
			
		||||
		return -1;		/* invalid pointer */
 | 
			
		||||
		}
 | 
			
		||||
		return -1; /* invalid pointer */
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ( dirp->dd_loc < dirp->dd_size )	/* valid index */
 | 
			
		||||
		return ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off;
 | 
			
		||||
	else				/* beginning of next directory block */
 | 
			
		||||
		return _lseek( dirp->dd_fd, (off_t)0, SEEK_CUR );
 | 
			
		||||
	if (dirp->dd_loc < dirp->dd_size) /* valid index */
 | 
			
		||||
		return ((struct dirent*)&dirp->dd_buf[dirp->dd_loc])->d_off;
 | 
			
		||||
	else /* beginning of next directory block */
 | 
			
		||||
		return _lseek(dirp->dd_fd, (off_t)0, SEEK_CUR);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,37 +3,38 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#if	defined(_POSIX_SOURCE)
 | 
			
		||||
#if defined(_POSIX_SOURCE)
 | 
			
		||||
 | 
			
		||||
/* This can't be done in setjmp.e, since SIG_SETMASK is defined in
 | 
			
		||||
 * <signal.h>. This is a C-file, which can't be included.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#include	<stddef.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
int _sigprocmask(int, sigset_t *, sigset_t *);
 | 
			
		||||
int _sigprocmask(int, sigset_t*, sigset_t*);
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
__testsigset(void) {
 | 
			
		||||
__testsigset(void)
 | 
			
		||||
{
 | 
			
		||||
	/* This switch compiles when a sigset_t has the right size. */
 | 
			
		||||
	switch(0) {
 | 
			
		||||
	case 0: 
 | 
			
		||||
	case sizeof(sigset_t) <= sizeof(long): break;
 | 
			
		||||
	switch (0)
 | 
			
		||||
	{
 | 
			
		||||
		case 0:
 | 
			
		||||
		case sizeof(sigset_t) <= sizeof(long):
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
__newsigset(sigset_t *p)
 | 
			
		||||
void __newsigset(sigset_t* p)
 | 
			
		||||
{
 | 
			
		||||
	/* The SIG_SETMASK is not significant */
 | 
			
		||||
	_sigprocmask(SIG_SETMASK, NULL, p);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
__oldsigset(sigset_t *p)
 | 
			
		||||
void __oldsigset(sigset_t* p)
 | 
			
		||||
{
 | 
			
		||||
	_sigprocmask(SIG_SETMASK, p, NULL);
 | 
			
		||||
}
 | 
			
		||||
#endif	/* _POSIX_SOURCE */
 | 
			
		||||
#endif /* _POSIX_SOURCE */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,13 +4,12 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#if	defined(_POSIX_SOURCE)
 | 
			
		||||
#if defined(_POSIX_SOURCE)
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
raise(int sig)
 | 
			
		||||
int raise(int sig)
 | 
			
		||||
{
 | 
			
		||||
	if (sig < 0 || sig > _NSIG)
 | 
			
		||||
		return -1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
(clearerr)(FILE *stream)
 | 
			
		||||
void(clearerr)(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	clearerr(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,24 +3,24 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
struct __iobuf __stdin = {
 | 
			
		||||
	0, 0, _IOREAD, 0,
 | 
			
		||||
	(unsigned char *)NULL, (unsigned char *)NULL, 
 | 
			
		||||
	(unsigned char*)NULL, (unsigned char*)NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct __iobuf __stdout = {
 | 
			
		||||
	0, 1, _IOWRITE, 0,
 | 
			
		||||
	(unsigned char *)NULL, (unsigned char *)NULL, 
 | 
			
		||||
	(unsigned char*)NULL, (unsigned char*)NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct __iobuf __stderr = {
 | 
			
		||||
	0, 2, _IOWRITE | _IOLBF, 0,
 | 
			
		||||
	(unsigned char *)NULL, (unsigned char *)NULL, 
 | 
			
		||||
	(unsigned char*)NULL, (unsigned char*)NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
FILE *__iotab[FOPEN_MAX] = {
 | 
			
		||||
FILE* __iotab[FOPEN_MAX] = {
 | 
			
		||||
	&__stdin,
 | 
			
		||||
	&__stdout,
 | 
			
		||||
	&__stderr,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,25 +3,29 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<ctype.h>
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
/* gnum() is used to get the width and precision fields of a format. */
 | 
			
		||||
static const char *
 | 
			
		||||
gnum(register const char *f, int *ip, va_list *app)
 | 
			
		||||
static const char*
 | 
			
		||||
gnum(register const char* f, int* ip, va_list* app)
 | 
			
		||||
{
 | 
			
		||||
	register int	i, c;
 | 
			
		||||
	register int i, c;
 | 
			
		||||
 | 
			
		||||
	if (*f == '*') {
 | 
			
		||||
	if (*f == '*')
 | 
			
		||||
	{
 | 
			
		||||
		*ip = va_arg((*app), int);
 | 
			
		||||
		f++;
 | 
			
		||||
	} else {
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		i = 0;
 | 
			
		||||
		while ((c = *f - '0') >= 0 && c <= 9) {
 | 
			
		||||
			i = i*10 + c;
 | 
			
		||||
		while ((c = *f - '0') >= 0 && c <= 9)
 | 
			
		||||
		{
 | 
			
		||||
			i = i * 10 + c;
 | 
			
		||||
			f++;
 | 
			
		||||
		}
 | 
			
		||||
		*ip = i;
 | 
			
		||||
| 
						 | 
				
			
			@ -29,91 +33,121 @@ gnum(register const char *f, int *ip, va_list *app)
 | 
			
		|||
	return f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if	_EM_WSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags)				/* nothing */
 | 
			
		||||
#elif	_EM_LSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags)	(flags |= FL_LONG)
 | 
			
		||||
#if _EM_WSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags) /* nothing */
 | 
			
		||||
#elif _EM_LSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags) (flags |= FL_LONG)
 | 
			
		||||
#else
 | 
			
		||||
#error garbage pointer size
 | 
			
		||||
#define set_pointer(flags)		/* compilation might continue */
 | 
			
		||||
#define set_pointer(flags) /* compilation might continue */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define PUTC(c) \
 | 
			
		||||
	do { \
 | 
			
		||||
#define PUTC(c)                  \
 | 
			
		||||
	do                           \
 | 
			
		||||
	{                            \
 | 
			
		||||
		int i = putc(c, stream); \
 | 
			
		||||
		if (i == EOF) \
 | 
			
		||||
		{ \
 | 
			
		||||
			if (ferror(stream)) \
 | 
			
		||||
				return -1; \
 | 
			
		||||
		} \
 | 
			
		||||
		if (i == EOF)            \
 | 
			
		||||
		{                        \
 | 
			
		||||
			if (ferror(stream))  \
 | 
			
		||||
				return -1;       \
 | 
			
		||||
		}                        \
 | 
			
		||||
	} while (0)
 | 
			
		||||
 | 
			
		||||
/* print an ordinal number */
 | 
			
		||||
static char *
 | 
			
		||||
o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed)
 | 
			
		||||
static char*
 | 
			
		||||
o_print(va_list* ap, int flags, char* s, char c, int precision, int is_signed)
 | 
			
		||||
{
 | 
			
		||||
	long signed_val;
 | 
			
		||||
	unsigned long unsigned_val;
 | 
			
		||||
	char *old_s = s;
 | 
			
		||||
	char* old_s = s;
 | 
			
		||||
	int base;
 | 
			
		||||
 | 
			
		||||
	switch (flags & (FL_SHORT | FL_LONG)) {
 | 
			
		||||
	case FL_SHORT:
 | 
			
		||||
		if (is_signed) {
 | 
			
		||||
			signed_val = (short) va_arg(*ap, int);
 | 
			
		||||
		} else {
 | 
			
		||||
			unsigned_val = (unsigned short) va_arg(*ap, unsigned);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	case FL_LONG:
 | 
			
		||||
		if (is_signed) {
 | 
			
		||||
			signed_val = va_arg(*ap, long);
 | 
			
		||||
		} else {
 | 
			
		||||
			unsigned_val = va_arg(*ap, unsigned long);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		if (is_signed) {
 | 
			
		||||
			signed_val = va_arg(*ap, int);
 | 
			
		||||
		} else {
 | 
			
		||||
			unsigned_val = va_arg(*ap, unsigned int);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	switch (flags & (FL_SHORT | FL_LONG))
 | 
			
		||||
	{
 | 
			
		||||
		case FL_SHORT:
 | 
			
		||||
			if (is_signed)
 | 
			
		||||
			{
 | 
			
		||||
				signed_val = (short)va_arg(*ap, int);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				unsigned_val = (unsigned short)va_arg(*ap, unsigned);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case FL_LONG:
 | 
			
		||||
			if (is_signed)
 | 
			
		||||
			{
 | 
			
		||||
				signed_val = va_arg(*ap, long);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				unsigned_val = va_arg(*ap, unsigned long);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			if (is_signed)
 | 
			
		||||
			{
 | 
			
		||||
				signed_val = va_arg(*ap, int);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				unsigned_val = va_arg(*ap, unsigned int);
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (is_signed) {
 | 
			
		||||
		if (signed_val < 0) {
 | 
			
		||||
	if (is_signed)
 | 
			
		||||
	{
 | 
			
		||||
		if (signed_val < 0)
 | 
			
		||||
		{
 | 
			
		||||
			*s++ = '-';
 | 
			
		||||
			signed_val = -signed_val;
 | 
			
		||||
		} else if (flags & FL_SIGN) *s++ = '+';
 | 
			
		||||
		else if (flags & FL_SPACE) *s++ = ' ';
 | 
			
		||||
		}
 | 
			
		||||
		else if (flags & FL_SIGN)
 | 
			
		||||
			*s++ = '+';
 | 
			
		||||
		else if (flags & FL_SPACE)
 | 
			
		||||
			*s++ = ' ';
 | 
			
		||||
		unsigned_val = signed_val;
 | 
			
		||||
	}
 | 
			
		||||
	if ((flags & FL_ALT) && (c == 'o')) *s++ = '0';
 | 
			
		||||
	if (!unsigned_val) {
 | 
			
		||||
		 if (!precision)
 | 
			
		||||
	if ((flags & FL_ALT) && (c == 'o'))
 | 
			
		||||
		*s++ = '0';
 | 
			
		||||
	if (!unsigned_val)
 | 
			
		||||
	{
 | 
			
		||||
		if (!precision)
 | 
			
		||||
			return s;
 | 
			
		||||
	} else if (((flags & FL_ALT) && (c == 'x' || c == 'X'))
 | 
			
		||||
		    || c == 'p') {
 | 
			
		||||
	}
 | 
			
		||||
	else if (((flags & FL_ALT) && (c == 'x' || c == 'X'))
 | 
			
		||||
	    || c == 'p')
 | 
			
		||||
	{
 | 
			
		||||
		*s++ = '0';
 | 
			
		||||
		*s++ = (c == 'X' ? 'X' : 'x');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch (c) {
 | 
			
		||||
	case 'b':	base = 2;	break;
 | 
			
		||||
	case 'o':	base = 8;	break;
 | 
			
		||||
	case 'd':
 | 
			
		||||
	case 'i':
 | 
			
		||||
	case 'u':	base = 10;	break;
 | 
			
		||||
	case 'x':
 | 
			
		||||
	case 'X':
 | 
			
		||||
	case 'p':	base = 16;	break;
 | 
			
		||||
	switch (c)
 | 
			
		||||
	{
 | 
			
		||||
		case 'b':
 | 
			
		||||
			base = 2;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'o':
 | 
			
		||||
			base = 8;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'd':
 | 
			
		||||
		case 'i':
 | 
			
		||||
		case 'u':
 | 
			
		||||
			base = 10;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'x':
 | 
			
		||||
		case 'X':
 | 
			
		||||
		case 'p':
 | 
			
		||||
			base = 16;
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s = _i_compute(unsigned_val, base, s, precision);
 | 
			
		||||
 | 
			
		||||
	if (c == 'X')
 | 
			
		||||
		while (old_s != s) {
 | 
			
		||||
		while (old_s != s)
 | 
			
		||||
		{
 | 
			
		||||
			*old_s = toupper(*old_s);
 | 
			
		||||
			old_s++;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -121,20 +155,22 @@ o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed)
 | 
			
		|||
	return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
_doprnt(register const char *fmt, va_list ap, FILE *stream)
 | 
			
		||||
int _doprnt(register const char* fmt, va_list ap, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register char	*s;
 | 
			
		||||
	register int	j;
 | 
			
		||||
	int		i, c, width, precision, zfill, flags, between_fill;
 | 
			
		||||
	int		nrchars=0;
 | 
			
		||||
	const char	*oldfmt;
 | 
			
		||||
	char		*s1, buf[1025];
 | 
			
		||||
	register char* s;
 | 
			
		||||
	register int j;
 | 
			
		||||
	int i, c, width, precision, zfill, flags, between_fill;
 | 
			
		||||
	int nrchars = 0;
 | 
			
		||||
	const char* oldfmt;
 | 
			
		||||
	char *s1, buf[1025];
 | 
			
		||||
 | 
			
		||||
	while (c = *fmt++) {
 | 
			
		||||
		if (c != '%') {
 | 
			
		||||
#ifdef	CPM
 | 
			
		||||
			if (c == '\n') {
 | 
			
		||||
	while (c = *fmt++)
 | 
			
		||||
	{
 | 
			
		||||
		if (c != '%')
 | 
			
		||||
		{
 | 
			
		||||
#ifdef CPM
 | 
			
		||||
			if (c == '\n')
 | 
			
		||||
			{
 | 
			
		||||
				PUTC('\r');
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -143,125 +179,164 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream)
 | 
			
		|||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		flags = 0;
 | 
			
		||||
		do {
 | 
			
		||||
			switch(*fmt) {
 | 
			
		||||
			case '-':	flags |= FL_LJUST;	break;
 | 
			
		||||
			case '+':	flags |= FL_SIGN;	break;
 | 
			
		||||
			case ' ':	flags |= FL_SPACE;	break;
 | 
			
		||||
			case '#':	flags |= FL_ALT;	break;
 | 
			
		||||
			case '0':	flags |= FL_ZEROFILL;	break;
 | 
			
		||||
			default:	flags |= FL_NOMORE;	continue;
 | 
			
		||||
		do
 | 
			
		||||
		{
 | 
			
		||||
			switch (*fmt)
 | 
			
		||||
			{
 | 
			
		||||
				case '-':
 | 
			
		||||
					flags |= FL_LJUST;
 | 
			
		||||
					break;
 | 
			
		||||
				case '+':
 | 
			
		||||
					flags |= FL_SIGN;
 | 
			
		||||
					break;
 | 
			
		||||
				case ' ':
 | 
			
		||||
					flags |= FL_SPACE;
 | 
			
		||||
					break;
 | 
			
		||||
				case '#':
 | 
			
		||||
					flags |= FL_ALT;
 | 
			
		||||
					break;
 | 
			
		||||
				case '0':
 | 
			
		||||
					flags |= FL_ZEROFILL;
 | 
			
		||||
					break;
 | 
			
		||||
				default:
 | 
			
		||||
					flags |= FL_NOMORE;
 | 
			
		||||
					continue;
 | 
			
		||||
			}
 | 
			
		||||
			fmt++;
 | 
			
		||||
		} while(!(flags & FL_NOMORE));
 | 
			
		||||
		} while (!(flags & FL_NOMORE));
 | 
			
		||||
 | 
			
		||||
		oldfmt = fmt;
 | 
			
		||||
		fmt = gnum(fmt, &width, &ap);
 | 
			
		||||
		if (fmt != oldfmt) flags |= FL_WIDTHSPEC;
 | 
			
		||||
		if (fmt != oldfmt)
 | 
			
		||||
			flags |= FL_WIDTHSPEC;
 | 
			
		||||
 | 
			
		||||
		if (*fmt == '.') {
 | 
			
		||||
			fmt++; oldfmt = fmt;
 | 
			
		||||
		if (*fmt == '.')
 | 
			
		||||
		{
 | 
			
		||||
			fmt++;
 | 
			
		||||
			oldfmt = fmt;
 | 
			
		||||
			fmt = gnum(fmt, &precision, &ap);
 | 
			
		||||
			if (precision >= 0) flags |= FL_PRECSPEC;
 | 
			
		||||
			if (precision >= 0)
 | 
			
		||||
				flags |= FL_PRECSPEC;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ((flags & FL_WIDTHSPEC) && width < 0) {
 | 
			
		||||
		if ((flags & FL_WIDTHSPEC) && width < 0)
 | 
			
		||||
		{
 | 
			
		||||
			width = -width;
 | 
			
		||||
			flags |= FL_LJUST;
 | 
			
		||||
		}
 | 
			
		||||
		if (!(flags & FL_WIDTHSPEC)) width = 0;
 | 
			
		||||
		if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
			width = 0;
 | 
			
		||||
 | 
			
		||||
		if (flags & FL_SIGN) flags &= ~FL_SPACE;
 | 
			
		||||
 | 
			
		||||
		if (flags & FL_LJUST) flags &= ~FL_ZEROFILL;
 | 
			
		||||
		if (flags & FL_SIGN)
 | 
			
		||||
			flags &= ~FL_SPACE;
 | 
			
		||||
 | 
			
		||||
		if (flags & FL_LJUST)
 | 
			
		||||
			flags &= ~FL_ZEROFILL;
 | 
			
		||||
 | 
			
		||||
		s = s1 = buf;
 | 
			
		||||
 | 
			
		||||
		switch (*fmt) {
 | 
			
		||||
		case 'h':	flags |= FL_SHORT; fmt++; break;
 | 
			
		||||
		case 'l':	flags |= FL_LONG; fmt++; break;
 | 
			
		||||
		case 'L':	flags |= FL_LONGDOUBLE; fmt++; break;
 | 
			
		||||
		switch (*fmt)
 | 
			
		||||
		{
 | 
			
		||||
			case 'h':
 | 
			
		||||
				flags |= FL_SHORT;
 | 
			
		||||
				fmt++;
 | 
			
		||||
				break;
 | 
			
		||||
			case 'l':
 | 
			
		||||
				flags |= FL_LONG;
 | 
			
		||||
				fmt++;
 | 
			
		||||
				break;
 | 
			
		||||
			case 'L':
 | 
			
		||||
				flags |= FL_LONGDOUBLE;
 | 
			
		||||
				fmt++;
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		switch (c = *fmt++) {
 | 
			
		||||
		default:
 | 
			
		||||
#ifdef	CPM
 | 
			
		||||
			if (c == '\n') {
 | 
			
		||||
				PUTC('\r');
 | 
			
		||||
				nrchars++;
 | 
			
		||||
			}
 | 
			
		||||
		switch (c = *fmt++)
 | 
			
		||||
		{
 | 
			
		||||
			default:
 | 
			
		||||
#ifdef CPM
 | 
			
		||||
				if (c == '\n')
 | 
			
		||||
				{
 | 
			
		||||
					PUTC('\r');
 | 
			
		||||
					nrchars++;
 | 
			
		||||
				}
 | 
			
		||||
#endif
 | 
			
		||||
			PUTC(c);
 | 
			
		||||
			nrchars++;
 | 
			
		||||
			continue;
 | 
			
		||||
		case 'n':
 | 
			
		||||
			if (flags & FL_SHORT)
 | 
			
		||||
				*va_arg(ap, short *) = (short) nrchars;
 | 
			
		||||
			else if (flags & FL_LONG)
 | 
			
		||||
				*va_arg(ap, long *) = (long) nrchars;
 | 
			
		||||
			else
 | 
			
		||||
				*va_arg(ap, int *) = (int) nrchars;
 | 
			
		||||
			continue;
 | 
			
		||||
		case 's':
 | 
			
		||||
			s1 = va_arg(ap, char *);
 | 
			
		||||
			if (s1 == NULL)
 | 
			
		||||
				s1 = "(null)";
 | 
			
		||||
			s = s1;
 | 
			
		||||
			while (precision || !(flags & FL_PRECSPEC)) {
 | 
			
		||||
				if (*s == '\0')
 | 
			
		||||
					break;
 | 
			
		||||
				s++;
 | 
			
		||||
				precision--;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 'p':
 | 
			
		||||
			set_pointer(flags);
 | 
			
		||||
				PUTC(c);
 | 
			
		||||
				nrchars++;
 | 
			
		||||
				continue;
 | 
			
		||||
			case 'n':
 | 
			
		||||
				if (flags & FL_SHORT)
 | 
			
		||||
					*va_arg(ap, short*) = (short)nrchars;
 | 
			
		||||
				else if (flags & FL_LONG)
 | 
			
		||||
					*va_arg(ap, long*) = (long)nrchars;
 | 
			
		||||
				else
 | 
			
		||||
					*va_arg(ap, int*) = (int)nrchars;
 | 
			
		||||
				continue;
 | 
			
		||||
			case 's':
 | 
			
		||||
				s1 = va_arg(ap, char*);
 | 
			
		||||
				if (s1 == NULL)
 | 
			
		||||
					s1 = "(null)";
 | 
			
		||||
				s = s1;
 | 
			
		||||
				while (precision || !(flags & FL_PRECSPEC))
 | 
			
		||||
				{
 | 
			
		||||
					if (*s == '\0')
 | 
			
		||||
						break;
 | 
			
		||||
					s++;
 | 
			
		||||
					precision--;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case 'p':
 | 
			
		||||
				set_pointer(flags);
 | 
			
		||||
			/* fallthrough */
 | 
			
		||||
		case 'b':
 | 
			
		||||
		case 'o':
 | 
			
		||||
		case 'u':
 | 
			
		||||
		case 'x':
 | 
			
		||||
		case 'X':
 | 
			
		||||
			if (!(flags & FL_PRECSPEC)) precision = 1;
 | 
			
		||||
			else if (c != 'p') flags &= ~FL_ZEROFILL;
 | 
			
		||||
			s = o_print(&ap, flags, s, c, precision, 0);
 | 
			
		||||
			break;
 | 
			
		||||
		case 'd':
 | 
			
		||||
		case 'i':
 | 
			
		||||
			flags |= FL_SIGNEDCONV;
 | 
			
		||||
			if (!(flags & FL_PRECSPEC)) precision = 1;
 | 
			
		||||
			else flags &= ~FL_ZEROFILL;
 | 
			
		||||
			s = o_print(&ap, flags, s, c, precision, 1);
 | 
			
		||||
			break;
 | 
			
		||||
		case 'c':
 | 
			
		||||
			*s++ = va_arg(ap, int);
 | 
			
		||||
			break;
 | 
			
		||||
			case 'b':
 | 
			
		||||
			case 'o':
 | 
			
		||||
			case 'u':
 | 
			
		||||
			case 'x':
 | 
			
		||||
			case 'X':
 | 
			
		||||
				if (!(flags & FL_PRECSPEC))
 | 
			
		||||
					precision = 1;
 | 
			
		||||
				else if (c != 'p')
 | 
			
		||||
					flags &= ~FL_ZEROFILL;
 | 
			
		||||
				s = o_print(&ap, flags, s, c, precision, 0);
 | 
			
		||||
				break;
 | 
			
		||||
			case 'd':
 | 
			
		||||
			case 'i':
 | 
			
		||||
				flags |= FL_SIGNEDCONV;
 | 
			
		||||
				if (!(flags & FL_PRECSPEC))
 | 
			
		||||
					precision = 1;
 | 
			
		||||
				else
 | 
			
		||||
					flags &= ~FL_ZEROFILL;
 | 
			
		||||
				s = o_print(&ap, flags, s, c, precision, 1);
 | 
			
		||||
				break;
 | 
			
		||||
			case 'c':
 | 
			
		||||
				*s++ = va_arg(ap, int);
 | 
			
		||||
				break;
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
		case 'G':
 | 
			
		||||
		case 'g':
 | 
			
		||||
			if ((flags & FL_PRECSPEC) && (precision == 0))
 | 
			
		||||
				precision = 1;
 | 
			
		||||
		case 'f':
 | 
			
		||||
		case 'E':
 | 
			
		||||
		case 'e':
 | 
			
		||||
			if (!(flags & FL_PRECSPEC)) 
 | 
			
		||||
				precision = 6;
 | 
			
		||||
			case 'G':
 | 
			
		||||
			case 'g':
 | 
			
		||||
				if ((flags & FL_PRECSPEC) && (precision == 0))
 | 
			
		||||
					precision = 1;
 | 
			
		||||
			case 'f':
 | 
			
		||||
			case 'E':
 | 
			
		||||
			case 'e':
 | 
			
		||||
				if (!(flags & FL_PRECSPEC))
 | 
			
		||||
					precision = 6;
 | 
			
		||||
 | 
			
		||||
			if (precision >= sizeof(buf))
 | 
			
		||||
				precision = sizeof(buf) - 1;
 | 
			
		||||
				if (precision >= sizeof(buf))
 | 
			
		||||
					precision = sizeof(buf) - 1;
 | 
			
		||||
 | 
			
		||||
			flags |= FL_SIGNEDCONV;
 | 
			
		||||
			s = _f_print(&ap, flags, s, c, precision);
 | 
			
		||||
			break;
 | 
			
		||||
#endif	/* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
		case 'r':
 | 
			
		||||
			ap = va_arg(ap, va_list);
 | 
			
		||||
			fmt = va_arg(ap, char *);
 | 
			
		||||
			continue;
 | 
			
		||||
				flags |= FL_SIGNEDCONV;
 | 
			
		||||
				s = _f_print(&ap, flags, s, c, precision);
 | 
			
		||||
				break;
 | 
			
		||||
#endif /* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
			case 'r':
 | 
			
		||||
				ap = va_arg(ap, va_list);
 | 
			
		||||
				fmt = va_arg(ap, char*);
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		zfill = ' ';
 | 
			
		||||
		if (flags & FL_ZEROFILL) zfill = '0';
 | 
			
		||||
		if (flags & FL_ZEROFILL)
 | 
			
		||||
			zfill = '0';
 | 
			
		||||
		j = s - s1;
 | 
			
		||||
 | 
			
		||||
		/* between_fill is true under the following conditions:
 | 
			
		||||
| 
						 | 
				
			
			@ -274,35 +349,45 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream)
 | 
			
		|||
		between_fill = 0;
 | 
			
		||||
		if ((flags & FL_ZEROFILL)
 | 
			
		||||
		    && (((c == 'x' || c == 'X') && (flags & FL_ALT))
 | 
			
		||||
			|| (c == 'p')
 | 
			
		||||
			|| ((flags & FL_SIGNEDCONV)
 | 
			
		||||
			    && ( *s1 == '+' || *s1 == '-' || *s1 == ' '))))
 | 
			
		||||
		           || (c == 'p')
 | 
			
		||||
		           || ((flags & FL_SIGNEDCONV)
 | 
			
		||||
		                  && (*s1 == '+' || *s1 == '-' || *s1 == ' '))))
 | 
			
		||||
			between_fill++;
 | 
			
		||||
 | 
			
		||||
		if ((i = width - j) > 0)
 | 
			
		||||
			if (!(flags & FL_LJUST)) {	/* right justify */
 | 
			
		||||
			if (!(flags & FL_LJUST))
 | 
			
		||||
			{ /* right justify */
 | 
			
		||||
				nrchars += i;
 | 
			
		||||
				if (between_fill) {
 | 
			
		||||
				    if (flags & FL_SIGNEDCONV) {
 | 
			
		||||
					j--; nrchars++;
 | 
			
		||||
					PUTC(*s1++);
 | 
			
		||||
				    } else {
 | 
			
		||||
					j -= 2; nrchars += 2;
 | 
			
		||||
					PUTC(*s1++);
 | 
			
		||||
					PUTC(*s1++);
 | 
			
		||||
				if (between_fill)
 | 
			
		||||
				{
 | 
			
		||||
					if (flags & FL_SIGNEDCONV)
 | 
			
		||||
					{
 | 
			
		||||
						j--;
 | 
			
		||||
						nrchars++;
 | 
			
		||||
						PUTC(*s1++);
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						j -= 2;
 | 
			
		||||
						nrchars += 2;
 | 
			
		||||
						PUTC(*s1++);
 | 
			
		||||
						PUTC(*s1++);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				do {
 | 
			
		||||
				do
 | 
			
		||||
				{
 | 
			
		||||
					PUTC(zfill);
 | 
			
		||||
				} while (--i);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		nrchars += j;
 | 
			
		||||
		while (--j >= 0) {
 | 
			
		||||
		while (--j >= 0)
 | 
			
		||||
		{
 | 
			
		||||
			PUTC(*s1++);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (i > 0) nrchars += i;
 | 
			
		||||
		if (i > 0)
 | 
			
		||||
			nrchars += i;
 | 
			
		||||
		while (--i >= 0)
 | 
			
		||||
			PUTC(zfill);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,26 +3,26 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	<ctype.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
#if	_EM_WSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags)				/* nothing */
 | 
			
		||||
#elif	_EM_LSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags)	(flags |= FL_LONG)
 | 
			
		||||
#if _EM_WSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags) /* nothing */
 | 
			
		||||
#elif _EM_LSIZE == _EM_PSIZE
 | 
			
		||||
#define set_pointer(flags) (flags |= FL_LONG)
 | 
			
		||||
#else
 | 
			
		||||
#error garbage pointer size
 | 
			
		||||
#define set_pointer(flags)		/* compilation might continue */
 | 
			
		||||
#define set_pointer(flags) /* compilation might continue */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define	NUMLEN	512
 | 
			
		||||
#define	NR_CHARS	256
 | 
			
		||||
#define NUMLEN 512
 | 
			
		||||
#define NR_CHARS 256
 | 
			
		||||
 | 
			
		||||
static char	Xtable[NR_CHARS];
 | 
			
		||||
static char	inp_buf[NUMLEN];
 | 
			
		||||
static char Xtable[NR_CHARS];
 | 
			
		||||
static char inp_buf[NUMLEN];
 | 
			
		||||
 | 
			
		||||
/* Collect a number of characters which constitite an ordinal number.
 | 
			
		||||
 * When the type is 'i', the base can be 8, 10, or 16, depending on the
 | 
			
		||||
| 
						 | 
				
			
			@ -30,65 +30,85 @@ static char	inp_buf[NUMLEN];
 | 
			
		|||
 * according to the format of the number. At the end of the function, base
 | 
			
		||||
 * is then set to 0, so strtol() will get the right argument.
 | 
			
		||||
 */
 | 
			
		||||
static char *
 | 
			
		||||
o_collect(register int c, register FILE *stream, char type,
 | 
			
		||||
			int width, int *basep)
 | 
			
		||||
static char*
 | 
			
		||||
o_collect(register int c, register FILE* stream, char type,
 | 
			
		||||
    int width, int* basep)
 | 
			
		||||
{
 | 
			
		||||
	register char *bufp = inp_buf;
 | 
			
		||||
	register char* bufp = inp_buf;
 | 
			
		||||
	register int base;
 | 
			
		||||
 | 
			
		||||
	switch (type) {
 | 
			
		||||
	case 'i':	/* i means octal, decimal or hexadecimal */
 | 
			
		||||
	case 'p':
 | 
			
		||||
	case 'x':
 | 
			
		||||
	case 'X':	base = 16;	break;
 | 
			
		||||
	case 'd':
 | 
			
		||||
	case 'u':	base = 10;	break;
 | 
			
		||||
	case 'o':	base = 8;	break;
 | 
			
		||||
	case 'b':	base = 2;	break;
 | 
			
		||||
	switch (type)
 | 
			
		||||
	{
 | 
			
		||||
		case 'i': /* i means octal, decimal or hexadecimal */
 | 
			
		||||
		case 'p':
 | 
			
		||||
		case 'x':
 | 
			
		||||
		case 'X':
 | 
			
		||||
			base = 16;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'd':
 | 
			
		||||
		case 'u':
 | 
			
		||||
			base = 10;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'o':
 | 
			
		||||
			base = 8;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'b':
 | 
			
		||||
			base = 2;
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (c == '-' || c == '+') {
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
		    c = getc(stream);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (width && c == '0' && base == 16) {
 | 
			
		||||
	if (c == '-' || c == '+')
 | 
			
		||||
	{
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
		if (c != 'x' && c != 'X') {
 | 
			
		||||
			if (type == 'i') base = 8;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (width && c == '0' && base == 16)
 | 
			
		||||
	{
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
		if (c != 'x' && c != 'X')
 | 
			
		||||
		{
 | 
			
		||||
			if (type == 'i')
 | 
			
		||||
				base = 8;
 | 
			
		||||
		}
 | 
			
		||||
		else if (width) {
 | 
			
		||||
		else if (width)
 | 
			
		||||
		{
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (type == 'i') base = 10;
 | 
			
		||||
	else if (type == 'i')
 | 
			
		||||
		base = 10;
 | 
			
		||||
 | 
			
		||||
	while (width) {
 | 
			
		||||
	while (width)
 | 
			
		||||
	{
 | 
			
		||||
		if (((base == 10) && isdigit(c))
 | 
			
		||||
		    || ((base == 16) && isxdigit(c))
 | 
			
		||||
		    || ((base == 8) && isdigit(c) && (c < '8'))
 | 
			
		||||
		    || ((base == 2) && isdigit(c) && (c < '2'))) {
 | 
			
		||||
		    || ((base == 2) && isdigit(c) && (c < '2')))
 | 
			
		||||
		{
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
		else break;
 | 
			
		||||
		else
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (width && c != EOF) ungetc(c, stream);
 | 
			
		||||
	if (type == 'i') base = 0;
 | 
			
		||||
	if (width && c != EOF)
 | 
			
		||||
		ungetc(c, stream);
 | 
			
		||||
	if (type == 'i')
 | 
			
		||||
		base = 0;
 | 
			
		||||
	*basep = base;
 | 
			
		||||
	*bufp = '\0';
 | 
			
		||||
	return bufp - 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef	ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
/* The function f_collect() reads a string that has the format of a
 | 
			
		||||
 * floating-point number. The function returns as soon as a format-error
 | 
			
		||||
 * is encountered, leaving the offending character in the input. This means
 | 
			
		||||
| 
						 | 
				
			
			@ -97,353 +117,425 @@ o_collect(register int c, register FILE *stream, char type,
 | 
			
		|||
 * not necessary, although the use of the width field can cause incomplete
 | 
			
		||||
 * numbers to be passed to strtod(). (e.g. 1.3e+)
 | 
			
		||||
 */
 | 
			
		||||
static char *
 | 
			
		||||
f_collect(register int c, register FILE *stream, register int width)
 | 
			
		||||
static char*
 | 
			
		||||
f_collect(register int c, register FILE* stream, register int width)
 | 
			
		||||
{
 | 
			
		||||
	register char *bufp = inp_buf;
 | 
			
		||||
	register char* bufp = inp_buf;
 | 
			
		||||
	int digit_seen = 0;
 | 
			
		||||
 | 
			
		||||
	if (c == '-' || c == '+') {
 | 
			
		||||
	if (c == '-' || c == '+')
 | 
			
		||||
	{
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (width && isdigit(c)) {
 | 
			
		||||
	while (width && isdigit(c))
 | 
			
		||||
	{
 | 
			
		||||
		digit_seen++;
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
	}
 | 
			
		||||
	if (width && c == '.') {
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if(--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
		while (width && isdigit(c)) {
 | 
			
		||||
			digit_seen++;
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!digit_seen) {
 | 
			
		||||
		if (width && c != EOF) ungetc(c, stream);
 | 
			
		||||
		return inp_buf - 1;
 | 
			
		||||
	}
 | 
			
		||||
	else digit_seen = 0;
 | 
			
		||||
 | 
			
		||||
	if (width && (c == 'e' || c == 'E')) {
 | 
			
		||||
	if (width && c == '.')
 | 
			
		||||
	{
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
		if (width && (c == '+' || c == '-')) {
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
		while (width && isdigit(c)) {
 | 
			
		||||
		while (width && isdigit(c))
 | 
			
		||||
		{
 | 
			
		||||
			digit_seen++;
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
		if (!digit_seen) {
 | 
			
		||||
			if (width && c != EOF) ungetc(c,stream);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!digit_seen)
 | 
			
		||||
	{
 | 
			
		||||
		if (width && c != EOF)
 | 
			
		||||
			ungetc(c, stream);
 | 
			
		||||
		return inp_buf - 1;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
		digit_seen = 0;
 | 
			
		||||
 | 
			
		||||
	if (width && (c == 'e' || c == 'E'))
 | 
			
		||||
	{
 | 
			
		||||
		*bufp++ = c;
 | 
			
		||||
		if (--width)
 | 
			
		||||
			c = getc(stream);
 | 
			
		||||
		if (width && (c == '+' || c == '-'))
 | 
			
		||||
		{
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
		while (width && isdigit(c))
 | 
			
		||||
		{
 | 
			
		||||
			digit_seen++;
 | 
			
		||||
			*bufp++ = c;
 | 
			
		||||
			if (--width)
 | 
			
		||||
				c = getc(stream);
 | 
			
		||||
		}
 | 
			
		||||
		if (!digit_seen)
 | 
			
		||||
		{
 | 
			
		||||
			if (width && c != EOF)
 | 
			
		||||
				ungetc(c, stream);
 | 
			
		||||
			return inp_buf - 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (width && c != EOF) ungetc(c, stream);
 | 
			
		||||
	if (width && c != EOF)
 | 
			
		||||
		ungetc(c, stream);
 | 
			
		||||
	*bufp = '\0';
 | 
			
		||||
	return bufp - 1;
 | 
			
		||||
}
 | 
			
		||||
#endif	/* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
 | 
			
		||||
#endif /* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * the routine that does the scanning 
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
_doscan(register FILE *stream, const char *format, va_list ap)
 | 
			
		||||
int _doscan(register FILE* stream, const char* format, va_list ap)
 | 
			
		||||
{
 | 
			
		||||
	int		done = 0;	/* number of items done */
 | 
			
		||||
	int		nrchars = 0;	/* number of characters read */
 | 
			
		||||
	int		conv = 0;	/* # of conversions */
 | 
			
		||||
	int		base;		/* conversion base */
 | 
			
		||||
	unsigned long	val;		/* an integer value */
 | 
			
		||||
	register char	*str;		/* temporary pointer */
 | 
			
		||||
	char		*tmp_string;	/* ditto */
 | 
			
		||||
	unsigned	width;		/* width of field */
 | 
			
		||||
	int		flags;		/* some flags */
 | 
			
		||||
	int		reverse;	/* reverse the checking in [...] */
 | 
			
		||||
	int		kind;
 | 
			
		||||
	register int	ic;		/* the input character */
 | 
			
		||||
#ifndef	ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
	long double	ld_val;
 | 
			
		||||
	int done = 0; /* number of items done */
 | 
			
		||||
	int nrchars = 0; /* number of characters read */
 | 
			
		||||
	int conv = 0; /* # of conversions */
 | 
			
		||||
	int base; /* conversion base */
 | 
			
		||||
	unsigned long val; /* an integer value */
 | 
			
		||||
	register char* str; /* temporary pointer */
 | 
			
		||||
	char* tmp_string; /* ditto */
 | 
			
		||||
	unsigned width; /* width of field */
 | 
			
		||||
	int flags; /* some flags */
 | 
			
		||||
	int reverse; /* reverse the checking in [...] */
 | 
			
		||||
	int kind;
 | 
			
		||||
	register int ic; /* the input character */
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
	long double ld_val;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (!*format) return 0;
 | 
			
		||||
	if (!*format)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	while (1) {
 | 
			
		||||
		if (isspace(*format)) {
 | 
			
		||||
	while (1)
 | 
			
		||||
	{
 | 
			
		||||
		if (isspace(*format))
 | 
			
		||||
		{
 | 
			
		||||
			while (isspace(*format))
 | 
			
		||||
				format++;	/* skip whitespace */
 | 
			
		||||
				format++; /* skip whitespace */
 | 
			
		||||
			ic = getc(stream);
 | 
			
		||||
			nrchars++;
 | 
			
		||||
			while (isspace (ic)) {
 | 
			
		||||
			while (isspace(ic))
 | 
			
		||||
			{
 | 
			
		||||
				ic = getc(stream);
 | 
			
		||||
				nrchars++;
 | 
			
		||||
			}
 | 
			
		||||
			if (ic != EOF) ungetc(ic,stream);
 | 
			
		||||
			if (ic != EOF)
 | 
			
		||||
				ungetc(ic, stream);
 | 
			
		||||
			nrchars--;
 | 
			
		||||
		}
 | 
			
		||||
		if (!*format) break;	/* end of format */
 | 
			
		||||
		if (!*format)
 | 
			
		||||
			break; /* end of format */
 | 
			
		||||
 | 
			
		||||
		if (*format != '%') {
 | 
			
		||||
		if (*format != '%')
 | 
			
		||||
		{
 | 
			
		||||
			ic = getc(stream);
 | 
			
		||||
			nrchars++;
 | 
			
		||||
			if (ic != *format++) {
 | 
			
		||||
				if (ic != EOF) ungetc(ic,stream);
 | 
			
		||||
			if (ic != *format++)
 | 
			
		||||
			{
 | 
			
		||||
				if (ic != EOF)
 | 
			
		||||
					ungetc(ic, stream);
 | 
			
		||||
				nrchars--;
 | 
			
		||||
				break;	/* error */
 | 
			
		||||
				break; /* error */
 | 
			
		||||
			}
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		format++;
 | 
			
		||||
		if (*format == '%') {
 | 
			
		||||
		if (*format == '%')
 | 
			
		||||
		{
 | 
			
		||||
			ic = getc(stream);
 | 
			
		||||
			nrchars++;
 | 
			
		||||
			if (ic == '%') {
 | 
			
		||||
			if (ic == '%')
 | 
			
		||||
			{
 | 
			
		||||
				format++;
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
			else break;
 | 
			
		||||
			else
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		flags = 0;
 | 
			
		||||
		if (*format == '*') {
 | 
			
		||||
		if (*format == '*')
 | 
			
		||||
		{
 | 
			
		||||
			format++;
 | 
			
		||||
			flags |= FL_NOASSIGN;
 | 
			
		||||
		}
 | 
			
		||||
		if (isdigit (*format)) {
 | 
			
		||||
		if (isdigit(*format))
 | 
			
		||||
		{
 | 
			
		||||
			flags |= FL_WIDTHSPEC;
 | 
			
		||||
			for (width = 0; isdigit (*format);)
 | 
			
		||||
			for (width = 0; isdigit(*format);)
 | 
			
		||||
				width = width * 10 + *format++ - '0';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		switch (*format) {
 | 
			
		||||
		case 'h': flags |= FL_SHORT; format++; break;
 | 
			
		||||
		case 'l': flags |= FL_LONG; format++; break;
 | 
			
		||||
		case 'L': flags |= FL_LONGDOUBLE; format++; break;
 | 
			
		||||
		switch (*format)
 | 
			
		||||
		{
 | 
			
		||||
			case 'h':
 | 
			
		||||
				flags |= FL_SHORT;
 | 
			
		||||
				format++;
 | 
			
		||||
				break;
 | 
			
		||||
			case 'l':
 | 
			
		||||
				flags |= FL_LONG;
 | 
			
		||||
				format++;
 | 
			
		||||
				break;
 | 
			
		||||
			case 'L':
 | 
			
		||||
				flags |= FL_LONGDOUBLE;
 | 
			
		||||
				format++;
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		kind = *format;
 | 
			
		||||
		if ((kind != 'c') && (kind != '[') && (kind != 'n')) {
 | 
			
		||||
			do {
 | 
			
		||||
		if ((kind != 'c') && (kind != '[') && (kind != 'n'))
 | 
			
		||||
		{
 | 
			
		||||
			do
 | 
			
		||||
			{
 | 
			
		||||
				ic = getc(stream);
 | 
			
		||||
				nrchars++;
 | 
			
		||||
			} while (isspace(ic));
 | 
			
		||||
			if (ic == EOF) break;		/* outer while */
 | 
			
		||||
		} else if (kind != 'n') {		/* %c or %[ */
 | 
			
		||||
			if (ic == EOF)
 | 
			
		||||
				break; /* outer while */
 | 
			
		||||
		}
 | 
			
		||||
		else if (kind != 'n')
 | 
			
		||||
		{ /* %c or %[ */
 | 
			
		||||
			ic = getc(stream);
 | 
			
		||||
			if (ic == EOF) break;		/* outer while */
 | 
			
		||||
			if (ic == EOF)
 | 
			
		||||
				break; /* outer while */
 | 
			
		||||
			nrchars++;
 | 
			
		||||
		}
 | 
			
		||||
		switch (kind) {
 | 
			
		||||
		default:
 | 
			
		||||
			/* not recognized, like %q */
 | 
			
		||||
			return conv || (ic != EOF) ? done : EOF;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'n':
 | 
			
		||||
			if (!(flags & FL_NOASSIGN)) {	/* silly, though */
 | 
			
		||||
				if (flags & FL_SHORT)
 | 
			
		||||
					*va_arg(ap, short *) = (short) nrchars;
 | 
			
		||||
				else if (flags & FL_LONG)
 | 
			
		||||
					*va_arg(ap, long *) = (long) nrchars;
 | 
			
		||||
				else
 | 
			
		||||
					*va_arg(ap, int *) = (int) nrchars;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 'p':		/* pointer */
 | 
			
		||||
			set_pointer(flags);
 | 
			
		||||
		switch (kind)
 | 
			
		||||
		{
 | 
			
		||||
			default:
 | 
			
		||||
				/* not recognized, like %q */
 | 
			
		||||
				return conv || (ic != EOF) ? done : EOF;
 | 
			
		||||
				break;
 | 
			
		||||
			case 'n':
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				{ /* silly, though */
 | 
			
		||||
					if (flags & FL_SHORT)
 | 
			
		||||
						*va_arg(ap, short*) = (short)nrchars;
 | 
			
		||||
					else if (flags & FL_LONG)
 | 
			
		||||
						*va_arg(ap, long*) = (long)nrchars;
 | 
			
		||||
					else
 | 
			
		||||
						*va_arg(ap, int*) = (int)nrchars;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case 'p': /* pointer */
 | 
			
		||||
				set_pointer(flags);
 | 
			
		||||
			/* fallthrough */
 | 
			
		||||
		case 'b':		/* binary */
 | 
			
		||||
		case 'd':		/* decimal */
 | 
			
		||||
		case 'i':		/* general integer */
 | 
			
		||||
		case 'o':		/* octal */
 | 
			
		||||
		case 'u':		/* unsigned */
 | 
			
		||||
		case 'x':		/* hexadecimal */
 | 
			
		||||
		case 'X':		/* ditto */
 | 
			
		||||
			if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
 | 
			
		||||
				width = NUMLEN;
 | 
			
		||||
			if (!width) return done;
 | 
			
		||||
			case 'b': /* binary */
 | 
			
		||||
			case 'd': /* decimal */
 | 
			
		||||
			case 'i': /* general integer */
 | 
			
		||||
			case 'o': /* octal */
 | 
			
		||||
			case 'u': /* unsigned */
 | 
			
		||||
			case 'x': /* hexadecimal */
 | 
			
		||||
			case 'X': /* ditto */
 | 
			
		||||
				if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
 | 
			
		||||
					width = NUMLEN;
 | 
			
		||||
				if (!width)
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
			str = o_collect(ic, stream, kind, width, &base);
 | 
			
		||||
			if (str < inp_buf
 | 
			
		||||
			    || (str == inp_buf
 | 
			
		||||
				    && (*str == '-'
 | 
			
		||||
					|| *str == '+'))) return done;
 | 
			
		||||
				str = o_collect(ic, stream, kind, width, &base);
 | 
			
		||||
				if (str < inp_buf
 | 
			
		||||
				    || (str == inp_buf
 | 
			
		||||
				           && (*str == '-'
 | 
			
		||||
				                  || *str == '+')))
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
				/*
 | 
			
		||||
			 * Although the length of the number is str-inp_buf+1
 | 
			
		||||
			 * we don't add the 1 since we counted it already
 | 
			
		||||
			 */
 | 
			
		||||
			nrchars += str - inp_buf;
 | 
			
		||||
				nrchars += str - inp_buf;
 | 
			
		||||
 | 
			
		||||
			if (!(flags & FL_NOASSIGN)) {
 | 
			
		||||
				if (kind == 'd' || kind == 'i')
 | 
			
		||||
				    val = strtol(inp_buf, &tmp_string, base);
 | 
			
		||||
				else
 | 
			
		||||
				    val = strtoul(inp_buf, &tmp_string, base);
 | 
			
		||||
				if (flags & FL_LONG)
 | 
			
		||||
					*va_arg(ap, unsigned long *) = (unsigned long) val;
 | 
			
		||||
				else if (flags & FL_SHORT)
 | 
			
		||||
					*va_arg(ap, unsigned short *) = (unsigned short) val;
 | 
			
		||||
				else
 | 
			
		||||
					*va_arg(ap, unsigned *) = (unsigned) val;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 'c':
 | 
			
		||||
			if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
				width = 1;
 | 
			
		||||
			if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				str = va_arg(ap, char *);
 | 
			
		||||
			if (!width) return done;
 | 
			
		||||
 | 
			
		||||
			while (width && ic != EOF) {
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
					*str++ = (char) ic;
 | 
			
		||||
				if (--width) {
 | 
			
		||||
					ic = getc(stream);
 | 
			
		||||
					nrchars++;
 | 
			
		||||
				{
 | 
			
		||||
					if (kind == 'd' || kind == 'i')
 | 
			
		||||
						val = strtol(inp_buf, &tmp_string, base);
 | 
			
		||||
					else
 | 
			
		||||
						val = strtoul(inp_buf, &tmp_string, base);
 | 
			
		||||
					if (flags & FL_LONG)
 | 
			
		||||
						*va_arg(ap, unsigned long*) = (unsigned long)val;
 | 
			
		||||
					else if (flags & FL_SHORT)
 | 
			
		||||
						*va_arg(ap, unsigned short*) = (unsigned short)val;
 | 
			
		||||
					else
 | 
			
		||||
						*va_arg(ap, unsigned*) = (unsigned)val;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (width) {
 | 
			
		||||
				if (ic != EOF) ungetc(ic,stream);
 | 
			
		||||
				nrchars--;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case 's':
 | 
			
		||||
			if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
				width = 0xffff;
 | 
			
		||||
			if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				str = va_arg(ap, char *);
 | 
			
		||||
			if (!width) return done;
 | 
			
		||||
 | 
			
		||||
			while (width && ic != EOF && !isspace(ic)) {
 | 
			
		||||
				break;
 | 
			
		||||
			case 'c':
 | 
			
		||||
				if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
					width = 1;
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
					*str++ = (char) ic;
 | 
			
		||||
				if (--width) {
 | 
			
		||||
					ic = getc(stream);
 | 
			
		||||
					nrchars++;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			/* terminate the string */
 | 
			
		||||
			if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				*str = '\0';	
 | 
			
		||||
			if (width) {
 | 
			
		||||
				if (ic != EOF) ungetc(ic,stream);
 | 
			
		||||
				nrchars--;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
		case '[':
 | 
			
		||||
			if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
				width = 0xffff;
 | 
			
		||||
			if (!width) return done;
 | 
			
		||||
					str = va_arg(ap, char*);
 | 
			
		||||
				if (!width)
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
			if ( *++format == '^' ) {
 | 
			
		||||
				reverse = 1;
 | 
			
		||||
				format++;
 | 
			
		||||
			} else
 | 
			
		||||
				reverse = 0;
 | 
			
		||||
 | 
			
		||||
			for (str = Xtable; str < &Xtable[NR_CHARS]
 | 
			
		||||
							; str++)
 | 
			
		||||
				*str = 0;
 | 
			
		||||
 | 
			
		||||
			if (*format == ']') Xtable[*format++] = 1;
 | 
			
		||||
 | 
			
		||||
			while (*format && *format != ']') {
 | 
			
		||||
				Xtable[*format++] = 1;
 | 
			
		||||
				if (*format == '-') {
 | 
			
		||||
					format++;
 | 
			
		||||
					if (*format
 | 
			
		||||
					    && *format != ']'
 | 
			
		||||
					    && *(format) >= *(format -2)) {
 | 
			
		||||
						int c;
 | 
			
		||||
 | 
			
		||||
						for( c = *(format -2) + 1
 | 
			
		||||
						    ; c <= *format ; c++)
 | 
			
		||||
							Xtable[c] = 1;
 | 
			
		||||
						format++;
 | 
			
		||||
				while (width && ic != EOF)
 | 
			
		||||
				{
 | 
			
		||||
					if (!(flags & FL_NOASSIGN))
 | 
			
		||||
						*str++ = (char)ic;
 | 
			
		||||
					if (--width)
 | 
			
		||||
					{
 | 
			
		||||
						ic = getc(stream);
 | 
			
		||||
						nrchars++;
 | 
			
		||||
					}
 | 
			
		||||
					else Xtable['-'] = 1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (!*format || !(Xtable[ic] ^ reverse)) {
 | 
			
		||||
				if (ic != EOF) ungetc(ic, stream);
 | 
			
		||||
				return done;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				str = va_arg(ap, char *);
 | 
			
		||||
 | 
			
		||||
			do {
 | 
			
		||||
				if (width)
 | 
			
		||||
				{
 | 
			
		||||
					if (ic != EOF)
 | 
			
		||||
						ungetc(ic, stream);
 | 
			
		||||
					nrchars--;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case 's':
 | 
			
		||||
				if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
					width = 0xffff;
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
					*str++ = (char) ic;
 | 
			
		||||
				if (--width) {
 | 
			
		||||
					ic = getc(stream);
 | 
			
		||||
					nrchars++;
 | 
			
		||||
					str = va_arg(ap, char*);
 | 
			
		||||
				if (!width)
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
				while (width && ic != EOF && !isspace(ic))
 | 
			
		||||
				{
 | 
			
		||||
					if (!(flags & FL_NOASSIGN))
 | 
			
		||||
						*str++ = (char)ic;
 | 
			
		||||
					if (--width)
 | 
			
		||||
					{
 | 
			
		||||
						ic = getc(stream);
 | 
			
		||||
						nrchars++;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			} while (width && ic != EOF && (Xtable[ic] ^ reverse));
 | 
			
		||||
				/* terminate the string */
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
					*str = '\0';
 | 
			
		||||
				if (width)
 | 
			
		||||
				{
 | 
			
		||||
					if (ic != EOF)
 | 
			
		||||
						ungetc(ic, stream);
 | 
			
		||||
					nrchars--;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case '[':
 | 
			
		||||
				if (!(flags & FL_WIDTHSPEC))
 | 
			
		||||
					width = 0xffff;
 | 
			
		||||
				if (!width)
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
			if (width) {
 | 
			
		||||
				if (ic != EOF) ungetc(ic, stream);
 | 
			
		||||
				nrchars--;
 | 
			
		||||
			}
 | 
			
		||||
			if (!(flags & FL_NOASSIGN)) {	/* terminate string */
 | 
			
		||||
				*str = '\0';	
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
#ifndef	ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
		case 'e':
 | 
			
		||||
		case 'E':
 | 
			
		||||
		case 'f':
 | 
			
		||||
		case 'g':
 | 
			
		||||
		case 'G':
 | 
			
		||||
			if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
 | 
			
		||||
				width = NUMLEN;
 | 
			
		||||
				if (*++format == '^')
 | 
			
		||||
				{
 | 
			
		||||
					reverse = 1;
 | 
			
		||||
					format++;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					reverse = 0;
 | 
			
		||||
 | 
			
		||||
			if (!width) return done;
 | 
			
		||||
			str = f_collect(ic, stream, width);
 | 
			
		||||
				for (str = Xtable; str < &Xtable[NR_CHARS]; str++)
 | 
			
		||||
					*str = 0;
 | 
			
		||||
 | 
			
		||||
			if (str < inp_buf
 | 
			
		||||
			    || (str == inp_buf
 | 
			
		||||
				&& (*str == '-'
 | 
			
		||||
				    || *str == '+'))) return done;
 | 
			
		||||
				if (*format == ']')
 | 
			
		||||
					Xtable[*format++] = 1;
 | 
			
		||||
 | 
			
		||||
			/*
 | 
			
		||||
				while (*format && *format != ']')
 | 
			
		||||
				{
 | 
			
		||||
					Xtable[*format++] = 1;
 | 
			
		||||
					if (*format == '-')
 | 
			
		||||
					{
 | 
			
		||||
						format++;
 | 
			
		||||
						if (*format
 | 
			
		||||
						    && *format != ']'
 | 
			
		||||
						    && *(format) >= *(format - 2))
 | 
			
		||||
						{
 | 
			
		||||
							int c;
 | 
			
		||||
 | 
			
		||||
							for (c = *(format - 2) + 1; c <= *format; c++)
 | 
			
		||||
								Xtable[c] = 1;
 | 
			
		||||
							format++;
 | 
			
		||||
						}
 | 
			
		||||
						else
 | 
			
		||||
							Xtable['-'] = 1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				if (!*format || !(Xtable[ic] ^ reverse))
 | 
			
		||||
				{
 | 
			
		||||
					if (ic != EOF)
 | 
			
		||||
						ungetc(ic, stream);
 | 
			
		||||
					return done;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
					str = va_arg(ap, char*);
 | 
			
		||||
 | 
			
		||||
				do
 | 
			
		||||
				{
 | 
			
		||||
					if (!(flags & FL_NOASSIGN))
 | 
			
		||||
						*str++ = (char)ic;
 | 
			
		||||
					if (--width)
 | 
			
		||||
					{
 | 
			
		||||
						ic = getc(stream);
 | 
			
		||||
						nrchars++;
 | 
			
		||||
					}
 | 
			
		||||
				} while (width && ic != EOF && (Xtable[ic] ^ reverse));
 | 
			
		||||
 | 
			
		||||
				if (width)
 | 
			
		||||
				{
 | 
			
		||||
					if (ic != EOF)
 | 
			
		||||
						ungetc(ic, stream);
 | 
			
		||||
					nrchars--;
 | 
			
		||||
				}
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				{ /* terminate string */
 | 
			
		||||
					*str = '\0';
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
			case 'e':
 | 
			
		||||
			case 'E':
 | 
			
		||||
			case 'f':
 | 
			
		||||
			case 'g':
 | 
			
		||||
			case 'G':
 | 
			
		||||
				if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
 | 
			
		||||
					width = NUMLEN;
 | 
			
		||||
 | 
			
		||||
				if (!width)
 | 
			
		||||
					return done;
 | 
			
		||||
				str = f_collect(ic, stream, width);
 | 
			
		||||
 | 
			
		||||
				if (str < inp_buf
 | 
			
		||||
				    || (str == inp_buf
 | 
			
		||||
				           && (*str == '-'
 | 
			
		||||
				                  || *str == '+')))
 | 
			
		||||
					return done;
 | 
			
		||||
 | 
			
		||||
				/*
 | 
			
		||||
			 * Although the length of the number is str-inp_buf+1
 | 
			
		||||
			 * we don't add the 1 since we counted it already
 | 
			
		||||
			 */
 | 
			
		||||
			nrchars += str - inp_buf;
 | 
			
		||||
				nrchars += str - inp_buf;
 | 
			
		||||
 | 
			
		||||
			if (!(flags & FL_NOASSIGN)) {
 | 
			
		||||
				ld_val = strtod(inp_buf, &tmp_string);
 | 
			
		||||
				if (flags & FL_LONGDOUBLE)
 | 
			
		||||
					*va_arg(ap, long double *) = (long double) ld_val;
 | 
			
		||||
				else
 | 
			
		||||
				    if (flags & FL_LONG)
 | 
			
		||||
					*va_arg(ap, double *) = (double) ld_val;
 | 
			
		||||
				else
 | 
			
		||||
					*va_arg(ap, float *) = (float) ld_val;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
				if (!(flags & FL_NOASSIGN))
 | 
			
		||||
				{
 | 
			
		||||
					ld_val = strtod(inp_buf, &tmp_string);
 | 
			
		||||
					if (flags & FL_LONGDOUBLE)
 | 
			
		||||
						*va_arg(ap, long double*) = (long double)ld_val;
 | 
			
		||||
					else if (flags & FL_LONG)
 | 
			
		||||
						*va_arg(ap, double*) = (double)ld_val;
 | 
			
		||||
					else
 | 
			
		||||
						*va_arg(ap, float*) = (float)ld_val;
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
#endif
 | 
			
		||||
		}		/* end switch */
 | 
			
		||||
		} /* end switch */
 | 
			
		||||
		conv++;
 | 
			
		||||
		if (!(flags & FL_NOASSIGN) && kind != 'n') done++;
 | 
			
		||||
		if (!(flags & FL_NOASSIGN) && kind != 'n')
 | 
			
		||||
			done++;
 | 
			
		||||
		format++;
 | 
			
		||||
	}
 | 
			
		||||
	return conv || (ic != EOF) ? done : EOF;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +1,15 @@
 | 
			
		|||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include    "loc_incl.h"
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
 | 
			
		||||
#include	"../stdlib/ext_fmt.h"
 | 
			
		||||
void _dbl_ext_cvt(double value, struct EXTEND *e);
 | 
			
		||||
char *_ext_str_cvt(struct EXTEND *e, int ndigit, int *decpt, int * sign, int ecvtflag);
 | 
			
		||||
#include "../stdlib/ext_fmt.h"
 | 
			
		||||
void _dbl_ext_cvt(double value, struct EXTEND* e);
 | 
			
		||||
char* _ext_str_cvt(struct EXTEND* e, int ndigit, int* decpt, int* sign, int ecvtflag);
 | 
			
		||||
 | 
			
		||||
static char *
 | 
			
		||||
cvt(long double value, int ndigit, int *decpt, int *sign, int ecvtflag)
 | 
			
		||||
static char*
 | 
			
		||||
cvt(long double value, int ndigit, int* decpt, int* sign, int ecvtflag)
 | 
			
		||||
{
 | 
			
		||||
	struct EXTEND e;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -17,17 +17,15 @@ cvt(long double value, int ndigit, int *decpt, int *sign, int ecvtflag)
 | 
			
		|||
	return _ext_str_cvt(&e, ndigit, decpt, sign, ecvtflag);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
_ecvt(long double value, int ndigit, int *decpt, int *sign)
 | 
			
		||||
char* _ecvt(long double value, int ndigit, int* decpt, int* sign)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	return cvt(value, ndigit, decpt, sign, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
_fcvt(long double value, int ndigit, int *decpt, int *sign)
 | 
			
		||||
char* _fcvt(long double value, int ndigit, int* decpt, int* sign)
 | 
			
		||||
{
 | 
			
		||||
	return cvt(value, ndigit, decpt, sign, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif	/* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
#endif /* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,23 +8,25 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fclose(FILE *fp)
 | 
			
		||||
int fclose(FILE* fp)
 | 
			
		||||
{
 | 
			
		||||
	register int i, retval = 0;
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<FOPEN_MAX; i++)
 | 
			
		||||
		if (fp == __iotab[i]) {
 | 
			
		||||
	for (i = 0; i < FOPEN_MAX; i++)
 | 
			
		||||
		if (fp == __iotab[i])
 | 
			
		||||
		{
 | 
			
		||||
			__iotab[i] = 0;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
	if (i >= FOPEN_MAX)
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (fflush(fp)) retval = EOF;
 | 
			
		||||
	if (close(fileno(fp))) retval = EOF;
 | 
			
		||||
	if ( io_testflag(fp,_IOMYBUF) && fp->_buf )
 | 
			
		||||
		free((void *)fp->_buf);
 | 
			
		||||
	if (fflush(fp))
 | 
			
		||||
		retval = EOF;
 | 
			
		||||
	if (close(fileno(fp)))
 | 
			
		||||
		retval = EOF;
 | 
			
		||||
	if (io_testflag(fp, _IOMYBUF) && fp->_buf)
 | 
			
		||||
		free((void*)fp->_buf);
 | 
			
		||||
	if (fp != stdin && fp != stdout && fp != stderr)
 | 
			
		||||
		free((void *)fp);
 | 
			
		||||
		free((void*)fp);
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,50 +3,54 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	"../stdio/loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "../stdio/loc_incl.h"
 | 
			
		||||
 | 
			
		||||
FILE *
 | 
			
		||||
fdopen(int fd, const char *mode)
 | 
			
		||||
FILE* fdopen(int fd, const char* mode)
 | 
			
		||||
{
 | 
			
		||||
	register int i;
 | 
			
		||||
	FILE *stream;
 | 
			
		||||
	FILE* stream;
 | 
			
		||||
	int flags = 0;
 | 
			
		||||
 | 
			
		||||
	if (fd < 0) return (FILE *)NULL;
 | 
			
		||||
	for (i = 0; __iotab[i] != 0 ; i++) 
 | 
			
		||||
		if (i >= FOPEN_MAX-1)
 | 
			
		||||
			return (FILE *)NULL;
 | 
			
		||||
	if (fd < 0)
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
	for (i = 0; __iotab[i] != 0; i++)
 | 
			
		||||
		if (i >= FOPEN_MAX - 1)
 | 
			
		||||
			return (FILE*)NULL;
 | 
			
		||||
 | 
			
		||||
	switch(*mode++) {
 | 
			
		||||
	case 'r':
 | 
			
		||||
		flags |= _IOREAD | _IOREADING;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'a':
 | 
			
		||||
		flags |= _IOAPPEND;
 | 
			
		||||
	case 'w':
 | 
			
		||||
		flags |= _IOWRITE | _IOWRITING;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
	}
 | 
			
		||||
	while(*mode) {
 | 
			
		||||
		switch(*mode++) {
 | 
			
		||||
		case 'b':
 | 
			
		||||
			continue;
 | 
			
		||||
		case '+':
 | 
			
		||||
			flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
			continue;
 | 
			
		||||
		/* The sequence may be followed by aditional characters */
 | 
			
		||||
		default:
 | 
			
		||||
	switch (*mode++)
 | 
			
		||||
	{
 | 
			
		||||
		case 'r':
 | 
			
		||||
			flags |= _IOREAD | _IOREADING;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'a':
 | 
			
		||||
			flags |= _IOAPPEND;
 | 
			
		||||
		case 'w':
 | 
			
		||||
			flags |= _IOWRITE | _IOWRITING;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
	while (*mode)
 | 
			
		||||
	{
 | 
			
		||||
		switch (*mode++)
 | 
			
		||||
		{
 | 
			
		||||
			case 'b':
 | 
			
		||||
				continue;
 | 
			
		||||
			case '+':
 | 
			
		||||
				flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
				continue;
 | 
			
		||||
			/* The sequence may be followed by aditional characters */
 | 
			
		||||
			default:
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((stream = (FILE *) malloc(sizeof(FILE))) == NULL) {
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
	if ((stream = (FILE*)malloc(sizeof(FILE))) == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((flags & _IOREAD) && (flags & _IOWRITE))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(feof)(FILE *stream)
 | 
			
		||||
int(feof)(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return feof(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(ferror)(FILE *stream)
 | 
			
		||||
int(ferror)(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return ferror(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,67 +8,71 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fflush(FILE *stream)
 | 
			
		||||
int fflush(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	int count, c1, i, retval = 0;
 | 
			
		||||
 | 
			
		||||
	if (!stream) {
 | 
			
		||||
	    for(i= 0; i < FOPEN_MAX; i++)
 | 
			
		||||
		if (__iotab[i] && fflush(__iotab[i]))
 | 
			
		||||
			retval = EOF;
 | 
			
		||||
	    return retval;
 | 
			
		||||
	if (!stream)
 | 
			
		||||
	{
 | 
			
		||||
		for (i = 0; i < FOPEN_MAX; i++)
 | 
			
		||||
			if (__iotab[i] && fflush(__iotab[i]))
 | 
			
		||||
				retval = EOF;
 | 
			
		||||
		return retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!stream->_buf
 | 
			
		||||
	    || (!io_testflag(stream, _IOREADING)
 | 
			
		||||
		&& !io_testflag(stream, _IOWRITING)))
 | 
			
		||||
	           && !io_testflag(stream, _IOWRITING)))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (io_testflag(stream, _IOREADING)) {
 | 
			
		||||
	if (io_testflag(stream, _IOREADING))
 | 
			
		||||
	{
 | 
			
		||||
		/* (void) fseek(stream, 0L, SEEK_CUR); */
 | 
			
		||||
		int adjust = 0;
 | 
			
		||||
		if (stream->_buf && !io_testflag(stream,_IONBF))
 | 
			
		||||
		if (stream->_buf && !io_testflag(stream, _IONBF))
 | 
			
		||||
			adjust = stream->_count;
 | 
			
		||||
		stream->_count = 0;
 | 
			
		||||
		lseek(fileno(stream), (off_t) adjust, SEEK_CUR);
 | 
			
		||||
		lseek(fileno(stream), (off_t)adjust, SEEK_CUR);
 | 
			
		||||
		if (io_testflag(stream, _IOWRITE))
 | 
			
		||||
			stream->_flags &= ~(_IOREADING | _IOWRITING);
 | 
			
		||||
		stream->_ptr = stream->_buf;
 | 
			
		||||
		return 0;
 | 
			
		||||
	} else if (io_testflag(stream, _IONBF)) return 0;
 | 
			
		||||
	}
 | 
			
		||||
	else if (io_testflag(stream, _IONBF))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if (io_testflag(stream, _IOREAD))		/* "a" or "+" mode */
 | 
			
		||||
	if (io_testflag(stream, _IOREAD)) /* "a" or "+" mode */
 | 
			
		||||
		stream->_flags &= ~_IOWRITING;
 | 
			
		||||
 | 
			
		||||
	count = stream->_ptr - stream->_buf;
 | 
			
		||||
	stream->_ptr = stream->_buf;
 | 
			
		||||
 | 
			
		||||
	if ( count <= 0 )
 | 
			
		||||
	if (count <= 0)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if (io_testflag(stream, _IOAPPEND)) {
 | 
			
		||||
		if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
 | 
			
		||||
	if (io_testflag(stream, _IOAPPEND))
 | 
			
		||||
	{
 | 
			
		||||
		if (lseek(fileno(stream), 0L, SEEK_END) == -1)
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IOERR;
 | 
			
		||||
			return EOF;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	c1 = write(stream->_fd, (char *)stream->_buf, count);
 | 
			
		||||
	c1 = write(stream->_fd, (char*)stream->_buf, count);
 | 
			
		||||
 | 
			
		||||
	stream->_count = 0;
 | 
			
		||||
 | 
			
		||||
	if ( count == c1 )
 | 
			
		||||
	if (count == c1)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	stream->_flags |= _IOERR;
 | 
			
		||||
	return EOF; 
 | 
			
		||||
	return EOF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
__cleanup(void)
 | 
			
		||||
void __cleanup(void)
 | 
			
		||||
{
 | 
			
		||||
	register int i;
 | 
			
		||||
 | 
			
		||||
	for(i= 0; i < FOPEN_MAX; i++)
 | 
			
		||||
	for (i = 0; i < FOPEN_MAX; i++)
 | 
			
		||||
		if (__iotab[i] && io_testflag(__iotab[i], _IOWRITING))
 | 
			
		||||
			(void) fflush(__iotab[i]);
 | 
			
		||||
			(void)fflush(__iotab[i]);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fgetc(FILE *stream)
 | 
			
		||||
int fgetc(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return getc(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,12 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fgetpos(FILE *stream, fpos_t *pos)
 | 
			
		||||
int fgetpos(FILE* stream, fpos_t* pos)
 | 
			
		||||
{
 | 
			
		||||
	*pos = ftell(stream);
 | 
			
		||||
	if (*pos == -1) return -1;
 | 
			
		||||
	if (*pos == -1)
 | 
			
		||||
		return -1;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,24 +3,29 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
fgets(char *s, register int n, register FILE *stream)
 | 
			
		||||
char* fgets(char* s, register int n, register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register int ch;
 | 
			
		||||
	register char *ptr;
 | 
			
		||||
	register char* ptr;
 | 
			
		||||
 | 
			
		||||
	ptr = s;
 | 
			
		||||
	while (--n > 0 && (ch = getc(stream)) != EOF) {
 | 
			
		||||
	while (--n > 0 && (ch = getc(stream)) != EOF)
 | 
			
		||||
	{
 | 
			
		||||
		*ptr++ = ch;
 | 
			
		||||
		if ( ch == '\n')
 | 
			
		||||
		if (ch == '\n')
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	if (ch == EOF) {
 | 
			
		||||
		if (feof(stream)) {
 | 
			
		||||
			if (ptr == s) return NULL;
 | 
			
		||||
		} else return NULL;
 | 
			
		||||
	if (ch == EOF)
 | 
			
		||||
	{
 | 
			
		||||
		if (feof(stream))
 | 
			
		||||
		{
 | 
			
		||||
			if (ptr == s)
 | 
			
		||||
				return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	*ptr = '\0';
 | 
			
		||||
	return s;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(fileno)(FILE *stream)
 | 
			
		||||
int(fileno)(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return stream->_fd;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,57 +8,67 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
__fillbuf(register FILE *stream)
 | 
			
		||||
int __fillbuf(register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	static unsigned char ch[FOPEN_MAX];
 | 
			
		||||
	register int i;
 | 
			
		||||
 | 
			
		||||
	stream->_count = 0;
 | 
			
		||||
	if (fileno(stream) < 0) return EOF;
 | 
			
		||||
	if (io_testflag(stream, _IOEOF)) return EOF;
 | 
			
		||||
	if (!io_testflag(stream, _IOREAD)) {
 | 
			
		||||
	if (fileno(stream) < 0)
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (io_testflag(stream, _IOEOF))
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (!io_testflag(stream, _IOREAD))
 | 
			
		||||
	{
 | 
			
		||||
		stream->_flags |= _IOERR;
 | 
			
		||||
		return EOF;
 | 
			
		||||
	}
 | 
			
		||||
	if (io_testflag(stream, _IOWRITING)) {
 | 
			
		||||
	if (io_testflag(stream, _IOWRITING))
 | 
			
		||||
	{
 | 
			
		||||
		stream->_flags |= _IOERR;
 | 
			
		||||
		return EOF;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!io_testflag(stream, _IOREADING))
 | 
			
		||||
		stream->_flags |= _IOREADING;
 | 
			
		||||
	
 | 
			
		||||
	if (!io_testflag(stream, _IONBF) && !stream->_buf) {
 | 
			
		||||
		stream->_buf = (unsigned char *) malloc(BUFSIZ);
 | 
			
		||||
		if (!stream->_buf) {
 | 
			
		||||
 | 
			
		||||
	if (!io_testflag(stream, _IONBF) && !stream->_buf)
 | 
			
		||||
	{
 | 
			
		||||
		stream->_buf = (unsigned char*)malloc(BUFSIZ);
 | 
			
		||||
		if (!stream->_buf)
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IONBF;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IOMYBUF;
 | 
			
		||||
			stream->_bufsiz = BUFSIZ;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* flush line-buffered output when filling an input buffer */
 | 
			
		||||
	for (i = 0; i < FOPEN_MAX; i++) {
 | 
			
		||||
	for (i = 0; i < FOPEN_MAX; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (__iotab[i] && io_testflag(__iotab[i], _IOLBF))
 | 
			
		||||
			if (io_testflag(__iotab[i], _IOWRITING))
 | 
			
		||||
				(void) fflush(__iotab[i]);
 | 
			
		||||
				(void)fflush(__iotab[i]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!stream->_buf) {
 | 
			
		||||
	if (!stream->_buf)
 | 
			
		||||
	{
 | 
			
		||||
		stream->_buf = &ch[fileno(stream)];
 | 
			
		||||
		stream->_bufsiz = 1;
 | 
			
		||||
	}
 | 
			
		||||
	stream->_ptr = stream->_buf;
 | 
			
		||||
	stream->_count = read(stream->_fd, (char *)stream->_buf, stream->_bufsiz);
 | 
			
		||||
	stream->_count = read(stream->_fd, (char*)stream->_buf, stream->_bufsiz);
 | 
			
		||||
 | 
			
		||||
	if (stream->_count <= 0){
 | 
			
		||||
		if (stream->_count == 0) {
 | 
			
		||||
	if (stream->_count <= 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (stream->_count == 0)
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IOEOF;
 | 
			
		||||
		}
 | 
			
		||||
		else 
 | 
			
		||||
		else
 | 
			
		||||
			stream->_flags |= _IOERR;
 | 
			
		||||
 | 
			
		||||
		return EOF;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,16 +3,16 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
#ifndef	ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
#ifndef ACKCONF_NO_STDIO_FLOAT
 | 
			
		||||
 | 
			
		||||
static char *
 | 
			
		||||
_pfloat(long double r, register char *s, int n, int flags)
 | 
			
		||||
static char*
 | 
			
		||||
_pfloat(long double r, register char* s, int n, int flags)
 | 
			
		||||
{
 | 
			
		||||
	register char *s1;
 | 
			
		||||
	register char* s1;
 | 
			
		||||
	int sign, dp;
 | 
			
		||||
	register int i;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -24,29 +24,34 @@ _pfloat(long double r, register char *s, int n, int flags)
 | 
			
		|||
	else if (flags & FL_SPACE)
 | 
			
		||||
		*s++ = ' ';
 | 
			
		||||
 | 
			
		||||
	if (dp<=0)
 | 
			
		||||
	if (dp <= 0)
 | 
			
		||||
		*s++ = '0';
 | 
			
		||||
	for (i=dp; i>0; i--)
 | 
			
		||||
		if (*s1) *s++ = *s1++;
 | 
			
		||||
		else *s++ = '0';
 | 
			
		||||
	if (((i=n) > 0) || (flags & FL_ALT))
 | 
			
		||||
	for (i = dp; i > 0; i--)
 | 
			
		||||
		if (*s1)
 | 
			
		||||
			*s++ = *s1++;
 | 
			
		||||
		else
 | 
			
		||||
			*s++ = '0';
 | 
			
		||||
	if (((i = n) > 0) || (flags & FL_ALT))
 | 
			
		||||
		*s++ = '.';
 | 
			
		||||
	while (++dp <= 0) {
 | 
			
		||||
		if (--i<0)
 | 
			
		||||
	while (++dp <= 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (--i < 0)
 | 
			
		||||
			break;
 | 
			
		||||
		*s++ = '0';
 | 
			
		||||
	}
 | 
			
		||||
	while (--i >= 0)
 | 
			
		||||
		if (*s1) *s++ = *s1++;
 | 
			
		||||
		else *s++ = '0';
 | 
			
		||||
		if (*s1)
 | 
			
		||||
			*s++ = *s1++;
 | 
			
		||||
		else
 | 
			
		||||
			*s++ = '0';
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char *
 | 
			
		||||
_pscien(long double r, register char *s, int n, int flags)
 | 
			
		||||
static char*
 | 
			
		||||
_pscien(long double r, register char* s, int n, int flags)
 | 
			
		||||
{
 | 
			
		||||
	int sign, dp; 
 | 
			
		||||
	register char *s1;
 | 
			
		||||
	int sign, dp;
 | 
			
		||||
	register char* s1;
 | 
			
		||||
 | 
			
		||||
	s1 = _ecvt(r, n + 1, &dp, &sign);
 | 
			
		||||
	if (sign)
 | 
			
		||||
| 
						 | 
				
			
			@ -60,30 +65,38 @@ _pscien(long double r, register char *s, int n, int flags)
 | 
			
		|||
	if ((n > 0) || (flags & FL_ALT))
 | 
			
		||||
		*s++ = '.';
 | 
			
		||||
	while (--n >= 0)
 | 
			
		||||
		if (*s1) *s++ = *s1++;
 | 
			
		||||
		else *s++ = '0';
 | 
			
		||||
		if (*s1)
 | 
			
		||||
			*s++ = *s1++;
 | 
			
		||||
		else
 | 
			
		||||
			*s++ = '0';
 | 
			
		||||
	*s++ = 'e';
 | 
			
		||||
	if ( r != 0 ) --dp ;
 | 
			
		||||
	if ( dp<0 ) {
 | 
			
		||||
		*s++ = '-' ; dp= -dp ;
 | 
			
		||||
	} else {
 | 
			
		||||
		*s++ = '+' ;
 | 
			
		||||
	if (r != 0)
 | 
			
		||||
		--dp;
 | 
			
		||||
	if (dp < 0)
 | 
			
		||||
	{
 | 
			
		||||
		*s++ = '-';
 | 
			
		||||
		dp = -dp;
 | 
			
		||||
	}
 | 
			
		||||
	if (dp >= 100) {
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		*s++ = '+';
 | 
			
		||||
	}
 | 
			
		||||
	if (dp >= 100)
 | 
			
		||||
	{
 | 
			
		||||
		*s++ = '0' + (dp / 100);
 | 
			
		||||
		dp %= 100;
 | 
			
		||||
	}
 | 
			
		||||
	*s++ = '0' + (dp/10);
 | 
			
		||||
	*s++ = '0' + (dp%10);
 | 
			
		||||
	*s++ = '0' + (dp / 10);
 | 
			
		||||
	*s++ = '0' + (dp % 10);
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define	NDIGINEXP(exp)		(((exp) >= 100 || (exp) <= -100) ? 3 : 2)
 | 
			
		||||
#define	LOW_EXP			-4
 | 
			
		||||
#define	USE_EXP(exp, ndigits)	(((exp) < LOW_EXP + 1) || (exp >= ndigits + 1))
 | 
			
		||||
#define NDIGINEXP(exp) (((exp) >= 100 || (exp) <= -100) ? 3 : 2)
 | 
			
		||||
#define LOW_EXP -4
 | 
			
		||||
#define USE_EXP(exp, ndigits) (((exp) < LOW_EXP + 1) || (exp >= ndigits + 1))
 | 
			
		||||
 | 
			
		||||
static char *
 | 
			
		||||
_gcvt(long double value, int ndigit, char *s, int flags)
 | 
			
		||||
static char*
 | 
			
		||||
_gcvt(long double value, int ndigit, char* s, int flags)
 | 
			
		||||
{
 | 
			
		||||
	int sign, dp;
 | 
			
		||||
	register char *s1, *s2;
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +105,8 @@ _gcvt(long double value, int ndigit, char *s, int flags)
 | 
			
		|||
 | 
			
		||||
	s1 = _ecvt(value, ndigit, &dp, &sign);
 | 
			
		||||
	s2 = s;
 | 
			
		||||
	if (sign) *s2++ = '-';
 | 
			
		||||
	if (sign)
 | 
			
		||||
		*s2++ = '-';
 | 
			
		||||
	else if (flags & FL_SIGN)
 | 
			
		||||
		*s2++ = '+';
 | 
			
		||||
	else if (flags & FL_SPACE)
 | 
			
		||||
| 
						 | 
				
			
			@ -102,78 +116,97 @@ _gcvt(long double value, int ndigit, char *s, int flags)
 | 
			
		|||
		for (i = nndigit - 1; i > 0 && s1[i] == '0'; i--)
 | 
			
		||||
			nndigit--;
 | 
			
		||||
 | 
			
		||||
	if (USE_EXP(dp,ndigit))	{
 | 
			
		||||
	if (USE_EXP(dp, ndigit))
 | 
			
		||||
	{
 | 
			
		||||
		/* Use E format */
 | 
			
		||||
		dp--;
 | 
			
		||||
		*s2++ = *s1++;
 | 
			
		||||
		if ((nndigit > 1) || (flags & FL_ALT)) *s2++ = '.';
 | 
			
		||||
		while (--nndigit > 0) *s2++ = *s1++;
 | 
			
		||||
		if ((nndigit > 1) || (flags & FL_ALT))
 | 
			
		||||
			*s2++ = '.';
 | 
			
		||||
		while (--nndigit > 0)
 | 
			
		||||
			*s2++ = *s1++;
 | 
			
		||||
		*s2++ = 'e';
 | 
			
		||||
		if (dp < 0) {
 | 
			
		||||
		if (dp < 0)
 | 
			
		||||
		{
 | 
			
		||||
			*s2++ = '-';
 | 
			
		||||
			dp = -dp;
 | 
			
		||||
		}
 | 
			
		||||
		else	 *s2++ = '+';
 | 
			
		||||
		else
 | 
			
		||||
			*s2++ = '+';
 | 
			
		||||
		s2 += NDIGINEXP(dp);
 | 
			
		||||
		*s2 = 0;
 | 
			
		||||
		for (i = NDIGINEXP(dp); i > 0; i--) {
 | 
			
		||||
		for (i = NDIGINEXP(dp); i > 0; i--)
 | 
			
		||||
		{
 | 
			
		||||
			*--s2 = dp % 10 + '0';
 | 
			
		||||
			dp /= 10;
 | 
			
		||||
		}
 | 
			
		||||
		return s;
 | 
			
		||||
	}
 | 
			
		||||
	/* Use f format */
 | 
			
		||||
	if (dp <= 0) {
 | 
			
		||||
		if (*s1 != '0')	{
 | 
			
		||||
	if (dp <= 0)
 | 
			
		||||
	{
 | 
			
		||||
		if (*s1 != '0')
 | 
			
		||||
		{
 | 
			
		||||
			/* otherwise the whole number is 0 */
 | 
			
		||||
			*s2++ = '0';
 | 
			
		||||
			*s2++ = '.';
 | 
			
		||||
		}
 | 
			
		||||
		while (dp < 0) {
 | 
			
		||||
		while (dp < 0)
 | 
			
		||||
		{
 | 
			
		||||
			dp++;
 | 
			
		||||
			*s2++ = '0';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	for (i = 1; i <= nndigit; i++) {
 | 
			
		||||
	for (i = 1; i <= nndigit; i++)
 | 
			
		||||
	{
 | 
			
		||||
		*s2++ = *s1++;
 | 
			
		||||
		if (i == dp) *s2++ = '.';
 | 
			
		||||
		if (i == dp)
 | 
			
		||||
			*s2++ = '.';
 | 
			
		||||
	}
 | 
			
		||||
	if (i <= dp) {
 | 
			
		||||
		while (i++ <= dp) *s2++ = '0';
 | 
			
		||||
	if (i <= dp)
 | 
			
		||||
	{
 | 
			
		||||
		while (i++ <= dp)
 | 
			
		||||
			*s2++ = '0';
 | 
			
		||||
		*s2++ = '.';
 | 
			
		||||
	}
 | 
			
		||||
	if ((s2[-1]=='.') && !(flags & FL_ALT)) s2--;
 | 
			
		||||
	if ((s2[-1] == '.') && !(flags & FL_ALT))
 | 
			
		||||
		s2--;
 | 
			
		||||
	*s2 = '\0';
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
_f_print(va_list *ap, int flags, char *s, char c, int precision)
 | 
			
		||||
char* _f_print(va_list* ap, int flags, char* s, char c, int precision)
 | 
			
		||||
{
 | 
			
		||||
	register char *old_s = s;
 | 
			
		||||
	register char* old_s = s;
 | 
			
		||||
	long double ld_val;
 | 
			
		||||
 | 
			
		||||
	if (flags & FL_LONGDOUBLE) ld_val = va_arg(*ap, long double);
 | 
			
		||||
	else ld_val = (long double) va_arg(*ap, double);
 | 
			
		||||
	if (flags & FL_LONGDOUBLE)
 | 
			
		||||
		ld_val = va_arg(*ap, long double);
 | 
			
		||||
	else
 | 
			
		||||
		ld_val = (long double)va_arg(*ap, double);
 | 
			
		||||
 | 
			
		||||
	switch(c) {
 | 
			
		||||
	case 'f':
 | 
			
		||||
		s = _pfloat(ld_val, s, precision, flags);
 | 
			
		||||
		break;
 | 
			
		||||
	case 'e':
 | 
			
		||||
	case 'E':
 | 
			
		||||
		s = _pscien(ld_val, s, precision , flags);
 | 
			
		||||
		break;
 | 
			
		||||
	case 'g':
 | 
			
		||||
	case 'G':
 | 
			
		||||
		s = _gcvt(ld_val, precision, s, flags);
 | 
			
		||||
		s += strlen(s);
 | 
			
		||||
		break;
 | 
			
		||||
	switch (c)
 | 
			
		||||
	{
 | 
			
		||||
		case 'f':
 | 
			
		||||
			s = _pfloat(ld_val, s, precision, flags);
 | 
			
		||||
			break;
 | 
			
		||||
		case 'e':
 | 
			
		||||
		case 'E':
 | 
			
		||||
			s = _pscien(ld_val, s, precision, flags);
 | 
			
		||||
			break;
 | 
			
		||||
		case 'g':
 | 
			
		||||
		case 'G':
 | 
			
		||||
			s = _gcvt(ld_val, precision, s, flags);
 | 
			
		||||
			s += strlen(s);
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	if ( c == 'E' || c == 'G') {
 | 
			
		||||
		while (*old_s && *old_s != 'e') old_s++;
 | 
			
		||||
		if (*old_s == 'e') *old_s = 'E';
 | 
			
		||||
	if (c == 'E' || c == 'G')
 | 
			
		||||
	{
 | 
			
		||||
		while (*old_s && *old_s != 'e')
 | 
			
		||||
			old_s++;
 | 
			
		||||
		if (*old_s == 'e')
 | 
			
		||||
			*old_s = 'E';
 | 
			
		||||
	}
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
#endif	/* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
#endif /* ACKCONF_NO_STDIO_FLOAT */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,107 +11,136 @@
 | 
			
		|||
extern void (*_clean)(void);
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
do_write(int d, char *buf, int nbytes)
 | 
			
		||||
do_write(int d, char* buf, int nbytes)
 | 
			
		||||
{
 | 
			
		||||
	int c;
 | 
			
		||||
 | 
			
		||||
	/* POSIX actually allows write() to return a positive value less
 | 
			
		||||
	   than nbytes, so loop ...
 | 
			
		||||
	*/
 | 
			
		||||
	while ((c = write(d, buf, nbytes)) > 0 && c < nbytes) {
 | 
			
		||||
	while ((c = write(d, buf, nbytes)) > 0 && c < nbytes)
 | 
			
		||||
	{
 | 
			
		||||
		nbytes -= c;
 | 
			
		||||
		buf += c;
 | 
			
		||||
	}
 | 
			
		||||
	return c > 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
__flushbuf(int c, FILE * stream)
 | 
			
		||||
int __flushbuf(int c, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	_clean = __cleanup;
 | 
			
		||||
	if (fileno(stream) < 0) return EOF;
 | 
			
		||||
	if (!io_testflag(stream, _IOWRITE)) return EOF;
 | 
			
		||||
	if (io_testflag(stream, _IOREADING) && !feof(stream)) return EOF;
 | 
			
		||||
	if (fileno(stream) < 0)
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (!io_testflag(stream, _IOWRITE))
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (io_testflag(stream, _IOREADING) && !feof(stream))
 | 
			
		||||
		return EOF;
 | 
			
		||||
 | 
			
		||||
	stream->_flags &= ~_IOREADING;
 | 
			
		||||
	stream->_flags |= _IOWRITING;
 | 
			
		||||
	if (!io_testflag(stream, _IONBF)) {
 | 
			
		||||
		if (!stream->_buf) {
 | 
			
		||||
			if (stream == stdout && isatty(fileno(stdout))) {
 | 
			
		||||
				if (!(stream->_buf =
 | 
			
		||||
					    (unsigned char *) malloc(BUFSIZ))) {
 | 
			
		||||
	if (!io_testflag(stream, _IONBF))
 | 
			
		||||
	{
 | 
			
		||||
		if (!stream->_buf)
 | 
			
		||||
		{
 | 
			
		||||
			if (stream == stdout && isatty(fileno(stdout)))
 | 
			
		||||
			{
 | 
			
		||||
				if (!(stream->_buf = (unsigned char*)malloc(BUFSIZ)))
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IONBF;
 | 
			
		||||
				} else {
 | 
			
		||||
					stream->_flags |= _IOLBF|_IOMYBUF;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IOLBF | _IOMYBUF;
 | 
			
		||||
					stream->_bufsiz = BUFSIZ;
 | 
			
		||||
					stream->_count = -1;
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				if (!(stream->_buf =
 | 
			
		||||
					    (unsigned char *) malloc(BUFSIZ))) {
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if (!(stream->_buf = (unsigned char*)malloc(BUFSIZ)))
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IONBF;
 | 
			
		||||
				} else {
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IOMYBUF;
 | 
			
		||||
					stream->_bufsiz = BUFSIZ;
 | 
			
		||||
					if (!io_testflag(stream, _IOLBF))
 | 
			
		||||
						stream->_count = BUFSIZ - 1;
 | 
			
		||||
					else	stream->_count = -1;
 | 
			
		||||
					else
 | 
			
		||||
						stream->_count = -1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			stream->_ptr = stream->_buf;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (io_testflag(stream, _IONBF)) {
 | 
			
		||||
	if (io_testflag(stream, _IONBF))
 | 
			
		||||
	{
 | 
			
		||||
		char c1 = c;
 | 
			
		||||
 | 
			
		||||
		stream->_count = 0;
 | 
			
		||||
		if (io_testflag(stream, _IOAPPEND)) {
 | 
			
		||||
			if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
 | 
			
		||||
		if (io_testflag(stream, _IOAPPEND))
 | 
			
		||||
		{
 | 
			
		||||
			if (lseek(fileno(stream), 0L, SEEK_END) == -1)
 | 
			
		||||
			{
 | 
			
		||||
				stream->_flags |= _IOERR;
 | 
			
		||||
				return EOF;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (write(fileno(stream), &c1, 1) != 1) {
 | 
			
		||||
		if (write(fileno(stream), &c1, 1) != 1)
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IOERR;
 | 
			
		||||
			return EOF;
 | 
			
		||||
		}
 | 
			
		||||
		return (unsigned char) c;
 | 
			
		||||
	} else if (io_testflag(stream, _IOLBF)) {
 | 
			
		||||
		return (unsigned char)c;
 | 
			
		||||
	}
 | 
			
		||||
	else if (io_testflag(stream, _IOLBF))
 | 
			
		||||
	{
 | 
			
		||||
		*stream->_ptr++ = c;
 | 
			
		||||
		/* stream->_count has been updated in putc macro. */
 | 
			
		||||
		if (c == '\n' || stream->_count == -stream->_bufsiz) {
 | 
			
		||||
		if (c == '\n' || stream->_count == -stream->_bufsiz)
 | 
			
		||||
		{
 | 
			
		||||
			int count = -stream->_count;
 | 
			
		||||
 | 
			
		||||
			stream->_ptr  = stream->_buf;
 | 
			
		||||
			stream->_ptr = stream->_buf;
 | 
			
		||||
			stream->_count = 0;
 | 
			
		||||
 | 
			
		||||
			if (io_testflag(stream, _IOAPPEND)) {
 | 
			
		||||
				if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
 | 
			
		||||
			if (io_testflag(stream, _IOAPPEND))
 | 
			
		||||
			{
 | 
			
		||||
				if (lseek(fileno(stream), 0L, SEEK_END) == -1)
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IOERR;
 | 
			
		||||
					return EOF;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (! do_write(fileno(stream), (char *)stream->_buf,
 | 
			
		||||
					count)) {
 | 
			
		||||
			if (!do_write(fileno(stream), (char*)stream->_buf,
 | 
			
		||||
			        count))
 | 
			
		||||
			{
 | 
			
		||||
				stream->_flags |= _IOERR;
 | 
			
		||||
				return EOF;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		int count = stream->_ptr - stream->_buf;
 | 
			
		||||
 | 
			
		||||
		stream->_count = stream->_bufsiz - 1;
 | 
			
		||||
		stream->_ptr = stream->_buf + 1;
 | 
			
		||||
 | 
			
		||||
		if (count > 0) {
 | 
			
		||||
			if (io_testflag(stream, _IOAPPEND)) {
 | 
			
		||||
				if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
 | 
			
		||||
		if (count > 0)
 | 
			
		||||
		{
 | 
			
		||||
			if (io_testflag(stream, _IOAPPEND))
 | 
			
		||||
			{
 | 
			
		||||
				if (lseek(fileno(stream), 0L, SEEK_END) == -1)
 | 
			
		||||
				{
 | 
			
		||||
					stream->_flags |= _IOERR;
 | 
			
		||||
					return EOF;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (! do_write(fileno(stream), (char *)stream->_buf, count)) {
 | 
			
		||||
			if (!do_write(fileno(stream), (char*)stream->_buf, count))
 | 
			
		||||
			{
 | 
			
		||||
				*(stream->_buf) = c;
 | 
			
		||||
				stream->_flags |= _IOERR;
 | 
			
		||||
				return EOF;
 | 
			
		||||
| 
						 | 
				
			
			@ -119,5 +148,5 @@ __flushbuf(int c, FILE * stream)
 | 
			
		|||
		}
 | 
			
		||||
		*(stream->_buf) = c;
 | 
			
		||||
	}
 | 
			
		||||
	return (unsigned char) c;
 | 
			
		||||
	return (unsigned char)c;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
#define	PMODE		0666
 | 
			
		||||
#define PMODE 0666
 | 
			
		||||
 | 
			
		||||
/* Since the O_CREAT flag is not available on all systems, we can't get it
 | 
			
		||||
 * from the standard library. Furthermore, even if we know that <fcntl.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -31,48 +31,50 @@
 | 
			
		|||
 * Remember to fix freopen.c if changing this.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE *
 | 
			
		||||
fopen(const char *name, const char *mode)
 | 
			
		||||
FILE* fopen(const char* name, const char* mode)
 | 
			
		||||
{
 | 
			
		||||
	register int i;
 | 
			
		||||
	int rwmode = 0, rwflags = 0;
 | 
			
		||||
	FILE *stream;
 | 
			
		||||
	FILE* stream;
 | 
			
		||||
	int fd, flags = 0;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; __iotab[i] != 0 ; i++) 
 | 
			
		||||
		if ( i >= FOPEN_MAX-1 )
 | 
			
		||||
			return (FILE *)NULL;
 | 
			
		||||
	for (i = 0; __iotab[i] != 0; i++)
 | 
			
		||||
		if (i >= FOPEN_MAX - 1)
 | 
			
		||||
			return (FILE*)NULL;
 | 
			
		||||
 | 
			
		||||
	switch(*mode++) {
 | 
			
		||||
	case 'r':
 | 
			
		||||
		flags |= _IOREAD | _IOREADING;	
 | 
			
		||||
		rwmode = O_RDONLY;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'w':
 | 
			
		||||
		flags |= _IOWRITE | _IOWRITING;
 | 
			
		||||
		rwmode = O_WRONLY;
 | 
			
		||||
		rwflags = O_CREAT | O_TRUNC;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'a': 
 | 
			
		||||
		flags |= _IOWRITE | _IOWRITING | _IOAPPEND;
 | 
			
		||||
		rwmode = O_WRONLY;
 | 
			
		||||
		rwflags |= O_APPEND | O_CREAT;
 | 
			
		||||
		break;         
 | 
			
		||||
	default:
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
	switch (*mode++)
 | 
			
		||||
	{
 | 
			
		||||
		case 'r':
 | 
			
		||||
			flags |= _IOREAD | _IOREADING;
 | 
			
		||||
			rwmode = O_RDONLY;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'w':
 | 
			
		||||
			flags |= _IOWRITE | _IOWRITING;
 | 
			
		||||
			rwmode = O_WRONLY;
 | 
			
		||||
			rwflags = O_CREAT | O_TRUNC;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'a':
 | 
			
		||||
			flags |= _IOWRITE | _IOWRITING | _IOAPPEND;
 | 
			
		||||
			rwmode = O_WRONLY;
 | 
			
		||||
			rwflags |= O_APPEND | O_CREAT;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (*mode) {
 | 
			
		||||
		switch(*mode++) {
 | 
			
		||||
		case 'b':
 | 
			
		||||
			continue;
 | 
			
		||||
		case '+':
 | 
			
		||||
			rwmode = O_RDWR;
 | 
			
		||||
			flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
			continue;
 | 
			
		||||
		/* The sequence may be followed by additional characters */
 | 
			
		||||
		default:
 | 
			
		||||
			break;
 | 
			
		||||
	while (*mode)
 | 
			
		||||
	{
 | 
			
		||||
		switch (*mode++)
 | 
			
		||||
		{
 | 
			
		||||
			case 'b':
 | 
			
		||||
				continue;
 | 
			
		||||
			case '+':
 | 
			
		||||
				rwmode = O_RDWR;
 | 
			
		||||
				flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
				continue;
 | 
			
		||||
			/* The sequence may be followed by additional characters */
 | 
			
		||||
			default:
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -82,22 +84,25 @@ fopen(const char *name, const char *mode)
 | 
			
		|||
	 */
 | 
			
		||||
	if ((rwflags & O_TRUNC)
 | 
			
		||||
	    || (((fd = open(name, rwmode)) < 0)
 | 
			
		||||
		    && (rwflags & O_CREAT))) {
 | 
			
		||||
		if (((fd = creat(name, PMODE)) > 0) && flags  | _IOREAD) {
 | 
			
		||||
			(void) close(fd);
 | 
			
		||||
	           && (rwflags & O_CREAT)))
 | 
			
		||||
	{
 | 
			
		||||
		if (((fd = creat(name, PMODE)) > 0) && flags | _IOREAD)
 | 
			
		||||
		{
 | 
			
		||||
			(void)close(fd);
 | 
			
		||||
			fd = open(name, rwmode);
 | 
			
		||||
		}
 | 
			
		||||
			
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (fd < 0) return (FILE *)NULL;
 | 
			
		||||
	if (fd < 0)
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
 | 
			
		||||
	if (( stream = (FILE *) malloc(sizeof(FILE))) == NULL ) {
 | 
			
		||||
	if ((stream = (FILE*)malloc(sizeof(FILE))) == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		close(fd);
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((flags & (_IOREAD | _IOWRITE))  == (_IOREAD | _IOWRITE))
 | 
			
		||||
	if ((flags & (_IOREAD | _IOWRITE)) == (_IOREAD | _IOWRITE))
 | 
			
		||||
		flags &= ~(_IOREADING | _IOWRITING);
 | 
			
		||||
 | 
			
		||||
	stream->_count = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,19 +3,18 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fprintf(FILE *stream, const char *format, ...)
 | 
			
		||||
int fprintf(FILE* stream, const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	va_start(ap, format);
 | 
			
		||||
 | 
			
		||||
	retval = _doprnt (format, ap, stream);
 | 
			
		||||
	retval = _doprnt(format, ap, stream);
 | 
			
		||||
 | 
			
		||||
	va_end(ap);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fputc(int c, FILE *stream)
 | 
			
		||||
int fputc(int c, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return putc(c, stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,16 +3,17 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fputs(register const char *s, register FILE *stream)
 | 
			
		||||
int fputs(register const char* s, register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register int i = 0;
 | 
			
		||||
 | 
			
		||||
	while (*s) 
 | 
			
		||||
		if (putc(*s++, stream) == EOF) return EOF;
 | 
			
		||||
		else i++;
 | 
			
		||||
	while (*s)
 | 
			
		||||
		if (putc(*s++, stream) == EOF)
 | 
			
		||||
			return EOF;
 | 
			
		||||
		else
 | 
			
		||||
			i++;
 | 
			
		||||
 | 
			
		||||
	return i;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,20 +3,22 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
fread(void *ptr, size_t size, size_t nmemb, register FILE *stream)
 | 
			
		||||
fread(void* ptr, size_t size, size_t nmemb, register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register char *cp = ptr;
 | 
			
		||||
	register char* cp = ptr;
 | 
			
		||||
	register int c;
 | 
			
		||||
	size_t ndone = 0;
 | 
			
		||||
	register size_t s;
 | 
			
		||||
 | 
			
		||||
	if (size)
 | 
			
		||||
		while ( ndone < nmemb ) {
 | 
			
		||||
		while (ndone < nmemb)
 | 
			
		||||
		{
 | 
			
		||||
			s = size;
 | 
			
		||||
			do {
 | 
			
		||||
			do
 | 
			
		||||
			{
 | 
			
		||||
				if ((c = getc(stream)) != EOF)
 | 
			
		||||
					*cp++ = c;
 | 
			
		||||
				else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,75 +9,82 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
#define	PMODE		0666
 | 
			
		||||
#define PMODE 0666
 | 
			
		||||
 | 
			
		||||
/* Do not "optimize" this file to use the open with O_CREAT if the file
 | 
			
		||||
 * does not exist. The reason is given in fopen.c.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FILE *
 | 
			
		||||
freopen(const char *name, const char *mode, FILE *stream)
 | 
			
		||||
FILE* freopen(const char* name, const char* mode, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register int i;
 | 
			
		||||
	int rwmode = 0, rwflags = 0;
 | 
			
		||||
	int fd, flags = stream->_flags & (_IONBF | _IOFBF | _IOLBF | _IOMYBUF);
 | 
			
		||||
 | 
			
		||||
	(void) fflush(stream);				/* ignore errors */
 | 
			
		||||
	(void) close(fileno(stream));
 | 
			
		||||
	(void)fflush(stream); /* ignore errors */
 | 
			
		||||
	(void)close(fileno(stream));
 | 
			
		||||
 | 
			
		||||
	switch(*mode++) {
 | 
			
		||||
	case 'r':
 | 
			
		||||
		flags |= _IOREAD;	
 | 
			
		||||
		rwmode = O_RDONLY;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'w':
 | 
			
		||||
		flags |= _IOWRITE;
 | 
			
		||||
		rwmode = O_WRONLY;
 | 
			
		||||
		rwflags = O_CREAT | O_TRUNC;
 | 
			
		||||
		break;
 | 
			
		||||
	case 'a': 
 | 
			
		||||
		flags |= _IOWRITE | _IOAPPEND;
 | 
			
		||||
		rwmode = O_WRONLY;
 | 
			
		||||
		rwflags |= O_APPEND | O_CREAT;
 | 
			
		||||
		break;         
 | 
			
		||||
	default:
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
	switch (*mode++)
 | 
			
		||||
	{
 | 
			
		||||
		case 'r':
 | 
			
		||||
			flags |= _IOREAD;
 | 
			
		||||
			rwmode = O_RDONLY;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'w':
 | 
			
		||||
			flags |= _IOWRITE;
 | 
			
		||||
			rwmode = O_WRONLY;
 | 
			
		||||
			rwflags = O_CREAT | O_TRUNC;
 | 
			
		||||
			break;
 | 
			
		||||
		case 'a':
 | 
			
		||||
			flags |= _IOWRITE | _IOAPPEND;
 | 
			
		||||
			rwmode = O_WRONLY;
 | 
			
		||||
			rwflags |= O_APPEND | O_CREAT;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (*mode) {
 | 
			
		||||
		switch(*mode++) {
 | 
			
		||||
		case 'b':
 | 
			
		||||
			continue;
 | 
			
		||||
		case '+':
 | 
			
		||||
			rwmode = O_RDWR;
 | 
			
		||||
			flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
			continue;
 | 
			
		||||
		/* The sequence may be followed by aditional characters */
 | 
			
		||||
		default:
 | 
			
		||||
			break;
 | 
			
		||||
	while (*mode)
 | 
			
		||||
	{
 | 
			
		||||
		switch (*mode++)
 | 
			
		||||
		{
 | 
			
		||||
			case 'b':
 | 
			
		||||
				continue;
 | 
			
		||||
			case '+':
 | 
			
		||||
				rwmode = O_RDWR;
 | 
			
		||||
				flags |= _IOREAD | _IOWRITE;
 | 
			
		||||
				continue;
 | 
			
		||||
			/* The sequence may be followed by aditional characters */
 | 
			
		||||
			default:
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((rwflags & O_TRUNC)
 | 
			
		||||
	    || (((fd = open(name, rwmode)) < 0)
 | 
			
		||||
		    && (rwflags & O_CREAT))) {
 | 
			
		||||
		if (((fd = creat(name, PMODE)) < 0) && flags | _IOREAD) {
 | 
			
		||||
			(void) close(fd);
 | 
			
		||||
	           && (rwflags & O_CREAT)))
 | 
			
		||||
	{
 | 
			
		||||
		if (((fd = creat(name, PMODE)) < 0) && flags | _IOREAD)
 | 
			
		||||
		{
 | 
			
		||||
			(void)close(fd);
 | 
			
		||||
			fd = open(name, rwmode);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (fd < 0) {
 | 
			
		||||
		for( i = 0; i < FOPEN_MAX; i++) {
 | 
			
		||||
			if (stream == __iotab[i]) {
 | 
			
		||||
	if (fd < 0)
 | 
			
		||||
	{
 | 
			
		||||
		for (i = 0; i < FOPEN_MAX; i++)
 | 
			
		||||
		{
 | 
			
		||||
			if (stream == __iotab[i])
 | 
			
		||||
			{
 | 
			
		||||
				__iotab[i] = 0;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (stream != stdin && stream != stdout && stream != stderr)
 | 
			
		||||
			free((void *)stream);
 | 
			
		||||
		return (FILE *)NULL;
 | 
			
		||||
			free((void*)stream);
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	stream->_count = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fscanf(FILE *stream, const char *format, ...)
 | 
			
		||||
int fscanf(FILE* stream, const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,8 +8,7 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fseek(FILE *stream, long int offset, int whence)
 | 
			
		||||
int fseek(FILE* stream, long int offset, int whence)
 | 
			
		||||
{
 | 
			
		||||
	int adjust = 0;
 | 
			
		||||
	long pos;
 | 
			
		||||
| 
						 | 
				
			
			@ -17,16 +16,20 @@ fseek(FILE *stream, long int offset, int whence)
 | 
			
		|||
	stream->_flags &= ~(_IOEOF | _IOERR);
 | 
			
		||||
	/* Clear both the end of file and error flags */
 | 
			
		||||
 | 
			
		||||
	if (io_testflag(stream, _IOREADING)) {
 | 
			
		||||
	if (io_testflag(stream, _IOREADING))
 | 
			
		||||
	{
 | 
			
		||||
		if (whence == SEEK_CUR
 | 
			
		||||
		    && stream->_buf
 | 
			
		||||
		    && !io_testflag(stream,_IONBF))
 | 
			
		||||
		    && !io_testflag(stream, _IONBF))
 | 
			
		||||
			adjust = stream->_count;
 | 
			
		||||
		stream->_count = 0;
 | 
			
		||||
	} else if (io_testflag(stream,_IOWRITING)) {
 | 
			
		||||
	}
 | 
			
		||||
	else if (io_testflag(stream, _IOWRITING))
 | 
			
		||||
	{
 | 
			
		||||
		fflush(stream);
 | 
			
		||||
	} else	/* neither reading nor writing. The buffer must be empty */
 | 
			
		||||
		/* EMPTY */ ;
 | 
			
		||||
	}
 | 
			
		||||
	else /* neither reading nor writing. The buffer must be empty */
 | 
			
		||||
		/* EMPTY */;
 | 
			
		||||
 | 
			
		||||
	pos = lseek(fileno(stream), offset - adjust, whence);
 | 
			
		||||
	if (io_testflag(stream, _IOREAD) && io_testflag(stream, _IOWRITE))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fsetpos(FILE *stream, fpos_t *pos)
 | 
			
		||||
int fsetpos(FILE* stream, fpos_t* pos)
 | 
			
		||||
{
 | 
			
		||||
	return fseek(stream, *pos, SEEK_SET);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,26 +6,27 @@
 | 
			
		|||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
long ftell(FILE *stream)
 | 
			
		||||
long ftell(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	long result;
 | 
			
		||||
	int adjust = 0;
 | 
			
		||||
 | 
			
		||||
	if (io_testflag(stream,_IOREADING))
 | 
			
		||||
	if (io_testflag(stream, _IOREADING))
 | 
			
		||||
		adjust = -stream->_count;
 | 
			
		||||
	else if (io_testflag(stream,_IOWRITING)
 | 
			
		||||
		    && stream->_buf
 | 
			
		||||
		    && !io_testflag(stream,_IONBF))
 | 
			
		||||
	else if (io_testflag(stream, _IOWRITING)
 | 
			
		||||
	    && stream->_buf
 | 
			
		||||
	    && !io_testflag(stream, _IONBF))
 | 
			
		||||
		adjust = stream->_ptr - stream->_buf;
 | 
			
		||||
	else adjust = 0;
 | 
			
		||||
	else
 | 
			
		||||
		adjust = 0;
 | 
			
		||||
 | 
			
		||||
	result = lseek(fileno(stream), 0, SEEK_CUR);
 | 
			
		||||
 | 
			
		||||
	if ( result == -1 )
 | 
			
		||||
	if (result == -1)
 | 
			
		||||
		return result;
 | 
			
		||||
 | 
			
		||||
	result += (long) adjust;
 | 
			
		||||
	result += (long)adjust;
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,26 +3,27 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
size_t
 | 
			
		||||
fwrite(const void *ptr, size_t size, size_t nmemb,
 | 
			
		||||
	    register FILE *stream)
 | 
			
		||||
fwrite(const void* ptr, size_t size, size_t nmemb,
 | 
			
		||||
    register FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	register const unsigned char *cp = ptr;
 | 
			
		||||
	register const unsigned char* cp = ptr;
 | 
			
		||||
	register size_t s;
 | 
			
		||||
	size_t ndone = 0;
 | 
			
		||||
 | 
			
		||||
	if (size)
 | 
			
		||||
		while ( ndone < nmemb ) {
 | 
			
		||||
		while (ndone < nmemb)
 | 
			
		||||
		{
 | 
			
		||||
			s = size;
 | 
			
		||||
			do {
 | 
			
		||||
			do
 | 
			
		||||
			{
 | 
			
		||||
				if (putc((int)*cp, stream)
 | 
			
		||||
					== EOF)
 | 
			
		||||
				    == EOF)
 | 
			
		||||
					return ndone;
 | 
			
		||||
				cp++;
 | 
			
		||||
			} 
 | 
			
		||||
			while (--s);
 | 
			
		||||
			} while (--s);
 | 
			
		||||
			ndone++;
 | 
			
		||||
		}
 | 
			
		||||
	return ndone;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(getc)(FILE *stream)
 | 
			
		||||
int(getc)(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return getc(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(getchar)(void)
 | 
			
		||||
int(getchar)(void)
 | 
			
		||||
{
 | 
			
		||||
	return getchar();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,23 +3,27 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
gets(char *s)
 | 
			
		||||
char* gets(char* s)
 | 
			
		||||
{
 | 
			
		||||
	register FILE *stream = stdin;
 | 
			
		||||
	register FILE* stream = stdin;
 | 
			
		||||
	register int ch;
 | 
			
		||||
	register char *ptr;
 | 
			
		||||
	register char* ptr;
 | 
			
		||||
 | 
			
		||||
	ptr = s;
 | 
			
		||||
	while ((ch = getc(stream)) != EOF && ch != '\n')
 | 
			
		||||
		*ptr++ = ch;
 | 
			
		||||
 | 
			
		||||
	if (ch == EOF) {
 | 
			
		||||
		if (feof(stream)) {
 | 
			
		||||
			if (ptr == s) return NULL;
 | 
			
		||||
		} else return NULL;
 | 
			
		||||
	if (ch == EOF)
 | 
			
		||||
	{
 | 
			
		||||
		if (feof(stream))
 | 
			
		||||
		{
 | 
			
		||||
			if (ptr == s)
 | 
			
		||||
				return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*ptr = '\0';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,19 +3,18 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
/* This routine is used in doprnt.c as well as in tmpfile.c and tmpnam.c. */
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
_i_compute(unsigned long val, int base, char *s, int nrdigits)
 | 
			
		||||
char* _i_compute(unsigned long val, int base, char* s, int nrdigits)
 | 
			
		||||
{
 | 
			
		||||
	int c;
 | 
			
		||||
 | 
			
		||||
	c= val % base ;
 | 
			
		||||
	val /= base ;
 | 
			
		||||
	c = val % base;
 | 
			
		||||
	val /= base;
 | 
			
		||||
	if (val || nrdigits > 1)
 | 
			
		||||
		s = _i_compute(val, base, s, nrdigits - 1);
 | 
			
		||||
	*s++ = (c>9 ? c-10+'a' : c+'0');
 | 
			
		||||
	*s++ = (c > 9 ? c - 10 + 'a' : c + '0');
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,11 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
int _gtty(int d, char *buf);
 | 
			
		||||
int _gtty(int d, char* buf);
 | 
			
		||||
 | 
			
		||||
int _isatty(int d)
 | 
			
		||||
{
 | 
			
		||||
	char buf[128]; 
 | 
			
		||||
	char buf[128];
 | 
			
		||||
	/* not a sgttyb struct; it might not be large enough;
 | 
			
		||||
	   I know for a fact that it isn't large enough on PC/IX,
 | 
			
		||||
	   where gtty is an ioctl(..., TCGETA, ...)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,17 +3,17 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<errno.h>
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
perror(const char *s)
 | 
			
		||||
void perror(const char* s)
 | 
			
		||||
{
 | 
			
		||||
	if (s && *s) {
 | 
			
		||||
		(void) fputs(s, stderr);
 | 
			
		||||
		(void) fputs(": ", stderr);
 | 
			
		||||
	if (s && *s)
 | 
			
		||||
	{
 | 
			
		||||
		(void)fputs(s, stderr);
 | 
			
		||||
		(void)fputs(": ", stderr);
 | 
			
		||||
	}
 | 
			
		||||
	(void) fputs(strerror(errno), stderr);
 | 
			
		||||
	(void) fputs("\n", stderr);
 | 
			
		||||
	(void)fputs(strerror(errno), stderr);
 | 
			
		||||
	(void)fputs("\n", stderr);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
printf(const char *format, ...)
 | 
			
		||||
int printf(const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(putc)(int c, FILE *stream)
 | 
			
		||||
int(putc)(int c, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	return putc(c, stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,10 +3,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
(putchar)(int c)
 | 
			
		||||
int(putchar)(int c)
 | 
			
		||||
{
 | 
			
		||||
	return putchar(c);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,18 +3,21 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
puts(register const char *s)
 | 
			
		||||
int puts(register const char* s)
 | 
			
		||||
{
 | 
			
		||||
	register FILE *file = stdout;
 | 
			
		||||
	register FILE* file = stdout;
 | 
			
		||||
	register int i = 0;
 | 
			
		||||
 | 
			
		||||
	while (*s) {
 | 
			
		||||
		if (putc(*s++, file) == EOF) return EOF;
 | 
			
		||||
		else i++;
 | 
			
		||||
	while (*s)
 | 
			
		||||
	{
 | 
			
		||||
		if (putc(*s++, file) == EOF)
 | 
			
		||||
			return EOF;
 | 
			
		||||
		else
 | 
			
		||||
			i++;
 | 
			
		||||
	}
 | 
			
		||||
	if (putc('\n', file) == EOF) return EOF;
 | 
			
		||||
	if (putc('\n', file) == EOF)
 | 
			
		||||
		return EOF;
 | 
			
		||||
	return i + 1;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
remove(const char *filename) {
 | 
			
		||||
int remove(const char* filename)
 | 
			
		||||
{
 | 
			
		||||
	return unlink(filename);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
rewind(FILE *stream)
 | 
			
		||||
void rewind(FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	(void) fseek(stream, 0L, SEEK_SET);
 | 
			
		||||
	(void)fseek(stream, 0L, SEEK_SET);
 | 
			
		||||
	clearerr(stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
scanf(const char *format, ...)
 | 
			
		||||
int scanf(const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,5 +20,3 @@ scanf(const char *format, ...)
 | 
			
		|||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,11 +3,10 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
setbuf(register FILE *stream, char *buf)
 | 
			
		||||
void setbuf(register FILE* stream, char* buf)
 | 
			
		||||
{
 | 
			
		||||
	(void) setvbuf(stream, buf, (buf ? _IOFBF : _IONBF), (size_t) BUFSIZ);
 | 
			
		||||
	(void)setvbuf(stream, buf, (buf ? _IOFBF : _IONBF), (size_t)BUFSIZ);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,14 +3,13 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
extern void (*_clean)(void);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
setvbuf(register FILE *stream, char *buf, int mode, size_t size)
 | 
			
		||||
int setvbuf(register FILE* stream, char* buf, int mode, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	int retval = 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,29 +17,37 @@ setvbuf(register FILE *stream, char *buf, int mode, size_t size)
 | 
			
		|||
	if (mode != _IOFBF && mode != _IOLBF && mode != _IONBF)
 | 
			
		||||
		return EOF;
 | 
			
		||||
 | 
			
		||||
	if (stream->_buf && io_testflag(stream,_IOMYBUF) )
 | 
			
		||||
		free((void *)stream->_buf);
 | 
			
		||||
	if (stream->_buf && io_testflag(stream, _IOMYBUF))
 | 
			
		||||
		free((void*)stream->_buf);
 | 
			
		||||
 | 
			
		||||
	stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF);
 | 
			
		||||
 | 
			
		||||
	if (buf && size <= 0) retval = EOF;
 | 
			
		||||
	if (!buf && (mode != _IONBF)) {
 | 
			
		||||
		if (size <= 0 || (buf = (char *) malloc(size)) == NULL) {
 | 
			
		||||
	if (buf && size <= 0)
 | 
			
		||||
		retval = EOF;
 | 
			
		||||
	if (!buf && (mode != _IONBF))
 | 
			
		||||
	{
 | 
			
		||||
		if (size <= 0 || (buf = (char*)malloc(size)) == NULL)
 | 
			
		||||
		{
 | 
			
		||||
			retval = EOF;
 | 
			
		||||
		} else {
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			stream->_flags |= _IOMYBUF;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	stream->_buf = (unsigned char *) buf;
 | 
			
		||||
	stream->_buf = (unsigned char*)buf;
 | 
			
		||||
 | 
			
		||||
	stream->_count = 0;
 | 
			
		||||
	stream->_flags |= mode;
 | 
			
		||||
	stream->_ptr = stream->_buf;
 | 
			
		||||
 | 
			
		||||
	if (!buf) {
 | 
			
		||||
	if (!buf)
 | 
			
		||||
	{
 | 
			
		||||
		stream->_bufsiz = 1;
 | 
			
		||||
	} else {
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		stream->_bufsiz = size;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
snprintf(char * s, size_t len, const char *format, ...)
 | 
			
		||||
int snprintf(char* s, size_t len, const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			@ -16,14 +15,14 @@ snprintf(char * s, size_t len, const char *format, ...)
 | 
			
		|||
 | 
			
		||||
	va_start(ap, format);
 | 
			
		||||
 | 
			
		||||
	tmp_stream._fd     = -1;
 | 
			
		||||
	tmp_stream._flags  = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._ptr    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._count  = len;
 | 
			
		||||
	tmp_stream._fd = -1;
 | 
			
		||||
	tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._ptr = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._count = len;
 | 
			
		||||
 | 
			
		||||
	retval = _doprnt(format, ap, &tmp_stream);
 | 
			
		||||
	putc('\0',&tmp_stream);
 | 
			
		||||
	putc('\0', &tmp_stream);
 | 
			
		||||
 | 
			
		||||
	va_end(ap);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
sprintf(char * s, const char *format, ...)
 | 
			
		||||
int sprintf(char* s, const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			@ -16,14 +15,14 @@ sprintf(char * s, const char *format, ...)
 | 
			
		|||
 | 
			
		||||
	va_start(ap, format);
 | 
			
		||||
 | 
			
		||||
	tmp_stream._fd     = -1;
 | 
			
		||||
	tmp_stream._flags  = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._ptr    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._count  = 32767;
 | 
			
		||||
	tmp_stream._fd = -1;
 | 
			
		||||
	tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._ptr = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._count = 32767;
 | 
			
		||||
 | 
			
		||||
	retval = _doprnt(format, ap, &tmp_stream);
 | 
			
		||||
	putc('\0',&tmp_stream);
 | 
			
		||||
	putc('\0', &tmp_stream);
 | 
			
		||||
 | 
			
		||||
	va_end(ap);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,12 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	<string.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int sscanf(const char *s, const char *format, ...)
 | 
			
		||||
int sscanf(const char* s, const char* format, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list ap;
 | 
			
		||||
	int retval;
 | 
			
		||||
| 
						 | 
				
			
			@ -16,11 +16,11 @@ int sscanf(const char *s, const char *format, ...)
 | 
			
		|||
 | 
			
		||||
	va_start(ap, format);
 | 
			
		||||
 | 
			
		||||
	tmp_stream._fd     = -1;
 | 
			
		||||
	tmp_stream._flags  = _IOREAD + _IONBF + _IOREADING;
 | 
			
		||||
	tmp_stream._buf    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._ptr    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._count  = strlen(s);
 | 
			
		||||
	tmp_stream._fd = -1;
 | 
			
		||||
	tmp_stream._flags = _IOREAD + _IONBF + _IOREADING;
 | 
			
		||||
	tmp_stream._buf = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._ptr = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._count = strlen(s);
 | 
			
		||||
 | 
			
		||||
	retval = _doscan(&tmp_stream, format, ap);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,20 +9,22 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
FILE *
 | 
			
		||||
tmpfile(void) {
 | 
			
		||||
	static char name_buffer[L_tmpnam] = "/tmp/tmp." ;
 | 
			
		||||
	static char *name = NULL;
 | 
			
		||||
	FILE *file;
 | 
			
		||||
FILE* tmpfile(void)
 | 
			
		||||
{
 | 
			
		||||
	static char name_buffer[L_tmpnam] = "/tmp/tmp.";
 | 
			
		||||
	static char* name = NULL;
 | 
			
		||||
	FILE* file;
 | 
			
		||||
 | 
			
		||||
	if (!name) {
 | 
			
		||||
	if (!name)
 | 
			
		||||
	{
 | 
			
		||||
		name = name_buffer + strlen(name_buffer);
 | 
			
		||||
		name = _i_compute(getpid(), 10, name, 5);
 | 
			
		||||
		*name = '\0';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	file = fopen(name_buffer,"wb+");
 | 
			
		||||
	if (!file) return (FILE *)NULL;
 | 
			
		||||
	(void) remove(name_buffer);
 | 
			
		||||
	file = fopen(name_buffer, "wb+");
 | 
			
		||||
	if (!file)
 | 
			
		||||
		return (FILE*)NULL;
 | 
			
		||||
	(void)remove(name_buffer);
 | 
			
		||||
	return file;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,20 +9,24 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
tmpnam(char *s) {
 | 
			
		||||
char* tmpnam(char* s)
 | 
			
		||||
{
 | 
			
		||||
	static char name_buffer[L_tmpnam] = "/tmp/tmp.";
 | 
			
		||||
	static unsigned long count = 0;
 | 
			
		||||
	static char *name = NULL;
 | 
			
		||||
	static char* name = NULL;
 | 
			
		||||
 | 
			
		||||
	if (!name) { 
 | 
			
		||||
	if (!name)
 | 
			
		||||
	{
 | 
			
		||||
		name = name_buffer + strlen(name_buffer);
 | 
			
		||||
		name = _i_compute(getpid(), 10, name, 5);
 | 
			
		||||
		*name++ = '.';
 | 
			
		||||
		*name = '\0';
 | 
			
		||||
	}
 | 
			
		||||
	if (++count > TMP_MAX) count = 1;	/* wrap-around */
 | 
			
		||||
	if (++count > TMP_MAX)
 | 
			
		||||
		count = 1; /* wrap-around */
 | 
			
		||||
	*_i_compute(count, 10, name, 3) = '\0';
 | 
			
		||||
	if (s) return strcpy(s, name_buffer);
 | 
			
		||||
	else return name_buffer;
 | 
			
		||||
	if (s)
 | 
			
		||||
		return strcpy(s, name_buffer);
 | 
			
		||||
	else
 | 
			
		||||
		return name_buffer;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,24 +3,25 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
ungetc(int ch, FILE *stream)
 | 
			
		||||
int ungetc(int ch, FILE* stream)
 | 
			
		||||
{
 | 
			
		||||
	unsigned char *p;
 | 
			
		||||
	unsigned char* p;
 | 
			
		||||
 | 
			
		||||
	if (ch == EOF  || !io_testflag(stream,_IOREADING))
 | 
			
		||||
	if (ch == EOF || !io_testflag(stream, _IOREADING))
 | 
			
		||||
		return EOF;
 | 
			
		||||
	if (stream->_ptr == stream->_buf) {
 | 
			
		||||
		if (stream->_count != 0) return EOF;
 | 
			
		||||
	if (stream->_ptr == stream->_buf)
 | 
			
		||||
	{
 | 
			
		||||
		if (stream->_count != 0)
 | 
			
		||||
			return EOF;
 | 
			
		||||
		stream->_ptr++;
 | 
			
		||||
	}
 | 
			
		||||
	stream->_count++;
 | 
			
		||||
	p = --(stream->_ptr);		/* ??? Bloody vax assembler !!! */
 | 
			
		||||
	p = --(stream->_ptr); /* ??? Bloody vax assembler !!! */
 | 
			
		||||
	/* ungetc() in sscanf() shouldn't write in rom */
 | 
			
		||||
	if (*p != (unsigned char) ch)
 | 
			
		||||
		*p = (unsigned char) ch;
 | 
			
		||||
	if (*p != (unsigned char)ch)
 | 
			
		||||
		*p = (unsigned char)ch;
 | 
			
		||||
	return ch;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vfprintf(FILE *stream, const char *format, va_list arg)
 | 
			
		||||
int vfprintf(FILE* stream, const char* format, va_list arg)
 | 
			
		||||
{
 | 
			
		||||
	return _doprnt (format, arg, stream);
 | 
			
		||||
	return _doprnt(format, arg, stream);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,12 +3,11 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vprintf(const char *format, va_list arg)
 | 
			
		||||
int vprintf(const char* format, va_list arg)
 | 
			
		||||
{
 | 
			
		||||
	return _doprnt(format, arg, stdout);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,24 +3,23 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vsnprintf(char *s, size_t len, const char *format, va_list arg)
 | 
			
		||||
int vsnprintf(char* s, size_t len, const char* format, va_list arg)
 | 
			
		||||
{
 | 
			
		||||
	int retval;
 | 
			
		||||
	FILE tmp_stream;
 | 
			
		||||
 | 
			
		||||
	tmp_stream._fd     = -1;
 | 
			
		||||
	tmp_stream._flags  = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._ptr    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._count  = len;
 | 
			
		||||
	tmp_stream._fd = -1;
 | 
			
		||||
	tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._ptr = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._count = len;
 | 
			
		||||
 | 
			
		||||
	retval = _doprnt(format, arg, &tmp_stream);
 | 
			
		||||
	putc('\0',&tmp_stream);
 | 
			
		||||
	putc('\0', &tmp_stream);
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,24 +3,23 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdio.h>
 | 
			
		||||
#include	<stdarg.h>
 | 
			
		||||
#include	"loc_incl.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "loc_incl.h"
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
vsprintf(char *s, const char *format, va_list arg)
 | 
			
		||||
int vsprintf(char* s, const char* format, va_list arg)
 | 
			
		||||
{
 | 
			
		||||
	int retval;
 | 
			
		||||
	FILE tmp_stream;
 | 
			
		||||
 | 
			
		||||
	tmp_stream._fd     = -1;
 | 
			
		||||
	tmp_stream._flags  = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._ptr    = (unsigned char *) s;
 | 
			
		||||
	tmp_stream._count  = 32767;
 | 
			
		||||
	tmp_stream._fd = -1;
 | 
			
		||||
	tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
 | 
			
		||||
	tmp_stream._buf = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._ptr = (unsigned char*)s;
 | 
			
		||||
	tmp_stream._count = 32767;
 | 
			
		||||
 | 
			
		||||
	retval = _doprnt(format, arg, &tmp_stream);
 | 
			
		||||
	putc('\0',&tmp_stream);
 | 
			
		||||
	putc('\0', &tmp_stream);
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,18 +4,17 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#if	defined(_POSIX_SOURCE)
 | 
			
		||||
#include	<sys/types.h>
 | 
			
		||||
#if defined(_POSIX_SOURCE)
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include	<signal.h>
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
extern void (*_clean)(void);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
abort(void)
 | 
			
		||||
void abort(void)
 | 
			
		||||
{
 | 
			
		||||
	if (_clean) _clean();		/* flush all output files */
 | 
			
		||||
	if (_clean)
 | 
			
		||||
		_clean(); /* flush all output files */
 | 
			
		||||
	raise(SIGABRT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,10 +4,9 @@
 | 
			
		|||
 */
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
 | 
			
		||||
#include	<stdlib.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
abs(register int i)
 | 
			
		||||
int abs(register int i)
 | 
			
		||||
{
 | 
			
		||||
	return i >= 0 ? i : -i;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		
		Reference in a new issue