~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/timezone/strftime.c

Tags: upstream-8.4.0
ImportĀ upstreamĀ versionĀ 8.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
16
 *
17
17
 * IDENTIFICATION
18
 
 *        $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.13 2008/02/19 12:06:35 mha Exp $
 
18
 *        $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.14 2009/06/11 14:49:15 momjian Exp $
19
19
 */
20
20
 
21
21
#include "postgres.h"
92
92
static char *_conv(int, const char *, char *, const char *);
93
93
static char *_fmt(const char *, const struct pg_tm *, char *,
94
94
         const char *, int *);
95
 
static char * _yconv(const int, const int, const int, const int, 
96
 
         char *, const char * const);
 
95
static char *_yconv(const int, const int, const int, const int,
 
96
           char *, const char *const);
97
97
 
98
98
#define IN_NONE 0
99
99
#define IN_SOME 1
368
368
                                                {
369
369
                                                        *warnp = IN_ALL;
370
370
                                                        pt = _yconv(year, base, 0, 1,
371
 
                                                                           pt, ptlim);
 
371
                                                                                pt, ptlim);
372
372
                                                }
373
373
                                                else
374
374
                                                        pt = _yconv(year, base, 1, 1,
375
 
                                                                           pt, ptlim);
 
375
                                                                                pt, ptlim);
376
376
                                        }
377
377
                                        continue;
378
378
                                case 'v':
493
493
 * with more only if necessary.
494
494
 */
495
495
static char *
496
 
_yconv(const int a, const int b, const int convert_top, 
497
 
           const int convert_yy, char *pt, const char * const ptlim)
 
496
_yconv(const int a, const int b, const int convert_top,
 
497
           const int convert_yy, char *pt, const char *const ptlim)
498
498
{
499
 
        int    lead;
500
 
        int    trail;
501
 
 
502
 
#define DIVISOR       100
 
499
        int                     lead;
 
500
        int                     trail;
 
501
 
 
502
#define DIVISOR           100
503
503
        trail = a % DIVISOR + b % DIVISOR;
504
504
        lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
505
505
        trail %= DIVISOR;
517
517
        {
518
518
                if (lead == 0 && trail < 0)
519
519
                        pt = _add("-0", pt, ptlim);
520
 
                else    pt = _conv(lead, "%02d", pt, ptlim);
 
520
                else
 
521
                        pt = _conv(lead, "%02d", pt, ptlim);
521
522
        }
522
523
        if (convert_yy)
523
524
                pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
524
525
        return pt;
525
526
}
526