[augeas-devel] [Augeas] #221: Output line number and character position in line in aug_span

Augeas trac at fedorahosted.org
Thu Oct 6 13:15:27 UTC 2011


#221: Output line number and character position in line in aug_span
--------------------------+-------------------------------------------------
  Reporter:  raphink      |       Owner:  fgiraldeau
      Type:  enhancement  |      Status:  assigned  
  Priority:  minor        |   Milestone:  next      
 Component:  Augeas       |     Version:  devel     
Resolution:               |    Keywords:  span      
--------------------------+-------------------------------------------------
Changes (by fgiraldeau):

  * owner:  lutter => fgiraldeau
  * status:  new => assigned

Comment:

 This feature would be better for human ;) I see two ways of doing it.
 First, to track line numbers and position while parsing and store it in an
 increased "span" struct. Or, this information can be recovered from the
 file itself, like what is done in store_error:

 {{{
 err_set(aug, err_info, s_pos, "%d", err->pos);
 if (text != NULL) {
     calc_line_ofs(text, err->pos, &line, &ofs);
     err_set(aug, err_info, s_line, "%zd", line);
     err_set(aug, err_info, s_char, "%zd", ofs);
 }
 }}}

 This solution requires to re-read the file, because the text itself is not
 available anymore.

 There is a third solution, and this one would be awesome because it would
 also fix another issue with span: render the file in memory with a put,
 then compute the line number from this generated text. This would report
 accurate line number in the case the tree is modified. In the case the
 tree is not modified, since the file is preserved, line numbers will be
 accurate. This is a problem with the current implementation of span,
 because the information is not updated when the tree is changed, thus the
 information returned is not correct anymore.

-- 
Ticket URL: <https://fedorahosted.org/augeas/ticket/221#comment:1>
Augeas <http://augeas.net/>
a configuration API




More information about the augeas-devel mailing list