Add manuals for the grapheme_to_*case_utf8-functions - libgrapheme - unicode st… | |
git clone git://git.suckless.org/libgrapheme | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0516e8545dc78a808f737831a04d75f06cb875b3 | |
parent 6777bc7a3ce98e703f2943b2c3a502a2bfc60798 | |
Author: Laslo Hunhold <[email protected]> | |
Date: Sun, 28 Aug 2022 17:22:35 +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 <[email protected]> | |
Diffstat: | |
M Makefile | 10 ++++++++-- | |
M man/grapheme_to_lowercase.sh | 1 + | |
A man/grapheme_to_lowercase_utf8.sh | 3 +++ | |
M man/grapheme_to_titlecase.sh | 1 + | |
A man/grapheme_to_titlecase_utf8.sh | 3 +++ | |
M man/grapheme_to_uppercase.sh | 1 + | |
A man/grapheme_to_uppercase_utf8.sh | 3 +++ | |
M man/libgrapheme.sh | 8 +++++++- | |
M man/template/to_case.sh | 34 +++++++++++++++++++++--------… | |
9 files changed, 50 insertions(+), 14 deletions(-) | |
--- | |
diff --git a/Makefile b/Makefile | |
@@ -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\ | |
@@ -191,8 +194,6 @@ gen/sentence-test.h: data/SentenceBreakTest.txt gen/sentenc… | |
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/… | |
man/grapheme_next_line_break.3: man/grapheme_next_line_break.sh man/template/n… | |
@@ -205,6 +206,11 @@ man/grapheme_next_word_break_utf8.3: man/grapheme_next_wor… | |
man/grapheme_to_uppercase.3: man/grapheme_to_uppercase.sh man/template/to_case… | |
man/grapheme_to_lowercase.3: man/grapheme_to_lowercase.sh man/template/to_case… | |
man/grapheme_to_titlecase.3: man/grapheme_to_titlecase.sh man/template/to_case… | |
+man/grapheme_to_uppercase_utf8.3: man/grapheme_to_uppercase_utf8.sh man/templa… | |
+man/grapheme_to_lowercase_utf8.3: man/grapheme_to_lowercase_utf8.sh man/templa… | |
+man/grapheme_to_titlecase_utf8.3: man/grapheme_to_titlecase_utf8.sh man/templa… | |
+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 | |
@@ -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… | |
@@ -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 | |
@@ -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… | |
@@ -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 | |
@@ -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… | |
@@ -0,0 +1,3 @@ | |
+ENCODING="utf8" \ | |
+CASE="lowercase" \ | |
+ $SH man/template/to_case.sh | |
diff --git a/man/libgrapheme.sh b/man/libgrapheme.sh | |
@@ -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 | |
@@ -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_least3… | |
+.Fn grapheme_to_$CASE$SUFFIX "const $DATATYPE *src" "size_t srclen" "$DATATYPE… | |
.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-encode… | |
.Va str | |
to $CASE and writes the result to | |
.Va dest | |
@@ -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 "… | |
+.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 | |
@@ -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 [email protected] |