[asterisk-users] Hierarchical Config file (re)writing (bug 8684)

Steve Murphy murf at parsetree.com
Thu Aug 30 18:25:35 CDT 2007


On Thu, 2007-08-30 at 16:35 -0400, Jared Smith wrote:
> On Thu, 2007-08-30 at 14:13 -0600, Steve Murphy wrote:
> > 2. Blank lines between entries will get dropped. Sorry. If you really
> > like
> > blank lines, then include a comment of a blank line.
> 
> Ouch... this makes it quite cumbersome.  In fact, that's the number one
> complaint I get from students in the bootcamp classes is that the
> Asterisk GUI eats their blank lines.


I'll try to see if I can put in some logic to generate line feeds based
on the line numbers from the initial read. It's not so pretty, as
comments can contain linefeeds, and there can be multiple comments
stored on the object. I have a gut feeling that preserving blank lines
will be possible, but ugly coding.

I suggest that you file this request as a bug against the new code; 
that way, I won't forget. Make sure it gets assigned to me.


> > 4. Trailing comments will get dropped. Put your comments in front of a
> > variable definition, or in front of a category definition. Comments with
> > no variable decls or category decls (you know, the [general] type
> > stuff...) will not be attached to anything, and will be lost.
> 
> Ouch... this one hurts too... most everyone I know uses trailing
> comments.  Is there a technical reason why this has to be?
> 

<caution:boring-details>
Well, "objects" in config files are basically category definitions (like
"[general]") and variable declarations (like "some-option=45"); These
little puppies are the meat inside a config file. Each one (category,
variable) ends up in a structure forming a tree of linked lists. Kinda
like a weeping willow tree, in *my* mind. 

I inserted code to vacuum up all the comments as the parser progresses
thru the config file. Comments come in two flavors; first are comments
that occur on lines without any decls. And then, there are comments that
occur on the same line as the object, but after the 'object'. When we
find an object, I attach all the comments I've sucked up until then.

Trailing comments get sucked up also; there is no object to tie them to,
so they are lost.

I guess I could make up some imaginary object to tie them to; but that
complicates both the parser and possibly the routines that traverse the
category/variable tree.  OR, I could add a third class of comments,
trailing comments, as another field in the objects, and attach them to
the last object scanned in the file, if we reach the end, and have some
comments in the buffers, and no object to tie them to. This also
complicates things, but not as much as the other option. I have to keep
track of the last object encountered, and stuff like that. Shouldn't be
too ugly.

So, if you actually want me to dive back into this code, and make this
enhancement, open yet one more bug and file this heart-felt wish, and
make sure it gets assigned to me, and I'll see if I can attack it.


</caution>

> Don't get me wrong, I'm happy to see the changes you've done.  I'd just
> like to make this as user-friendly as possible.  One of the overriding
> goals of the Asterisk GUI is to leave the config files hand-editable,
> and removing comments and blank lines makes that harder.
> 

Digium pays me to make the user community happy (among other things).
So, it behooves me to acquiesce to your request. (I can hear the sound
of dictionaries being consulted!) ;)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3239 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20070830/529b2701/attachment.bin 


More information about the asterisk-users mailing list