mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
Bugfix: chars followed by backspace should not be displayed
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1126 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
57318c7012
commit
a9624c80cc
1
AUTHORS
1
AUTHORS
@ -64,6 +64,7 @@ David McCabe
|
||||
|
||||
garo <nikolas at garofil dot be>
|
||||
gw_iface fix
|
||||
deleted chars fix
|
||||
|
||||
Ram Yalamanchili
|
||||
tztime
|
||||
|
@ -3,6 +3,8 @@
|
||||
2008-06-04
|
||||
* Fix bug where conky tries to free a already freed pointer when you
|
||||
use gw_iface with a empty routingtable in linux
|
||||
* Fix bug where conky tries to tries to display deleted chars in a
|
||||
string (chars followed by a backspace-char) causing strange output.
|
||||
|
||||
2008-06-03
|
||||
* Added NVIDIA Graficcard support patch (thanks meissna)
|
||||
|
16
src/conky.c
16
src/conky.c
@ -4251,6 +4251,21 @@ char *format_time(unsigned long timeval, const int width)
|
||||
return strndup("<inf>", text_buffer_size);
|
||||
}
|
||||
|
||||
//remove backspaced chars, example: "dog^H^H^Hcat" becomes "cat"
|
||||
//string has to end with \0 and it's length should fit in a int
|
||||
#define BACKSPACE 8
|
||||
void remove_deleted_chars(char *string){
|
||||
int i = 0;
|
||||
while(string[i] != 0){
|
||||
if(string[i] == BACKSPACE){
|
||||
if(i != 0){
|
||||
strcpy( &(string[i-1]), &(string[i+1]) );
|
||||
i--;
|
||||
}else strcpy( &(string[i]), &(string[i+1]) ); //necessary for ^H's at the start of a string
|
||||
}else i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void generate_text_internal(char *p, int p_max_size,
|
||||
struct text_object *objs, unsigned int object_count,
|
||||
struct information *cur)
|
||||
@ -4761,6 +4776,7 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
pclose(fp);
|
||||
|
||||
p[length] = '\0';
|
||||
remove_deleted_chars(p);
|
||||
if (length > 0 && p[length - 1] == '\n') {
|
||||
p[length - 1] = '\0';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user