64 lines
1.3 KiB
Makefile
Executable File
64 lines
1.3 KiB
Makefile
Executable File
# Makefile.string
|
|
# author: byuu
|
|
# license: public domain
|
|
|
|
[A-Z] = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
|
[a-z] = a b c d e f g h i j k l m n o p q r s t u v w x y z
|
|
[0-9] = 0 1 2 3 4 5 6 7 8 9
|
|
[markup] = ` ~ ! @ \# $$ % ^ & * ( ) - _ = + [ { ] } \ | ; : ' " , < . > / ?
|
|
[all] = $([A-Z]) $([a-z]) $([0-9]) $([markup])
|
|
[space] :=
|
|
[space] +=
|
|
|
|
#####
|
|
# function strtr(source, from, to)
|
|
#####
|
|
strtr = \
|
|
$(eval __temp := $1) \
|
|
$(strip \
|
|
$(foreach c, \
|
|
$(join $(addsuffix :,$2),$3), \
|
|
$(eval __temp := \
|
|
$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$(__temp)) \
|
|
) \
|
|
) \
|
|
$(__temp) \
|
|
)
|
|
|
|
#####
|
|
# function strupper(source)
|
|
#####
|
|
strupper = $(call strtr,$1,$([a-z]),$([A-Z]))
|
|
|
|
#####
|
|
# function strlower(source)
|
|
#####
|
|
strlower = $(call strtr,$1,$([A-Z]),$([a-z]))
|
|
|
|
#####
|
|
# function strlen(source)
|
|
#####
|
|
strlen = \
|
|
$(eval __temp := $(subst $([space]),_,$1)) \
|
|
$(words \
|
|
$(strip \
|
|
$(foreach c, \
|
|
$([all]), \
|
|
$(eval __temp := \
|
|
$(subst $c,$c ,$(__temp)) \
|
|
) \
|
|
) \
|
|
$(__temp) \
|
|
) \
|
|
)
|
|
|
|
#####
|
|
# function streq(source)
|
|
#####
|
|
streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),,1)
|
|
|
|
#####
|
|
# function strne(source)
|
|
#####
|
|
strne = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),1,)
|