Commit c49e4ae1 authored by Andrew Dunstan's avatar Andrew Dunstan

Use non-literal format for possibly non-standard strftime formats.

Per recent -hackers discussion. The formats in question are %G and %V,
and cause warnings on MinGW at least. We assume the ecpg application
knows what it's doing if it passes these formats to the library.
parent ab0ba6e7
...@@ -501,17 +501,22 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, ...@@ -501,17 +501,22 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
* 4-digit year corresponding to the ISO week number. * 4-digit year corresponding to the ISO week number.
*/ */
case 'G': case 'G':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%G", tm);
if (i == 0)
return -1;
while (*q)
{ {
q++; /* Keep compiler quiet - Don't use a literal format */
(*pstr_len)--; const char *fmt = "%G";
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, fmt, tm);
if (i == 0)
return -1;
while (*q)
{
q++;
(*pstr_len)--;
}
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
} }
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break; break;
/* /*
...@@ -682,15 +687,20 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, ...@@ -682,15 +687,20 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
* decimal number. * decimal number.
*/ */
case 'V': case 'V':
i = strftime(q, *pstr_len, "%V", tm);
if (i == 0)
return -1;
while (*q)
{ {
q++; /* Keep compiler quiet - Don't use a literal format */
(*pstr_len)--; const char *fmt = "%V";
i = strftime(q, *pstr_len, fmt, tm);
if (i == 0)
return -1;
while (*q)
{
q++;
(*pstr_len)--;
}
replace_type = PGTYPES_TYPE_NOTHING;
} }
replace_type = PGTYPES_TYPE_NOTHING;
break; break;
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment