unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* How do I determine the argument type...
@ 2003-05-10  3:27 Bruce Korb
  2003-05-10  3:31 ` Bruce Korb
  2003-05-17 20:14 ` Marius Vollmer
  0 siblings, 2 replies; 13+ messages in thread
From: Bruce Korb @ 2003-05-10  3:27 UTC (permalink / raw)



The problem is with gh_scm2newstr:

    size_t  len;
    char*   pz = gh_scm2newstr( str, &len );

This is a problem on a platform where the argument is actually
int* and the platform is I32LP64.  i.e., the size_t is 64 bits.
Since other versions of the library use size_t, I think I'm
pretty much hosed without using an scm2newstr_size_t :-(


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-10  3:27 How do I determine the argument type Bruce Korb
@ 2003-05-10  3:31 ` Bruce Korb
  2003-05-17 20:14 ` Marius Vollmer
  1 sibling, 0 replies; 13+ messages in thread
From: Bruce Korb @ 2003-05-10  3:31 UTC (permalink / raw)


Bruce Korb wrote:
> 
> The problem is with gh_scm2newstr:
> 
>     size_t  len;
>     char*   pz = gh_scm2newstr( str, &len );
> 
> This is a problem on a platform where the argument is actually
> int* and the platform is I32LP64.  i.e., the size_t is 64 bits.
> Since other versions of the library use size_t, I think I'm
> pretty much hosed without using an scm2newstr_size_t :-(

P.S. please change the interface name when you change arg lists.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-10  3:27 How do I determine the argument type Bruce Korb
  2003-05-10  3:31 ` Bruce Korb
@ 2003-05-17 20:14 ` Marius Vollmer
  2003-05-17 21:16   ` Bruce Korb
  1 sibling, 1 reply; 13+ messages in thread
From: Marius Vollmer @ 2003-05-17 20:14 UTC (permalink / raw)
  Cc: guile development

Bruce Korb <bkorb@veritas.com> writes:

> The problem is with gh_scm2newstr:
> 
>     size_t  len;
>     char*   pz = gh_scm2newstr( str, &len );
> 
> This is a problem on a platform where the argument is actually
> int* and the platform is I32LP64.  i.e., the size_t is 64 bits.
> Since other versions of the library use size_t, I think I'm
> pretty much hosed without using an scm2newstr_size_t :-(

I don't understand.  Bothe 1.6 and 1.7 have this prototype for
gh_scm2newstr:

    char *gh_scm2newstr (SCM str, size_t *lenp);

On what platform is the argument actually an "int*"?  Can you give a
specific example that must fail?

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-17 20:14 ` Marius Vollmer
@ 2003-05-17 21:16   ` Bruce Korb
  2003-05-18  1:57     ` Marius Vollmer
  0 siblings, 1 reply; 13+ messages in thread
From: Bruce Korb @ 2003-05-17 21:16 UTC (permalink / raw)
  Cc: guile development

Marius Vollmer wrote:
> 
> Bruce Korb <bkorb@veritas.com> writes:
> 
> > The problem is with gh_scm2newstr:
> >
> >     size_t  len;
> >     char*   pz = gh_scm2newstr( str, &len );
> >
> > This is a problem on a platform where the argument is actually
> > int* and the platform is I32LP64.  i.e., the size_t is 64 bits.
> > Since other versions of the library use size_t, I think I'm
> > pretty much hosed without using an scm2newstr_size_t :-(
> 
> I don't understand.  Both 1.6 and 1.7 have this prototype for
> gh_scm2newstr:
> 
>     char *gh_scm2newstr (SCM str, size_t *lenp);
> 
> On what platform is the argument actually an "int*"?  Can you give a
> specific example that must fail?

> $ guile --version
> Guile 1.4
> Copyright (c) 1995, 1996, 1997, 2000 Free Software Foundation
> ...
> $ fgrep gh_scm2newstr /opt/TWWfsw/guile14/include/guile/gh.h
> char *gh_scm2newstr(SCM str, int *lenp);
> $ uname -a
> HP-UX kibo B.11.00 A 9000/800 1596730518 two-user license

This is an I32LP64 platform.  I don't manage it.  This is
the Guile version they have.  It is only 3 years old, not
truely ancient.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-17 21:16   ` Bruce Korb
@ 2003-05-18  1:57     ` Marius Vollmer
  2003-05-18  2:59       ` Bruce Korb
  2003-05-19  0:07       ` Kevin Ryde
  0 siblings, 2 replies; 13+ messages in thread
From: Marius Vollmer @ 2003-05-18  1:57 UTC (permalink / raw)
  Cc: guile development

Bruce Korb <bkorb@veritas.com> writes:

> > I don't understand.  Both 1.6 and 1.7 have this prototype for
> > gh_scm2newstr:
> > 
> >     char *gh_scm2newstr (SCM str, size_t *lenp);
> > 
> > On what platform is the argument actually an "int*"?  Can you give a
> > specific example that must fail?
> 
> $ guile --version
> Guile 1.4
> Copyright (c) 1995, 1996, 1997, 2000 Free Software Foundation
> ...
> $ fgrep gh_scm2newstr /opt/TWWfsw/guile14/include/guile/gh.h
> char *gh_scm2newstr(SCM str, int *lenp);
> $ uname -a
> HP-UX kibo B.11.00 A 9000/800 1596730518 two-user license

Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
way.  I'm not sure what to do about this.  Changing this back is just
as bad as the original change from int to size_t.

Personally, I would stop supporting Guile 1.4 and just require Guile
1.6 for newer versions of your code...

I dirty workaround, in this particular case, might be to always pass
NULL as lenp and get the length via scm_string_length (or strlen if
you don't care about '\0' characters in the middle of the string).

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-18  1:57     ` Marius Vollmer
@ 2003-05-18  2:59       ` Bruce Korb
  2003-05-19  0:07       ` Kevin Ryde
  1 sibling, 0 replies; 13+ messages in thread
From: Bruce Korb @ 2003-05-18  2:59 UTC (permalink / raw)
  Cc: guile development

Marius Vollmer wrote:

> Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
> way.  I'm not sure what to do about this.  Changing this back is just
> as bad as the original change from int to size_t.

Right.  So, what to do now is set up a config macro that
puts an scm2newstr_size_t into config.h and provide it for your
clients (e.g. me).

> Personally, I would stop supporting Guile 1.4 and just require Guile
> 1.6 for newer versions of your code...

Not a good choice until 1.4 becomes fairly rare.  A few more years yet.
Heck, some people still sweat K&R compilers and functionless shells!

> I dirty workaround, in this particular case, might be to always pass
> NULL as lenp and get the length via scm_string_length

I thought of that and, in the end, I devised a way to avoid the
offending calls.  The code is tighter now.  :-)

But, the truth is, this is just an annoyance problem.  I would _really_
like to fix the error messages emitted by libguile without having to
read source code to figure out how to rewrite gh_eval_str to be able
to plug in a file name and line number.  I've actually made a couple
of runs at it, but I confess to finding the code a bit difficult to
follow..... :-(

Regards,
	Bruce


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-18  1:57     ` Marius Vollmer
  2003-05-18  2:59       ` Bruce Korb
@ 2003-05-19  0:07       ` Kevin Ryde
  2003-05-19  0:34         ` Bruce Korb
  2003-06-01 18:45         ` Marius Vollmer
  1 sibling, 2 replies; 13+ messages in thread
From: Kevin Ryde @ 2003-05-19  0:07 UTC (permalink / raw)


Marius Vollmer <mvo@zagadka.de> writes:
>
> Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
> way.  I'm not sure what to do about this.  Changing this back is just
> as bad as the original change from int to size_t.

The manual still says "int".  Maybe call it a bug fix and put it back
to that.

Or making it a macro could hide the variation for plain calls, which
is presumably most usages.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-19  0:07       ` Kevin Ryde
@ 2003-05-19  0:34         ` Bruce Korb
  2003-05-19  0:47           ` Kevin Ryde
  2003-06-01 18:45         ` Marius Vollmer
  1 sibling, 1 reply; 13+ messages in thread
From: Bruce Korb @ 2003-05-19  0:34 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde wrote:
> 
> Marius Vollmer <mvo@zagadka.de> writes:
> >
> > Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
> > way.  I'm not sure what to do about this.  Changing this back is just
> > as bad as the original change from int to size_t.
> 
> The manual still says "int".  Maybe call it a bug fix and put it back
> to that.
> 
> Or making it a macro could hide the variation for plain calls, which
> is presumably most usages.

A macro cannot hide the problem.  You cannot set it back to int without
breaking everyone who adapted to size_t.  The best choice is to just
say, "Oops.  Sorry.  Either reject Guile 1.4 or use this configury macro
to specify the type passed to gh_scm2newstr()."  Or, alternatively,
always pass NULL as the second argument.  Don't go back, though.  Thanks!


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-19  0:34         ` Bruce Korb
@ 2003-05-19  0:47           ` Kevin Ryde
  2003-05-19  1:44             ` Bruce Korb
  0 siblings, 1 reply; 13+ messages in thread
From: Kevin Ryde @ 2003-05-19  0:47 UTC (permalink / raw)


Bruce Korb <bkorb@veritas.com> writes:
>
> A macro cannot hide the problem.  You cannot set it back to int without
> breaking everyone who adapted to size_t.

I was thinking of something like,

#define gh_scm2newstr(str,lenp) \
  gh_scm2newstr_helper (str, lenp, sizeof (*lenp))

Not sure if all compilers will enjoy "sizeof(*NULL)" though.

Another way would be the following, though it unfortunately evaluates
the parameters more than once.  In gcc that could be avoided,
probably.

#define gh_scm2newstr(str,lenp) \
  ((lenp) ? *(lenp) = gh_scmstrlen (str) : 0,  \
   gh_scm2newstr_helper (str))

> "Oops.

I guess insofar as it's contrary to the docs it's an oops.

> use this configury macro to specify the type passed to
> gh_scm2newstr()."

Probably as simple as an AC_TRY_COMPILE (or AC_COMPILE_IFELSE, or
whatever it's called these days).


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-19  0:47           ` Kevin Ryde
@ 2003-05-19  1:44             ` Bruce Korb
  0 siblings, 0 replies; 13+ messages in thread
From: Bruce Korb @ 2003-05-19  1:44 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde wrote:
> 
> Bruce Korb <bkorb@veritas.com> writes:
> >
> > A macro cannot hide the problem.  You cannot set it back to int without
> > breaking everyone who adapted to size_t.
> 
> I was thinking of something like,
> 
> #define gh_scm2newstr(str,lenp) \
>   gh_scm2newstr_helper (str, lenp, sizeof (*lenp))
> 
> Not sure if all compilers will enjoy "sizeof(*NULL)" though.

Certainly not.  Even if it did, what would the chances of ``-Wall -Werror'' be?

Nobody is responding to my real problem though, so I read some code
and pieced this together as an addition for strports.c.  The problem with
it is that it looks very version specific (viz., wouldn't work with any
version but 1.6):


EXPORT SCM
scm_c_eval_string_with_file_line( tCC* pzExpr, tCC* pzFile, int line )
{
    static const char zEx[] = "eval-string-with-file-line";
    static SCM file = SCM_UNDEFINED;
    SCM expr   = scm_makfrom0str (pzExpr);
    SCM port   = scm_mkstrport (SCM_INUM0, expr, SCM_OPN | SCM_RDNG, zEx);
    SCM res;

    SCM_PTAB_ENTRY (port)->line_number = line - 1;

    if (  (file == SCM_UNDEFINED)
       || (strcmp(SCM_CHARS (file), pzFile) != 0) )  {
        file = scm_makfrom0str (pzFile);
        SCM_PTAB_ENTRY (port)->file_name = file;
    }

    res = scm_c_call_with_current_module(
        scm_interaction_environment(), inner_eval_string, (void*)port );
    return res;
}

It seems to do what I want.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-05-19  0:07       ` Kevin Ryde
  2003-05-19  0:34         ` Bruce Korb
@ 2003-06-01 18:45         ` Marius Vollmer
  2003-06-01 20:07           ` Bruce Korb
  2003-06-11 22:33           ` Kevin Ryde
  1 sibling, 2 replies; 13+ messages in thread
From: Marius Vollmer @ 2003-06-01 18:45 UTC (permalink / raw)
  Cc: guile-devel

Kevin Ryde <user42@zip.com.au> writes:

> Marius Vollmer <mvo@zagadka.de> writes:
> >
> > Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
> > way.  I'm not sure what to do about this.  Changing this back is just
> > as bad as the original change from int to size_t.
> 
> The manual still says "int".

Damn.

> Maybe call it a bug fix and put it back to that.

Hmm, no, I prefer changing the docs.  "size_t" is the right type, and
not many people seem to be affected by the int -> size_t change, so we
chould leave it at size_t.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-06-01 18:45         ` Marius Vollmer
@ 2003-06-01 20:07           ` Bruce Korb
  2003-06-11 22:33           ` Kevin Ryde
  1 sibling, 0 replies; 13+ messages in thread
From: Bruce Korb @ 2003-06-01 20:07 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer wrote:
> > > Ahh, I see.  Yes, it was not a good thing to change gh_new2str that
> > > way.  I'm not sure what to do about this.  Changing this back is just
> > > as bad as the original change from int to size_t.
> >
> > The manual still says "int".

> > Maybe call it a bug fix and put it back to that.
> 
> Hmm, no, I prefer changing the docs.  "size_t" is the right type, and
> not many people seem to be affected by the int -> size_t change, so we
> chould leave it at size_t.

"int" is fine for the purpose since there is little need to cope with
multi-gigabyte strings.  OTOH, you have two libraries in the field.
Right now, clients writing to the 1.4 interface that use the length
argument to gh_new2str are hosed on I32LP64 platforms.

If you were to change it back, clients writing to the current interface
using that argument would be hosed on I32LP64 platforms.
Re-doc it and leave it be (says the guy who was first to cry "ouch"
from stubbing his toe on this.)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How do I determine the argument type...
  2003-06-01 18:45         ` Marius Vollmer
  2003-06-01 20:07           ` Bruce Korb
@ 2003-06-11 22:33           ` Kevin Ryde
  1 sibling, 0 replies; 13+ messages in thread
From: Kevin Ryde @ 2003-06-11 22:33 UTC (permalink / raw)


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

Marius Vollmer <mvo@zagadka.de> writes:
>
> Hmm, no, I prefer changing the docs.  "size_t" is the right type, and
> not many people seem to be affected by the int -> size_t change, so we
> chould leave it at size_t.

Not that it's much to do with me, but while I'm working on the docs I
made this change.

        * gh.texi (Scheme to C): In gh_scm2newstr, lenp is size_t* not int*.
        This changed in guile 1.6, the docs weren't updated.

Dunno if the manual itself needs a compatibility note.  If no-one else
has tripped over it and the interface itself is considered obsolete
then hardly worth worrying.


[-- Attachment #2: gh.texi.gh_scm2newstr.diff --]
[-- Type: text/plain, Size: 524 bytes --]

--- gh.texi.~1.6.~	2003-04-05 16:47:18.000000000 +1000
+++ gh.texi	2003-06-10 16:47:40.000000000 +1000
@@ -433,7 +433,7 @@
 These routines convert the Scheme object to the given C type.
 @end deftypefun
 
-@deftypefun char *gh_scm2newstr (SCM @var{str}, int *@var{lenp})
+@deftypefun char *gh_scm2newstr (SCM @var{str}, size_t *@var{lenp})
 Given a Scheme string @var{str}, return a pointer to a new copy of its
 contents, followed by a null byte.  If @var{lenp} is non-null, set
 @code{*@var{lenp}} to the string's length.

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

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-06-11 22:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-10  3:27 How do I determine the argument type Bruce Korb
2003-05-10  3:31 ` Bruce Korb
2003-05-17 20:14 ` Marius Vollmer
2003-05-17 21:16   ` Bruce Korb
2003-05-18  1:57     ` Marius Vollmer
2003-05-18  2:59       ` Bruce Korb
2003-05-19  0:07       ` Kevin Ryde
2003-05-19  0:34         ` Bruce Korb
2003-05-19  0:47           ` Kevin Ryde
2003-05-19  1:44             ` Bruce Korb
2003-06-01 18:45         ` Marius Vollmer
2003-06-01 20:07           ` Bruce Korb
2003-06-11 22:33           ` Kevin Ryde

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).