This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Word break characters are language dependent


Hello,

I was working on implementing proper completion for Ada in GDB, and
ended up reading this part of the code (completer.c:localtion_completer()):

      else if (strchr (gdb_completer_word_break_characters, *p))
        symbol_start = p + 1;

Unfortunately, the word-break characters for Ada are not exactly the
same as the ones used by default.  As a consequence, the current
completer does not always find the correct starting location of the
symbol name.  So I think we should make them language-dependent by
adding a new field to the language vector.

For instance, we could add a new pointer to a function that would
return the string of word-break characters.

My proposal is the following:

  - Add the following field to struct language_defn:

    char * (*la_word_break_characters) (const char *);

  - Move static char *gdb_completer_word_break_characters and
    get_gdb_completer_word_break_characters() to language.[hc]
    and call them: default_completer_word_break_characters
    and get_default_completer_word_break_characters() respectively.

  - Initialize the new field inside all languages to this
    default function.

  - Update completer.c to use the language-dependent version
    of this string, rather than the current hard-coded one.

Sounds reasonable?

Also, while we are looking at this, would it be worth considering
the same for 
  - gdb_completer_command_word_break_characters: I don't think so.
    Command names are independent of the language.
  - gdb_completer_file_name_break_characters: I don't think so either.
    Independent from the filename.
  - gdb_completer_loc_break_characters: Likewise.
  - gdb_completer_quote_characters: This is less obvious. Maybe some
    future language will want to have it's own different quote character.
    Not obvious, so I would leave it as is too.

Thanks,
-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]