[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 09/15: scm_ungetc, scm_ungets instead of _unlocked varia
From: |
Andy Wingo |
Subject: |
[Guile-commits] 09/15: scm_ungetc, scm_ungets instead of _unlocked variants |
Date: |
Tue, 26 Apr 2016 21:38:55 +0000 |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 122c8e6b37ad9dd44226d66e3357802f40d75f5f
Author: Andy Wingo <address@hidden>
Date: Sat Apr 23 22:20:18 2016 +0200
scm_ungetc, scm_ungets instead of _unlocked variants
* libguile/ports.h (scm_ungetc_unlocked, scm_ungets_unlocked): Remove;
replace with scm_ungetc, scm_ungets.
* libguile/ports.c (scm_ungetc, scm_ungets, scm_unread_char)
(scm_unread_string): Adapt.
* libguile/rdelim.c (scm_read_delimited_x): Use scm_ungetc.
* libguile/read.c: Unread characers with scm_ungetc, not
scm_ungetc_unlocked.
---
libguile/ports.c | 30 +++++-------------------------
libguile/ports.h | 2 --
libguile/rdelim.c | 2 +-
libguile/read.c | 42 +++++++++++++++++++++---------------------
4 files changed, 27 insertions(+), 49 deletions(-)
diff --git a/libguile/ports.c b/libguile/ports.c
index 754cb4f..8405a0a 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -2037,7 +2037,7 @@ scm_unget_byte (int c, SCM port)
}
void
-scm_ungetc_unlocked (scm_t_wchar c, SCM port)
+scm_ungetc (scm_t_wchar c, SCM port)
#define FUNC_NAME "scm_ungetc"
{
scm_t_port *pt = SCM_PTAB_ENTRY (port);
@@ -2089,17 +2089,7 @@ scm_ungetc_unlocked (scm_t_wchar c, SCM port)
#undef FUNC_NAME
void
-scm_ungetc (scm_t_wchar c, SCM port)
-{
- scm_i_pthread_mutex_t *lock;
- scm_c_lock_port (port, &lock);
- scm_ungetc_unlocked (c, port);
- if (lock)
- scm_i_pthread_mutex_unlock (lock);
-}
-
-void
-scm_ungets_unlocked (const char *s, int n, SCM port)
+scm_ungets (const char *s, int n, SCM port)
{
/* This is simple minded and inefficient, but unreading strings is
* probably not a common operation, and remember that line and
@@ -2108,17 +2098,7 @@ scm_ungets_unlocked (const char *s, int n, SCM port)
* Please feel free to write an optimized version!
*/
while (n--)
- scm_ungetc_unlocked (s[n], port);
-}
-
-void
-scm_ungets (const char *s, int n, SCM port)
-{
- scm_i_pthread_mutex_t *lock;
- scm_c_lock_port (port, &lock);
- scm_ungets_unlocked (s, n, port);
- if (lock)
- scm_i_pthread_mutex_unlock (lock);
+ scm_ungetc (s[n], port);
}
SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
@@ -2202,7 +2182,7 @@ SCM_DEFINE (scm_unread_char, "unread-char", 1, 1, 0,
c = SCM_CHAR (cobj);
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
return cobj;
}
#undef FUNC_NAME
@@ -2224,7 +2204,7 @@ SCM_DEFINE (scm_unread_string, "unread-string", 2, 0, 0,
n = scm_i_string_length (str);
while (n--)
- scm_ungetc_unlocked (scm_i_string_ref (str, n), port);
+ scm_ungetc (scm_i_string_ref (str, n), port);
return str;
}
diff --git a/libguile/ports.h b/libguile/ports.h
index 4d9c72b..82b2553 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -306,9 +306,7 @@ SCM_API SCM scm_read_char (SCM port);
SCM_API void scm_unget_bytes (const unsigned char *buf, size_t len, SCM port);
SCM_API void scm_unget_byte (int c, SCM port);
SCM_API void scm_ungetc (scm_t_wchar c, SCM port);
-SCM_API void scm_ungetc_unlocked (scm_t_wchar c, SCM port);
SCM_API void scm_ungets (const char *s, int n, SCM port);
-SCM_API void scm_ungets_unlocked (const char *s, int n, SCM port);
SCM_API SCM scm_peek_char (SCM port);
SCM_API SCM scm_unread_char (SCM cobj, SCM port);
SCM_API SCM scm_unread_string (SCM str, SCM port);
diff --git a/libguile/rdelim.c b/libguile/rdelim.c
index 14955a9..9d14967 100644
--- a/libguile/rdelim.c
+++ b/libguile/rdelim.c
@@ -85,7 +85,7 @@ SCM_DEFINE (scm_read_delimited_x, "%read-delimited!", 3, 3, 0,
if (scm_i_string_ref (delims, k) == c)
{
if (scm_is_false (gobble))
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
return scm_cons (SCM_MAKE_CHAR (c),
scm_from_size_t (j - cstart));
diff --git a/libguile/read.c b/libguile/read.c
index dece2b5..bcbf37e 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -381,7 +381,7 @@ flush_ws (SCM port, scm_t_read_opts *opts, const char
*eoferr)
}
/* fall through */
default:
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
return '#';
}
break;
@@ -440,7 +440,7 @@ scm_read_sexp (scm_t_wchar chr, SCM port, scm_t_read_opts
*opts)
if (terminating_char == c)
return SCM_EOL;
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
tmp = scm_read_expression (port, opts);
/* Note that it is possible for scm_read_expression to return
@@ -468,7 +468,7 @@ scm_read_sexp (scm_t_wchar chr, SCM port, scm_t_read_opts
*opts)
"in pair: mismatched close paren: ~A",
scm_list_1 (SCM_MAKE_CHAR (c)));
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
tmp = scm_read_expression (port, opts);
/* See above note about scm_sym_dot. */
@@ -593,7 +593,7 @@ skip_intraline_whitespace (SCM port)
}
while (c == '\t' || uc_is_general_category (c, UC_SPACE_SEPARATOR));
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
}
/* Read either a double-quoted string or an R7RS-style symbol delimited
@@ -741,7 +741,7 @@ scm_read_number (scm_t_wchar chr, SCM port, scm_t_read_opts
*opts)
long line = SCM_LINUM (port);
int column = SCM_COL (port) - 1;
- scm_ungetc_unlocked (chr, port);
+ scm_ungetc (chr, port);
buffer = read_complete_token (port, opts, local_buffer, sizeof local_buffer,
&bytes_read);
@@ -772,7 +772,7 @@ scm_read_mixed_case_symbol (scm_t_wchar chr, SCM port,
scm_t_read_opts *opts)
char local_buffer[READER_BUFFER_SIZE], *buffer;
SCM str;
- scm_ungetc_unlocked (chr, port);
+ scm_ungetc (chr, port);
buffer = read_complete_token (port, opts, local_buffer, sizeof local_buffer,
&bytes_read);
if (bytes_read > 0)
@@ -832,8 +832,8 @@ scm_read_number_and_radix (scm_t_wchar chr, SCM port,
scm_t_read_opts *opts)
break;
default:
- scm_ungetc_unlocked (chr, port);
- scm_ungetc_unlocked ('#', port);
+ scm_ungetc (chr, port);
+ scm_ungetc ('#', port);
radix = 10;
}
@@ -881,7 +881,7 @@ scm_read_quote (int chr, SCM port, scm_t_read_opts *opts)
p = scm_sym_uq_splicing;
else
{
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
p = scm_sym_unquote;
}
break;
@@ -928,7 +928,7 @@ scm_read_syntax (int chr, SCM port, scm_t_read_opts *opts)
p = sym_unsyntax_splicing;
else
{
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
p = sym_unsyntax;
}
break;
@@ -992,7 +992,7 @@ try_read_ci_chars (SCM port, const char *expected_chars)
break;
else if (c_tolower (c) != expected_chars[num_chars_read])
{
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
break;
}
else
@@ -1004,7 +1004,7 @@ try_read_ci_chars (SCM port, const char *expected_chars)
else
{
while (num_chars_read > 0)
- scm_ungetc_unlocked (chars_read[--num_chars_read], port);
+ scm_ungetc (chars_read[--num_chars_read], port);
return 0;
}
}
@@ -1228,7 +1228,7 @@ scm_read_array (int c, SCM port, scm_t_read_opts *opts,
long line, int column)
if (c == 'a' && try_read_ci_chars (port, "lse"))
return SCM_BOOL_F;
else if (c != EOF)
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
return SCM_BOOL_F;
}
rank = 1;
@@ -1384,7 +1384,7 @@ scm_read_guile_bit_vector (scm_t_wchar chr, SCM port,
scm_t_read_opts *opts,
}
if (chr != EOF)
- scm_ungetc_unlocked (chr, port);
+ scm_ungetc (chr, port);
return maybe_annotate_source
(scm_bitvector (scm_reverse_x (s_bits, SCM_EOL)),
@@ -1439,7 +1439,7 @@ scm_read_shebang (scm_t_wchar chr, SCM port,
scm_t_read_opts *opts)
name[i++] = c;
else if (CHAR_IS_DELIMITER (c))
{
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
name[i] = '\0';
if (0 == strcmp ("r6rs", name))
; /* Silently ignore */
@@ -1461,12 +1461,12 @@ scm_read_shebang (scm_t_wchar chr, SCM port,
scm_t_read_opts *opts)
}
else
{
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
break;
}
}
while (i > 0)
- scm_ungetc_unlocked (name[--i], port);
+ scm_ungetc (name[--i], port);
return scm_read_scsh_block_comment (chr, port);
}
@@ -1518,7 +1518,7 @@ scm_read_commented_expression (scm_t_wchar chr, SCM port,
if (EOF == c)
scm_i_input_error ("read_commented_expression", port,
"no expression after #; comment", SCM_EOL);
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
scm_read_expression (port, opts);
return SCM_UNSPECIFIED;
}
@@ -1868,7 +1868,7 @@ scm_read_expression (SCM port, scm_t_read_opts *opts)
int c = flush_ws (port, opts, (char *) NULL);
if (c == EOF)
return SCM_EOF_VAL;
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
line = SCM_LINUM (port);
column = SCM_COL (port);
}
@@ -1903,7 +1903,7 @@ scm_read_expression (SCM port, scm_t_read_opts *opts)
else
{
if (chr != EOF)
- scm_ungetc_unlocked (chr, port);
+ scm_ungetc (chr, port);
break;
}
maybe_annotate_source (expr, port, opts, line, column);
@@ -1937,7 +1937,7 @@ SCM_DEFINE (scm_read, "read", 0, 1, 0,
c = flush_ws (port, &opts, (char *) NULL);
if (EOF == c)
return SCM_EOF_VAL;
- scm_ungetc_unlocked (c, port);
+ scm_ungetc (c, port);
return (scm_read_expression (port, &opts));
}
- [Guile-commits] branch wip-port-refactor updated (5a342f6 -> 15d5304), Andy Wingo, 2016/04/26
- [Guile-commits] 01/15: Refactor thread safety for %port-property, Andy Wingo, 2016/04/26
- [Guile-commits] 03/15: scm_c_read instead of scm_c_read_unlock, Andy Wingo, 2016/04/26
- [Guile-commits] 02/15: Refactor to internal get/peek-byte functions, Andy Wingo, 2016/04/26
- [Guile-commits] 04/15: Remove port rw_active field, Andy Wingo, 2016/04/26
- [Guile-commits] 08/15: Remove scm_unget_{byte,bytes}_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 06/15: Remove scm_c_read_bytes_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 10/15: Remove locking in scm_end_input, Andy Wingo, 2016/04/26
- [Guile-commits] 05/15: Remove scm_flush_unlocked / scm_end_input_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 11/15: Remove scm_fill_input_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 09/15: scm_ungetc, scm_ungets instead of _unlocked variants,
Andy Wingo <=
- [Guile-commits] 07/15: Replace scm_getc with scm_getc_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 14/15: Remove scm_c_write_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 15/15: scm_lfwrite, not scm_lfwrite_unlocked, Andy Wingo, 2016/04/26
- [Guile-commits] 12/15: Remove scm_putc_unlocked., Andy Wingo, 2016/04/26
- [Guile-commits] 13/15: Remove scm_puts_unlocked., Andy Wingo, 2016/04/26