mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-29 05:12:41 +00:00
Optimised and corrected print_startcase
This commit is contained in:
parent
49638c6c19
commit
435d05dc6e
25
src/misc.cc
25
src/misc.cc
@ -87,26 +87,19 @@ void print_catp(struct text_object *obj, char *p, unsigned int p_max_size) {
|
|||||||
|
|
||||||
void print_startcase(struct text_object *obj, char *p,
|
void print_startcase(struct text_object *obj, char *p,
|
||||||
unsigned int p_max_size) {
|
unsigned int p_max_size) {
|
||||||
unsigned int x = 0;
|
|
||||||
int z = 0;
|
|
||||||
char buf[DEFAULT_TEXT_BUFFER_SIZE];
|
|
||||||
char *src = obj->data.s;
|
|
||||||
char *dest = buf;
|
|
||||||
|
|
||||||
evaluate(obj->data.s, p, p_max_size);
|
evaluate(obj->data.s, p, p_max_size);
|
||||||
if (0 != strcmp(p, "")) { src = p; }
|
for (unsigned int x = 0, z = 0; x < p_max_size - 1 && p[x]; x++) {
|
||||||
|
if (isspace(p[x])) {
|
||||||
for (; *src && p_max_size - 1 > x; src++, x++) {
|
z = 0;
|
||||||
if (0 == z) {
|
} else if (z == 0) {
|
||||||
*dest++ = (toupper(static_cast<unsigned char>(*src)));
|
p[x] = toupper(p[x]);
|
||||||
|
z++;
|
||||||
|
} else {
|
||||||
|
p[x] = tolower(p[x]);
|
||||||
z++;
|
z++;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
*dest++ = *src;
|
|
||||||
if (' ' == *src) z = 0;
|
|
||||||
}
|
}
|
||||||
*dest = '\0';
|
p[p_max_size - 1] = '\0';
|
||||||
snprintf(p, p_max_size, "%s", buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_lowercase(struct text_object *obj, char *p,
|
void print_lowercase(struct text_object *obj, char *p,
|
||||||
|
Loading…
Reference in New Issue
Block a user