In a project of mine, I wrote a completer function that does only return strdup("\t"); (to disable completion of filenames, which are meaningless for my project). However, this prints ^I instead of a tab as it should. When I try to return something like strdup("hello world"), it prints hello\ world instead. I assume that the issue is due to the very questionable implementation of CTL() and META(). It seems to me that the proper way of doing this is to use a type larger than a char, where the modifers are stored in higher bits. Of course this will require changing the public interface to libeditline, so maybe the current functions should be deprecated (but still remain), and new, proper functions should be added.
I just did some digging and found out that the string returned from my completer function is passed to insert_string(), which passes it to tty_string(), and then each character goes to tty_show(), which does use the ISCTL() and ISMETA() macros to incorrectly convert a tab into ^I. Also, it is line 1385 of editline.c which adds a newline before spaces. No idea why it does that though.
In a project of mine, I wrote a completer function that does only
return strdup("\t");(to disable completion of filenames, which are meaningless for my project). However, this prints^Iinstead of a tab as it should. When I try to return something likestrdup("hello world"), it printshello\ worldinstead. I assume that the issue is due to the very questionable implementation ofCTL()andMETA(). It seems to me that the proper way of doing this is to use a type larger than a char, where the modifers are stored in higher bits. Of course this will require changing the public interface to libeditline, so maybe the current functions should be deprecated (but still remain), and new, proper functions should be added.I just did some digging and found out that the string returned from my completer function is passed to
insert_string(), which passes it totty_string(), and then each character goes totty_show(), which does use theISCTL()andISMETA()macros to incorrectly convert a tab into^I. Also, it is line 1385 of editline.c which adds a newline before spaces. No idea why it does that though.