diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d5e024..99b37dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 93e221c..44d71a5 100644 --- a/README.md +++ b/README.md @@ -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 @@ -37,7 +38,7 @@ 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 @@ -45,13 +46,14 @@ To get started with Fossil Io, ensure you have the following installed: 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: @@ -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 @@ -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 diff --git a/code/logic/soap.c b/code/logic/soap.c index e35f2d2..f3ee4ec 100644 --- a/code/logic/soap.c +++ b/code/logic/soap.c @@ -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 }; @@ -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)); +} diff --git a/code/tests/cases/test_soap.cpp b/code/tests/cases/test_soap.cpp index ab3a1bd..82694fc 100644 --- a/code/tests/cases/test_soap.cpp +++ b/code/tests/cases/test_soap.cpp @@ -194,7 +194,6 @@ FOSSIL_TEST_CASE(cpp_test_soap_sanitize_with_punctuation) { ASSUME_ITS_EQUAL_CSTR(expected, input); } - // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/meson.build b/meson.build index e06beeb..625b299 100644 --- a/meson.build +++ b/meson.build @@ -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')