aboutsummaryrefslogtreecommitdiffstats
path: root/missing
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-22 01:28:00 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-10-22 01:28:00 +0000
commit9c60701e4f39d7039da73e7dd5a36f5edade308a (patch)
tree3475fe7f783e96106c803fca0c28620dd27e9f2f /missing
parent1a61008f18e651ef8848813a34cdebd6d8fd5eba (diff)
downloadruby-9c60701e4f39d7039da73e7dd5a36f5edade308a.tar.gz
* missing.h, missing/*.c: SUSv3 compatible strcasecmp and strncasecmp,
ANSI compatible strtol and strtoul, and ANSI styled other functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing')
-rw-r--r--missing/acosh.c9
-rw-r--r--missing/dup2.c3
-rw-r--r--missing/erf.c12
-rw-r--r--missing/finite.c3
-rw-r--r--missing/hypot.c3
-rw-r--r--missing/isnan.c8
-rw-r--r--missing/strcasecmp.c3
-rw-r--r--missing/strerror.c3
-rw-r--r--missing/strncasecmp.c6
-rw-r--r--missing/strtol.c9
-rw-r--r--missing/strtoul.c14
11 files changed, 27 insertions, 46 deletions
diff --git a/missing/acosh.c b/missing/acosh.c
index a4443e191f..59f4af9248 100644
--- a/missing/acosh.c
+++ b/missing/acosh.c
@@ -33,8 +33,7 @@
#ifndef HAVE_ACOSH
double
-acosh(x)
- double x;
+acosh(double x)
{
if (x < 1)
x = -1; /* NaN */
@@ -50,8 +49,7 @@ acosh(x)
#ifndef HAVE_ASINH
double
-asinh(x)
- double x;
+asinh(double x)
{
int neg = x < 0;
double z = fabs(x);
@@ -74,8 +72,7 @@ asinh(x)
#ifndef HAVE_ATANH
double
-atanh(x)
- double x;
+atanh(double x)
{
int neg = x < 0;
double z = fabs(x);
diff --git a/missing/dup2.c b/missing/dup2.c
index e7cc46f4c1..00d8145976 100644
--- a/missing/dup2.c
+++ b/missing/dup2.c
@@ -24,8 +24,7 @@
#define BADEXIT -1
int
-dup2(fd1, fd2)
-int fd1, fd2;
+dup2(int fd1, int fd2)
{
#if defined(HAVE_FCNTL) && defined(F_DUPFD)
if (fd1 != fd2) {
diff --git a/missing/erf.c b/missing/erf.c
index d9e7469024..fe65b9a479 100644
--- a/missing/erf.c
+++ b/missing/erf.c
@@ -25,8 +25,7 @@ static double q_gamma(double, double, double);
/* Incomplete gamma function
1 / Gamma(a) * Int_0^x exp(-t) t^(a-1) dt */
-static double p_gamma(a, x, loggamma_a)
- double a, x, loggamma_a;
+static double p_gamma(double a, double x, double loggamma_a)
{
int k;
double result, term, previous;
@@ -45,8 +44,7 @@ static double p_gamma(a, x, loggamma_a)
/* Incomplete gamma function
1 / Gamma(a) * Int_x^inf exp(-t) t^(a-1) dt */
-static double q_gamma(a, x, loggamma_a)
- double a, x, loggamma_a;
+static double q_gamma(double a, double x, double loggamma_a)
{
int k;
double result, w, temp, previous;
@@ -69,8 +67,7 @@ static double q_gamma(a, x, loggamma_a)
#define LOG_PI_OVER_2 0.572364942924700087071713675675 /* log_e(PI)/2 */
-double erf(x)
- double x;
+double erf(double x)
{
if (!finite(x)) {
if (isnan(x)) return x; /* erf(NaN) = NaN */
@@ -80,8 +77,7 @@ double erf(x)
else return - p_gamma(0.5, x * x, LOG_PI_OVER_2);
}
-double erfc(x)
- double x;
+double erfc(double x)
{
if (!finite(x)) {
if (isnan(x)) return x; /* erfc(NaN) = NaN */
diff --git a/missing/finite.c b/missing/finite.c
index f91035a8cd..8d0b7af262 100644
--- a/missing/finite.c
+++ b/missing/finite.c
@@ -1,8 +1,7 @@
/* public domain rewrite of finite(3) */
int
-finite(n)
- double n;
+finite(double n)
{
return !isnan(n) && !isinf(n);
}
diff --git a/missing/hypot.c b/missing/hypot.c
index aad5259e92..5a663553cf 100644
--- a/missing/hypot.c
+++ b/missing/hypot.c
@@ -2,8 +2,7 @@
#include <math.h>
-double hypot(x,y)
- double x, y;
+double hypot(double x, double y)
{
if (x < 0) x = -x;
if (y < 0) y = -y;
diff --git a/missing/isnan.c b/missing/isnan.c
index 459048e936..a8733978ad 100644
--- a/missing/isnan.c
+++ b/missing/isnan.c
@@ -1,17 +1,15 @@
/* public domain rewrite of isnan(3) */
-static int double_ne();
+static int double_ne(double n1, double n2);
int
-isnan(n)
- double n;
+isnan(double n)
{
return double_ne(n, n);
}
static int
-double_ne(n1, n2)
- double n1, n2;
+double_ne(double n1, double n2)
{
return n1 != n2;
}
diff --git a/missing/strcasecmp.c b/missing/strcasecmp.c
index fddb8385be..1ce20704c1 100644
--- a/missing/strcasecmp.c
+++ b/missing/strcasecmp.c
@@ -3,8 +3,7 @@
#include <ctype.h>
int
-strcasecmp(p1, p2)
- char *p1, *p2;
+strcasecmp(const char *p1, const char *p2)
{
while (*p1 && *p2) {
if (toupper(*p1) != toupper(*p2))
diff --git a/missing/strerror.c b/missing/strerror.c
index c1bf6feff8..023935a1ff 100644
--- a/missing/strerror.c
+++ b/missing/strerror.c
@@ -6,8 +6,7 @@ extern char *sys_errlist[];
static char msg[50];
char *
-strerror(error)
- int error;
+strerror(int error)
{
if (error <= sys_nerr && error > 0) {
return sys_errlist[error];
diff --git a/missing/strncasecmp.c b/missing/strncasecmp.c
index a4cc5828b8..59d4477a40 100644
--- a/missing/strncasecmp.c
+++ b/missing/strncasecmp.c
@@ -1,12 +1,10 @@
/* public domain rewrite of strncasecmp(3) */
#include <ctype.h>
+#include <stddef.h>
int
-strncasecmp(p1, p2, len)
- char *p1;
- char *p2;
- int len;
+strncasecmp(const char *p1, const char *p2, size_t len)
{
while (len != 0) {
if (toupper(*p1) != toupper(*p2)) {
diff --git a/missing/strtol.c b/missing/strtol.c
index e94aa54ca0..da6636f316 100644
--- a/missing/strtol.c
+++ b/missing/strtol.c
@@ -3,13 +3,10 @@
#include <ctype.h>
long
-strtol(nptr, endptr, base)
- char *nptr;
- char **endptr;
- int base;
+strtol(const char *nptr, char **endptr, int base)
{
long result;
- char *p = nptr;
+ const char *p = nptr;
while (isspace(*p)) {
p++;
@@ -23,7 +20,7 @@ strtol(nptr, endptr, base)
result = strtoul(p, endptr, base);
}
if (endptr != 0 && *endptr == p) {
- *endptr = nptr;
+ *endptr = (char *)nptr;
}
return result;
}
diff --git a/missing/strtoul.c b/missing/strtoul.c
index f16f2ad9cf..4f09f899a1 100644
--- a/missing/strtoul.c
+++ b/missing/strtoul.c
@@ -21,7 +21,7 @@
* (100 for non-digit characters).
*/
-static char cvtIn[] = {
+static const char cvtIn[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */
100, 100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */
@@ -53,22 +53,22 @@ static char cvtIn[] = {
*/
unsigned long int
-strtoul(string, endPtr, base)
- char *string; /* String of ASCII digits, possibly
+strtoul(
+ const char *string, /* String of ASCII digits, possibly
* preceded by white space. For bases
* greater than 10, either lower- or
* upper-case digits may be used.
*/
- char **endPtr; /* Where to store address of terminating
+ char **endPtr, /* Where to store address of terminating
* character, or NULL. */
- int base; /* Base for conversion. Must be less
+ int base) /* Base for conversion. Must be less
* than 37. If 0, then the base is chosen
* from the leading characters of string:
* "0x" means hex, "0" means octal, anything
* else means decimal.
*/
{
- register char *p;
+ register const char *p;
register unsigned long int result = 0;
register unsigned digit;
int anyDigits = 0;
@@ -177,7 +177,7 @@ strtoul(string, endPtr, base)
}
if (endPtr != 0) {
- *endPtr = p;
+ *endPtr = (char *)p;
}
return result;