~ubuntu-branches/ubuntu/quantal/gtkpod-aac/quantal

« back to all changes in this revision

Viewing changes to src/date_parser.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-07-17 18:25:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070717182525-rhl5w4pk8lbk6pna
Tags: 0.99.10-2ubuntu1
* Resynchronise with gtkpod 0.9.10-2.
* Hack in dpatch support, since it was removed.
* Rename debian/patches/03-configure.dpatch to
  debian/patches/aac-configure.dpatch.
* Update debian/gtkpod-aac.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#define FLEX_SCANNER
10
10
#define YY_FLEX_MAJOR_VERSION 2
11
11
#define YY_FLEX_MINOR_VERSION 5
12
 
#define YY_FLEX_SUBMINOR_VERSION 31
 
12
#define YY_FLEX_SUBMINOR_VERSION 33
13
13
#if YY_FLEX_SUBMINOR_VERSION > 0
14
14
#define FLEX_BETA
15
15
#endif
31
31
 
32
32
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
33
 
34
 
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
 
34
#if __STDC_VERSION__ >= 199901L
 
35
 
 
36
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
 
37
 * if you want the limit (max/min) macros for int types. 
 
38
 */
 
39
#ifndef __STDC_LIMIT_MACROS
 
40
#define __STDC_LIMIT_MACROS 1
 
41
#endif
 
42
 
35
43
#include <inttypes.h>
36
44
typedef int8_t flex_int8_t;
37
45
typedef uint8_t flex_uint8_t;
135
143
#define YY_BUF_SIZE 16384
136
144
#endif
137
145
 
 
146
/* The state buf must be large enough to hold one state per character in the main buffer.
 
147
 */
 
148
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
 
149
 
138
150
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
139
151
#define YY_TYPEDEF_YY_BUFFER_STATE
140
152
typedef struct yy_buffer_state *YY_BUFFER_STATE;
268
280
 
269
281
/* Points to current character in buffer. */
270
282
static char *yy_c_buf_p = (char *) 0;
271
 
static int yy_init = 1;         /* whether we need to initialize */
 
283
static int yy_init = 0;         /* whether we need to initialize */
272
284
static int yy_start = 0;        /* start state number */
273
285
 
274
286
/* Flag which is used to allow lexdpwrap()'s to do buffer switches
324
336
 
325
337
/* Begin user sect3 */
326
338
 
327
 
#define lexdpwrap(n) 1
 
339
#define lexdpwrap() 1
328
340
#define YY_SKIP_YYWRAP
329
341
 
330
342
typedef unsigned char YY_CHAR;
456
468
char *lexdptext;
457
469
#line 1 "date_parser.l"
458
470
/* -*- mode: c -*-
459
 
| Time-stamp: <2005-04-29 12:13:19 jcs>
 
471
| Time-stamp: <2007-01-19 01:52:29 jcs>
460
472
|
461
473
|  Copyright (C) 2002-2003 Jorg Schuler <jcsjcs at users.sourceforge.net>
462
474
|  Part of the gtkpod project.
549
561
/* e.g. +8:54.23           */
550
562
/* e.g. 5d6m3s             */
551
563
/* e.g. -3M5d              */
552
 
#line 553 "date_parser.c"
 
564
#line 565 "date_parser.c"
553
565
 
554
566
#define INITIAL 0
555
567
 
565
577
#define YY_EXTRA_TYPE void *
566
578
#endif
567
579
 
 
580
static int yy_init_globals (void );
 
581
 
568
582
/* Macros after this point can all be overridden by user definitions in
569
583
 * section 1.
570
584
 */
701
715
#line 116 "date_parser.l"
702
716
 
703
717
 
704
 
#line 705 "date_parser.c"
 
718
#line 719 "date_parser.c"
705
719
 
706
 
        if ( (yy_init) )
 
720
        if ( !(yy_init) )
707
721
                {
708
 
                (yy_init) = 0;
 
722
                (yy_init) = 1;
709
723
 
710
724
#ifdef YY_USER_INIT
711
725
                YY_USER_INIT;
974
988
#line 273 "date_parser.l"
975
989
ECHO;
976
990
        YY_BREAK
977
 
#line 978 "date_parser.c"
 
991
#line 992 "date_parser.c"
978
992
case YY_STATE_EOF(INITIAL):
979
993
        yyterminate();
980
994
 
1160
1174
 
1161
1175
        else
1162
1176
                {
1163
 
                        size_t num_to_read =
 
1177
                        int num_to_read =
1164
1178
                        YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1165
1179
 
1166
1180
                while ( num_to_read <= 0 )
1205
1219
 
1206
1220
                /* Read in more data. */
1207
1221
                YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1208
 
                        (yy_n_chars), num_to_read );
 
1222
                        (yy_n_chars), (size_t) num_to_read );
1209
1223
 
1210
1224
                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1211
1225
                }
1669
1683
 
1670
1684
/** Setup the input buffer state to scan a string. The next call to lexdplex() will
1671
1685
 * scan from a @e copy of @a str.
1672
 
 * @param str a NUL-terminated string to scan
 
1686
 * @param yystr a NUL-terminated string to scan
1673
1687
 * 
1674
1688
 * @return the newly allocated buffer state object.
1675
1689
 * @note If you want to scan bytes that may contain NUL values, then use
1676
1690
 *       lexdp_scan_bytes() instead.
1677
1691
 */
1678
 
YY_BUFFER_STATE lexdp_scan_string (yyconst char * yy_str )
 
1692
YY_BUFFER_STATE lexdp_scan_string (yyconst char * yystr )
1679
1693
{
1680
1694
    
1681
 
        return lexdp_scan_bytes(yy_str,strlen(yy_str) );
 
1695
        return lexdp_scan_bytes(yystr,strlen(yystr) );
1682
1696
}
1683
1697
 
1684
1698
/** Setup the input buffer state to scan the given bytes. The next call to lexdplex() will
1688
1702
 * 
1689
1703
 * @return the newly allocated buffer state object.
1690
1704
 */
1691
 
YY_BUFFER_STATE lexdp_scan_bytes  (yyconst char * bytes, int  len )
 
1705
YY_BUFFER_STATE lexdp_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
1692
1706
{
1693
1707
        YY_BUFFER_STATE b;
1694
1708
        char *buf;
1696
1710
        int i;
1697
1711
    
1698
1712
        /* Get memory for full buffer, including space for trailing EOB's. */
1699
 
        n = len + 2;
 
1713
        n = _yybytes_len + 2;
1700
1714
        buf = (char *) lexdpalloc(n  );
1701
1715
        if ( ! buf )
1702
1716
                YY_FATAL_ERROR( "out of dynamic memory in lexdp_scan_bytes()" );
1703
1717
 
1704
 
        for ( i = 0; i < len; ++i )
1705
 
                buf[i] = bytes[i];
 
1718
        for ( i = 0; i < _yybytes_len; ++i )
 
1719
                buf[i] = yybytes[i];
1706
1720
 
1707
 
        buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
 
1721
        buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1708
1722
 
1709
1723
        b = lexdp_scan_buffer(buf,n );
1710
1724
        if ( ! b )
1825
1839
        lexdp_flex_debug = bdebug ;
1826
1840
}
1827
1841
 
 
1842
static int yy_init_globals (void)
 
1843
{
 
1844
        /* Initialization is the same as for the non-reentrant scanner.
 
1845
     * This function is called from lexdplex_destroy(), so don't allocate here.
 
1846
     */
 
1847
 
 
1848
    (yy_buffer_stack) = 0;
 
1849
    (yy_buffer_stack_top) = 0;
 
1850
    (yy_buffer_stack_max) = 0;
 
1851
    (yy_c_buf_p) = (char *) 0;
 
1852
    (yy_init) = 0;
 
1853
    (yy_start) = 0;
 
1854
 
 
1855
/* Defined in main.c */
 
1856
#ifdef YY_STDINIT
 
1857
    lexdpin = stdin;
 
1858
    lexdpout = stdout;
 
1859
#else
 
1860
    lexdpin = (FILE *) 0;
 
1861
    lexdpout = (FILE *) 0;
 
1862
#endif
 
1863
 
 
1864
    /* For future reference: Set errno on error, since we are called by
 
1865
     * lexdplex_init()
 
1866
     */
 
1867
    return 0;
 
1868
}
 
1869
 
1828
1870
/* lexdplex_destroy is for both reentrant and non-reentrant scanners. */
1829
1871
int lexdplex_destroy  (void)
1830
1872
{
1840
1882
        lexdpfree((yy_buffer_stack) );
1841
1883
        (yy_buffer_stack) = NULL;
1842
1884
 
 
1885
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
 
1886
     * lexdplex() is called, initialization will occur. */
 
1887
    yy_init_globals( );
 
1888
 
1843
1889
    return 0;
1844
1890
}
1845
1891
 
1851
1897
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1852
1898
{
1853
1899
        register int i;
1854
 
        for ( i = 0; i < n; ++i )
 
1900
        for ( i = 0; i < n; ++i )
1855
1901
                s1[i] = s2[i];
1856
1902
}
1857
1903
#endif
1860
1906
static int yy_flex_strlen (yyconst char * s )
1861
1907
{
1862
1908
        register int n;
1863
 
        for ( n = 0; s[n]; ++n )
 
1909
        for ( n = 0; s[n]; ++n )
1864
1910
                ;
1865
1911
 
1866
1912
        return n;
1891
1937
 
1892
1938
#define YYTABLES_NAME "yytables"
1893
1939
 
1894
 
#undef YY_NEW_FILE
1895
 
#undef YY_FLUSH_BUFFER
1896
 
#undef yy_set_bol
1897
 
#undef yy_new_buffer
1898
 
#undef yy_set_interactive
1899
 
#undef yytext_ptr
1900
 
#undef YY_DO_BEFORE_ACTION
1901
 
 
1902
 
#ifdef YY_DECL_IS_OURS
1903
 
#undef YY_DECL_IS_OURS
1904
 
#undef YY_DECL
1905
 
#endif
1906
1940
#line 273 "date_parser.l"
1907
1941
 
1908
1942
 
2065
2099
 *
2066
2100
 * Return value:
2067
2101
 *
2068
 
 * TRUE:  no error occured
2069
 
 * FALSE: error occured
 
2102
 * TRUE:  no error occurred
 
2103
 * FALSE: error occurred
2070
2104
 */
2071
2105
gboolean dp_parse (gchar *dp_str, time_t *result,
2072
2106
                   gboolean lower_margin, gboolean strict)
2078
2112
    parsed_time = FALSE;
2079
2113
    /* did not yet parse any relative time string */
2080
2114
    reltime = DP_INF;
2081
 
    /* no error occured (yet) */
 
2115
    /* no error occurred (yet) */
2082
2116
    dp_error = FALSE;
2083
2117
    /* set parameters */
2084
2118
    lower = lower_margin;