[comp.sys.atari.st] gnuplot

mdoerr@uklirb.UUCP (04/10/87)

> and whether they would like the hacked limited version or wait for the
> super++ version.

I definitely want, it but prefer to wait for the full version.

>  sizeof("anystring") returns 4 (the size of the pointer!!!!), not 10.

This (in my opinion) isn't a bug. Any C compiler I know of treats an
ordinary string as a pointer to an array of chars.
Try c = "ABCDEF"[2]; and you'll find (c=='C') to be true.
Use strlen("anystring") instead of sizeof("anystring").

> Since I am also stuck with the lousy Megamax FP library I would like
> to hear when any new version comes out. Despite having paid my money
> for Megamax and sent off my card asking for information (and also a
> letter telling Megamax of other bugs!) I have never heard a word from
> them. Ought I to have waited for MWC? Are they any better?

MWC are much better. I've send my registration card to Chicago and received
their upgrade notice (to V.2.0) prior to the German distributor having
arranged the updates.

> Mike Gerard.

	Michael Doerr

ericr@hpvcla.UUCP (04/10/87)

> In doing this I have found two (more!) bugs in Megamax:-
>
>  sizeof("anystring") returns 4 (the size of the pointer!!!!), not 10.

A literal string IS a pointer, so the sizeof did return the correct
value.  This is why you can do things such as:

char *pt;

pt = "String";

----
Eric Ross
Hewlett Packard, Vancouver, WA (Home of the Thinkjet and Quietjet printers)
   
HPDesk: Eric Ross/HP5400/AL (HP Internal)
UUCP:   ihnp4!hpfcla!hpvcla!ericr
CIS:    72347,2664
GEnie:  E.ROSS
Phone:  (206)254-8110

john@viper.UUCP (04/11/87)

In article <461@cernvax.UUCP> jmg@cernvax.UUCP () writes:
 >
 >I have just about got the original version of gnuplot running on my ST.

Congratulations!

 > My query is whether anybody wants it,
 >and whether they would like the hacked limited version or wait for the
 >super++ version.
 >

I will be glad to see your current version -and- would be happy to
see the final version also...  My net address is below.  Feel free
to send me a copy when you get the time unless you're planning to
post it to the .binarys. or .source. newsgroups...

 >In doing this I have found two (more!) bugs in Megamax:-
 >
 >  sizeof("anystring") returns 4 (the size of the pointer!!!!), not 10.

Excuse me, but this doesn't sound like a bug...  If you take a look at
K&R page 94, "In fact, any reference to an array is converted by the
compiler to a pointer to the beginning of the array."  This means you're
taking sizeof a pointer, which is in fact 4...(Remember, in C a string
is no different from a null terminated array of characters.)

  Sure you didn't intend to use strlen("anystring") instead?  That, would
return 9 as the length of the string....

 >
 >Also, the %-* used in various print statements fails in Megamax (another
 >bug!).
 >

This doesn't work in -most- librarys...  Try %* and using a negative
argument instead....

---
John Stanley (john@viper.UUCP)
Software Consultant - DynaSoft Systems
UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john

jsgray@watrose.UUCP (04/12/87)

In article <813@viper.UUCP> john@viper.UUCP (John Stanley) writes:
>In article <461@cernvax.UUCP> jmg@cernvax.UUCP () writes:
> >In doing this I have found two (more!) bugs in Megamax:-
> >  sizeof("anystring") returns 4 (the size of the pointer!!!!), not 10.
>Excuse me, but this doesn't sound like a bug...  If you take a look at
>K&R page 94, "In fact, any reference to an array is converted by the
>compiler to a pointer to the beginning of the array."  This means you're
>taking sizeof a pointer, which is in fact 4...(Remember, in C a string
>is no different from a null terminated array of characters.)

Excuse me, but it is a bug. K&R p. 188: "When applied to an array, the
result is the total number of bytes in the array."  What sort of consulting
do you do?

Jan Gray    jsgray@watrose    University of Waterloo    (519) 885-1211 x3870

john@viper.UUCP (John Stanley) (04/19/87)

In article <8640@watrose.UUCP> jsgray@watrose.UUCP (Jan Gray) writes:
 >
 >Excuse me, but it is a bug. K&R p. 188: "When applied to an array, the
 >result is the total number of bytes in the array."

  Enough already...  This subject has been flogged to death...  The
ANSI answer appears to be yours.  I've made it a point not to use
the construct on string constants just because I've run into more
than one compiler where it didn't work that way...  I tend to use
a static and take the sizeof that (which works 99% of the time...)

 >  What sort of consulting do you do?

  A great deal of consulting that requires the things I do to work
on almost any compiler or machine.  From experience I've learned to
avoid using things that compiler writers tend to twist, bend or
otherwise screw up on.  This happens to be one of those.

  Since I've found situations where either answer is "the way things
work" ("correct" or not...), I over reacted when whoever it was
stated that his compiler was "wrong".  If he continues to use that 
construct and assumes that it will work (until ANSI regins supreme) 
he will probably get burnt when he trys to port it to some-machine 
some-day.

  Good enough?

--- 
John Stanley (john@viper.UUCP)
Software Consultant - DynaSoft Systems
UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john