* Added gcvt() implementation - this fixes bug #1757.
* Added gcvt(), ecvt(), and fcvt() prototypes to stdlib.h - they are all marked legacy, but are still part of the POSIX standard, so we might want to implement them if the need arises. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23896 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b2b8943d50
commit
392eb518d5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2002-2008, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _STDLIB_H_
|
||||
@ -66,6 +66,11 @@ extern int system(const char *command);
|
||||
extern char *mktemp(char *name);
|
||||
extern int mkstemp(char *templat);
|
||||
|
||||
extern char *ecvt(double value, int digits, int *_decimalPoint, int *_sign);
|
||||
extern char *fcvt(double value, int precision, int *_decimalPoint,
|
||||
int *_sign);
|
||||
extern char *gcvt(double value, int digits, char *buffer);
|
||||
|
||||
/* environment variables */
|
||||
extern char **environ;
|
||||
extern char *getenv(const char *name);
|
||||
@ -131,11 +136,16 @@ typedef int (*_compare_function)(const void *, const void *);
|
||||
|
||||
extern void *bsearch(const void *key, const void *base, size_t numElements,
|
||||
size_t sizeOfElement, _compare_function);
|
||||
extern int heapsort(void *base, size_t numElements, size_t sizeOfElement, _compare_function);
|
||||
extern int mergesort(void *base, size_t numElements, size_t sizeOfElement, _compare_function);
|
||||
extern void qsort(void *base, size_t numElements, size_t sizeOfElement, _compare_function);
|
||||
extern int radixsort(u_char const **base, int numElements, u_char const *table, u_int endByte);
|
||||
extern int sradixsort(u_char const **base, int numElements, u_char const *table, u_int endByte);
|
||||
extern int heapsort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern int mergesort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern void qsort(void *base, size_t numElements, size_t sizeOfElement,
|
||||
_compare_function);
|
||||
extern int radixsort(u_char const **base, int numElements,
|
||||
u_char const *table, u_int endByte);
|
||||
extern int sradixsort(u_char const **base, int numElements,
|
||||
u_char const *table, u_int endByte);
|
||||
|
||||
/* misc math functions */
|
||||
extern int abs(int number);
|
||||
|
@ -12,6 +12,7 @@ MergeObject posix_stdlib.o :
|
||||
div.c
|
||||
env.c
|
||||
exit.c
|
||||
gcvt.c
|
||||
heapsort.c
|
||||
merge.c
|
||||
mktemp.c
|
||||
|
18
src/system/libroot/posix/stdlib/gcvt.c
Normal file
18
src/system/libroot/posix/stdlib/gcvt.c
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
char *
|
||||
gcvt(double value, int digits, char *buffer)
|
||||
{
|
||||
sprintf(buffer, "%.*g", digits, value);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
// TODO: eventually add ecvt(), and fcvt() as well, if needed.
|
Loading…
Reference in New Issue
Block a user