~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/read.c

  • Committer: Bazaar Package Importer
  • Author(s): Rob Browning
  • Date: 2008-05-10 12:18:50 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080510121850-mwi7tobbfkat03vr
Tags: 1.8.5+1-1
* Incorporate new upstream stable release.

* Fix gcc 4.3 compilation problems (fixed upstream now).  Thanks to
  Alexander Schmehl <tolimar@debian.org> for the previous, related
  1.8.4+1-2.1 NMU, and to Maximiliano Curia and Daniel Schepler for the
  original patch. (closes: #462384, #466778)

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
SCM_GLOBAL_SYMBOL (scm_sym_dot, ".");
56
56
SCM_SYMBOL (scm_keyword_prefix, "prefix");
 
57
SCM_SYMBOL (scm_keyword_postfix, "postfix");
57
58
 
58
59
scm_t_option scm_read_opts[] = {
59
60
  { SCM_OPTION_BOOLEAN, "copy", 0,
63
64
  { SCM_OPTION_BOOLEAN, "case-insensitive", 0,
64
65
    "Convert symbols to lower case."},
65
66
  { SCM_OPTION_SCM, "keywords", SCM_UNPACK (SCM_BOOL_F),
66
 
    "Style of keyword recognition: #f or 'prefix."}
 
67
    "Style of keyword recognition: #f, 'prefix or 'postfix."}
67
68
#if SCM_ENABLE_ELISP
68
69
  ,
69
70
  { SCM_OPTION_BOOLEAN, "elisp-vectors", 0,
181
182
  (((_chr) <= UCHAR_MAX) ? tolower (_chr) : (_chr))
182
183
 
183
184
 
 
185
#ifndef HAVE_DECL_STRNCASECMP
 
186
extern int strncasecmp (char const *s1, char const *s2, size_t n);
 
187
#endif
 
188
 
184
189
#ifndef HAVE_STRNCASECMP
185
190
/* XXX: Use Gnulib's `strncasecmp ()'.  */
186
191
 
317
322
  register int c;
318
323
  register SCM tmp;
319
324
  register SCM tl, ans = SCM_EOL;
320
 
  SCM tl2 = SCM_EOL, ans2 = SCM_EOL, copy = SCM_BOOL_F;;
 
325
  SCM tl2 = SCM_EOL, ans2 = SCM_EOL, copy = SCM_BOOL_F;
321
326
  static const int terminating_char = ')';
322
327
 
323
328
  /* Need to capture line and column numbers here. */
557
562
scm_read_mixed_case_symbol (int chr, SCM port)
558
563
{
559
564
  SCM result, str = SCM_EOL;
560
 
  int overflow = 0;
 
565
  int overflow = 0, ends_with_colon = 0;
561
566
  char buffer[READER_BUFFER_SIZE];
562
567
  size_t read = 0;
 
568
  int postfix = scm_is_eq (SCM_PACK (SCM_KEYWORD_STYLE), scm_keyword_postfix);
563
569
 
564
570
  scm_ungetc (chr, port);
565
571
  do
566
572
    {
567
573
      overflow = read_token (port, buffer, sizeof (buffer), &read);
568
574
 
 
575
      if (read > 0)
 
576
        ends_with_colon = (buffer[read - 1] == ':');
 
577
 
569
578
      if ((overflow) || (scm_is_pair (str)))
570
579
        str = scm_cons (scm_from_locale_stringn (buffer, read), str);
571
580
    }
575
584
    {
576
585
      str = scm_string_concatenate (scm_reverse_x (str, SCM_EOL));
577
586
      result = scm_string_to_symbol (str);
 
587
 
 
588
      /* Per SRFI-88, `:' alone is an identifier, not a keyword.  */
 
589
      if (postfix && ends_with_colon && (scm_c_string_length (result) > 1))
 
590
        result = scm_symbol_to_keyword (result);
578
591
    }
579
592
  else
580
 
    /* For symbols smaller than `sizeof (buffer)', we don't need to recur to
581
 
       Scheme strings.  Therefore, we only create one Scheme object (a
582
 
       symbol) per symbol read.  */
583
 
    result = scm_from_locale_symboln (buffer, read);
 
593
    {
 
594
      /* For symbols smaller than `sizeof (buffer)', we don't need to recur
 
595
         to Scheme strings.  Therefore, we only create one Scheme object (a
 
596
         symbol) per symbol read.  */
 
597
      if (postfix && ends_with_colon && (read > 1))
 
598
        result = scm_from_locale_keywordn (buffer, read - 1);
 
599
      else
 
600
        result = scm_from_locale_symboln (buffer, read);
 
601
    }
584
602
 
585
603
  return result;
586
604
}