• Julia Lawall's avatar
    annotations: add the annotation functionality · 5667e7ef
    Julia Lawall authored
    Provide the new command-line option:
    --annotate (abbreviated -T)
    --annotate provides one or more filenames and line numbers indicating
    the origin of a given line.  The filename is expressed relative the the
    filename provided on the command line.  Nothing is printed for overlays,
    -T can be repeated giving more verbose annotations.  These consist of
    one or more tuples of: filename, starting line, starting column, ending
    line ending column.  The full path is given for the file name.
    Overlays, etc are annotated with <no-file>:<no-line>.
    The verbose annotations may be too verbose for normal use.
    There are numerous changes in srcpos.c to provide the relative filenames
    (variables initial_path, initial_pathlen and initial_cpp, new functions
    set_initial_path and shorten_to_initial_path, and changes in
    srcfile_push and srcpos_set_line).  The change in srcpos_set_line takes
    care of the case where cpp is used as a preprocessor.  In that case the
    initial file name is not the one provided on the command line but the
    one found at the beginnning of the cpp output.
    shorten_to_initial_path only returns a string if it has some shortening
    to do.  Otherwise it returns NULL and relies on the caller to use the
    initial string.  This simplifies memory management, by making clear to
    the caller whether a new string is allocated.
    The new functions srcpos_string_comment, srcpos_string_first, and
    srcpos_string_last print the annotations.  srcpos_string_comment is
    recursive to print a list of source file positions.
    Various changes are sprinkled throughout treesource.c to print the
    Signed-off-by: 's avatarJulia Lawall <Julia.Lawall@lip6.fr>
    Signed-off-by: 's avatarDavid Gibson <david@gibson.dropbear.id.au>