From 52f57f78cc6a6673fa9559774c090fc7da74318a Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 27 Nov 2020 23:35:16 +0100 Subject: Docs and minor update of cstr.h --- README.md | 26 +++++++++++++------------- stc/cstr.h | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 38f86632..9cb49a58 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,19 @@ Introduction ------------ An elegant, fully typesafe, generic, customizable, user-friendly, consistent, and very fast standard container library for C99. This is a small headers only library with the most used container components, and a few algorithms: -- [**carray** - Dynamic generic ***multi-dimensional array***](docs/cbitset_api.md), implemented as a single contiguous block of memory. -- [**cbitset** - A ***bitset*** - *std::bitset*- or *boost::dynamic_bitset*-like](docs/cbitset_api.md) -- [**clist** - Generic circular ***singly linked List*** type](docs/clist_api.md). Can be used as a *queue* as it supports *push_back(), push_front(), and pop_front()*. Supports various *splice* functions and *merge sort*. -- [**cmap** - Generic fast ***unordered map/set*** types](docs/cstr_api.md) Implemented as open hashing without tombstones. Highly customizable and fast. -- [**cstr** - Powerful and compact ***string*** type](docs/cstr_api.md) -- [**cvec** - Dynamic generic ***vector*** type](docs/cvec_api.md) -- [**cstack** - A ***stack*** adapter type](docs/cstack_api.md) -- [**cqueue** - A ***queue*** adapter type](docs/cqueue_api.md) -- [**cpqueue** - A ***priority queue*** adapter type](docs/cpqueue_api.md) -- [**cptr** - Support for pointers and shared pointers in containers](docs/cptr_api.md) -- [**coption** - Implements *coption_get()*, a ***getopt_long***-like function](docs/coption_api.md), for command line argument parsing. -- [**crandom** - A few very efficent modern ***random number generators***](docs/crandom_api.md) *pcg32* and my own *64-bit PRNG* inspired by *sfc64*, with uniform and normal distributions. -- [**ccommon** - Collection of general definitions](docs/ccommon_api.md) +- [***carray*** - Dynamic generic **multi-dimensional array**](docs/cbitset_api.md), implemented as a single contiguous block of memory. +- [***cbitset*** - A **bitset** - *std::bitset*- or *boost::dynamic_bitset*-like](docs/cbitset_api.md) +- [***clist*** - Generic circular **singly linked List** type](docs/clist_api.md). Can be used as a *queue* as it supports *push_back(), push_front(), and pop_front()*. Supports various *splice* functions and *merge sort*. +- [***cmap*** - Generic fast **unordered map/set** types](docs/cstr_api.md) Implemented as open hashing without tombstones. Highly customizable and fast. +- [***cstr*** - Powerful and compact **string** type](docs/cstr_api.md) +- [***cvec*** - Dynamic generic **vector** type](docs/cvec_api.md) +- [***cstack*** - A **stack** adapter type](docs/cstack_api.md) +- [***cqueue*** - A **queue** adapter type](docs/cqueue_api.md) +- [***cpqueue*** - A **priority queue** adapter type](docs/cpqueue_api.md) +- [***cptr*** - Support for pointers and shared pointers in containers](docs/cptr_api.md) +- [***coption*** - Implements *coption_get()*, a **getopt_long**-like function](docs/coption_api.md), for command line argument parsing. +- [***crandom*** - A few very efficent modern **random number generators**](docs/crandom_api.md) *pcg32* and my own *64-bit PRNG* inspired by *sfc64*, with uniform and normal distributions. +- [***ccommon*** - Collection of general definitions](docs/ccommon_api.md) The usage of the containers is quite similar to the C++ standard containers, so it should be easy if you are familiar with them. diff --git a/stc/cstr.h b/stc/cstr.h index def10d98..1ae06456 100644 --- a/stc/cstr.h +++ b/stc/cstr.h @@ -223,12 +223,12 @@ cstr_ibegins_with(cstr_t s, const char* needle) { STC_INLINE bool cstr_ends_with(cstr_t s, const char* needle) { size_t n = strlen(needle), sz = cstr_size(s); - return n <= sz ? strcmp(s.str + sz - n, needle) == 0 : false; + return n <= sz ? memcmp(s.str + sz - n, needle, n) == 0 : false; } STC_INLINE bool cstr_iends_with(cstr_t s, const char* needle) { size_t n = strlen(needle), sz = cstr_size(s); - return n <= sz ? c_strncasecmp(s.str + sz - n, needle, cstr_npos) == 0 : false; + return n <= sz ? c_strncasecmp(s.str + sz - n, needle, n) == 0 : false; } /* cvec/cmap API functions: */ -- cgit v1.2.3