[Geany-devel] Changes to templates

Matthew Brush matthewbrush at xxxxx
Tue Mar 15 01:12:20 UTC 2011

Sorry all, I've been having mail client issues, I hope this goes to the 
list this time.

Matthew Brush (codebrainz)

-------- Original Message --------
Subject: 	Re: [Geany-devel] Changes to templates
Date: 	Sun, 13 Mar 2011 11:53:46 -0700
From: 	Matthew Brush <matthewbrush at gmail.com>
To: 	Lex Trotman <elextr at gmail.com>

On 03/13/11 03:19, Lex Trotman wrote:
>  I don't think this is a good idea since g_strstrip() doesn't actually
>  change the size recorded in the GString, it might appear to work
>  sometimes but it might also fail. Note that a GString also does not
>  have to be null terminated so the g_strstrip might write beyond the
>  buffer if you are unlucky.  I think you are better not to do this.

I have updated the patch (see attachment) to be more safe, based on your
comments.  I'm not 100% confident this is the Best Way, but maybe if
someone has time to review the way it's being done, they could fix it or
suggest the best way.  My idea is to allocate a buffer filled with
zeroes, one bigger than the ->len size, copy the ->str member into the
new buffer, except its nul char, and the new buffer is sure to have at
least a nul at the end.  After, the new buffer is stripped of whitespace
and split into lines.  From reading the GString docs, it sounds like the
->str member *is* always nul terminated, but this way is safe even if it
isn't, I think.

Is this better?  Overkill?  Stupid?

Matthew Brush (codebrainz)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20110314/5c78a846/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: geany-template-indent.patch
Type: text/x-patch
Size: 3519 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20110314/5c78a846/attachment.bin>

More information about the Devel mailing list