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

Commita2c1c33

Browse files
author
Michael Meskes
committed
Initialize day of year value.
There are cases where the day of year value in struct tm is used, but it nevergot calculated. Problem found by Coverity scan.
1 parentd9f37e6 commita2c1c33

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, const char **
255255
*tzn=NULL;
256256
}
257257

258+
tm->tm_yday=dDate-date2j(tm->tm_year,1,1)+1;
259+
258260
return0;
259261
}/* timestamp2tm() */
260262

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
147147
free(text);
148148
free(out);
149149

150+
out= (char*)malloc(48);
151+
i=PGTYPEStimestamp_fmt_asc(&ts1,out,47,"Which is day number %j in %Y.");
152+
printf("%s\n",out);
153+
free(out);
154+
155+
150156
/* rdate_defmt_asc() */
151157

152158
date1=0;text="";
@@ -431,16 +437,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
431437
free(text);
432438

433439
{ECPGtrans(__LINE__,NULL,"rollback");
434-
#line359 "dt_test.pgc"
440+
#line365 "dt_test.pgc"
435441

436442
if (sqlca.sqlcode<0)sqlprint ( );}
437-
#line359 "dt_test.pgc"
443+
#line365 "dt_test.pgc"
438444

439445
{ECPGdisconnect(__LINE__,"CURRENT");
440-
#line360 "dt_test.pgc"
446+
#line366 "dt_test.pgc"
441447

442448
if (sqlca.sqlcode<0)sqlprint ( );}
443-
#line360 "dt_test.pgc"
449+
#line366 "dt_test.pgc"
444450

445451

446452
return (0);

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
[NO_PID]: sqlca: code: 0, state: 00000
4343
[NO_PID]: ecpg_get_data on line 38: RESULT: 2000-07-12 17:34:29 offset: -1; array: no
4444
[NO_PID]: sqlca: code: 0, state: 00000
45-
[NO_PID]: ECPGtrans on line359: action "rollback"; connection "regress1"
45+
[NO_PID]: ECPGtrans on line365: action "rollback"; connection "regress1"
4646
[NO_PID]: sqlca: code: 0, state: 00000
4747
[NO_PID]: ecpg_finish: connection regress1 closed
4848
[NO_PID]: sqlca: code: 0, state: 00000

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ date seems to get encoded to julian -622
66
m: 4, d: 19, y: 1998
77
date_day of 2003-12-04 17:34:29 is 4
88
Above date in format "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end" is "(Thu), Dec. 04, 2003, repeat: (Thu), Dec. 04, 2003. end"
9+
Which is day number 338 in 2003.
910
date_defmt_asc1: 1995-12-25
1011
date_defmt_asc2: 0095-12-25
1112
date_defmt_asc3: 0095-12-25

‎src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ main(void)
7373
free(text);
7474
free(out);
7575

76+
out = (char*) malloc(48);
77+
i = PGTYPEStimestamp_fmt_asc(&ts1, out, 47, "Which is day number %j in %Y.");
78+
printf("%s\n", out);
79+
free(out);
80+
81+
7682
/* rdate_defmt_asc() */
7783

7884
date1 = 0; text = "";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp