8000 Convert DOS newlines to Unix newlines. · postgrespro/postgres_cluster@e9a028f · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e9a028f

Browse files
committed
Convert DOS newlines to Unix newlines.
1 parent 7146eb0 commit e9a028f

File tree

9 files changed

+4751
-4753
lines changed

9 files changed

+4751
-4753
lines changed

src/timezone/asctime.c

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
#include "pgtz.h"
2-
/*
3-
** This file is in the public domain, so clarified as of
4-
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
5-
*/
6-
7-
#ifndef lint
8-
#ifndef NOID
9-
static char elsieid[] = "@(#)asctime.c 7.9";
10-
#endif /* !defined NOID */
11-
#endif /* !defined lint */
12-
13-
/*LINTLIBRARY*/
14-
15-
#include "private.h"
16-
#include "tzfile.h"
17-
18-
/*
19-
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
20-
*/
21-
22-
char *
23-
asctime_r(timeptr, buf)
24-
register const struct tm * timeptr;
25-
char * buf;
26-
{
27-
static const char wday_name[][3] = {
28-
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
29-
};
30-
static const char mon_name[][3] = {
31-
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
32-
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
33-
};
34-
register const char * wn;
35-
register const char * mn;
36-
37-
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
38-
wn = "???";
39-
else wn = wday_name[timeptr->tm_wday];
40-
if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR)
41-
mn = "???";
42-
else mn = mon_name[timeptr->tm_mon];
43-
/*
44-
** The X3J11-suggested format is
45-
** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
46-
** Since the .2 in 02.2d is ignored, we drop it.
47-
*/
48-
(void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
49-
wn, mn,
50-
timeptr->tm_mday, timeptr->tm_hour,
51-
timeptr->tm_min, timeptr->tm_sec,
52-
TM_YEAR_BASE + timeptr->tm_year);
53-
return buf;
54-
}
55-
56-
/*
57-
** A la X3J11, with core dump avoidance.
58-
*/
59-
60-
char *
61-
asctime(timeptr)
62-
register const struct tm * timeptr;
63-
{
64-
/*
65-
** Big enough for something such as
66-
** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
67-
** (two three-character abbreviations, five strings denoting integers,
68-
** three explicit spaces, two explicit colons, a newline,
69-
** and a trailing ASCII nul).
70-
*/
71-
static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
72-
3 + 2 + 1 + 1];
73-
74-
return asctime_r(timeptr, result);
75-
}
1+
#include "pgtz.h"
2+
/*
3+
** This file is in the public domain, so clarified as of
4+
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
5+
*/
6+
7+
#ifndef lint
8+
#ifndef NOID
9+
static char elsieid[] = "@(#)asctime.c 7.9";
10+
#endif /* !defined NOID */
11+
#endif /* !defined lint */
12+
13+
/*LINTLIBRARY*/
14+
15+
#include "private.h"
16+
#include "tzfile.h"
17+
18+
/*
19+
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
20+
*/
21+
22+
char *
23+
asctime_r(timeptr, buf)
24+
register const struct tm * timeptr;
25+
char * buf;
26+
{
27+
static const char wday_name[][3] = {
28+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
29+
};
30+
static const char mon_name[][3] = {
31+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
32+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
33+
};
34+
register const char * wn;
35+
register const char * mn;
36+
37+
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
38+
wn = "???";
39+
else wn = wday_name[timeptr->tm_wday];
40+
if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR)
41+
mn = "???";
42+
else mn = mon_name[timeptr->tm_mon];
43+
/*
44+
** The X3J11-suggested format is
45+
** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
46+
** Since the .2 in 02.2d is ignored, we drop it.
47+
*/
48+
(void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
49+
wn, mn,
50+
timeptr->tm_mday, timeptr->tm_hour,
51+
timeptr->tm_min, timeptr->tm_sec,
52+
TM_YEAR_BASE + timeptr->tm_year);
53+
return buf;
54+
}
55+
56+
/*
57+
** A la X3J11, with core dump avoidance.
58+
*/
59+
60+
char *
61+
asctime(timeptr)
62+
register const struct tm * timeptr;
63+
{
64+
/*
65+
** Big enough for something such as
66+
** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
67+
** (two three-character abbreviations, five strings denoting integers,
68+
** three explicit spaces, two explicit colons, a newline,
69+
** and a trailing ASCII nul).
70+
*/
71+
static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
72+
3 + 2 + 1 + 1];
73+
74+
return asctime_r(timeptr, result);
75+
}

src/timezone/difftime.c

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
1-
#include "pgtz.h"
2-
/*
3-
** This file is in the public domain, so clarified as of
4-
** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
5-
*/
6-
7-
#ifndef lint
8-
#ifndef NOID
9-
static char elsieid[] = "@(#)difftime.c 7.9";
10-
#endif /* !defined NOID */
11-
#endif /* !defined lint */
12-
13-
/*LINTLIBRARY*/
14-
15-
#include "private.h"
16-
17-
/*
18-
** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
19-
*/
20-
21-
#ifdef HAVE_LONG_DOUBLE
22-
#define long_double long double
23-
#endif /* defined HAVE_LONG_DOUBLE */
24-
#ifndef HAVE_LONG_DOUBLE
25-
#define long_double double
26-
#endif /* !defined HAVE_LONG_DOUBLE */
27-
28-
double
29-
difftime(time1, time0)
30-
const time_t time1;
31-
const time_t time0;
32-
{
33-
time_t delta;
34-
time_t hibit;
35-
36-
{
37-
time_t tt;
38-
double d;
39-
long_double ld;
40-
41-
if (sizeof tt < sizeof d)
42-
return (double) time1 - (double) time0;
43-
if (sizeof tt < sizeof ld)
44-
return (long_double) time1 - (long_double) time0;
45-
}
46-
if (time1 < time0)
47-
return -difftime(time0, time1);
48-
/*
49-
** As much as possible, avoid loss of precision
50-
** by computing the difference before converting to double.
51-
*/
52-
delta = time1 - time0;
53-
if (delta >= 0)
54-
return delta;
55-
/*
56-
** Repair delta overflow.
57-
*/
58-
hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
59-
/*
60-
** The following expression rounds twice, which means
61-
** the result may not be the closest to the true answer.
62-
** For example, suppose time_t is 64-bit signed int,
63-
** long_double is IEEE 754 double with default rounding,
64-
** time1 = 9223372036854775807 and time0 = -1536.
65-
** Then the true difference is 9223372036854777343,
66-
** which rounds to 9223372036854777856
67-
** with a total error of 513.
68-
** But delta overflows to -9223372036854774273,
69-
** which rounds to -9223372036854774784, and correcting
70-
** this by subtracting 2 * (long_double) hibit
71-
** (i.e. by adding 2**64 = 18446744073709551616)
72-
** yields 9223372036854776832, which
73-
** rounds to 9223372036854775808
74-
** with a total error of 1535 instead.
75-
** This problem occurs only with very large differences.
76-
** It's too painful to fix this portably.
77-
** We are not alone in this problem;
78-
** some C compilers round twice when converting
79-
** large unsigned types to small floating types,
80-
** so if time_t is unsigned the "return delta" above
81-
** has the same double-rounding problem with those compilers.
82-
*/
83-
return delta - 2 * (long_double) hibit;
84-
}
1+
#include "pgtz.h"
2+
/*
3+
** This file is in the public domain, so clarified as of
4+
** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
5+
*/
6+
7+
#ifndef lint
8+
#ifndef NOID
9+
static char elsieid[] = "@(#)difftime.c 7.9";
10+
#endif /* !defined NOID */
11+
#endif /* !defined lint */
12+
13+
/*LINTLIBRARY*/
14+
15+
#include "private.h"
16+
17+
/*
18+
** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
19+
*/
20+
21+
#ifdef HAVE_LONG_DOUBLE
22+
#define long_double long double
23+
#endif /* defined HAVE_LONG_DOUBLE */
24+
#ifndef HAVE_LONG_DOUBLE
25+
#define long_double double
26+
#endif /* !defined HAVE_LONG_DOUBLE */
27+
28+
double
29+
difftime(time1, time0)
30+
const time_t time1;
31+
const time_t time0;
32+
{
33+
time_t delta;
34+
time_t hibit;
35+
36+
{
37+
time_t tt;
38+
double d;
39+
long_double ld;
40+
41+
if (sizeof tt < sizeof d)
42+
return (double) time1 - (double) time0;
43+
if (sizeof tt < sizeof ld)
44+
return (long_double) time1 - (long_double) time0;
45+
}
46+
if (time1 < time0)
47+
return -difftime(time0, time1);
48+
/*
49+
** As much as possible, avoid loss of precision
50+
** by computing the difference before converting to double.
51+
*/
52+
delta = time1 - time0;
53+
if (delta >= 0)
54+
return delta;
55+
/*
56+
** Repair delta overflow.
57+
*/
58+
hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
59+
/*
60+
** The following expression rounds twice, which means
61+
** the result may not be the closest to the true answer.
62+
** For example, suppose time_t is 64-bit signed int,
63+
** long_double is IEEE 754 double with default rounding,
64+
** time1 = 9223372036854775807 and time0 = -1536.
65+
** Then the true difference is 9223372036854777343,
66+
** which rounds to 9223372036854777856
67+
** with a total error of 513.
68+
** But delta overflows to -9223372036854774273,
69+
** which rounds to -9223372036854774784, and correcting
70+
** this by subtracting 2 * (long_double) hibit
71+
** (i.e. by adding 2**64 = 18446744073709551616)
72+
** yields 9223372036854776832, which
73+
** rounds to 9223372036854775808
74+
** with a total error of 1535 instead.
75+
** This problem occurs only with very large differences.
76+
** It's too painful to fix this portably.
77+
** We are not alone in this problem;
78+
** some C compilers round twice when converting
79+
** large unsigned types to small floating types,
80+
** so if time_t is unsigned the "return delta" above
81+
** has the same double-rounding problem with those compilers.
82+
*/
83+
return delta - 2 * (long_double) hibit;
84+
}

0 commit comments

Comments
 (0)
0