mirror of
https://github.com/theoludwig/libcproject.git
synced 2025-05-21 23:21:15 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
6eee39fffb
|
|||
ab9860e969
|
|||
a50773e058
|
|||
1e0bf99ef6
|
|||
ec6e748d24
|
|||
9bb21e070f
|
|||
bb9c7a1668
|
|||
211648d29f
|
|||
574aeb414e
|
|||
e0115dd7d9 |
@ -1,2 +1,2 @@
|
|||||||
BasedOnStyle: 'Google'
|
BasedOnStyle: "Google"
|
||||||
ColumnLimit: 0
|
ColumnLimit: 0
|
||||||
|
8
.github/ISSUE_TEMPLATE/BUG.md
vendored
8
.github/ISSUE_TEMPLATE/BUG.md
vendored
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: '🐛 Bug Report'
|
name: "🐛 Bug Report"
|
||||||
about: 'Report an unexpected problem or unintended behavior.'
|
about: "Report an unexpected problem or unintended behavior."
|
||||||
title: '[Bug]'
|
title: "[Bug]"
|
||||||
labels: 'bug'
|
labels: "bug"
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
8
.github/ISSUE_TEMPLATE/DOCUMENTATION.md
vendored
8
.github/ISSUE_TEMPLATE/DOCUMENTATION.md
vendored
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: '📜 Documentation'
|
name: "📜 Documentation"
|
||||||
about: 'Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...).'
|
about: "Correct spelling errors, improvements or additions to documentation files (README, CONTRIBUTING...)."
|
||||||
title: '[Documentation]'
|
title: "[Documentation]"
|
||||||
labels: 'documentation'
|
labels: "documentation"
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Please make sure your issue has not already been fixed. -->
|
<!-- Please make sure your issue has not already been fixed. -->
|
||||||
|
8
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
8
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: '✨ Feature Request'
|
name: "✨ Feature Request"
|
||||||
about: 'Suggest a new feature idea.'
|
about: "Suggest a new feature idea."
|
||||||
title: '[Feature]'
|
title: "[Feature]"
|
||||||
labels: 'feature request'
|
labels: "feature request"
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Please make sure your issue has not already been fixed. -->
|
<!-- Please make sure your issue has not already been fixed. -->
|
||||||
|
8
.github/ISSUE_TEMPLATE/IMPROVEMENT.md
vendored
8
.github/ISSUE_TEMPLATE/IMPROVEMENT.md
vendored
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: '🔧 Improvement'
|
name: "🔧 Improvement"
|
||||||
about: 'Improve structure/format/performance/refactor/tests of the code.'
|
about: "Improve structure/format/performance/refactor/tests of the code."
|
||||||
title: '[Improvement]'
|
title: "[Improvement]"
|
||||||
labels: 'improvement'
|
labels: "improvement"
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- Please make sure your issue has not already been fixed. -->
|
<!-- Please make sure your issue has not already been fixed. -->
|
||||||
|
8
.github/ISSUE_TEMPLATE/QUESTION.md
vendored
8
.github/ISSUE_TEMPLATE/QUESTION.md
vendored
@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
name: '🙋 Question'
|
name: "🙋 Question"
|
||||||
about: 'Further information is requested.'
|
about: "Further information is requested."
|
||||||
title: '[Question]'
|
title: "[Question]"
|
||||||
labels: 'question'
|
labels: "question"
|
||||||
---
|
---
|
||||||
|
|
||||||
### Question
|
### Question
|
||||||
|
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: 'CI'
|
name: "CI"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -8,33 +8,33 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.5.3'
|
- uses: "actions/checkout@v4.1.1"
|
||||||
|
|
||||||
- run: 'sudo apt update'
|
- run: "sudo apt update"
|
||||||
|
|
||||||
- name: 'Install Build Tools'
|
- name: "Install Build Tools"
|
||||||
run: 'sudo apt install --yes build-essential gcc make clang-format'
|
run: "sudo apt install --yes build-essential gcc make clang-format"
|
||||||
|
|
||||||
- name: 'Install Documentation Tools'
|
- name: "Install Documentation Tools"
|
||||||
run: 'sudo apt install --yes doxygen doxygen-gui doxygen-doc graphviz'
|
run: "sudo apt install --yes doxygen doxygen-gui doxygen-doc graphviz"
|
||||||
|
|
||||||
- run: 'gcc --version'
|
- run: "gcc --version"
|
||||||
|
|
||||||
- run: 'make'
|
- run: "make"
|
||||||
- run: 'make run'
|
- run: "make run"
|
||||||
- run: 'make test'
|
- run: "make test"
|
||||||
- run: 'make lint'
|
- run: "make lint"
|
||||||
- run: 'make documentation'
|
- run: "make documentation"
|
||||||
- run: 'make set_version'
|
- run: "make set_version"
|
||||||
- run: 'make clean'
|
- run: "make clean"
|
||||||
|
|
||||||
lint-commit:
|
lint-commit:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.5.3'
|
- uses: "actions/checkout@v4.1.1"
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: 'wagoid/commitlint-github-action@v5.4.1'
|
- uses: "wagoid/commitlint-github-action@v5.4.4"
|
||||||
|
46
.github/workflows/release.yml
vendored
46
.github/workflows/release.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: 'Release'
|
name: "Release"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -6,52 +6,52 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: 'ubuntu-latest'
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: 'actions/checkout@v3.5.3'
|
- uses: "actions/checkout@v4.1.1"
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
submodules: recursive
|
submodules: "recursive"
|
||||||
|
|
||||||
- name: 'Import GPG key'
|
- name: "Import GPG key"
|
||||||
uses: 'crazy-max/ghaction-import-gpg@v5.3.0'
|
uses: "crazy-max/ghaction-import-gpg@v6.1.0"
|
||||||
with:
|
with:
|
||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
git_user_signingkey: true
|
git_user_signingkey: true
|
||||||
git_commit_gpgsign: true
|
git_commit_gpgsign: true
|
||||||
|
|
||||||
- run: 'sudo apt update'
|
- run: "sudo apt update"
|
||||||
|
|
||||||
- name: 'Install Build Tools'
|
- name: "Install Build Tools"
|
||||||
run: 'sudo apt install --yes build-essential gcc make clang-format'
|
run: "sudo apt install --yes build-essential gcc make clang-format"
|
||||||
|
|
||||||
- name: 'Install Documentation Tools'
|
- name: "Install Documentation Tools"
|
||||||
run: 'sudo apt install --yes doxygen doxygen-gui doxygen-doc graphviz'
|
run: "sudo apt install --yes doxygen doxygen-gui doxygen-doc graphviz"
|
||||||
|
|
||||||
- run: 'make set_version'
|
- run: "make set_version"
|
||||||
|
|
||||||
- name: 'Use Node.js'
|
- name: "Use Node.js"
|
||||||
uses: 'actions/setup-node@v3.7.0'
|
uses: "actions/setup-node@v4.0.1"
|
||||||
with:
|
with:
|
||||||
node-version: '18.17.0'
|
node-version: "20.10.0"
|
||||||
|
|
||||||
- name: 'Install Release Tools'
|
- name: "Install Release Tools"
|
||||||
run: 'npm install --save-dev semantic-release@21.0.7 @commitlint/cli@17.6.7 @commitlint/config-conventional@17.6.7 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 @saithodev/semantic-release-backmerge@3.2.0 vercel@31.2.2'
|
run: "npm install --save-dev semantic-release@22.0.12 @commitlint/cli@18.4.3 @commitlint/config-conventional@18.4.3 @semantic-release/git@10.0.1 @semantic-release/exec@6.0.3 @saithodev/semantic-release-backmerge@4.0.1 vercel@33.0.1"
|
||||||
|
|
||||||
- run: 'rm --force package.json package-lock.json'
|
- run: "rm --force package.json package-lock.json"
|
||||||
|
|
||||||
- name: 'Release'
|
- name: "Release"
|
||||||
run: 'npx semantic-release'
|
run: "npx semantic-release"
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
GIT_COMMITTER_NAME: ${{ secrets.GIT_NAME }}
|
GIT_COMMITTER_NAME: ${{ secrets.GIT_NAME }}
|
||||||
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_EMAIL }}
|
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_EMAIL }}
|
||||||
|
|
||||||
- name: 'Generate Documentation'
|
- name: "Generate Documentation"
|
||||||
run: 'make documentation'
|
run: "make documentation"
|
||||||
|
|
||||||
- name: 'Deploy to Vercel'
|
- name: "Deploy to Vercel"
|
||||||
run: 'npx vercel ./documentation/html --token="${VERCEL_TOKEN}" --prod'
|
run: 'npx vercel ./documentation/html --token="${VERCEL_TOKEN}" --prod'
|
||||||
env:
|
env:
|
||||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
MIT License
|
# MIT License
|
||||||
|
|
||||||
Copyright (c) Théo LUDWIG
|
Copyright (c) Théo LUDWIG
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /></a>
|
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="Contributing" /></a>
|
||||||
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
|
||||||
<a href="./CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
<a href="./CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
||||||
<br />
|
<br />
|
||||||
<a href="https://github.com/theoludwig/libcproject/actions/workflows/ci.yml"><img src="https://github.com/theoludwig/libcproject/actions/workflows/ci.yml/badge.svg?branch=develop" /></a>
|
<a href="https://github.com/theoludwig/libcproject/actions/workflows/ci.yml"><img src="https://github.com/theoludwig/libcproject/actions/workflows/ci.yml/badge.svg?branch=develop" alt="CI" /></a>
|
||||||
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
||||||
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
Submodule doxygen-awesome-css updated: df83fbf22c...df88fe4fdd
@ -25,8 +25,8 @@ void array_list_remove(struct array_list* list, size_t index) {
|
|||||||
if (index >= list->size) {
|
if (index >= list->size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (size_t i = index + 1; i < list->size - 1; i++) {
|
for (size_t i = index; i < list->size - 1; i++) {
|
||||||
list->data[i - 1] = list->data[i];
|
list->data[i] = list->data[i + 1];
|
||||||
}
|
}
|
||||||
list->size--;
|
list->size--;
|
||||||
}
|
}
|
||||||
|
23
lib/string.c
23
lib/string.c
@ -384,3 +384,26 @@ bool string_ends_with(const string_t string, const string_t prefix) {
|
|||||||
}
|
}
|
||||||
return ends_with;
|
return ends_with;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t string_position_of(const string_t string, const char character) {
|
||||||
|
size_t position_found = 0;
|
||||||
|
size_t string_length = string_get_length(string);
|
||||||
|
for (size_t index = 0; index < string_length && position_found == 0; index++) {
|
||||||
|
if (string[index] == character) {
|
||||||
|
position_found = index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return position_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t string_last_position_of(const string_t string, const char character) {
|
||||||
|
size_t position_found = 0;
|
||||||
|
size_t string_length = string_get_length(string);
|
||||||
|
while (string_length > 0 && position_found == 0) {
|
||||||
|
if (string[string_length - 1] == character) {
|
||||||
|
position_found = string_length;
|
||||||
|
}
|
||||||
|
string_length--;
|
||||||
|
}
|
||||||
|
return position_found;
|
||||||
|
}
|
||||||
|
22
lib/string.h
22
lib/string.h
@ -264,4 +264,26 @@ bool string_starts_with(const string_t string, const string_t prefix);
|
|||||||
*/
|
*/
|
||||||
bool string_ends_with(const string_t string, const string_t prefix);
|
bool string_ends_with(const string_t string, const string_t prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the position (index + 1) within the string of the first occurrence of the specified substring (0 if not found).
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* @param substring
|
||||||
|
* @return size_t
|
||||||
|
* @example string_position_of("hello world", 'e') // 2
|
||||||
|
* @since v4.2.0
|
||||||
|
*/
|
||||||
|
size_t string_position_of(const string_t string, const char character);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the position (index + 1) within the string of the last occurrence of the specified substring (0 if not found).
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* @param character
|
||||||
|
* @return size_t
|
||||||
|
* @example string_last_position_of("hello world", 'o') // 8
|
||||||
|
* @since v4.2.0
|
||||||
|
*/
|
||||||
|
size_t string_last_position_of(const string_t string, const char character);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,4 +34,15 @@ void array_list_test() {
|
|||||||
assert(array_list_get(list, 100) == (void *)95);
|
assert(array_list_get(list, 100) == (void *)95);
|
||||||
|
|
||||||
array_list_free(list);
|
array_list_free(list);
|
||||||
|
|
||||||
|
list = array_list_initialization();
|
||||||
|
array_list_add(list, (void *)'a');
|
||||||
|
array_list_add(list, (void *)'b');
|
||||||
|
array_list_add(list, (void *)'c');
|
||||||
|
array_list_remove(list, 1);
|
||||||
|
assert(array_list_get(list, 0) == (void *)'a');
|
||||||
|
assert(array_list_get(list, 1) == (void *)'c');
|
||||||
|
assert(list->size == 2);
|
||||||
|
|
||||||
|
array_list_free(list);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ void string_test() {
|
|||||||
string_get_last_occurence_of_character_test();
|
string_get_last_occurence_of_character_test();
|
||||||
string_starts_with_test();
|
string_starts_with_test();
|
||||||
string_ends_with_test();
|
string_ends_with_test();
|
||||||
|
string_position_of_test();
|
||||||
|
string_last_position_of_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
void string_get_length_test() {
|
void string_get_length_test() {
|
||||||
@ -277,3 +279,27 @@ void string_ends_with_test() {
|
|||||||
assert(!string_ends_with("abcdef", "bcd"));
|
assert(!string_ends_with("abcdef", "bcd"));
|
||||||
assert(!string_ends_with("abcdef", "abcdefg"));
|
assert(!string_ends_with("abcdef", "abcdefg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void string_position_of_test() {
|
||||||
|
assert(string_position_of("hello world", 'e') == 2);
|
||||||
|
assert(string_position_of("hello world", 'o') == 5);
|
||||||
|
assert(string_position_of("abcdef", 'a') == 1);
|
||||||
|
assert(string_position_of("abcdef", 'b') == 2);
|
||||||
|
assert(string_position_of("abcdef", 'c') == 3);
|
||||||
|
assert(string_position_of("abcdef", 'd') == 4);
|
||||||
|
assert(string_position_of("abcdef", 'e') == 5);
|
||||||
|
assert(string_position_of("abcdef", 'f') == 6);
|
||||||
|
assert(string_position_of("abcdef", 'g') == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void string_last_position_of_test() {
|
||||||
|
assert(string_last_position_of("hello world", 'e') == 2);
|
||||||
|
assert(string_last_position_of("hello world", 'o') == 8);
|
||||||
|
assert(string_last_position_of("abcdef", 'a') == 1);
|
||||||
|
assert(string_last_position_of("abcdef", 'b') == 2);
|
||||||
|
assert(string_last_position_of("abcdef", 'c') == 3);
|
||||||
|
assert(string_last_position_of("abcdef", 'd') == 4);
|
||||||
|
assert(string_last_position_of("abcdef", 'e') == 5);
|
||||||
|
assert(string_last_position_of("abcdef", 'f') == 6);
|
||||||
|
assert(string_last_position_of("abcdef", 'g') == 0);
|
||||||
|
}
|
||||||
|
@ -58,4 +58,8 @@ void string_starts_with_test();
|
|||||||
|
|
||||||
void string_ends_with_test();
|
void string_ends_with_test();
|
||||||
|
|
||||||
|
void string_position_of_test();
|
||||||
|
|
||||||
|
void string_last_position_of_test();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user