unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Andreas Vögele" <voegelas@gmx.net>
Subject: Re: Guile 1.7.1 has been released.
Date: Sun, 29 Aug 2004 11:23:33 +0200	[thread overview]
Message-ID: <193B2882-F99D-11D8-A510-000D93673682@gmx.net> (raw)
In-Reply-To: <24CF5BB2-F93A-11D8-B8A1-000A95C37894@lurchi.franken.de>

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Michael Tuexen writes:

> Hi Marius,
>
> I tried to compile it on Mac OS X, but the following comes up: [...]
>
> srfi-13.c: In function `scm_string_trim_right':
> srfi-13.c:771: warning: passing arg 3 of `scm_i_get_substring_spec'
> from incompatible pointer type

I've attached a patch that replaces the remaining occurrences of int in 
srfi-13.c with size_t. In addition to these replacements, the function 
string_reverse_x() makes sure that the variable cend is only 
decremented if it's value is greater than zero.

One thing that I noted is that the variable cfrom in scm_xsubstring() 
and the variable csfrom in scm_string_xcopy_x() are of type size_t but 
that they are checked for negative values:

int t = ((cfrom < 0) ? -cfrom : cfrom) % (cend - cstart);
if (cfrom < 0)
....

I've tested this patch on Mac OS X and OpenBSD.

BTW, do you prefer included or attached patches?


[-- Attachment #2: srfi-13.c.diff --]
[-- Type: application/octet-stream, Size: 3832 bytes --]

Index: libguile/srfi-13.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/srfi-13.c,v
retrieving revision 1.3
diff -u -r1.3 srfi-13.c
--- libguile/srfi-13.c	25 Aug 2004 16:04:09 -0000	1.3
+++ libguile/srfi-13.c	29 Aug 2004 09:12:07 -0000
@@ -106,7 +106,7 @@
     }
   else if (SCM_CHARSETP (char_pred))
     {
-      int i;
+      size_t i;
       for (i = cstart; i < cend; i++)
         if (SCM_CHARSET_GET (char_pred, cstr[i]))
 	  {
@@ -163,7 +163,7 @@
   if (SCM_CHARP (char_pred))
     {
       char cchr = SCM_CHAR (char_pred);
-      int i;
+      size_t i;
       for (i = cstart; i < cend; i++)
         if (cstr[i] != cchr)
 	  {
@@ -173,7 +173,7 @@
     }
   else if (SCM_CHARSETP (char_pred))
     {
-      int i;
+      size_t i;
       for (i = cstart; i < cend; i++)
         if (!SCM_CHARSET_GET (char_pred, cstr[i]))
 	  {
@@ -225,7 +225,7 @@
       /* The RES string remains untouched since nobody knows about it
 	 yet. No need to refetch P.
       */
-      ch = scm_call_1 (proc, scm_from_int (i));
+      ch = scm_call_1 (proc, scm_from_size_t (i));
       if (!SCM_CHARP (ch))
 	SCM_MISC_ERROR ("procedure ~S returned non-char", scm_list_1 (proc));
       *p++ = SCM_CHAR (ch);
@@ -764,7 +764,7 @@
 #define FUNC_NAME s_scm_string_trim_right
 {
   const char *cstr;
-  int cstart, cend;
+  size_t cstart, cend;
 
   MY_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr,
 				   3, start, cstart,
@@ -2326,7 +2326,7 @@
 /* Helper function for the string uppercase conversion functions.
  * No argument checking is performed.  */
 static SCM
-string_upcase_x (SCM v, int start, int end)
+string_upcase_x (SCM v, size_t start, size_t end)
 {
   size_t k;
   char *dst;
@@ -2392,7 +2392,7 @@
 /* Helper function for the string lowercase conversion functions.
  * No argument checking is performed.  */
 static SCM
-string_downcase_x (SCM v, int start, int end)
+string_downcase_x (SCM v, size_t start, size_t end)
 {
   size_t k;
   char *dst;
@@ -2460,7 +2460,7 @@
 /* Helper function for the string capitalization functions.
  * No argument checking is performed.  */
 static SCM
-string_titlecase_x (SCM str, int start, int end)
+string_titlecase_x (SCM str, size_t start, size_t end)
 {
   unsigned char *sz;
   size_t i;
@@ -2555,18 +2555,21 @@
 /* Reverse the portion of @var{str} between str[cstart] (including)
    and str[cend] excluding.  */
 static void
-string_reverse_x (char * str, int cstart, int cend)
+string_reverse_x (char * str, size_t cstart, size_t cend)
 {
   char tmp;
 
-  cend--;
-  while (cstart < cend)
+  if (cend > 0)
     {
-      tmp = str[cstart];
-      str[cstart] = str[cend];
-      str[cend] = tmp;
-      cstart++;
       cend--;
+      while (cstart < cend)
+	{
+	  tmp = str[cstart];
+	  str[cstart] = str[cend];
+	  str[cend] = tmp;
+	  cstart++;
+	  cend--;
+	}
     }
 }
 
@@ -3032,7 +3035,7 @@
   cs = scm_i_string_chars (s);
   while (cfrom < cto)
     {
-      int t = ((cfrom < 0) ? -cfrom : cfrom) % (cend - cstart);
+      size_t t = ((cfrom < 0) ? -cfrom : cfrom) % (cend - cstart);
       if (cfrom < 0)
 	*p = cs[(cend - cstart) - t];
       else
@@ -3060,7 +3063,7 @@
   const char *cs;
   size_t ctstart, csfrom, csto, cstart, cend;
   SCM dummy = SCM_UNDEFINED;
-  int cdummy;
+  size_t cdummy;
 
   MY_VALIDATE_SUBSTRING_SPEC (1, target,
 			      2, tstart, ctstart,
@@ -3082,7 +3085,7 @@
   cs = scm_i_string_chars (s);
   while (csfrom < csto)
     {
-      int t = ((csfrom < 0) ? -csfrom : csfrom) % (cend - cstart);
+      size_t t = ((csfrom < 0) ? -csfrom : csfrom) % (cend - cstart);
       if (csfrom < 0)
 	*p = cs[(cend - cstart) - t];
       else
@@ -3155,7 +3158,7 @@
 
   if (SCM_CHARSETP (token_set))
     {
-      int idx;
+      size_t idx;
 
       while (cstart < cend)
 	{

[-- Attachment #3: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

  reply	other threads:[~2004-08-29  9:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-26 23:02 Guile 1.7.1 has been released Marius Vollmer
2004-08-27 22:57 ` Jonathan Bartlett
2004-08-28 21:35 ` Michael Tuexen
2004-08-29  9:23   ` Andreas Vögele [this message]
2004-09-20 22:53     ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=193B2882-F99D-11D8-A510-000D93673682@gmx.net \
    --to=voegelas@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).