commit cd82185dc9bbb7b2d1771952a625152da5e47591
parent 6e6c538e4efb4d191a2f0391466556eb758d76bd
Author: Laslo Hunhold <dev@frign.de>
Date: Wed, 7 Sep 2022 22:19:41 +0200
Add manuals for the grapheme_is_*case*()-functions
Signed-off-by: Laslo Hunhold <dev@frign.de>
Diffstat:
9 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -82,6 +82,12 @@ MAN3 =\
man/grapheme_to_uppercase_utf8\
man/grapheme_to_lowercase_utf8\
man/grapheme_to_titlecase_utf8\
+ man/grapheme_is_uppercase\
+ man/grapheme_is_lowercase\
+ man/grapheme_is_titlecase\
+ man/grapheme_is_uppercase_utf8\
+ man/grapheme_is_lowercase_utf8\
+ man/grapheme_is_titlecase_utf8\
MAN7 =\
man/libgrapheme\
@@ -195,6 +201,12 @@ gen/word.h: data/WordBreakProperty.txt gen/word
gen/word-test.h: data/WordBreakTest.txt gen/word-test
man/grapheme_is_character_break.3: man/grapheme_is_character_break.sh config.mk
+man/grapheme_is_uppercase.3: man/grapheme_is_uppercase.sh man/template/is_case.sh config.mk
+man/grapheme_is_lowercase.3: man/grapheme_is_lowercase.sh man/template/is_case.sh config.mk
+man/grapheme_is_titlecase.3: man/grapheme_is_titlecase.sh man/template/is_case.sh config.mk
+man/grapheme_is_uppercase_utf8.3: man/grapheme_is_uppercase_utf8.sh man/template/is_case.sh config.mk
+man/grapheme_is_lowercase_utf8.3: man/grapheme_is_lowercase_utf8.sh man/template/is_case.sh config.mk
+man/grapheme_is_titlecase_utf8.3: man/grapheme_is_titlecase_utf8.sh man/template/is_case.sh config.mk
man/grapheme_next_character_break.3: man/grapheme_next_character_break.sh man/template/next_break.sh config.mk
man/grapheme_next_line_break.3: man/grapheme_next_line_break.sh man/template/next_break.sh config.mk
man/grapheme_next_sentence_break.3: man/grapheme_next_sentence_break.sh man/template/next_break.sh config.mk
diff --git a/man/grapheme_is_lowercase.sh b/man/grapheme_is_lowercase.sh
@@ -0,0 +1,3 @@
+ENCODING="codepoint" \
+CASE="lowercase" \
+ $SH man/template/is_case.sh
diff --git a/man/grapheme_is_lowercase_utf8.sh b/man/grapheme_is_lowercase_utf8.sh
@@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="lowercase" \
+ $SH man/template/is_case.sh
diff --git a/man/grapheme_is_titlecase.sh b/man/grapheme_is_titlecase.sh
@@ -0,0 +1,3 @@
+ENCODING="codepoint" \
+CASE="titlecase" \
+ $SH man/template/is_case.sh
diff --git a/man/grapheme_is_titlecase_utf8.sh b/man/grapheme_is_titlecase_utf8.sh
@@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="titlecase" \
+ $SH man/template/is_case.sh
diff --git a/man/grapheme_is_uppercase.sh b/man/grapheme_is_uppercase.sh
@@ -0,0 +1,3 @@
+ENCODING="codepoint" \
+CASE="uppercase" \
+ $SH man/template/is_case.sh
diff --git a/man/grapheme_is_uppercase_utf8.sh b/man/grapheme_is_uppercase_utf8.sh
@@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="lowercase" \
+ $SH man/template/is_case.sh
diff --git a/man/libgrapheme.sh b/man/libgrapheme.sh
@@ -39,6 +39,12 @@ example illustrating the possible usage.
.Xr grapheme_decode_utf8 3 ,
.Xr grapheme_encode_utf8 3 ,
.Xr grapheme_is_character_break 3 ,
+.Xr grapheme_is_lowercase 3 ,
+.Xr grapheme_is_lowercase_utf8 3 ,
+.Xr grapheme_is_uppercase 3 ,
+.Xr grapheme_is_uppercase_utf8 3 ,
+.Xr grapheme_is_titlecase 3 ,
+.Xr grapheme_is_titlecase_utf8 3 ,
.Xr grapheme_next_character_break 3 ,
.Xr grapheme_next_character_break_utf8 3 ,
.Xr grapheme_next_line_break 3 ,
diff --git a/man/template/is_case.sh b/man/template/is_case.sh
@@ -0,0 +1,67 @@
+if [ "$ENCODING" = "utf8" ]; then
+ UNIT="byte"
+ ARRAYTYPE="UTF-8-encoded string"
+ SUFFIX="_utf8"
+ ANTISUFFIX=""
+ DATATYPE="char"
+else
+ UNIT="codepoint"
+ ARRAYTYPE="codepoint array"
+ SUFFIX=""
+ ANTISUFFIX="_utf8"
+ DATATYPE="uint_least32_t"
+fi
+
+cat << EOF
+.Dd ${MAN_DATE}
+.Dt GRAPHEME_IS_$(printf "%s%s" "$CASE" "$SUFFIX" | tr [:lower:] [:upper:]) 3
+.Os suckless.org
+.Sh NAME
+.Nm grapheme_is_${CASE}${SUFFIX}
+.Nd check if ${ARRAYTYPE} is ${CASE}
+.Sh SYNOPSIS
+.In grapheme.h
+.Ft size_t
+.Fn grapheme_is_${CASE}${SUFFIX} "const ${DATATYPE} *str" "size_t len" "size_t caselen"
+.Sh DESCRIPTION
+The
+.Fn grapheme_is_${CASE}${SUFFIX}
+function checks if the ${ARRAYTYPE}
+.Va str
+is ${CASE} and writes the length of the matching ${CASE}-sequence to the integer pointed to by
+.Va caselen ,
+unless
+.Va caselen
+is set to
+.Dv NULL .
+.Pp
+If
+.Va len
+is set to
+.Dv SIZE_MAX
+(stdint.h is already included by grapheme.h) the ${ARRAYTYPE}
+.Va src
+is interpreted to be NUL-terminated and processing stops when a
+NUL-byte is encountered.
+.Pp
+For $(if [ "$ENCODING" != "utf8" ]; then printf "UTF-8-encoded"; else printf "non-UTF-8"; fi) input data
+.Xr grapheme_is_${CASE}${ANTISUFFIX} 3
+can be used instead.
+.Sh RETURN VALUES
+The
+.Fn grapheme_is_${CASE}${SUFFIX}
+function returns
+.Dv true
+if the ${ARRAYTYPE}
+.Va str
+is ${CASE}, otherwise
+.Dv false .
+.Sh SEE ALSO
+.Xr grapheme_is_${CASE}${ANTISUFFIX} 3 ,
+.Xr libgrapheme 7
+.Sh STANDARDS
+.Fn grapheme_is_${CASE}${SUFFIX}
+is compliant with the Unicode ${UNICODE_VERSION} specification.
+.Sh AUTHORS
+.An Laslo Hunhold Aq Mt dev@frign.de
+EOF