LCOV - code coverage report
Current view: top level - src/timezone - strftime.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13beta1 Lines: 68 229 29.7 %
Date: 2020-06-01 00:06:26 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Convert a broken-down timestamp to a string.  */
       2             : 
       3             : /*
       4             :  * Copyright 1989 The Regents of the University of California.
       5             :  * All rights reserved.
       6             :  *
       7             :  * Redistribution and use in source and binary forms, with or without
       8             :  * modification, are permitted provided that the following conditions
       9             :  * are met:
      10             :  * 1. Redistributions of source code must retain the above copyright
      11             :  *    notice, this list of conditions and the following disclaimer.
      12             :  * 2. Redistributions in binary form must reproduce the above copyright
      13             :  *    notice, this list of conditions and the following disclaimer in the
      14             :  *    documentation and/or other materials provided with the distribution.
      15             :  * 3. Neither the name of the University nor the names of its contributors
      16             :  *    may be used to endorse or promote products derived from this software
      17             :  *    without specific prior written permission.
      18             :  *
      19             :  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
      20             :  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      21             :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      22             :  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
      23             :  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      24             :  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      25             :  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      26             :  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      27             :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      28             :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      29             :  * SUCH DAMAGE.
      30             :  */
      31             : 
      32             : /*
      33             :  * Based on the UCB version with the copyright notice appearing above.
      34             :  *
      35             :  * This is ANSIish only when "multibyte character == plain character".
      36             :  *
      37             :  * IDENTIFICATION
      38             :  *    src/timezone/strftime.c
      39             :  */
      40             : 
      41             : #include "postgres.h"
      42             : 
      43             : #include <fcntl.h>
      44             : 
      45             : #include "private.h"
      46             : 
      47             : 
      48             : struct lc_time_T
      49             : {
      50             :     const char *mon[MONSPERYEAR];
      51             :     const char *month[MONSPERYEAR];
      52             :     const char *wday[DAYSPERWEEK];
      53             :     const char *weekday[DAYSPERWEEK];
      54             :     const char *X_fmt;
      55             :     const char *x_fmt;
      56             :     const char *c_fmt;
      57             :     const char *am;
      58             :     const char *pm;
      59             :     const char *date_fmt;
      60             : };
      61             : 
      62             : #define Locale  (&C_time_locale)
      63             : 
      64             : static const struct lc_time_T C_time_locale = {
      65             :     {
      66             :         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
      67             :         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
      68             :     }, {
      69             :         "January", "February", "March", "April", "May", "June",
      70             :         "July", "August", "September", "October", "November", "December"
      71             :     }, {
      72             :         "Sun", "Mon", "Tue", "Wed",
      73             :         "Thu", "Fri", "Sat"
      74             :     }, {
      75             :         "Sunday", "Monday", "Tuesday", "Wednesday",
      76             :         "Thursday", "Friday", "Saturday"
      77             :     },
      78             : 
      79             :     /* X_fmt */
      80             :     "%H:%M:%S",
      81             : 
      82             :     /*
      83             :      * x_fmt
      84             :      *
      85             :      * C99 and later require this format. Using just numbers (as here) makes
      86             :      * Quakers happier; it's also compatible with SVR4.
      87             :      */
      88             :     "%m/%d/%y",
      89             : 
      90             :     /*
      91             :      * c_fmt
      92             :      *
      93             :      * C99 and later require this format. Previously this code used "%D %X",
      94             :      * but we now conform to C99. Note that "%a %b %d %H:%M:%S %Y" is used by
      95             :      * Solaris 2.3.
      96             :      */
      97             :     "%a %b %e %T %Y",
      98             : 
      99             :     /* am */
     100             :     "AM",
     101             : 
     102             :     /* pm */
     103             :     "PM",
     104             : 
     105             :     /* date_fmt */
     106             :     "%a %b %e %H:%M:%S %Z %Y"
     107             : };
     108             : 
     109             : enum warn
     110             : {
     111             :     IN_NONE, IN_SOME, IN_THIS, IN_ALL
     112             : };
     113             : 
     114             : static char *_add(const char *, char *, const char *);
     115             : static char *_conv(int, const char *, char *, const char *);
     116             : static char *_fmt(const char *, const struct pg_tm *, char *, const char *,
     117             :                   enum warn *);
     118             : static char *_yconv(int, int, bool, bool, char *, char const *);
     119             : 
     120             : 
     121             : /*
     122             :  * Convert timestamp t to string s, a caller-allocated buffer of size maxsize,
     123             :  * using the given format pattern.
     124             :  *
     125             :  * See also timestamptz_to_str.
     126             :  */
     127             : size_t
     128      232368 : pg_strftime(char *s, size_t maxsize, const char *format, const struct pg_tm *t)
     129             : {
     130             :     char       *p;
     131      232368 :     enum warn   warn = IN_NONE;
     132             : 
     133      232368 :     p = _fmt(format, t, s, s + maxsize, &warn);
     134      232368 :     if (p == s + maxsize)
     135           0 :         return 0;
     136      232368 :     *p = '\0';
     137      232368 :     return p - s;
     138             : }
     139             : 
     140             : static char *
     141      232368 : _fmt(const char *format, const struct pg_tm *t, char *pt,
     142             :      const char *ptlim, enum warn *warnp)
     143             : {
     144     3669482 :     for (; *format; ++format)
     145             :     {
     146     3437114 :         if (*format == '%')
     147             :         {
     148     1629770 :     label:
     149     1629770 :             switch (*++format)
     150             :             {
     151           0 :                 case '\0':
     152           0 :                     --format;
     153           0 :                     break;
     154           0 :                 case 'A':
     155           0 :                     pt = _add((t->tm_wday < 0 ||
     156           0 :                                t->tm_wday >= DAYSPERWEEK) ?
     157           0 :                               "?" : Locale->weekday[t->tm_wday],
     158             :                               pt, ptlim);
     159           0 :                     continue;
     160        1600 :                 case 'a':
     161        3200 :                     pt = _add((t->tm_wday < 0 ||
     162        1600 :                                t->tm_wday >= DAYSPERWEEK) ?
     163        1600 :                               "?" : Locale->wday[t->tm_wday],
     164             :                               pt, ptlim);
     165        1600 :                     continue;
     166           0 :                 case 'B':
     167           0 :                     pt = _add((t->tm_mon < 0 ||
     168           0 :                                t->tm_mon >= MONSPERYEAR) ?
     169           0 :                               "?" : Locale->month[t->tm_mon],
     170             :                               pt, ptlim);
     171           0 :                     continue;
     172        1600 :                 case 'b':
     173             :                 case 'h':
     174        3200 :                     pt = _add((t->tm_mon < 0 ||
     175        1600 :                                t->tm_mon >= MONSPERYEAR) ?
     176        1600 :                               "?" : Locale->mon[t->tm_mon],
     177             :                               pt, ptlim);
     178        1600 :                     continue;
     179           0 :                 case 'C':
     180             : 
     181             :                     /*
     182             :                      * %C used to do a... _fmt("%a %b %e %X %Y", t);
     183             :                      * ...whereas now POSIX 1003.2 calls for something
     184             :                      * completely different. (ado, 1993-05-24)
     185             :                      */
     186           0 :                     pt = _yconv(t->tm_year, TM_YEAR_BASE,
     187             :                                 true, false, pt, ptlim);
     188           0 :                     continue;
     189           0 :                 case 'c':
     190           0 :                     {
     191           0 :                         enum warn   warn2 = IN_SOME;
     192             : 
     193           0 :                         pt = _fmt(Locale->c_fmt, t, pt, ptlim, &warn2);
     194           0 :                         if (warn2 == IN_ALL)
     195           0 :                             warn2 = IN_THIS;
     196           0 :                         if (warn2 > *warnp)
     197           0 :                             *warnp = warn2;
     198             :                     }
     199           0 :                     continue;
     200           0 :                 case 'D':
     201           0 :                     pt = _fmt("%m/%d/%y", t, pt, ptlim, warnp);
     202           0 :                     continue;
     203      232368 :                 case 'd':
     204      232368 :                     pt = _conv(t->tm_mday, "%02d", pt, ptlim);
     205      232368 :                     continue;
     206           0 :                 case 'E':
     207             :                 case 'O':
     208             : 
     209             :                     /*
     210             :                      * Locale modifiers of C99 and later. The sequences %Ec
     211             :                      * %EC %Ex %EX %Ey %EY %Od %oe %OH %OI %Om %OM %OS %Ou %OU
     212             :                      * %OV %Ow %OW %Oy are supposed to provide alternative
     213             :                      * representations.
     214             :                      */
     215           0 :                     goto label;
     216           0 :                 case 'e':
     217           0 :                     pt = _conv(t->tm_mday, "%2d", pt, ptlim);
     218           0 :                     continue;
     219           0 :                 case 'F':
     220           0 :                     pt = _fmt("%Y-%m-%d", t, pt, ptlim, warnp);
     221           0 :                     continue;
     222      232368 :                 case 'H':
     223      232368 :                     pt = _conv(t->tm_hour, "%02d", pt, ptlim);
     224      232368 :                     continue;
     225           0 :                 case 'I':
     226           0 :                     pt = _conv((t->tm_hour % 12) ?
     227           0 :                                (t->tm_hour % 12) : 12,
     228             :                                "%02d", pt, ptlim);
     229           0 :                     continue;
     230           0 :                 case 'j':
     231           0 :                     pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim);
     232           0 :                     continue;
     233           0 :                 case 'k':
     234             : 
     235             :                     /*
     236             :                      * This used to be... _conv(t->tm_hour % 12 ? t->tm_hour %
     237             :                      * 12 : 12, 2, ' '); ...and has been changed to the below
     238             :                      * to match SunOS 4.1.1 and Arnold Robbins' strftime
     239             :                      * version 3.0. That is, "%k" and "%l" have been swapped.
     240             :                      * (ado, 1993-05-24)
     241             :                      */
     242           0 :                     pt = _conv(t->tm_hour, "%2d", pt, ptlim);
     243           0 :                     continue;
     244             : #ifdef KITCHEN_SINK
     245             :                 case 'K':
     246             : 
     247             :                     /*
     248             :                      * After all this time, still unclaimed!
     249             :                      */
     250             :                     pt = _add("kitchen sink", pt, ptlim);
     251             :                     continue;
     252             : #endif                          /* defined KITCHEN_SINK */
     253           0 :                 case 'l':
     254             : 
     255             :                     /*
     256             :                      * This used to be... _conv(t->tm_hour, 2, ' '); ...and
     257             :                      * has been changed to the below to match SunOS 4.1.1 and
     258             :                      * Arnold Robbin's strftime version 3.0. That is, "%k" and
     259             :                      * "%l" have been swapped. (ado, 1993-05-24)
     260             :                      */
     261           0 :                     pt = _conv((t->tm_hour % 12) ?
     262           0 :                                (t->tm_hour % 12) : 12,
     263             :                                "%2d", pt, ptlim);
     264           0 :                     continue;
     265      232368 :                 case 'M':
     266      232368 :                     pt = _conv(t->tm_min, "%02d", pt, ptlim);
     267      232368 :                     continue;
     268      230768 :                 case 'm':
     269      230768 :                     pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim);
     270      230768 :                     continue;
     271           0 :                 case 'n':
     272           0 :                     pt = _add("\n", pt, ptlim);
     273           0 :                     continue;
     274           0 :                 case 'p':
     275           0 :                     pt = _add((t->tm_hour >= (HOURSPERDAY / 2)) ?
     276             :                               Locale->pm :
     277             :                               Locale->am,
     278             :                               pt, ptlim);
     279           0 :                     continue;
     280           0 :                 case 'R':
     281           0 :                     pt = _fmt("%H:%M", t, pt, ptlim, warnp);
     282           0 :                     continue;
     283           0 :                 case 'r':
     284           0 :                     pt = _fmt("%I:%M:%S %p", t, pt, ptlim, warnp);
     285           0 :                     continue;
     286      232368 :                 case 'S':
     287      232368 :                     pt = _conv(t->tm_sec, "%02d", pt, ptlim);
     288      232368 :                     continue;
     289           0 :                 case 'T':
     290           0 :                     pt = _fmt("%H:%M:%S", t, pt, ptlim, warnp);
     291           0 :                     continue;
     292           0 :                 case 't':
     293           0 :                     pt = _add("\t", pt, ptlim);
     294           0 :                     continue;
     295           0 :                 case 'U':
     296           0 :                     pt = _conv((t->tm_yday + DAYSPERWEEK -
     297           0 :                                 t->tm_wday) / DAYSPERWEEK,
     298             :                                "%02d", pt, ptlim);
     299           0 :                     continue;
     300           0 :                 case 'u':
     301             : 
     302             :                     /*
     303             :                      * From Arnold Robbins' strftime version 3.0: "ISO 8601:
     304             :                      * Weekday as a decimal number [1 (Monday) - 7]" (ado,
     305             :                      * 1993-05-24)
     306             :                      */
     307           0 :                     pt = _conv((t->tm_wday == 0) ?
     308             :                                DAYSPERWEEK : t->tm_wday,
     309             :                                "%d", pt, ptlim);
     310           0 :                     continue;
     311           0 :                 case 'V':       /* ISO 8601 week number */
     312             :                 case 'G':       /* ISO 8601 year (four digits) */
     313             :                 case 'g':       /* ISO 8601 year (two digits) */
     314             : /*
     315             :  * From Arnold Robbins' strftime version 3.0: "the week number of the
     316             :  * year (the first Monday as the first day of week 1) as a decimal number
     317             :  * (01-53)."
     318             :  * (ado, 1993-05-24)
     319             :  *
     320             :  * From <https://www.cl.cam.ac.uk/~mgk25/iso-time.html> by Markus Kuhn:
     321             :  * "Week 01 of a year is per definition the first week which has the
     322             :  * Thursday in this year, which is equivalent to the week which contains
     323             :  * the fourth day of January. In other words, the first week of a new year
     324             :  * is the week which has the majority of its days in the new year. Week 01
     325             :  * might also contain days from the previous year and the week before week
     326             :  * 01 of a year is the last week (52 or 53) of the previous year even if
     327             :  * it contains days from the new year. A week starts with Monday (day 1)
     328             :  * and ends with Sunday (day 7). For example, the first week of the year
     329             :  * 1997 lasts from 1996-12-30 to 1997-01-05..."
     330             :  * (ado, 1996-01-02)
     331             :  */
     332             :                     {
     333             :                         int         year;
     334             :                         int         base;
     335             :                         int         yday;
     336             :                         int         wday;
     337             :                         int         w;
     338             : 
     339           0 :                         year = t->tm_year;
     340           0 :                         base = TM_YEAR_BASE;
     341           0 :                         yday = t->tm_yday;
     342           0 :                         wday = t->tm_wday;
     343             :                         for (;;)
     344           0 :                         {
     345             :                             int         len;
     346             :                             int         bot;
     347             :                             int         top;
     348             : 
     349           0 :                             len = isleap_sum(year, base) ?
     350           0 :                                 DAYSPERLYEAR :
     351             :                                 DAYSPERNYEAR;
     352             : 
     353             :                             /*
     354             :                              * What yday (-3 ... 3) does the ISO year begin
     355             :                              * on?
     356             :                              */
     357           0 :                             bot = ((yday + 11 - wday) %
     358             :                                    DAYSPERWEEK) - 3;
     359             : 
     360             :                             /*
     361             :                              * What yday does the NEXT ISO year begin on?
     362             :                              */
     363           0 :                             top = bot -
     364           0 :                                 (len % DAYSPERWEEK);
     365           0 :                             if (top < -3)
     366           0 :                                 top += DAYSPERWEEK;
     367           0 :                             top += len;
     368           0 :                             if (yday >= top)
     369             :                             {
     370           0 :                                 ++base;
     371           0 :                                 w = 1;
     372           0 :                                 break;
     373             :                             }
     374           0 :                             if (yday >= bot)
     375             :                             {
     376           0 :                                 w = 1 + ((yday - bot) /
     377             :                                          DAYSPERWEEK);
     378           0 :                                 break;
     379             :                             }
     380           0 :                             --base;
     381           0 :                             yday += isleap_sum(year, base) ?
     382           0 :                                 DAYSPERLYEAR :
     383             :                                 DAYSPERNYEAR;
     384             :                         }
     385           0 :                         if (*format == 'V')
     386           0 :                             pt = _conv(w, "%02d",
     387             :                                        pt, ptlim);
     388           0 :                         else if (*format == 'g')
     389             :                         {
     390           0 :                             *warnp = IN_ALL;
     391           0 :                             pt = _yconv(year, base,
     392             :                                         false, true,
     393             :                                         pt, ptlim);
     394             :                         }
     395             :                         else
     396           0 :                             pt = _yconv(year, base,
     397             :                                         true, true,
     398             :                                         pt, ptlim);
     399             :                     }
     400           0 :                     continue;
     401           0 :                 case 'v':
     402             : 
     403             :                     /*
     404             :                      * From Arnold Robbins' strftime version 3.0: "date as
     405             :                      * dd-bbb-YYYY" (ado, 1993-05-24)
     406             :                      */
     407           0 :                     pt = _fmt("%e-%b-%Y", t, pt, ptlim, warnp);
     408           0 :                     continue;
     409           0 :                 case 'W':
     410           0 :                     pt = _conv((t->tm_yday + DAYSPERWEEK -
     411           0 :                                 (t->tm_wday ?
     412           0 :                                  (t->tm_wday - 1) :
     413             :                                  (DAYSPERWEEK - 1))) / DAYSPERWEEK,
     414             :                                "%02d", pt, ptlim);
     415           0 :                     continue;
     416           0 :                 case 'w':
     417           0 :                     pt = _conv(t->tm_wday, "%d", pt, ptlim);
     418           0 :                     continue;
     419           0 :                 case 'X':
     420           0 :                     pt = _fmt(Locale->X_fmt, t, pt, ptlim, warnp);
     421           0 :                     continue;
     422           0 :                 case 'x':
     423           0 :                     {
     424           0 :                         enum warn   warn2 = IN_SOME;
     425             : 
     426           0 :                         pt = _fmt(Locale->x_fmt, t, pt, ptlim, &warn2);
     427           0 :                         if (warn2 == IN_ALL)
     428           0 :                             warn2 = IN_THIS;
     429           0 :                         if (warn2 > *warnp)
     430           0 :                             *warnp = warn2;
     431             :                     }
     432           0 :                     continue;
     433           0 :                 case 'y':
     434           0 :                     *warnp = IN_ALL;
     435           0 :                     pt = _yconv(t->tm_year, TM_YEAR_BASE,
     436             :                                 false, true,
     437             :                                 pt, ptlim);
     438           0 :                     continue;
     439      232368 :                 case 'Y':
     440      232368 :                     pt = _yconv(t->tm_year, TM_YEAR_BASE,
     441             :                                 true, true,
     442             :                                 pt, ptlim);
     443      232368 :                     continue;
     444      232362 :                 case 'Z':
     445      232362 :                     if (t->tm_zone != NULL)
     446      232362 :                         pt = _add(t->tm_zone, pt, ptlim);
     447             : 
     448             :                     /*
     449             :                      * C99 and later say that %Z must be replaced by the empty
     450             :                      * string if the time zone abbreviation is not
     451             :                      * determinable.
     452             :                      */
     453      232362 :                     continue;
     454           0 :                 case 'z':
     455             :                     {
     456             :                         long        diff;
     457             :                         char const *sign;
     458             :                         bool        negative;
     459             : 
     460           0 :                         if (t->tm_isdst < 0)
     461           0 :                             continue;
     462           0 :                         diff = t->tm_gmtoff;
     463           0 :                         negative = diff < 0;
     464           0 :                         if (diff == 0)
     465             :                         {
     466           0 :                             if (t->tm_zone != NULL)
     467           0 :                                 negative = t->tm_zone[0] == '-';
     468             :                         }
     469           0 :                         if (negative)
     470             :                         {
     471           0 :                             sign = "-";
     472           0 :                             diff = -diff;
     473             :                         }
     474             :                         else
     475           0 :                             sign = "+";
     476           0 :                         pt = _add(sign, pt, ptlim);
     477           0 :                         diff /= SECSPERMIN;
     478           0 :                         diff = (diff / MINSPERHOUR) * 100 +
     479           0 :                             (diff % MINSPERHOUR);
     480           0 :                         pt = _conv(diff, "%04d", pt, ptlim);
     481             :                     }
     482           0 :                     continue;
     483           0 :                 case '+':
     484           0 :                     pt = _fmt(Locale->date_fmt, t, pt, ptlim,
     485             :                               warnp);
     486           0 :                     continue;
     487        1600 :                 case '%':
     488             : 
     489             :                     /*
     490             :                      * X311J/88-090 (4.12.3.5): if conversion char is
     491             :                      * undefined, behavior is undefined. Print out the
     492             :                      * character itself as printf(3) also does.
     493             :                      */
     494             :                 default:
     495        1600 :                     break;
     496             :             }
     497     1807344 :         }
     498     1808944 :         if (pt == ptlim)
     499           0 :             break;
     500     1808944 :         *pt++ = *format;
     501             :     }
     502      232368 :     return pt;
     503             : }
     504             : 
     505             : static char *
     506     1624976 : _conv(int n, const char *format, char *pt, const char *ptlim)
     507             : {
     508             :     char        buf[INT_STRLEN_MAXIMUM(int) + 1];
     509             : 
     510     1624976 :     sprintf(buf, format, n);
     511     1624976 :     return _add(buf, pt, ptlim);
     512             : }
     513             : 
     514             : static char *
     515     1860538 : _add(const char *str, char *pt, const char *ptlim)
     516             : {
     517     5817176 :     while (pt < ptlim && (*pt = *str++) != '\0')
     518     3956638 :         ++pt;
     519     1860538 :     return pt;
     520             : }
     521             : 
     522             : /*
     523             :  * POSIX and the C Standard are unclear or inconsistent about
     524             :  * what %C and %y do if the year is negative or exceeds 9999.
     525             :  * Use the convention that %C concatenated with %y yields the
     526             :  * same output as %Y, and that %Y contains at least 4 bytes,
     527             :  * with more only if necessary.
     528             :  */
     529             : 
     530             : static char *
     531      232368 : _yconv(int a, int b, bool convert_top, bool convert_yy,
     532             :        char *pt, const char *ptlim)
     533             : {
     534             :     int         lead;
     535             :     int         trail;
     536             : 
     537             : #define DIVISOR 100
     538      232368 :     trail = a % DIVISOR + b % DIVISOR;
     539      232368 :     lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
     540      232368 :     trail %= DIVISOR;
     541      232368 :     if (trail < 0 && lead > 0)
     542             :     {
     543           0 :         trail += DIVISOR;
     544           0 :         --lead;
     545             :     }
     546      232368 :     else if (lead < 0 && trail > 0)
     547             :     {
     548           0 :         trail -= DIVISOR;
     549           0 :         ++lead;
     550             :     }
     551      232368 :     if (convert_top)
     552             :     {
     553      232368 :         if (lead == 0 && trail < 0)
     554           0 :             pt = _add("-0", pt, ptlim);
     555             :         else
     556      232368 :             pt = _conv(lead, "%02d", pt, ptlim);
     557             :     }
     558      232368 :     if (convert_yy)
     559      232368 :         pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
     560      232368 :     return pt;
     561             : }

Generated by: LCOV version 1.13