mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +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,
|
||||
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);
|
||||
if (0 != strcmp(p, "")) { src = p; }
|
||||
|
||||
for (; *src && p_max_size - 1 > x; src++, x++) {
|
||||
if (0 == z) {
|
||||
*dest++ = (toupper(static_cast<unsigned char>(*src)));
|
||||
for (unsigned int x = 0, z = 0; x < p_max_size - 1 && p[x]; x++) {
|
||||
if (isspace(p[x])) {
|
||||
z = 0;
|
||||
} else if (z == 0) {
|
||||
p[x] = toupper(p[x]);
|
||||
z++;
|
||||
} else {
|
||||
p[x] = tolower(p[x]);
|
||||
z++;
|
||||
continue;
|
||||
}
|
||||
*dest++ = *src;
|
||||
if (' ' == *src) z = 0;
|
||||
}
|
||||
*dest = '\0';
|
||||
snprintf(p, p_max_size, "%s", buf);
|
||||
p[p_max_size - 1] = '\0';
|
||||
}
|
||||
|
||||
void print_lowercase(struct text_object *obj, char *p,
|
||||
|
Loading…
Reference in New Issue
Block a user