-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multipathd: replace libreadline with fgets() #41
Conversation
libreadline changed the license to be incompatible with multipath-tools usage, so replace it with a simple fgets(). Signed-off-by: Hannes Reinecke <hare@suse.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hannes, we still use the email-based workflow for multipath-tools. There are some exceptions, but this affects functionality and should thus go to the ML.
This patch conflicts with mine that enables the libedit replacement. Unless you object, I'll merge this with my changes, and submit.
rl_completion_entry_function = key_generator; | ||
while ((line = readline("multipathd> "))) { | ||
for (i = 0; i < strlen(prompt); i++) | ||
fputc(prompt[i], stdout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just use fputs()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because fputs() always attaches a newline, and we want to display a prompt (ie without a newline).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because fputs() always attaches a newline
puts()
does this but fputs()
does not.
while ((line = readline("multipathd> "))) { | ||
for (i = 0; i < strlen(prompt); i++) | ||
fputc(prompt[i], stdout); | ||
while (fgets(line, 256, stdin)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need some error handling here, especially for overflow, and we should strip training newline. I'd prefer using getline()
, actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sure. The really was a quick-and-dirty hack, and fgets() was the first function which came to my mind. getline() is fine, too.
libreadline changed the license to be incompatible with multipath-tools
usage, so replace it with a simple fgets().
Fixes: Issue #36
Signed-off-by: Hannes Reinecke hare@suse.de