From b3a2b67b19dd12e2e1e4bf633f83442df14374d2 Mon Sep 17 00:00:00 2001 From: j8takagi Date: Mon, 11 Mar 2019 10:33:00 +0900 Subject: [PATCH 1/1] =?utf8?q?strip=5Fcasl2=5Fcomment=E3=81=A8strip=5Fend?= =?utf8?q?=E9=96=A2=E6=95=B0=E3=81=AE=E8=BF=94=E3=82=8A=E5=80=A4=E3=82=92v?= =?utf8?q?oid=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 文字列を扱う関数がミュータブルかイミュータブルかを明示するため --- include/cmem.h | 17 +++++++++++++---- src/cmem.c | 10 +++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/cmem.h b/include/cmem.h index e8b0aba..2411980 100644 --- a/include/cmem.h +++ b/include/cmem.h @@ -70,19 +70,28 @@ char *strndup_chk(const char *s, size_t len, const char *tag); /** * @brief 文字列の末尾から、改行と空白とタブを削除する * - * @return 末尾から改行と空白とタブを削除した文字列 + * @return なし * * @param s 文字列 */ -char *strip_end(char *s); +void strip_end(char *s); /** * @brief 文字列から「'」以降の文字列をCASL IIのコメントとして削除する。「''」の場合は除く * - * @return コメントを削除した文字列 + * @return なし + * + * @param s 文字列 + */ +void strip_casl2_comment(char *s); + +/** + * @brief 逆にした文字列を返す + * + * @return 逆にしたした文字列 * * @param s 文字列 */ -char *strip_casl2_comment(char *s); +char *strrev(const char *s); #endif diff --git a/src/cmem.c b/src/cmem.c index 48bc632..b536895 100644 --- a/src/cmem.c +++ b/src/cmem.c @@ -47,15 +47,14 @@ char *strndup_chk(const char *s, size_t len, const char *tag) return t; } -char *strip_end(char *s) +void strip_end(char *s) { - for(int i = strlen(s) - 1; i > 0 && (s[i] == '\n' || s[i] == ' ' || s[i] == '\t'); i--) { + for(int i = strlen(s) - 1; i > 0 && (s[i] == '\n' || s[i] == '\r' || s[i] == ' ' || s[i] == '\t'); i--) { s[i] = '\0'; } - return s; } -char *strip_casl2_comment(char *s) +void strip_casl2_comment(char *s) { bool quoting = false; @@ -69,5 +68,6 @@ char *strip_casl2_comment(char *s) break; } } - return s; +} + } -- 2.18.0