Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitfefe703

Browse files
author
Michael Meskes
committed
More cleaning up and removed some duplicates.
1 parent34dc9ab commitfefe703

File tree

13 files changed

+164
-456
lines changed

13 files changed

+164
-456
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,5 +2225,9 @@ Tue, 14 Aug 2007 11:46:51 +0200
22252225
- Use '$n' for positional variables, '?' is still possible via ecpg
22262226
option.
22272227
- Cleaned up the sources a little bit.
2228+
2229+
Wed, 22 Aug 2007 08:41:33 +0200
2230+
2231+
- More cleaning up and removed some duplicates.
22282232
- Set ecpg library version to 6.0.
22292233
- Set ecpg version to 4.4.

‎src/interfaces/ecpg/pgtypeslib/dt.h

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.37 2007/08/14 10:01:53 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.38 2007/08/22 08:20:58 meskes Exp $ */
22

33
#ifndefDT_H
44
#defineDT_H
@@ -310,31 +310,24 @@ do { \
310310
#defineTIMESTAMP_IS_NOEND(j)((j) == DT_NOEND)
311311
#defineTIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
312312

313-
intDecodeTimeOnly(char**field,int*ftype,
314-
intnf,int*dtype,
315-
structtm*tm,fsec_t*fsec,int*tzp);
316-
317-
intDecodeInterval(char**field,int*ftype,
318-
intnf,int*dtype,
319-
structtm*tm,fsec_t*fsec);
320-
321-
intEncodeTimeOnly(structtm*tm,fsec_tfsec,int*tzp,intstyle,char*str);
322-
intEncodeDateTime(structtm*tm,fsec_tfsec,int*tzp,char**tzn,intstyle,char*str,bool);
323-
intEncodeInterval(structtm*tm,fsec_tfsec,intstyle,char*str);
324-
325-
inttm2timestamp(structtm*,fsec_t,int*,timestamp*);
326-
327-
intDecodeUnits(intfield,char*lowtoken,int*val);
328-
329-
boolCheckDateTokenTables(void);
330-
331-
intEncodeDateOnly(structtm*,int,char*,bool);
332-
voidGetEpochTime(structtm*);
333-
intParseDateTime(char*,char*,char**,int*,int,int*,char**);
334-
intDecodeDateTime(char**,int*,int,int*,structtm*,fsec_t*,bool);
335-
voidj2date(int,int*,int*,int*);
336-
voidGetCurrentDateTime(structtm*);
337-
intdate2j(int,int,int);
313+
intDecodeTimeOnly(char**,int*,int,int*,structtm*,fsec_t*,int*);
314+
intDecodeInterval(char**,int*,int,int*,structtm*,fsec_t*);
315+
intDecodeTime(char*,int,int*,structtm*,fsec_t*);
316+
intEncodeTimeOnly(structtm*,fsec_t,int*,int,char*);
317+
intEncodeDateTime(structtm*,fsec_t,int*,char**,int,char*,bool);
318+
intEncodeInterval(structtm*,fsec_t,int,char*);
319+
inttm2timestamp(structtm*,fsec_t,int*,timestamp*);
320+
intDecodeUnits(intfield,char*lowtoken,int*val);
321+
boolCheckDateTokenTables(void);
322+
intEncodeDateOnly(structtm*,int,char*,bool);
323+
voidGetEpochTime(structtm*);
324+
intParseDateTime(char*,char*,char**,int*,int,int*,char**);
325+
intDecodeDateTime(char**,int*,int,int*,structtm*,fsec_t*,bool);
326+
voidj2date(int,int*,int*,int*);
327+
voidGetCurrentDateTime(structtm*);
328+
intdate2j(int,int,int);
329+
voidTrimTrailingZeros(char*);
330+
voiddt2time(double,int*,int*,int*,fsec_t*);
338331

339332
externchar*pgtypes_date_weekdays_short[];
340333
externchar*pgtypes_date_months[];

‎src/interfaces/ecpg/pgtypeslib/dt_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.41 2007/08/14 10:01:53 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.42 2007/08/22 08:20:58 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -743,7 +743,7 @@ EncodeDateOnly(struct tm * tm, int style, char *str, bool EuroDates)
743743
return TRUE;
744744
}/* EncodeDateOnly() */
745745

746-
staticvoid
746+
void
747747
TrimTrailingZeros(char*str)
748748
{
749749
intlen=strlen(str);
@@ -1090,7 +1090,7 @@ GetCurrentDateTime(struct tm * tm)
10901090
abstime2tm(time(NULL),&tz,tm,NULL);
10911091
}
10921092

1093-
staticvoid
1093+
void
10941094
dt2time(doublejd,int*hour,int*min,int*sec,fsec_t*fsec)
10951095
{
10961096
#ifdefHAVE_INT64_TIMESTAMP
@@ -1469,7 +1469,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm, bool EuroDates)
14691469
* Only check the lower limit on hours, since this same code
14701470
*can be used to represent time spans.
14711471
*/
1472-
staticint
1472+
int
14731473
DecodeTime(char*str,intfmask,int*tmask,structtm*tm,fsec_t*fsec)
14741474
{
14751475
char*cp;

‎src/interfaces/ecpg/pgtypeslib/interval.c

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.37 2007/08/22 08:20:58 meskes Exp $ */
22

33
#include"postgres_fe.h"
44
#include<time.h>
@@ -13,90 +13,6 @@
1313
#include"pgtypes_error.h"
1414
#include"pgtypes_interval.h"
1515

16-
/* TrimTrailingZeros()
17-
* ... resulting from printing numbers with full precision.
18-
*/
19-
staticvoid
20-
TrimTrailingZeros(char*str)
21-
{
22-
intlen=strlen(str);
23-
24-
/* chop off trailing zeros... but leave at least 2 fractional digits */
25-
while (*(str+len-1)=='0'&&*(str+len-3)!='.')
26-
{
27-
len--;
28-
*(str+len)='\0';
29-
}
30-
}
31-
32-
/* DecodeTime()
33-
* Decode time string which includes delimiters.
34-
* Only check the lower limit on hours, since this same code
35-
*can be used to represent time spans.
36-
*/
37-
staticint
38-
DecodeTime(char*str,intfmask,int*tmask,structtm*tm,fsec_t*fsec)
39-
{
40-
char*cp;
41-
42-
*tmask=DTK_TIME_M;
43-
44-
tm->tm_hour=strtol(str,&cp,10);
45-
if (*cp!=':')
46-
return-1;
47-
str=cp+1;
48-
tm->tm_min=strtol(str,&cp,10);
49-
if (*cp=='\0')
50-
{
51-
tm->tm_sec=0;
52-
*fsec=0;
53-
}
54-
elseif (*cp!=':')
55-
return-1;
56-
else
57-
{
58-
str=cp+1;
59-
tm->tm_sec=strtol(str,&cp,10);
60-
if (*cp=='\0')
61-
*fsec=0;
62-
elseif (*cp=='.')
63-
{
64-
#ifdefHAVE_INT64_TIMESTAMP
65-
charfstr[MAXDATELEN+1];
66-
67-
/*
68-
* OK, we have at most six digits to work with. Let's construct a
69-
* string and then do the conversion to an integer.
70-
*/
71-
strncpy(fstr, (cp+1),7);
72-
strcpy(fstr+strlen(fstr),"000000");
73-
*(fstr+6)='\0';
74-
*fsec=strtol(fstr,&cp,10);
75-
#else
76-
str=cp;
77-
*fsec=strtod(str,&cp);
78-
#endif
79-
if (*cp!='\0')
80-
return-1;
81-
}
82-
else
83-
return-1;
84-
}
85-
86-
/* do a sanity check */
87-
#ifdefHAVE_INT64_TIMESTAMP
88-
if (tm->tm_hour<0||tm->tm_min<0||tm->tm_min>59||
89-
tm->tm_sec<0||tm->tm_sec>59||*fsec >=USECS_PER_SEC)
90-
return-1;
91-
#else
92-
if (tm->tm_hour<0||tm->tm_min<0||tm->tm_min>59||
93-
tm->tm_sec<0||tm->tm_sec>59||*fsec >=1)
94-
return-1;
95-
#endif
96-
97-
return0;
98-
}/* DecodeTime() */
99-
10016
/* DecodeInterval()
10117
* Interpret previously parsed fields for general time interval.
10218
* Return 0 if decoded and -1 if problems.

‎src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,6 @@ SetEpochTimestamp(void)
9797
returndt;
9898
}/* SetEpochTimestamp() */
9999

100-
staticvoid
101-
dt2time(timestampjd,int*hour,int*min,int*sec,fsec_t*fsec)
102-
{
103-
#ifdefHAVE_INT64_TIMESTAMP
104-
int64time;
105-
#else
106-
doubletime;
107-
#endif
108-
109-
time=jd;
110-
111-
#ifdefHAVE_INT64_TIMESTAMP
112-
*hour=time /USECS_PER_HOUR;
113-
time-= (*hour)*USECS_PER_HOUR;
114-
*min=time /USECS_PER_MINUTE;
115-
time-= (*min)*USECS_PER_MINUTE;
116-
*sec=time /USECS_PER_SEC;
117-
*fsec=time-*sec*USECS_PER_SEC;
118-
*sec=time /USECS_PER_SEC;
119-
*fsec=time-*sec*USECS_PER_SEC;
120-
#else
121-
*hour=time /SECS_PER_HOUR;
122-
time-= (*hour)*SECS_PER_HOUR;
123-
*min=time /SECS_PER_MINUTE;
124-
time-= (*min)*SECS_PER_MINUTE;
125-
*sec=time;
126-
*fsec=time-*sec;
127-
#endif
128-
}/* dt2time() */
129-
130100
/* timestamp2tm()
131101
* Convert timestamp data type to POSIX time structure.
132102
* Note that year is _not_ 1900-based, but is an explicit full value.

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2007, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.127 2007/08/14 10:01:53 meskes Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.128 2007/08/22 08:20:58 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -27,7 +27,7 @@ override CFLAGS += -Wno-error
2727
endif
2828
overrideCFLAGS +=$(PTHREAD_CFLAGS)
2929

30-
OBJS=preproc.o type.o ecpg.oecpg_keywords.ooutput.o parser.o\
30+
OBJS=preproc.o type.o ecpg.o output.o parser.o\
3131
keywords.o c_keywords.o ../ecpglib/typename.o descriptor.o variable.o\
3232
$(WIN32RES)
3333

@@ -57,7 +57,7 @@ else
5757
@$(missing) flex $< $@
5858
endif
5959

60-
c_keywords.oecpg_keywords.okeywords.opreproc.oparser.o: preproc.h
60+
c_keywords.okeywords.opreproc.oparser.o: preproc.h
6161

6262
parser.c:$(top_srcdir)/src/backend/parser/parser.c
6363
rm -f$@&&$(LN_S)$<.

‎src/interfaces/ecpg/preproc/c_keywords.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* keywords.c
44
* lexical token lookup for reserved words in postgres embedded SQL
55
*
6-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.20 2007/05/10 09:53:16 meskes Exp $
6+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.21 2007/08/22 08:20:58 meskes Exp $
77
* §
88
*-------------------------------------------------------------------------
99
*/
@@ -20,7 +20,7 @@
2020
* !!WARNING!!: This list must be sorted, because binary
2121
* search is used to locate entries.
2222
*/
23-
staticScanKeywordScanKeywords[]= {
23+
staticconstScanKeywordScanCKeywords[]= {
2424
/* namevalue*/
2525
{"VARCHAR",VARCHAR},
2626
{"auto",S_AUTO},
@@ -50,25 +50,8 @@ static ScanKeyword ScanKeywords[] = {
5050
{"year",YEAR_P},
5151
};
5252

53-
ScanKeyword*
53+
constScanKeyword*
5454
ScanCKeywordLookup(char*text)
5555
{
56-
ScanKeyword*low=&ScanKeywords[0];
57-
ScanKeyword*high=endof(ScanKeywords)-1;
58-
ScanKeyword*middle;
59-
intdifference;
60-
61-
while (low <=high)
62-
{
63-
middle=low+ (high-low) /2;
64-
difference=strcmp(middle->name,text);
65-
if (difference==0)
66-
returnmiddle;
67-
elseif (difference<0)
68-
low=middle+1;
69-
else
70-
high=middle-1;
71-
}
72-
73-
returnNULL;
56+
returnDoLookup(text,&ScanCKeywords[0],endof(ScanCKeywords)-1);
7457
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp