diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-02 22:17:14 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-02 22:28:08 +0200 |
commit | e4a1686d5ca41ad02672c6530588f94c34a1c678 (patch) | |
tree | cd143c5dcbc5b8182ce7df521bf48f4de2617628 /libnumtext_remove_separators.c | |
download | libnumtext-e4a1686d5ca41ad02672c6530588f94c34a1c678.tar.gz libnumtext-e4a1686d5ca41ad02672c6530588f94c34a1c678.tar.bz2 libnumtext-e4a1686d5ca41ad02672c6530588f94c34a1c678.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libnumtext_remove_separators.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libnumtext_remove_separators.c b/libnumtext_remove_separators.c new file mode 100644 index 0000000..41b14ea --- /dev/null +++ b/libnumtext_remove_separators.c @@ -0,0 +1,29 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +ssize_t +libnumtext_remove_separators(char outbuf[], size_t outbuf_size, const char *num, size_t num_len, enum libnumtext_language lang) +{ + char *p = outbuf; + ssize_t len = 0; + + switch (lang) { + + case LIBNUMTEXT_SWEDISH: + for (; num_len--; num++) { + if (*num != ' ' && *num != '\'' && *num != '.') { + if (outbuf_size) { + *p++ = *num; + outbuf_size--; + } + len += 1; + } + } + return len; + + default: + errno = EINVAL; + return -1; + } +} |