* str: line breaks, comments
authorUrban Wallasch <urban.wallasch@freenet.de>
Mon, 28 Oct 2019 20:34:33 +0000 (21:34 +0100)
committerUrban Wallasch <urban.wallasch@freenet.de>
Mon, 28 Oct 2019 20:34:33 +0000 (21:34 +0100)
README.html
str/str.h

index c883fd5b9fa31961e3528a73a479b34952ced500..8a72c02a4bef81597fb0e7204f4fc5a77e3571bd 100644 (file)
@@ -20,7 +20,7 @@ simple IPv4 and IPv6 based TCP and UDP client/server handling
 href="/?p=oddbits.git;a=tree;f=str;hb=HEAD"><b>
 str
 </b></a></td><td>-</td><td>
-collection of various inline functions to complement string.h
+standard C string processing functions to complement string.h
 </td></tr>
 
 </table>
index a14ce7c1325687792782c5fd758e6292e27de090..382a9b1857c55f463fea4bffacf51bf081c9c895 100644 (file)
--- a/str/str.h
+++ b/str/str.h
@@ -4,7 +4,20 @@
  * Copyright (c) 2019, Urban Wallasch
  * BSD 3-Clause License, see LICENSE file for more details.
  *
- * String comparison and search functions to complement string.h.
+ * standard C string processing functions to complement string.h
+ *
+ * A lot of the functions below are basically clones of non-standard
+ * extensions found in various C libraries.  The code should build and
+ * work just fine when translated as ISO C99 or above, e.g. with:
+ *   gcc -std=c99 -Wpedantic -Wall -Wextra [...]
+ *
+ * The names were chosen in a way that should avoid name clashes with
+ * existing C library functions.
+ *
+ * No claim is made that the particular implementations are the most
+ * efficient, but the code should perform reasonably well under real
+ * world conditions when optimized by a decent compiler.
+ *
  *
  * str_icmp,
  * str_nicmp - compare two strings ignoring case
@@ -35,7 +48,7 @@
  * str_toupper,
  * str_tolower - convert case of characters in string
  *
- * str_nlen   - determine the length of a fixed-size string
+ * str_nlen  - determine the length of a fixed-size string
  *
  * str_ncpy  - copy initial part of a string (a better strncpy)
  *
@@ -159,7 +172,8 @@ static inline char *str_istr(const char *haystack, const char *needle) {
  * not found.  If the search pattern is of zero length, the functions
  * return haystack.
  */
-static inline void *mem_mem(const void *haystack, size_t h, const void *needle, size_t n) {
+static inline void *mem_mem(const void *haystack, size_t h,
+                            const void *needle, size_t n) {
     if (h >= n) {
         const char *p = haystack;
         h -= n;
@@ -172,11 +186,13 @@ static inline void *mem_mem(const void *haystack, size_t h, const void *needle,
     return NULL;
 }
 
-static inline void *mem_str(const void *haystack, size_t h, const char *needle) {
+static inline void *mem_str(const void *haystack, size_t h,
+                            const char *needle) {
     return mem_mem(haystack, h, needle, needle ? strlen(needle) : 0);
 }
 
-static inline void *mem_istr(const void *haystack, size_t h, const char *needle) {
+static inline void *mem_istr(const void *haystack, size_t h,
+                            const char *needle) {
     size_t n = needle ? strlen(needle) : 0;
 
     if (h >= n) {