[Coco] help with C problem

Robert Gault robert.gault at worldnet.att.net
Mon Jan 2 08:38:22 EST 2006


Assuming there is not a BUG, looks like the error is dependent on the 
software in use. This works with Microware C in OS-9. The crucial lines 
might be found if you can get the program saved as an .a file.

_3                  (int)*s2 < 128
  ldb [6,s]
  sex
  cmpd #128
  lblt _4

If there is no equivalent to sex on your system or there is some other 
size mismatch, then maybe (int)*s2 will always be less than 128. Turns 
out that in OS-9 you get the exact same conversion with  *s2<128,
(char)*s2 < 128, or (short)*s2 <128.

If the OS-9 package is not "outside the pale" for C usage, then most 
likely char *s2 or (int)*s2 does not result in what you are expecting.

Bob Devries wrote:
> To all you C gurus: I have a problem with compiling the following code:
> 
> char *
> strhcpy(s1, s2)
> char *s1;
> char *s2;
> {
>         while ((int)*s2 < 128) { /* line 8*/
>               *s1++ = *s2++;
>               }
>         *s1++ = *s2++ & 0x7F;
>         *s1 = '\0';
>         return (s1);
> }
> 
> The compiler always gives a warning  in line 8:  [Warning] comparison is 
> always true due to limited range of data type
> 
> Can someone PLEASE tell me what I'm doing wrong?
> Yes, you're right, I'm trying to write a PC version of the OS9 library 
> function strhcpy().
> 
> -- 
> Regards, Bob Devries, Dalby, Queensland, Australia
> 
> Isaiah 50:4 The sovereign Lord has given me
> the capacity to be his spokesman,
> so that I know how to help the weary.
> 
> website: http://www.home.gil.com.au/~bdevasl
> my blog: http://bdevries.invigorated.org/
> 
> 



More information about the Coco mailing list