virsh: remove trailing whitespace even when editing the description

When editing the title of a domain or network via the `desc` or
`net-desc` commands, we strip the final newline that is added by some
editors.

Do the same when editing the description as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2024-02-28 13:33:12 +01:00
parent 2f22d2a1ef
commit 3b31aeaae3
2 changed files with 3 additions and 5 deletions

View File

@ -8525,10 +8525,9 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
return false;
/* strip a possible newline at the end of file; some
* editors enforce a newline, this makes editing the title
* editors enforce a newline, this makes editing
* more convenient */
if (title &&
(tmpstr = strrchr(desc_edited, '\n')) &&
if ((tmpstr = strrchr(desc_edited, '\n')) &&
*(tmpstr+1) == '\0')
*tmpstr = '\0';

View File

@ -481,8 +481,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
/* strip a possible newline at the end of file; some
* editors enforce a newline, this makes editing the title
* more convenient */
if (title &&
(tmpstr = strrchr(desc_edited, '\n')) &&
if ((tmpstr = strrchr(desc_edited, '\n')) &&
*(tmpstr+1) == '\0')
*tmpstr = '\0';