-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
86 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"rust-analyzer.checkOnSave": true, | ||
"rust-analyzer.check.overrideCommand": ["cargo", "clippy", "--message-format=json"] | ||
"rust-analyzer.check.overrideCommand": [ | ||
"cargo", | ||
"clippy", | ||
"--message-format=json" | ||
], | ||
"files.associations": { | ||
"*.h": "c", | ||
}, | ||
"cmake.sourceDirectory": "/Users/Omar/Projects/Rust/kuliya/c" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[requires] | ||
jsmn/1.1.0 | ||
libunistring/1.1 | ||
|
||
[generators] | ||
CMakeDeps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_library(helpers SHARED file.h my_string.h my_string.c) | ||
set_target_properties(helpers PROPERTIES LINKER_LANGUAGE C) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "my_string.h" | ||
|
||
void remove_chars(char *str, int c, ...) | ||
{ | ||
va_list args; | ||
va_start(args, c); | ||
|
||
while (42) // The answer for everything | ||
{ | ||
char char_to_remove = va_arg(args, int); | ||
if (char_to_remove == '\0') | ||
break; | ||
|
||
size_t j = 0; | ||
for (size_t i = 0; str[i] != '\0'; ++i) | ||
{ | ||
if (str[i] != char_to_remove) | ||
str[j++] = str[i]; | ||
} | ||
str[j] = '\0'; | ||
} | ||
|
||
va_end(args); | ||
|
||
// This is to confirm deleting the first vararg character | ||
size_t j = 0; | ||
for (size_t i = 0; str[i] != '\0'; ++i) | ||
{ | ||
if (str[i] != c) | ||
str[j++] = str[i]; | ||
} | ||
str[j] = '\0'; | ||
} | ||
|
||
void replace_char(char *str, char find, char replace) | ||
{ | ||
char *current_pos = strchr(str, find); | ||
while (current_pos) | ||
{ | ||
*current_pos = replace; | ||
current_pos = strchr(current_pos, find); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters