aboutsummaryrefslogtreecommitdiff
path: root/src/extString.c
diff options
context:
space:
mode:
authoraxtlos <rose@pinkro.se>2025-06-19 00:47:45 +0200
committeraxtlos <rose@pinkro.se>2025-06-19 00:47:45 +0200
commitcd3b65bd1c2d84780f916bb61aea616ff65f6d7d (patch)
tree71eef403d9de916e68a3b9becc70c433e1f62a16 /src/extString.c
parent7654df2f9cb61572636183887d0832e448957689 (diff)
downloadautodarkmode-main.tar.gz
autodarkmode-main.tar.bz2
Make gclue dependency optional with build optionHEADmain
Diffstat (limited to 'src/extString.c')
-rw-r--r--src/extString.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/extString.c b/src/extString.c
index e7ebeaa..2703ed6 100644
--- a/src/extString.c
+++ b/src/extString.c
@@ -52,31 +52,31 @@ char *trim(const char *s)
}
char *replaceStr(const char *s, const char *old, const char *replace) {
- char* result;
- int i, cnt = 0;
- size_t newSize = strlen(replace);
- size_t oldSize = strlen(old);
-
- for (i = 0; s[i] != '\0'; i++) {
- if (strstr(&s[i], old) == &s[i]) {
- cnt++;
- i += oldSize - 1;
- }
- }
+ char* result;
+ int i, cnt = 0;
+ size_t newSize = strlen(replace);
+ size_t oldSize = strlen(old);
- result = (char*)malloc(i + cnt * (newSize - oldSize) + 1);
-
- i = 0;
- while (*s) {
- if (strstr(s, old) == s) {
- strcpy(&result[i], replace);
- i += newSize;
- s += oldSize;
- }
+ for (i = 0; s[i] != '\0'; i++) {
+ if (strstr(&s[i], old) == &s[i]) {
+ cnt++;
+ i += oldSize - 1;
+ }
+ }
+
+ result = (char*)malloc(i + cnt * (newSize - oldSize) + 1);
+
+ i = 0;
+ while (*s) {
+ if (strstr(s, old) == s) {
+ strcpy(&result[i], replace);
+ i += newSize;
+ s += oldSize;
+ }
else
- result[i++] = *s++;
- }
-
- result[i] = '\0';
- return result;
+ result[i++] = *s++;
+ }
+
+ result[i] = '\0';
+ return result;
};