[hackers] [libgrapheme] Add manuals for the grapheme_to_*case_utf8-functions || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Sun, 28 Aug 2022 17:39:45 +0200 (CEST)

commit 0516e8545dc78a808f737831a04d75f06cb875b3
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Sun Aug 28 17:22:35 2022 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Sun Aug 28 17:39:32 2022 +0200

    Add manuals for the grapheme_to_*case_utf8-functions
    
    In the spirit of the templates, this is achieved by generalizing
    the to_case-template.
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/Makefile b/Makefile
index a396309..bd1ca96 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -79,6 +79,9 @@ MAN3 =\
         man/grapheme_to_uppercase\
         man/grapheme_to_lowercase\
         man/grapheme_to_titlecase\
+ man/grapheme_to_uppercase_utf8\
+ man/grapheme_to_lowercase_utf8\
+ man/grapheme_to_titlecase_utf8\
 
 MAN7 =\
         man/libgrapheme\
_AT_@ -191,8 +194,6 @@ gen/sentence-test.h: data/SentenceBreakTest.txt gen/sentence-test
 gen/word.h: data/WordBreakProperty.txt gen/word
 gen/word-test.h: data/WordBreakTest.txt gen/word-test
 
-man/grapheme_decode_utf8.3: man/grapheme_decode_utf8.sh config.mk
-man/grapheme_encode_utf8.3: man/grapheme_encode_utf8.sh config.mk
 man/grapheme_is_character_break.3: man/grapheme_is_character_break.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
_AT_@ -205,6 +206,11 @@ man/grapheme_next_word_break_utf8.3: man/grapheme_next_word_break_utf8.sh man/te
 man/grapheme_to_uppercase.3: man/grapheme_to_uppercase.sh man/template/to_case.sh config.mk
 man/grapheme_to_lowercase.3: man/grapheme_to_lowercase.sh man/template/to_case.sh config.mk
 man/grapheme_to_titlecase.3: man/grapheme_to_titlecase.sh man/template/to_case.sh config.mk
+man/grapheme_to_uppercase_utf8.3: man/grapheme_to_uppercase_utf8.sh man/template/to_case.sh config.mk
+man/grapheme_to_lowercase_utf8.3: man/grapheme_to_lowercase_utf8.sh man/template/to_case.sh config.mk
+man/grapheme_to_titlecase_utf8.3: man/grapheme_to_titlecase_utf8.sh man/template/to_case.sh config.mk
+man/grapheme_decode_utf8.3: man/grapheme_decode_utf8.sh config.mk
+man/grapheme_encode_utf8.3: man/grapheme_encode_utf8.sh config.mk
 
 man/libgrapheme.7: man/libgrapheme.sh config.mk
 
diff --git a/man/grapheme_to_lowercase.sh b/man/grapheme_to_lowercase.sh
index 635e617..d171935 100644
--- a/man/grapheme_to_lowercase.sh
+++ b/man/grapheme_to_lowercase.sh
_AT_@ -1,2 +1,3 @@
+ENCODING="codepoint" \
 CASE="lowercase" \
         $SH man/template/to_case.sh
diff --git a/man/grapheme_to_lowercase_utf8.sh b/man/grapheme_to_lowercase_utf8.sh
new file mode 100644
index 0000000..ca94c62
--- /dev/null
+++ b/man/grapheme_to_lowercase_utf8.sh
_AT_@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="lowercase" \
+ $SH man/template/to_case.sh
diff --git a/man/grapheme_to_titlecase.sh b/man/grapheme_to_titlecase.sh
index e0a42f1..7357721 100644
--- a/man/grapheme_to_titlecase.sh
+++ b/man/grapheme_to_titlecase.sh
_AT_@ -1,2 +1,3 @@
+ENCODING="codepoint" \
 CASE="titlecase" \
         $SH man/template/to_case.sh
diff --git a/man/grapheme_to_titlecase_utf8.sh b/man/grapheme_to_titlecase_utf8.sh
new file mode 100644
index 0000000..82e812f
--- /dev/null
+++ b/man/grapheme_to_titlecase_utf8.sh
_AT_@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="titlecase" \
+ $SH man/template/to_case.sh
diff --git a/man/grapheme_to_uppercase.sh b/man/grapheme_to_uppercase.sh
index 7f3f3a0..6e004bc 100644
--- a/man/grapheme_to_uppercase.sh
+++ b/man/grapheme_to_uppercase.sh
_AT_@ -1,2 +1,3 @@
+ENCODING="codepoint" \
 CASE="uppercase" \
         $SH man/template/to_case.sh
diff --git a/man/grapheme_to_uppercase_utf8.sh b/man/grapheme_to_uppercase_utf8.sh
new file mode 100644
index 0000000..ca94c62
--- /dev/null
+++ b/man/grapheme_to_uppercase_utf8.sh
_AT_@ -0,0 +1,3 @@
+ENCODING="utf8" \
+CASE="lowercase" \
+ $SH man/template/to_case.sh
diff --git a/man/libgrapheme.sh b/man/libgrapheme.sh
index 327cc6e..47bbe34 100644
--- a/man/libgrapheme.sh
+++ b/man/libgrapheme.sh
_AT_@ -46,7 +46,13 @@ example illustrating the possible usage.
 .Xr grapheme_next_sentence_break 3 ,
 .Xr grapheme_next_sentence_break_utf8 3 ,
 .Xr grapheme_next_word_break 3 ,
-.Xr grapheme_next_word_break_utf8 3
+.Xr grapheme_next_word_break_utf8 3 ,
+.Xr grapheme_to_lowercase 3 ,
+.Xr grapheme_to_lowercase_utf8 3 ,
+.Xr grapheme_to_uppercase 3 ,
+.Xr grapheme_to_uppercase_utf8 3 ,
+.Xr grapheme_to_titlecase 3 ,
+.Xr grapheme_to_titlecase_utf8 3
 .Sh STANDARDS
 .Nm
 is compliant with the Unicode $UNICODE_VERSION specification.
diff --git a/man/template/to_case.sh b/man/template/to_case.sh
index 3c6a103..0403db8 100644
--- a/man/template/to_case.sh
+++ b/man/template/to_case.sh
_AT_@ -1,18 +1,30 @@
+if [ "$ENCODING" = "utf8" ]; then
+ UNIT="byte"
+ SUFFIX="_utf8"
+ ANTISUFFIX=""
+ DATATYPE="char"
+else
+ UNIT="codepoint"
+ SUFFIX=""
+ ANTISUFFIX="_utf8"
+ DATATYPE="uint_least32_t"
+fi
+
 cat << EOF
 .Dd $MAN_DATE
-.Dt GRAPHEME_TO_$(printf $CASE | tr [:lower:] [:upper:]) 3
+.Dt GRAPHEME_TO_$(printf "%s%s" "$CASE" "$SUFFIX" | tr [:lower:] [:upper:]) 3
 .Os suckless.org
 .Sh NAME
-.Nm grapheme_to_$CASE
+.Nm grapheme_to_$CASE$SUFFIX
 .Nd convert codepoint array to $CASE
 .Sh SYNOPSIS
 .In grapheme.h
 .Ft size_t
-.Fn grapheme_to_$CASE "const uint_least32_t *src" "size_t srclen" "uint_least32_t *dest" "size_t destlen"
+.Fn grapheme_to_$CASE$SUFFIX "const $DATATYPE *src" "size_t srclen" "$DATATYPE *dest" "size_t destlen"
 .Sh DESCRIPTION
 The
-.Fn grapheme_to_$CASE
-function converts the codepoint array
+.Fn grapheme_to_$CASE$SUFFIX
+function converts the $(if [ "$ENCODING" = "utf8" ]; then printf "UTF-8-encoded string"; else printf "codepoint array"; fi)
 .Va str
 to $CASE and writes the result to
 .Va dest
_AT_@ -32,13 +44,13 @@ is set to
 is interpreted to be NUL-terminated and processing stops when a
 NUL-byte is encountered.
 .Pp
-For UTF-8-encoded input data
-.Xr grapheme_to_$(printf $CASE)_utf8 3
+For $(if [ "$ENCODING" != "utf8" ]; then printf "UTF-8-encoded"; else printf "non-UTF-8"; fi) input data
+.Xr grapheme_to_$ANTISUFFIX 3
 can be used instead.
 .Sh RETURN VALUES
 The
-.Fn grapheme_to_$CASE
-function returns the number of codepoints in the array resulting
+.Fn grapheme_to_$CASE$SUFFIX
+function returns the number of $(printf $UNIT)s in the array resulting
 from converting
 .Va src
 to $CASE, even if
_AT_@ -48,10 +60,10 @@ is not large enough or
 is
 .Dv NULL .
 .Sh SEE ALSO
-.Xr grapheme_to_$(printf $CASE)_utf8 3 ,
+.Xr grapheme_to_$ANTISUFFIX 3 ,
 .Xr libgrapheme 7
 .Sh STANDARDS
-.Fn grapheme_to_$CASE
+.Fn grapheme_to_$CASE$SUFFIX
 is compliant with the Unicode $UNICODE_VERSION specification.
 .Sh AUTHORS
 .An Laslo Hunhold Aq Mt dev_AT_frign.de
Received on Sun Aug 28 2022 - 17:39:45 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 28 2022 - 17:48:35 CEST