Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fossil Io Version Update #13

Merged
merged 6 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.13.4)

# Project metadata
project(FossilIo VERSION 0.1.4 LANGUAGES C CXX)
project(FossilIo VERSION 0.1.5 LANGUAGES C CXX)

# Set the C and C++ standards
set(CMAKE_C_STANDARD 11)
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ To get started with Fossil Io, ensure you have the following installed:
- **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).
- **CMake Build System**: If you don’t have CMake installed, follow the installation instructions on the official [CMake website](https://cmake.org/getting-started/).

### Adding Fossil Test Dependency
### Adding Fossil Io Dependency

#### Adding Fossil Test Dependency With Meson
#### Adding Fossil Io Dependency With Meson

1. **Install Meson Build System**:
Install Meson version `1.3` or newer:

```sh
python -m pip install meson # To install Meson
python -m pip install --upgrade meson # To upgrade Meson
Expand All @@ -37,21 +38,22 @@ To get started with Fossil Io, ensure you have the following installed:
# ======================
[wrap-git]
url = https://github.com/fossillogic/fossil-io.git
revision = v0.1.4
revision = v0.1.5

[provide]
fossil-io = fossil_io_dep
```

3. **Integrate the Dependency**:
In your `meson.build` file, integrate Fossil Io by adding the following line:

```ini
dep = dependency('fossil-io')
```

---

#### Adding Fossil Test Dependency With CMake
#### Adding Fossil Io Dependency With CMake

To use Fossil Io with CMake, follow these steps:

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

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

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

---

**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.
**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.

## Configure Options

Expand Down
63 changes: 23 additions & 40 deletions code/logic/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static const char *FOSSIL_SOAP_ROTBRAIN[] = {
"rizz", "skibidi", "yeet", "sus", "vibe", "lit", "no cap", "bet", "fam", "bruh",
"flex", "ghost", "goat", "gucci", "hype", "janky", "lowkey", "mood", "salty", "shade",
"slay", "snatched", "stan", "tea", "thirsty", "woke", "yolo", "zaddy", "drip", "fire",
"lol", "omg", "brb", "sus"
"lol", "omg", "brb"

// Support for other terms can be added via PR to this repository
};
Expand Down Expand Up @@ -132,62 +132,45 @@ void fossil_soap_sanitize(char *input) {
}
}

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

for (size_t i = 0; i < sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(FOSSIL_SOAP_OFFENSIVE[0]); ++i) {
if (strcasecmp(word, FOSSIL_SOAP_OFFENSIVE[i]) == 0) {
return EXIT_FAILURE;
}
for (size_t i = 0; i < list_size; ++i) {
if (strcasecmp(word, list[i]) == 0) return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

// Function to get the number of offensive words found in a string
int32_t fossil_soap_count_offensive(const char *input) {
if (input == NULL || *input == '\0') return 0;

int count = 0;
char *copy = custom_strdup(input);
if (copy == NULL) return EXIT_SUCCESS;

char *token = strtok(copy, " ,.!?;:"); // Tokenize the string by space and punctuation
while (token != NULL) {
if (fossil_soap_is_offensive(token)) {
count++;
}
token = strtok(NULL, " ,.!?;:");
}
free(copy); // Free the memory allocated for the copy
return count;
int32_t fossil_soap_is_offensive(const char *word) {
return is_in_list(word, FOSSIL_SOAP_OFFENSIVE, sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(*FOSSIL_SOAP_OFFENSIVE));
}

int32_t fossil_soap_is_rotbrain(const char *word) {
if (word == NULL || *word == '\0') return EXIT_SUCCESS;

for (size_t i = 0; i < sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(FOSSIL_SOAP_ROTBRAIN[0]); ++i) {
if (strcasecmp(word, FOSSIL_SOAP_ROTBRAIN[i]) == 0) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
return is_in_list(word, FOSSIL_SOAP_ROTBRAIN, sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(*FOSSIL_SOAP_ROTBRAIN));
}

int32_t fossil_soap_count_rotbrain(const char *input) {
if (input == NULL || *input == '\0') return 0;
static int32_t count_matches(const char *input, const char **list, size_t list_size) {
if (!input || *input == '\0') return 0;

int count = 0;
char *copy = custom_strdup(input);
if (copy == NULL) return EXIT_SUCCESS;
if (!copy) return EXIT_SUCCESS;

char *token = strtok(copy, " ,.!?;:"); // Tokenize the string by space and punctuation
while (token != NULL) {
if (fossil_soap_is_rotbrain(token)) {
char *token = strtok(copy, " ,.!?;:");
while (token) {
if (is_in_list(token, list, list_size) == EXIT_FAILURE) {
count++;
}
token = strtok(NULL, " ,.!?;:");
}
free(copy); // Free the memory allocated for the copy
free(copy);
return count;
}

int32_t fossil_soap_count_offensive(const char *input) {
return count_matches(input, FOSSIL_SOAP_OFFENSIVE, sizeof(FOSSIL_SOAP_OFFENSIVE) / sizeof(*FOSSIL_SOAP_OFFENSIVE));
}

int32_t fossil_soap_count_rotbrain(const char *input) {
return count_matches(input, FOSSIL_SOAP_ROTBRAIN, sizeof(FOSSIL_SOAP_ROTBRAIN) / sizeof(*FOSSIL_SOAP_ROTBRAIN));
}
1 change: 0 additions & 1 deletion code/tests/cases/test_soap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ FOSSIL_TEST_CASE(cpp_test_soap_sanitize_with_punctuation) {
ASSUME_ITS_EQUAL_CSTR(expected, input);
}


// * * * * * * * * * * * * * * * * * * * * * * * *
// * Fossil Logic Test Pool
// * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('Fossil IO', 'c', 'cpp',
meson_version: '>=1.3.0',
license: 'MPL-2.0',
version: '0.1.4',
version: '0.1.5',
default_options: ['c_std=c17,c18', 'cpp_std=c++20'])

subdir('code')