🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #16987

Re: Why doesn't this work?

#16987
From: Macintosh Users Group
Date: Sat, 20 Jun 1987 17:23
53 lines
2091 bytes
In article <1376@batcomputer.tn.cornell.edu> steig@tcgould.tn.cornell.edu (Mark J. Steiglitz) writes:
>
>/*This works*/
>Cstring=PtoCstr(Pstring);
>stpcpy(copyofCstring,Cstring);
>
>/*This doesn't*/
>stpcpy(copyofCstring,PtoCstr(Pstring);
>
>/*Why?*/

This was an annoying bug in the MacTraps released with versions of LSC before
2.01, where PtoCstr/CtoPstr didn't return a pointer to the string as one would
expect, making it necessary to declare a dummy Str255.

THINK clearly states on page 13-88 of the LSC Manual...

"However, this function also returns a pointer to the converted string."

And with LSC 2.01, PtoCstr & CtoPstr now returns a pointer, per 13-88.

I just found this out, because I had trouble with {P,C}to{C,P}str when using
LSC 1.02, I simply forgot to try it out when I received 2.01 !! So, I ran
the following thru LSC just now, and had no problems.

#include <strings.h>
#include <pascal.h>

#define TestPString "\pThis is a test string."

main()
{
	char	s[256];
	
	/*This works*/

	stpcpy(s,TestPString);
	PtoCstr(s);
	printf("1: %s\n",s);

	/* This does too! */

	printf("2: %s\n",PtoCstr(TestPString));
}


Hope that helps,
		Jason Haines

Club Mac Macintosh Users Group, Sydney, Australia
Snail:     Box 213, Holme Building, Sydney University, NSW, 2006, Australia
ACSnet:    clubmac@runx.ips.oz	   ARPA:   clubmac%runx.ips.oz@seismo.css.gov
UUCP:{enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.ips.oz!clubmac
Technical Details
Message-ID: <978@runx.ips.oz>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!munnari!otc!metro!ipso!runx!clubmac
References: <1376@batcomputer.tn.cornell.edu>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!munnari!otc!metro!ipso!runx!clubmac
From: clubmac@runx.ips.oz (Macintosh Users Group)
Newsgroups: comp.sys.mac
Subject: Re: Why doesn't this work?
Message-ID: <978@runx.ips.oz>
Date: Sat, 20-Jun-87 13:23:50 EDT
Article-I.D.: runx.978
Posted: Sat Jun 20 13:23:50 1987
Date-Received: Wed, 24-Jun-87 07:24:57 EDT
References: <1376@batcomputer.tn.cornell.edu>
Reply-To: clubmac@runx.OZ (Macintosh Users Group - Sydney, Australia)
Organization: RUNX  Un*x Timeshare. Sydney, Australia.
Lines: 53