mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 04:32:55 +00:00
Made various misc.cc functions more concise
This commit is contained in:
parent
8dc04f3902
commit
9bee2eec39
14
src/misc.cc
14
src/misc.cc
@ -88,14 +88,12 @@ 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) {
|
||||||
evaluate(obj->data.s, p, p_max_size);
|
evaluate(obj->data.s, p, p_max_size);
|
||||||
|
|
||||||
for (unsigned int x = 0, z = 0; x < p_max_size - 1 && p[x]; x++) {
|
for (unsigned int x = 0, z = 0; x < p_max_size - 1 && p[x]; x++) {
|
||||||
if (isspace(p[x])) {
|
if (isspace(p[x])) {
|
||||||
z = 0;
|
z = 0;
|
||||||
} else if (z == 0) {
|
|
||||||
p[x] = toupper(p[x]);
|
|
||||||
z++;
|
|
||||||
} else {
|
} else {
|
||||||
p[x] = tolower(p[x]);
|
p[x] = z ? tolower(p[x]) : toupper(p[x]);
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,17 +102,17 @@ void print_startcase(struct text_object *obj, char *p,
|
|||||||
void print_lowercase(struct text_object *obj, char *p,
|
void print_lowercase(struct text_object *obj, char *p,
|
||||||
unsigned int p_max_size) {
|
unsigned int p_max_size) {
|
||||||
evaluate(obj->data.s, p, p_max_size);
|
evaluate(obj->data.s, p, p_max_size);
|
||||||
for (unsigned int x = 0; x < p_max_size - 1 && p[x]; x++) {
|
|
||||||
|
for (unsigned int x = 0; x < p_max_size - 1 && p[x]; x++)
|
||||||
p[x] = tolower(p[x]);
|
p[x] = tolower(p[x]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_uppercase(struct text_object *obj, char *p,
|
void print_uppercase(struct text_object *obj, char *p,
|
||||||
unsigned int p_max_size) {
|
unsigned int p_max_size) {
|
||||||
evaluate(obj->data.s, p, p_max_size);
|
evaluate(obj->data.s, p, p_max_size);
|
||||||
for (unsigned int x = 0; x < p_max_size - 1 && p[x]; x++) {
|
|
||||||
|
for (unsigned int x = 0; x < p_max_size - 1 && p[x]; x++)
|
||||||
p[x] = toupper(p[x]);
|
p[x] = toupper(p[x]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void strip_trailing_whitespace(struct text_object *obj, char *p,
|
void strip_trailing_whitespace(struct text_object *obj, char *p,
|
||||||
|
Loading…
Reference in New Issue
Block a user