guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 15/15: scm_lfwrite, not scm_lfwrite_unlocked


From: Andy Wingo
Subject: [Guile-commits] 15/15: scm_lfwrite, not scm_lfwrite_unlocked
Date: Tue, 26 Apr 2016 21:38:56 +0000

wingo pushed a commit to branch wip-port-refactor
in repository guile.

commit 15d53047233ad3d3b1ac39764d3c417e3b87f118
Author: Andy Wingo <address@hidden>
Date:   Tue Apr 26 23:17:22 2016 +0200

    scm_lfwrite, not scm_lfwrite_unlocked
    
    * libguile/ports.h (scm_lfwrite_unlocked): Remove.
    * libguile/ports.c (scm_lfwrite): Rename from scm_lfwrite_unlocked.
    * libguile/numbers.c:
    * libguile/print.c: Adapt to call scm_lfwrite.
---
 libguile/numbers.c |   10 +++++-----
 libguile/ports.c   |   16 +++-------------
 libguile/ports.h   |    1 -
 libguile/print.c   |   46 +++++++++++++++++++++++-----------------------
 4 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 14d98ff..4f740c5 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -5692,7 +5692,7 @@ int
 scm_print_real (SCM sexp, SCM port, scm_print_state *pstate SCM_UNUSED)
 {
   char num_buf[FLOBUFLEN];
-  scm_lfwrite_unlocked (num_buf, iflo2str (sexp, num_buf, 10), port);
+  scm_lfwrite (num_buf, iflo2str (sexp, num_buf, 10), port);
   return !0;
 }
 
@@ -5700,7 +5700,7 @@ void
 scm_i_print_double (double val, SCM port)
 {
   char num_buf[FLOBUFLEN];
-  scm_lfwrite_unlocked (num_buf, idbl2str (val, num_buf, 10), port);
+  scm_lfwrite (num_buf, idbl2str (val, num_buf, 10), port);
 }
 
 int
@@ -5708,7 +5708,7 @@ scm_print_complex (SCM sexp, SCM port, scm_print_state 
*pstate SCM_UNUSED)
 
 {
   char num_buf[FLOBUFLEN];
-  scm_lfwrite_unlocked (num_buf, iflo2str (sexp, num_buf, 10), port);
+  scm_lfwrite (num_buf, iflo2str (sexp, num_buf, 10), port);
   return !0;
 }
 
@@ -5716,7 +5716,7 @@ void
 scm_i_print_complex (double real, double imag, SCM port)
 {
   char num_buf[FLOBUFLEN];
-  scm_lfwrite_unlocked (num_buf, icmplx2str (real, imag, num_buf, 10), port);
+  scm_lfwrite (num_buf, icmplx2str (real, imag, num_buf, 10), port);
 }
 
 int
@@ -5737,7 +5737,7 @@ scm_bigprint (SCM exp, SCM port, scm_print_state *pstate 
SCM_UNUSED)
   void (*freefunc) (void *, size_t);
   mp_get_memory_functions (NULL, NULL, &freefunc);
   scm_remember_upto_here_1 (exp);
-  scm_lfwrite_unlocked (str, len, port);
+  scm_lfwrite (str, len, port);
   freefunc (str, len + 1);
   return !0;
 }
diff --git a/libguile/ports.c b/libguile/ports.c
index 14be368..cc33bd9 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -2480,14 +2480,14 @@ void
 scm_putc (char c, SCM port)
 {
   SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
-  scm_lfwrite_unlocked (&c, 1, port);
+  scm_lfwrite (&c, 1, port);
 }
 
 void
 scm_puts (const char *s, SCM port)
 {
   SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
-  scm_lfwrite_unlocked (s, strlen (s), port);
+  scm_lfwrite (s, strlen (s), port);
 }
   
 static void
@@ -2615,7 +2615,7 @@ scm_c_write (SCM port, const void *ptr, size_t size)
  * This function differs from scm_c_write; it updates port line and
  * column, flushing line-buffered ports when appropriate. */
 void
-scm_lfwrite_unlocked (const char *ptr, size_t size, SCM port)
+scm_lfwrite (const char *ptr, size_t size, SCM port)
 {
   int saved_line;
 
@@ -2630,16 +2630,6 @@ scm_lfwrite_unlocked (const char *ptr, size_t size, SCM 
port)
     scm_flush (port);
 }
 
-void
-scm_lfwrite (const char *ptr, size_t size, SCM port)
-{
-  scm_i_pthread_mutex_t *lock;
-  scm_c_lock_port (port, &lock);
-  scm_lfwrite_unlocked (ptr, size, port);
-  if (lock)
-    scm_i_pthread_mutex_unlock (lock);
-}
-
 /* Write STR to PORT from START inclusive to END exclusive.  */
 void
 scm_lfwrite_substr (SCM str, size_t start, size_t end, SCM port)
diff --git a/libguile/ports.h b/libguile/ports.h
index d916205..d88fb21 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -328,7 +328,6 @@ SCM_API void scm_puts (const char *str_data, SCM port);
 SCM_API void scm_c_write (SCM port, const void *buffer, size_t size);
 SCM_API void scm_c_write_bytes (SCM port, SCM src, size_t start, size_t count);
 SCM_API void scm_lfwrite (const char *ptr, size_t size, SCM port);
-SCM_API void scm_lfwrite_unlocked (const char *ptr, size_t size, SCM port);
 SCM_INTERNAL void scm_lfwrite_substr (SCM str, size_t start, size_t end,
                                      SCM port);
 
diff --git a/libguile/print.c b/libguile/print.c
index 2f03d0c..514a725 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -453,7 +453,7 @@ print_extended_symbol (SCM sym, SCM port)
   len = scm_i_symbol_length (sym);
   strategy = PORT_CONVERSION_HANDLER (port);
 
-  scm_lfwrite_unlocked ("#{", 2, port);
+  scm_lfwrite ("#{", 2, port);
 
   for (pos = 0; pos < len; pos++)
     {
@@ -471,13 +471,13 @@ print_extended_symbol (SCM sym, SCM port)
         }
       else
         {
-          scm_lfwrite_unlocked ("\\x", 2, port);
+          scm_lfwrite ("\\x", 2, port);
           scm_intprint (c, 16, port);
           scm_putc (';', port);
         }
     }
 
-  scm_lfwrite_unlocked ("}#", 2, port);
+  scm_lfwrite ("}#", 2, port);
 }
 
 static void
@@ -497,13 +497,13 @@ print_r7rs_extended_symbol (SCM sym, SCM port)
 
       switch (c)
         {
-        case '\a': scm_lfwrite_unlocked ("\\a", 2, port); break;
-        case '\b': scm_lfwrite_unlocked ("\\b", 2, port); break;
-        case '\t': scm_lfwrite_unlocked ("\\t", 2, port); break;
-        case '\n': scm_lfwrite_unlocked ("\\n", 2, port); break;
-        case '\r': scm_lfwrite_unlocked ("\\r", 2, port); break;
-        case '|':  scm_lfwrite_unlocked ("\\|", 2, port); break;
-        case '\\': scm_lfwrite_unlocked ("\\x5c;", 5, port); break;
+        case '\a': scm_lfwrite ("\\a", 2, port); break;
+        case '\b': scm_lfwrite ("\\b", 2, port); break;
+        case '\t': scm_lfwrite ("\\t", 2, port); break;
+        case '\n': scm_lfwrite ("\\n", 2, port); break;
+        case '\r': scm_lfwrite ("\\r", 2, port); break;
+        case '|':  scm_lfwrite ("\\|", 2, port); break;
+        case '\\': scm_lfwrite ("\\x5c;", 5, port); break;
         default:
           if (uc_is_general_category_withtable (c,
                                                 UC_CATEGORY_MASK_L
@@ -520,7 +520,7 @@ print_r7rs_extended_symbol (SCM sym, SCM port)
             }
           else
             {
-              scm_lfwrite_unlocked ("\\x", 2, port);
+              scm_lfwrite ("\\x", 2, port);
               scm_intprint (c, 16, port);
               scm_putc (';', port);
             }
@@ -956,7 +956,7 @@ display_string_as_utf8 (const void *str, int narrow_p, 
size_t len,
 
       /* INPUT was successfully converted, entirely; print the
         result.  */
-      scm_lfwrite_unlocked (utf8_buf, utf8_len, port);
+      scm_lfwrite (utf8_buf, utf8_len, port);
       printed += i - printed;
     }
 
@@ -976,7 +976,7 @@ display_string_as_latin1 (const void *str, int narrow_p, 
size_t len,
 
   if (narrow_p)
     {
-      scm_lfwrite_unlocked (str, len, port);
+      scm_lfwrite (str, len, port);
       return len;
     }
 
@@ -995,7 +995,7 @@ display_string_as_latin1 (const void *str, int narrow_p, 
size_t len,
             break;
         }
 
-      scm_lfwrite_unlocked (buf, i, port);
+      scm_lfwrite (buf, i, port);
 
       if (i < sizeof(buf) && printed < len)
         {
@@ -1081,7 +1081,7 @@ display_string_using_iconv (const void *str, int 
narrow_p, size_t len,
          iconv (id->output_cd, NULL, NULL, NULL, NULL);
 
          /* Print the OUTPUT_LEN bytes successfully converted.  */
-         scm_lfwrite_unlocked (encoded_output, output_len, port);
+         scm_lfwrite (encoded_output, output_len, port);
 
          /* See how many input codepoints these OUTPUT_LEN bytes
             corresponds to.  */
@@ -1116,7 +1116,7 @@ display_string_using_iconv (const void *str, int 
narrow_p, size_t len,
        {
          /* INPUT was successfully converted, entirely; print the
             result.  */
-         scm_lfwrite_unlocked (encoded_output, output_len, port);
+         scm_lfwrite (encoded_output, output_len, port);
          codepoints_read = i - printed;
          printed += codepoints_read;
        }
@@ -1217,7 +1217,7 @@ write_character_escaped (scm_t_wchar ch, int 
string_escapes_p, SCM port)
          /* Use special escapes for some C0 controls.  */
          buf[0] = '\\';
          buf[1] = escapes[ch - 0x07];
-         scm_lfwrite_unlocked (buf, 2, port);
+         scm_lfwrite (buf, 2, port);
        }
       else if (!SCM_R6RS_ESCAPES_P)
        {
@@ -1227,7 +1227,7 @@ write_character_escaped (scm_t_wchar ch, int 
string_escapes_p, SCM port)
              buf[1] = 'x';
              buf[2] = hex[ch / 16];
              buf[3] = hex[ch % 16];
-             scm_lfwrite_unlocked (buf, 4, port);
+             scm_lfwrite (buf, 4, port);
            }
          else if (ch <= 0xFFFF)
            {
@@ -1237,7 +1237,7 @@ write_character_escaped (scm_t_wchar ch, int 
string_escapes_p, SCM port)
              buf[3] = hex[(ch & 0xF00) >> 8];
              buf[4] = hex[(ch & 0xF0) >> 4];
              buf[5] = hex[(ch & 0xF)];
-             scm_lfwrite_unlocked (buf, 6, port);
+             scm_lfwrite (buf, 6, port);
            }
          else if (ch > 0xFFFF)
            {
@@ -1249,7 +1249,7 @@ write_character_escaped (scm_t_wchar ch, int 
string_escapes_p, SCM port)
              buf[5] = hex[(ch & 0xF00) >> 8];
              buf[6] = hex[(ch & 0xF0) >> 4];
              buf[7] = hex[(ch & 0xF)];
-             scm_lfwrite_unlocked (buf, 8, port);
+             scm_lfwrite (buf, 8, port);
            }
        }
       else
@@ -1272,7 +1272,7 @@ write_character_escaped (scm_t_wchar ch, int 
string_escapes_p, SCM port)
          buf[i] = 'x';
          i --;
          buf[i] = '\\';
-         scm_lfwrite_unlocked (buf + i, 9 - i, port);
+         scm_lfwrite (buf + i, 9 - i, port);
        }
     }
   else
@@ -1376,14 +1376,14 @@ void
 scm_intprint (scm_t_intmax n, int radix, SCM port)
 {
   char num_buf[SCM_INTBUFLEN];
-  scm_lfwrite_unlocked (num_buf, scm_iint2str (n, radix, num_buf), port);
+  scm_lfwrite (num_buf, scm_iint2str (n, radix, num_buf), port);
 }
 
 void 
 scm_uintprint (scm_t_uintmax n, int radix, SCM port)
 {
   char num_buf[SCM_INTBUFLEN];
-  scm_lfwrite_unlocked (num_buf, scm_iuint2str (n, radix, num_buf), port);
+  scm_lfwrite (num_buf, scm_iuint2str (n, radix, num_buf), port);
 }
 
 /* Print an object of unrecognized type.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]