mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-21 22:09:23 +01:00
client: fix missing character for line breaks without spaces
In nearly all cases the auto-line breaks can be on spaces in the string. The only exception (so far) is DPP which displays a very long URI without any spaces. When this is displayed a single character was lost on each break. This was due to the current line being NULL terminated prior to the next line string being returned. To handle both cases the next line is copied prior to terminating the current line. The offsets were modified slightly so the line will be broken *after* the space, not on the space. This leaves the space at the end of the current line which is invisible to the user but allows the no-space case to also work without loss of the last character (since that last character is where the space normally would be).
This commit is contained in:
parent
9d042ca321
commit
dc6575130e
@ -405,6 +405,7 @@ static char* next_line(char *s, unsigned int width, unsigned int *new_width,
|
|||||||
int last_color = -1;
|
int last_color = -1;
|
||||||
unsigned int s_len = strlen(s);
|
unsigned int s_len = strlen(s);
|
||||||
unsigned int color_adjust = 0;
|
unsigned int color_adjust = 0;
|
||||||
|
char *ret;
|
||||||
|
|
||||||
*new_width = width;
|
*new_width = width;
|
||||||
*color_out = NULL;
|
*color_out = NULL;
|
||||||
@ -452,7 +453,7 @@ static char* next_line(char *s, unsigned int width, unsigned int *new_width,
|
|||||||
|
|
||||||
/* Not anywhere nice to split the line */
|
/* Not anywhere nice to split the line */
|
||||||
if (last_space == -1)
|
if (last_space == -1)
|
||||||
last_space = *new_width - 1;
|
last_space = *new_width;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only set the color if it occurred prior to the last space. If after,
|
* Only set the color if it occurred prior to the last space. If after,
|
||||||
@ -464,9 +465,11 @@ static char* next_line(char *s, unsigned int width, unsigned int *new_width,
|
|||||||
else if (last_color != -1 && last_space < last_color)
|
else if (last_color != -1 && last_space < last_color)
|
||||||
*new_width -= color_adjust;
|
*new_width -= color_adjust;
|
||||||
|
|
||||||
s[last_space] = '\0';
|
ret = l_strdup(s + last_space + 1);
|
||||||
|
|
||||||
return l_strdup(s + last_space + 1);
|
s[last_space + 1] = '\0';
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct table_entry {
|
struct table_entry {
|
||||||
|
Loading…
Reference in New Issue
Block a user