Skip to content

Buffer and print also what follows the last newline#79

Merged
RobSanders merged 1 commit intodparrish:staging-1.10.8from
nokia:dev/fix-buffered-print
Dec 1, 2022
Merged

Buffer and print also what follows the last newline#79
RobSanders merged 1 commit intodparrish:staging-1.10.8from
nokia:dev/fix-buffered-print

Conversation

@JereLeppanen
Copy link
Copy Markdown
Contributor

_print() saves in cli->buffer whatever follows the last newline, but
then just throws it away on the next call. Use cli->buffer by copying
it in front of the new input.

@RobSanders
Copy link
Copy Markdown
Collaborator

I see what you are seeing - the regular prints will ensure the entire buffer is displayed. However if you call cli_bufprint() then while processing that buffer anything after the last newline is dropped, or if there is no newline at all it is also dropped.
Will merge into the upcoming 1.10.8 release.

@RobSanders RobSanders changed the base branch from stable to staging-1.10.8 November 16, 2022 16:11
@RobSanders
Copy link
Copy Markdown
Collaborator

Quick secondary question before I merge this - any specific reason you didn't do a realloc() instead of the malloc() and then manually copying things? Not saying it should be done that way, just curious....

@JereLeppanen
Copy link
Copy Markdown
Contributor Author

No reason that I can recall. realloc() would probably be slightly better. I can change that, if you wish.

@RobSanders
Copy link
Copy Markdown
Collaborator

If you want to - go for it. Otherwise I can clean that up in the staging branch.

@RobSanders
Copy link
Copy Markdown
Collaborator

One of the things I've been meaning to do is to make libcli screen dimension aware. Our app that uses libcli does this for output before calling cli_print, so we can do pagination. I'd like to get libcli able to pull screen dimensions from the telnet connect, or from the terminal settings (like from ssh). I had some demo code showing I could get that info (if provided). I'd also provide override so the user could specify the screen settings. Initially this would be for output only, but ideally I'd like to get the line editting to be screen size aware also. Just a matter of finding time. Our team would like this, but it rather far down the list of to-dos.....

_print() saves in cli->buffer whatever follows the last newline, but
then just throws it away on the next call. Use cli->buffer by copying
it in front of the new input.
@JereLeppanen JereLeppanen force-pushed the dev/fix-buffered-print branch from e015047 to 3379324 Compare November 18, 2022 12:04
@JereLeppanen
Copy link
Copy Markdown
Contributor Author

Yeah, we could have pretty long commands at some point, so editing long lines on a narrow screen would be very useful.

I changed the malloc() to realloc(). Also, after changing my test a little I noticed that something was missing from my commit. We need to include the terminating null in the memmove(). Fixed that as well.

@RobSanders RobSanders merged commit 05070e9 into dparrish:staging-1.10.8 Dec 1, 2022
@RobSanders
Copy link
Copy Markdown
Collaborator

Do you have an email account you would like me to use in the spec file change log to recognize your contribution? Or I can use my email, but in the comment reference your github handle.

@JereLeppanen
Copy link
Copy Markdown
Contributor Author

I see that other github handles have been mentioned in the spec file, so that's fine for me 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