diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-05-24 13:25:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 13:25:01 -0400 |
commit | c205840e737b23614a686a9675b896106cee5c64 (patch) | |
tree | f2eb9d93edb1540221daea3682bf13254d28128c /lib/str.c | |
parent | 03e39ae5dcd4002ac9657a550c48b8e9f85c449c (diff) | |
parent | a38fbb5766b48a9695ea139f79634fc746642bdd (diff) | |
download | spmc-c205840e737b23614a686a9675b896106cee5c64.tar.gz |
Merge pull request #37 from jhunkeler/version-fixups
Version fixups
Diffstat (limited to 'lib/str.c')
-rw-r--r-- | lib/str.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -817,3 +817,30 @@ int strcmp_array(const char **a, const char **b) { } return result; } + +/** + * Determine whether a string is comprised of digits + * @param s + * @return 0=no, 1=yes + */ +int isdigit_s(char *s) { + for (size_t i = 0; s[i] != '\0'; i++) { + if (isdigit(s[i]) == 0) { + return 0; // non-digit found, fail + } + } + return 1; // all digits, succeed +} + +/** + * Convert input string to lowercase + * @param s + * @return pointer to input string + */ +char *tolower_s(char *s) { + for (size_t i = 0; s[i] != '\0'; i++) { + s[i] = (char)tolower(s[i]); + } + return s; +} + |