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

Commitbad5116

Browse files
committed
Const-ify a couple of datetime parsing subroutines.
More could be done in this line, but I just grabbed some low-hangingfruit. Principal objective was to remove the need for several uglyunconstify() usages in formatting.c.
1 parentccff2d2 commitbad5116

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

‎src/backend/utils/adt/datetime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,7 @@ DecodeNumberField(int len, char *str, int fmask,
31453145
* Return 0 if okay (and set *tzp), a DTERR code if not okay.
31463146
*/
31473147
int
3148-
DecodeTimezone(char*str,int*tzp)
3148+
DecodeTimezone(constchar*str,int*tzp)
31493149
{
31503150
inttz;
31513151
inthr,
@@ -3223,7 +3223,7 @@ DecodeTimezone(char *str, int *tzp)
32233223
*will be related in format.
32243224
*/
32253225
int
3226-
DecodeTimezoneAbbrev(intfield,char*lowtoken,
3226+
DecodeTimezoneAbbrev(intfield,constchar*lowtoken,
32273227
int*offset,pg_tz**tz)
32283228
{
32293229
inttype;
@@ -3278,7 +3278,7 @@ DecodeTimezoneAbbrev(int field, char *lowtoken,
32783278
*will be related in format.
32793279
*/
32803280
int
3281-
DecodeSpecial(intfield,char*lowtoken,int*val)
3281+
DecodeSpecial(intfield,constchar*lowtoken,int*val)
32823282
{
32833283
inttype;
32843284
constdatetkn*tp;
@@ -3985,7 +3985,7 @@ DecodeISO8601Interval(char *str,
39853985
*will be related in format.
39863986
*/
39873987
int
3988-
DecodeUnits(intfield,char*lowtoken,int*val)
3988+
DecodeUnits(intfield,constchar*lowtoken,int*val)
39893989
{
39903990
inttype;
39913991
constdatetkn*tp;

‎src/backend/utils/adt/formatting.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,7 +4246,7 @@ to_timestamp(PG_FUNCTION_ARGS)
42464246
/* Use the specified time zone, if any. */
42474247
if (tm.tm_zone)
42484248
{
4249-
intdterr=DecodeTimezone(unconstify(char*,tm.tm_zone),&tz);
4249+
intdterr=DecodeTimezone(tm.tm_zone,&tz);
42504250

42514251
if (dterr)
42524252
DateTimeParseError(dterr,text_to_cstring(date_txt),"timestamptz");
@@ -4343,7 +4343,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
43434343

43444344
if (tm.tm_zone)
43454345
{
4346-
intdterr=DecodeTimezone(unconstify(char*,tm.tm_zone),tz);
4346+
intdterr=DecodeTimezone(tm.tm_zone,tz);
43474347

43484348
if (dterr)
43494349
DateTimeParseError(dterr,text_to_cstring(date_txt),"timestamptz");
@@ -4429,7 +4429,7 @@ parse_datetime(text *date_txt, text *fmt, Oid collid, bool strict,
44294429

44304430
if (tm.tm_zone)
44314431
{
4432-
intdterr=DecodeTimezone(unconstify(char*,tm.tm_zone),tz);
4432+
intdterr=DecodeTimezone(tm.tm_zone,tz);
44334433

44344434
if (dterr)
44354435
RETURN_ERROR(DateTimeParseError(dterr,text_to_cstring(date_txt),"timetz"));

‎src/include/utils/datetime.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ extern intParseDateTime(const char *timestr, char *workbuf, size_t buflen,
296296
externintDecodeDateTime(char**field,int*ftype,
297297
intnf,int*dtype,
298298
structpg_tm*tm,fsec_t*fsec,int*tzp);
299-
externintDecodeTimezone(char*str,int*tzp);
299+
externintDecodeTimezone(constchar*str,int*tzp);
300300
externintDecodeTimeOnly(char**field,int*ftype,
301301
intnf,int*dtype,
302302
structpg_tm*tm,fsec_t*fsec,int*tzp);
@@ -322,10 +322,10 @@ extern void EncodeSpecialTimestamp(Timestamp dt, char *str);
322322
externintValidateDate(intfmask,boolisjulian,boolis2digits,boolbc,
323323
structpg_tm*tm);
324324

325-
externintDecodeTimezoneAbbrev(intfield,char*lowtoken,
325+
externintDecodeTimezoneAbbrev(intfield,constchar*lowtoken,
326326
int*offset,pg_tz**tz);
327-
externintDecodeSpecial(intfield,char*lowtoken,int*val);
328-
externintDecodeUnits(intfield,char*lowtoken,int*val);
327+
externintDecodeSpecial(intfield,constchar*lowtoken,int*val);
328+
externintDecodeUnits(intfield,constchar*lowtoken,int*val);
329329

330330
externintj2day(intdate);
331331

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp