]> granicus.if.org Git - postgresql/commitdiff
Use non-literal format for possibly non-standard strftime formats.
authorAndrew Dunstan <andrew@dunslane.net>
Thu, 28 Apr 2011 23:58:49 +0000 (19:58 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Thu, 28 Apr 2011 23:58:49 +0000 (19:58 -0400)
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.

src/interfaces/ecpg/pgtypeslib/timestamp.c

index f9222b35387b6492670c362ec156a487c091be63..3db57ad3cb0141ac92741dc92a5c36476b56f89c 100644 (file)
@@ -501,17 +501,22 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                                         * 4-digit year corresponding to the ISO week number.
                                         */
                                case 'G':
-                                       tm->tm_mon -= 1;
-                                       i = strftime(q, *pstr_len, "%G", tm);
-                                       if (i == 0)
-                                               return -1;
-                                       while (*q)
                                        {
-                                               q++;
-                                               (*pstr_len)--;
+                                               /* Keep compiler quiet - Don't use a literal format */
+                                               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;
 
                                        /*
@@ -682,15 +687,20 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                                         * decimal number.
                                         */
                                case 'V':
-                                       i = strftime(q, *pstr_len, "%V", tm);
-                                       if (i == 0)
-                                               return -1;
-                                       while (*q)
                                        {
-                                               q++;
-                                               (*pstr_len)--;
+                                               /* Keep compiler quiet - Don't use a literal format */
+                                               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;
 
                                        /*