libconf-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libconf-dev] [chl <address@hidden>] [ Task #2129] solve the indent


From: chl
Subject: Re: [Libconf-dev] [chl <address@hidden>] [ Task #2129] solve the indentation problem
Date: 06 May 2003 03:34:47 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

address@hidden writes:

> We'll be really near the exact same output.
> Solving this comment issue is the goal of the task about "changing comment
> structure". I'll try to do it for the 18th may.

Of course, this comment issue has to be done if we want to
respect the md5sum constraint.
 
> Could you think about an algorythm to find out what is the indentation of the
> file in th following situation :

First, I suppose the comment issue is solved. If we want to
support indentation :

> - we add an atom in a section where there are already original atoms (should 
> be
>   trivial, we look at the /^\s+/ of the other atoms

To keep it simple, we can assume that the indentation is the same
for each atom in the current section. (Assumption 1)

> - we add an atom in a section where there are no original atoms (maybe we
>   should look at the other section, and find out what is the indentation?)

To keep it simple, we can assume that the indentation is the same
for each section in the current file. (Assumption 2)

At this point we only need a global variable for one template
(like $INDENT_SPACES) that could be correctly setted at the
parsing of the conf file.

> - we build the file from scratch, but with section and atoms. which 
> indentation
>   do we choose?

If we build the file from scratch, there is two alternatives :
1) the $INDENT_SPACES variable is not set, so we don't indent.
2) the $INDENT_SPACES variable is set to and the template use it
to generate a file with indentation.

This is the easiest way to implement indentation in libconf, IMHO.
If we only do like this libconf don't respect the md5sum
constraint. Do we really need to fully respect the md5sum
constraint ? That's the real question :)


Libconf could implement the above method for indentation, or if
we want to fully respect the md5sum constraint, use some of the
following ideas :

1/ Libconf could print warnings, if the conf file have strange
indentation that brakes libconf assumptions about indentation.
(like different indentation in the same section, or between two
sections of the same level).

2/ I think it's possible to respect the md5sum constraint. In that
case, we will need to store the indentation for each atom for
each line. IMO, this is the worst solution, we must avoid it.

3/ Maybe an hybrid solution is the best : use $INDENT_SPACES
everywhere it's possible, and only store the atom's indentation
where it brakes the libconf assumptions about indentation.

Regards,

Charles





reply via email to

[Prev in Thread] Current Thread [Next in Thread]