~registry/glib/glib-2-30

« back to all changes in this revision

Viewing changes to gdate.c

  • Committer: Owen Taylor
  • Date: 1998-12-15 05:28:02 UTC
  • Revision ID: git-v1:931ea952650b013b834041b91b0c37a748ffd449
This commit merges the glib-threads branch into the main
branch. See the ChangeLog for details of the changes.

In brief overview:

 - The set of threading functions can be set
 - A default implementation is provided in -lgthread
 - All static data structures are locked using these
   functions if g_thread_init() is called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
17
 * Boston, MA 02111-1307, USA.
18
18
 */
 
19
 
 
20
/* 
 
21
 * MT safe
 
22
 */
 
23
 
19
24
#include "glib.h"
20
25
 
21
26
#include <time.h>
383
388
  memset (d, 0x0, ndates*sizeof (GDate)); 
384
389
}
385
390
 
 
391
static G_LOCK_DEFINE(g_date_global);
 
392
 
386
393
/* These are for the parser, output to the user should use *
387
394
 * g_date_strftime () - this creates more never-freed memory to annoy
388
395
 * all those memory debugger users. :-) 
429
436
 
430
437
#define NUM_LEN 10
431
438
 
 
439
/* HOLDS: g_date_global_lock */
432
440
static void
433
441
g_date_fill_parse_tokens (const gchar *str, GDateParseTokens *pt)
434
442
{
488
496
              if (found != NULL)
489
497
                {
490
498
                  pt->month = i;
491
 
                  return;
 
499
                  return;
492
500
                }
493
501
            }
494
502
          
502
510
                  return;
503
511
                }
504
512
            }
505
 
          
 
513
 
506
514
          ++i;
507
 
        }
 
515
        }      
508
516
    }
509
517
}
510
518
 
 
519
/* HOLDS: g_date_global_lock */
511
520
static void
512
521
g_date_prepare_to_parse (const gchar *str, GDateParseTokens *pt)
513
522
{
641
650
  /* set invalid */
642
651
  g_date_clear (d, 1);
643
652
  
 
653
  g_lock (g_date_global);
 
654
 
644
655
  g_date_prepare_to_parse (str, &pt);
645
656
  
646
657
#ifdef G_ENABLE_DEBUG
649
660
#endif
650
661
  
651
662
  
652
 
  if (pt.num_ints == 4) return; /* presumably a typo; bail out. */
 
663
  if (pt.num_ints == 4) 
 
664
    {
 
665
      g_unlock (g_date_global);
 
666
      return; /* presumably a typo; bail out. */
 
667
    }
653
668
  
654
669
  if (pt.num_ints > 1)
655
670
    {
765
780
  else 
766
781
    g_message ("Rejected DMY %u %u %u", day, m, y);
767
782
#endif
 
783
  g_unlock (g_date_global);
768
784
}
769
785
 
770
786
void