guile-cvs
[Top][All Lists]
Advanced

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

guile/guile-core/libguile ChangeLog strop.c


From: Dirk Herrmann
Subject: guile/guile-core/libguile ChangeLog strop.c
Date: Fri, 26 Jan 2001 10:04:33 -0800

CVSROOT:        /cvs
Module name:    guile
Changes by:     Dirk Herrmann <address@hidden>  01/01/26 10:04:32

Modified files:
        guile-core/libguile: ChangeLog strop.c 

Log message:
        * Fix parameter error reporting and avoid redundant parameter checks.

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1251&r2=1.1252
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/strop.c.diff?r1=1.48&r2=1.49

Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1251 
guile/guile-core/libguile/ChangeLog:1.1252
--- guile/guile-core/libguile/ChangeLog:1.1251  Fri Jan 26 09:30:53 2001
+++ guile/guile-core/libguile/ChangeLog Fri Jan 26 10:04:32 2001
@@ -1,5 +1,20 @@
 2001-01-26  Dirk Herrmann  <address@hidden>
 
+       The following patch was sent by Martin Grabmueller.  It makes sure
+       that in case of parameter errors the correct function name is
+       shown, and that parameter types are only checked once.
+
+       * strop.c (string_copy, string_upcase_x, string_downcase_x,
+       string_capitalize_x):  New functions.  Each one performs the core
+       functionality of the corresponding scm_* function.
+
+       (scm_string_copy, scm_string_upcase_x, scm_string_upcase,
+       scm_string_downcase_x, scm_string_downcase,
+       scm_string_capitalize_x, scm_string_capitalize):  Reduced to
+       parameter checking wrappers of the above functions.
+
+2001-01-26  Dirk Herrmann  <address@hidden>
+
        * continuations.c, dynl.c, keywords.c, load.c:  Include
        strings.h.  Thanks to Bill Schottstaedt for the bug report.
 
Index: guile/guile-core/libguile/strop.c
diff -u guile/guile-core/libguile/strop.c:1.48 
guile/guile-core/libguile/strop.c:1.49
--- guile/guile-core/libguile/strop.c:1.48      Tue Nov 28 10:22:23 2000
+++ guile/guile-core/libguile/strop.c   Fri Jan 26 10:04:32 2001
@@ -330,14 +330,23 @@
 #undef FUNC_NAME
 
 
+/* Helper function for the string copy and string conversion functions.
+ * No argument checking is performed.  */
+static SCM
+string_copy (SCM str)
+{
+  return scm_makfromstr (SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str), 0);
+}
 
+
 SCM_DEFINE (scm_string_copy, "string-copy", 1, 0, 0, 
-           (SCM str),
+           (SCM str),
            "Returns a newly allocated copy of the given @var{string}. (r5rs)")
 #define FUNC_NAME s_scm_string_copy
 {
   SCM_VALIDATE_STRING (1, str);
-  return scm_makfromstr (SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str), 0);
+
+  return string_copy (str);
 }
 #undef FUNC_NAME
 
@@ -357,8 +366,23 @@
 }
 #undef FUNC_NAME
 
+
+/* Helper function for the string uppercase conversion functions.  
+ * No argument checking is performed.  */
+static SCM
+string_upcase_x (SCM v)
+{
+  unsigned long k;
+
+  for (k = 0; k < SCM_STRING_LENGTH (v); ++k)
+    SCM_STRING_UCHARS (v) [k] = scm_upcase (SCM_STRING_UCHARS (v) [k]);
+
+  return v;
+}
+
+
 SCM_DEFINE (scm_string_upcase_x, "string-upcase!", 1, 0, 0, 
-           (SCM v),
+           (SCM str),
            "Destructively upcase every character in @code{str}.\n\n"
            "(qdocs:) Converts each element in @var{str} to upper case.\n\n"
            "@example\n"
@@ -369,28 +393,41 @@
            "@end example")
 #define FUNC_NAME s_scm_string_upcase_x
 {
-  unsigned long k;
-
-  SCM_VALIDATE_STRING (1, v);
-
-  for (k = 0; k < SCM_STRING_LENGTH (v); ++k)
-    SCM_STRING_UCHARS (v) [k] = scm_upcase (SCM_STRING_UCHARS (v) [k]);
+  SCM_VALIDATE_STRING (1, str);
 
-  return v;
+  return string_upcase_x (str);
 }
 #undef FUNC_NAME
 
+
 SCM_DEFINE (scm_string_upcase, "string-upcase", 1, 0, 0, 
-           (SCM str),
+           (SCM str),
            "Upcase every character in @code{str}.")
 #define FUNC_NAME s_scm_string_upcase
 {
-  return scm_string_upcase_x(scm_string_copy(str));
+  SCM_VALIDATE_STRING (1, str);
+
+  return string_upcase_x (string_copy (str));
 }
 #undef FUNC_NAME
 
+
+/* Helper function for the string lowercase conversion functions.  
+ * No argument checking is performed.  */
+static SCM
+string_downcase_x (SCM v)
+{
+  unsigned long k;
+
+  for (k = 0; k < SCM_STRING_LENGTH (v); ++k)
+    SCM_STRING_UCHARS (v) [k] = scm_downcase (SCM_STRING_UCHARS (v) [k]);
+
+  return v;
+}
+
+
 SCM_DEFINE (scm_string_downcase_x, "string-downcase!", 1, 0, 0, 
-           (SCM v),
+           (SCM str),
            "Destructively downcase every character in @code{str}.\n\n"
            "(qdocs:) Converts each element in @var{str} to lower case.\n\n"
            "@example\n"
@@ -403,35 +440,33 @@
            "@end example")
 #define FUNC_NAME s_scm_string_downcase_x
 {
-  unsigned long k;
-
-  SCM_VALIDATE_STRING (1, v);
-
-  for (k = 0; k < SCM_STRING_LENGTH (v); ++k)
-    SCM_STRING_UCHARS (v) [k] = scm_downcase (SCM_STRING_UCHARS (v) [k]);
+  SCM_VALIDATE_STRING (1, str);
 
-  return v;
+  return string_downcase_x (str);
 }
 #undef FUNC_NAME
 
+
 SCM_DEFINE (scm_string_downcase, "string-downcase", 1, 0, 0, 
-           (SCM str),
+           (SCM str),
            "Downcase every character in @code{str}.")
 #define FUNC_NAME s_scm_string_downcase
 {
-  SCM_VALIDATE_STRING (1,str);
-  return scm_string_downcase_x(scm_string_copy(str));
+  SCM_VALIDATE_STRING (1, str);
+
+  return string_downcase_x (string_copy (str));
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_string_capitalize_x, "string-capitalize!", 1, 0, 0, 
-           (SCM str),
-           "Destructively capitalize every character in @code{str}.")
-#define FUNC_NAME s_scm_string_capitalize_x
+
+/* Helper function for the string capitalization functions.  
+ * No argument checking is performed.  */
+static SCM
+string_capitalize_x (SCM str)
 {
   char *sz;
   int i, len, in_word=0;
-  SCM_VALIDATE_STRING (1,str);
+
   len = SCM_STRING_LENGTH(str);
   sz = SCM_STRING_CHARS (str);
   for(i=0; i<len;  i++) {
@@ -447,17 +482,31 @@
   }
   return str;
 }
+
+
+SCM_DEFINE (scm_string_capitalize_x, "string-capitalize!", 1, 0, 0, 
+           (SCM str),
+           "Destructively capitalize every character in @code{str}.")
+#define FUNC_NAME s_scm_string_capitalize_x
+{
+  SCM_VALIDATE_STRING (1, str);
+
+  return string_capitalize_x (str);
+}
 #undef FUNC_NAME
 
+
 SCM_DEFINE (scm_string_capitalize, "string-capitalize", 1, 0, 0, 
-           (SCM str),
+           (SCM str),
            "Capitalize every character in @code{str}.")
 #define FUNC_NAME s_scm_string_capitalize
 {
-  SCM_VALIDATE_STRING (1,str);
-  return scm_string_capitalize_x(scm_string_copy(str));
+  SCM_VALIDATE_STRING (1, str);
+
+  return string_capitalize_x (string_copy (str));
 }
 #undef FUNC_NAME
+
 
 SCM_DEFINE (scm_string_ci_to_symbol, "string-ci->symbol", 1, 0, 0, 
            (SCM str),



reply via email to

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