Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

hreinecke
Copy link
Contributor

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

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>
Copy link
Collaborator

@mwilck mwilck left a 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);
Copy link
Collaborator

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()?

Copy link
Contributor Author

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).

Copy link
Collaborator

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)) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants