Re: Patch for Scintillua style handling

Mitchell <[email protected]>
Newsgroups gmane.editors.scite.general
Message-ID <[email protected]>
Hi Neil,

On Tue, 30 Aug 2022 09:33:58 +1000
"'Neil Hodgson' via scite-interest" <[email protected]> wrote:

>    Mitchell, the lifetime of the variable referred to by 'name' may be a problem. 'name' is a reference, which is essentially a pointer and does not keep the thing referred to alive. I'm unsure of the actual C++ rules here but I think the value returned by 'wEditor.NameOfStyle(style)' can be deallocated at the end of that statement so will be dead when 'name' is used. Its better to just make 'name' a 'std::string' rather than a reference.
> 
> 		const std::string &name = wEditor.NameOfStyle(style);
> 		...
> 			end = name.find('.', ++end);

Before returning the name of a style, my Scintillua lexer stores it inside its own std::string and returns the c_str(), which is guaranteed to exist until the next call to NameOfStyle. Therefore, I didn't think lifetime was an issue here, as it is for most char* returns. If you prefer to use std::string, then that's fine with me.

Cheers,
Mitchell

-- 
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/20220831085530.23ac99f5244c9b9e61d7692b%40triplequasar.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.