Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

!07/11 PDP a ni deppart m'I !pleH


programming / comp.lang.tcl / it is allowed to manipulate the string output from Tcl_GetStringFromObj direct?

SubjectAuthor
* it is allowed to manipulate the string output fromaotto1968
`- Re: it is allowed to manipulate the string output fromSchelte

1
Subject: it is allowed to manipulate the string output from Tcl_GetStringFromObj direct?
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Thu, 12 May 2022 09:13 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1...@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: it is allowed to manipulate the string output from
Tcl_GetStringFromObj direct?
Date: Thu, 12 May 2022 11:13:50 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <t5ij4e$uag$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 12 May 2022 09:13:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="28c48b4ccd9b4209ca51b8500fedf60b";
logging-data="31056"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZFJrCzAtCP6ak6Y9cQiWl21oR38pleRU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:plhGFcbkI+OFh/yPsn8EYqiqTy4=
Content-Language: en-US
View all headers
Hi,

the "char *Tcl_GetStringFromObj(objPtr, lengthPtr)" return an "char*" not an "const char*".

question:

1) it is possible to manipulate the string without extend the objPtr->length border?

2) after manipulation (discard space and tokenize "|"→"\0") the new string is shorter and has additional '\0' values. It is allowed to modify the objPtr->length to the new (shorter) length ?


mfg AO


Subject: Re: it is allowed to manipulate the string output from Tcl_GetStringFromObj direct?
From: Schelte
Newsgroups: comp.lang.tcl
Organization: KPN B.V.
Date: Thu, 12 May 2022 09:51 UTC
References: 1
Date: Thu, 12 May 2022 11:51:30 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Subject: Re: it is allowed to manipulate the string output from
Tcl_GetStringFromObj direct?
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <t5ij4e$uag$1@dont-email.me>
From: nos...@wanadoo.nl (Schelte)
In-Reply-To: <t5ij4e$uag$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <nnd$0989a10f$3451d46b@9beb6e106d91c483>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 28
Injection-Date: Thu, 12 May 2022 11:51:30 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1967
View all headers
On 12/05/2022 11:13, aotto1968 wrote:
the "char *Tcl_GetStringFromObj(objPtr, lengthPtr)" return an "char*" not an "const char*".

question:

1) it is possible to manipulate the string without extend the objPtr->length border?

2) after manipulation (discard space and tokenize "|"→"\0") the new string is shorter and has additional '\0' values. It is allowed to modify the objPtr->length to the new (shorter) length ?


The man page says: "The storage referenced by the returned byte pointer is owned by the value manager. It is passed back as a writable pointer so that extension author creating their own Tcl_ObjType will be able to modify the string representation within the Tcl_UpdateStringProc of their Tcl_ObjType. Except for that limited purpose, the pointer returned by Tcl_GetStringFromObj or Tcl_GetString should be treated as read-only. It is recommended that this pointer be assigned to a (const char *) variable."

So the answer to your question would be no.


Schelte.


1
rocksolid light 0.7.2
clearneti2ptor