Skip to content

Commit b51dc23

Browse files
Merge pull request #13 from dreamer-coding/main
Fossil Io Version Update
2 parents 3448f2c + 419c63b commit b51dc23

File tree

5 files changed

+33
-49
lines changed

5 files changed

+33
-49
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cmake_minimum_required(VERSION 3.13.4)
33

44
# Project metadata
5-
project(FossilIo VERSION 0.1.4 LANGUAGES C CXX)
5+
project(FossilIo VERSION 0.1.5 LANGUAGES C CXX)
66

77
# Set the C and C++ standards
88
set(CMAKE_C_STANDARD 11)

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ To get started with Fossil Io, ensure you have the following installed:
1717
- **Meson Build System**: If you don’t have Meson installed, follow the installation instructions on the official [Meson website](https://mesonbuild.com/Getting-meson.html).
1818
- **CMake Build System**: If you don’t have CMake installed, follow the installation instructions on the official [CMake website](https://cmake.org/getting-started/).
1919

20-
### Adding Fossil Test Dependency
20+
### Adding Fossil Io Dependency
2121

22-
#### Adding Fossil Test Dependency With Meson
22+
#### Adding Fossil Io Dependency With Meson
2323

2424
1. **Install Meson Build System**:
2525
Install Meson version `1.3` or newer:
26+
2627
```sh
2728
python -m pip install meson # To install Meson
2829
python -m pip install --upgrade meson # To upgrade Meson
@@ -37,21 +38,22 @@ To get started with Fossil Io, ensure you have the following installed:
3738
# ======================
3839
[wrap-git]
3940
url = https://github.com/fossillogic/fossil-io.git
40-
revision = v0.1.4
41+
revision = v0.1.5
4142

4243
[provide]
4344
fossil-io = fossil_io_dep
4445
```
4546

4647
3. **Integrate the Dependency**:
4748
In your `meson.build` file, integrate Fossil Io by adding the following line:
49+
4850
```ini
4951
dep = dependency('fossil-io')
5052
```
5153

5254
---
5355

54-
#### Adding Fossil Test Dependency With CMake
56+
#### Adding Fossil Io Dependency With CMake
5557

5658
To use Fossil Io with CMake, follow these steps:
5759

@@ -63,7 +65,7 @@ To use Fossil Io with CMake, follow these steps:
6365
python -m pip install --upgrade cmake # To upgrade CMake
6466
```
6567

66-
2. **Find and Integrate Fossil Test**:
68+
2. **Find and Integrate Fossil Io**:
6769
After installing CMake, you can integrate Fossil Io as a dependency. Add the following lines to your `CMakeLists.txt` file:
6870

6971
```cmake
@@ -81,7 +83,7 @@ To use Fossil Io with CMake, follow these steps:
8183

8284
---
8385

84-
**Note**: For the best experience, always use the latest release of Fossil Test. Visit the [Fossil Io Releases](https://github.com/fossillogic/fossil-io/releases) page for the latest versions.
86+
**Note**: For the best experience, always use the latest release of Fossil Io. Visit the [Fossil Io Releases](https://github.com/fossillogic/fossil-io/releases) page for the latest versions.
8587

8688
## Configure Options
8789

code/logic/soap.c

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static const char *FOSSIL_SOAP_ROTBRAIN[] = {
6161
"rizz", "skibidi", "yeet", "sus", "vibe", "lit", "no cap", "bet", "fam", "bruh",
6262
"flex", "ghost", "goat", "gucci", "hype", "janky", "lowkey", "mood", "salty", "shade",
6363
"slay", "snatched", "stan", "tea", "thirsty", "woke", "yolo", "zaddy", "drip", "fire",
64-
"lol", "omg", "brb", "sus"
64+
"lol", "omg", "brb"
6565

6666
// Support for other terms can be added via PR to this repository
6767
};
@@ -132,62 +132,45 @@ void fossil_soap_sanitize(char *input) {
132132
}
133133
}
134134

135-
// Function to check if a word is an offensive word or phrase
136-
int32_t fossil_soap_is_offensive(const char *word) {
137-
if (word == NULL || *word == '\0') return EXIT_SUCCESS;
135+
static int32_t is_in_list(const char *word, const char **list, size_t list_size) {
136+
if (!word || *word == '\0') return EXIT_SUCCESS;
138137

139-
for (size_t i = 0; i < sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(FOSSIL_SOAP_OFFENSIVE[0]); ++i) {
140-
if (strcasecmp(word, FOSSIL_SOAP_OFFENSIVE[i]) == 0) {
141-
return EXIT_FAILURE;
142-
}
138+
for (size_t i = 0; i < list_size; ++i) {
139+
if (strcasecmp(word, list[i]) == 0) return EXIT_FAILURE;
143140
}
144141
return EXIT_SUCCESS;
145142
}
146143

147-
// Function to get the number of offensive words found in a string
148-
int32_t fossil_soap_count_offensive(const char *input) {
149-
if (input == NULL || *input == '\0') return 0;
150-
151-
int count = 0;
152-
char *copy = custom_strdup(input);
153-
if (copy == NULL) return EXIT_SUCCESS;
154-
155-
char *token = strtok(copy, " ,.!?;:"); // Tokenize the string by space and punctuation
156-
while (token != NULL) {
157-
if (fossil_soap_is_offensive(token)) {
158-
count++;
159-
}
160-
token = strtok(NULL, " ,.!?;:");
161-
}
162-
free(copy); // Free the memory allocated for the copy
163-
return count;
144+
int32_t fossil_soap_is_offensive(const char *word) {
145+
return is_in_list(word, FOSSIL_SOAP_OFFENSIVE, sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(*FOSSIL_SOAP_OFFENSIVE));
164146
}
165147

166148
int32_t fossil_soap_is_rotbrain(const char *word) {
167-
if (word == NULL || *word == '\0') return EXIT_SUCCESS;
168-
169-
for (size_t i = 0; i < sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(FOSSIL_SOAP_ROTBRAIN[0]); ++i) {
170-
if (strcasecmp(word, FOSSIL_SOAP_ROTBRAIN[i]) == 0) {
171-
return EXIT_FAILURE;
172-
}
173-
}
174-
return EXIT_SUCCESS;
149+
return is_in_list(word, FOSSIL_SOAP_ROTBRAIN, sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(*FOSSIL_SOAP_ROTBRAIN));
175150
}
176151

177-
int32_t fossil_soap_count_rotbrain(const char *input) {
178-
if (input == NULL || *input == '\0') return 0;
152+
static int32_t count_matches(const char *input, const char **list, size_t list_size) {
153+
if (!input || *input == '\0') return 0;
179154

180155
int count = 0;
181156
char *copy = custom_strdup(input);
182-
if (copy == NULL) return EXIT_SUCCESS;
157+
if (!copy) return EXIT_SUCCESS;
183158

184-
char *token = strtok(copy, " ,.!?;:"); // Tokenize the string by space and punctuation
185-
while (token != NULL) {
186-
if (fossil_soap_is_rotbrain(token)) {
159+
char *token = strtok(copy, " ,.!?;:");
160+
while (token) {
161+
if (is_in_list(token, list, list_size) == EXIT_FAILURE) {
187162
count++;
188163
}
189164
token = strtok(NULL, " ,.!?;:");
190165
}
191-
free(copy); // Free the memory allocated for the copy
166+
free(copy);
192167
return count;
193168
}
169+
170+
int32_t fossil_soap_count_offensive(const char *input) {
171+
return count_matches(input, FOSSIL_SOAP_OFFENSIVE, sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(*FOSSIL_SOAP_OFFENSIVE));
172+
}
173+
174+
int32_t fossil_soap_count_rotbrain(const char *input) {
175+
return count_matches(input, FOSSIL_SOAP_ROTBRAIN, sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(*FOSSIL_SOAP_ROTBRAIN));
176+
}

code/tests/cases/test_soap.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ FOSSIL_TEST_CASE(cpp_test_soap_sanitize_with_punctuation) {
194194
ASSUME_ITS_EQUAL_CSTR(expected, input);
195195
}
196196

197-
198197
// * * * * * * * * * * * * * * * * * * * * * * * *
199198
// * Fossil Logic Test Pool
200199
// * * * * * * * * * * * * * * * * * * * * * * * *

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project('Fossil IO', 'c', 'cpp',
22
meson_version: '>=1.3.0',
33
license: 'MPL-2.0',
4-
version: '0.1.4',
4+
version: '0.1.5',
55
default_options: ['c_std=c17,c18', 'cpp_std=c++20'])
66

77
subdir('code')

0 commit comments

Comments
 (0)