11cb0ef41Sopenharmony_ci# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
21cb0ef41Sopenharmony_ci# ----------------------------------------------------
31cb0ef41Sopenharmony_ci# Expand into
41cb0ef41Sopenharmony_ci# | case WORD in
51cb0ef41Sopenharmony_ci# | PATTERN1) IF-MATCHED1 ;;
61cb0ef41Sopenharmony_ci# | ...
71cb0ef41Sopenharmony_ci# | *) DEFAULT ;;
81cb0ef41Sopenharmony_ci# | esac
91cb0ef41Sopenharmony_cim4_define([_AS_CASE],
101cb0ef41Sopenharmony_ci[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
111cb0ef41Sopenharmony_ci       [$#], 1, [  *) $1 ;;],
121cb0ef41Sopenharmony_ci       [$#], 2, [  $1) m4_default([$2], [:]) ;;],
131cb0ef41Sopenharmony_ci       [  $1) m4_default([$2], [:]) ;;
141cb0ef41Sopenharmony_ci$0(m4_shiftn(2, $@))])dnl
151cb0ef41Sopenharmony_ci])
161cb0ef41Sopenharmony_cim4_defun([AS_CASE],
171cb0ef41Sopenharmony_ci[m4_ifval([$2$3],
181cb0ef41Sopenharmony_ci[case $1 in
191cb0ef41Sopenharmony_ci_AS_CASE(m4_shift($@))
201cb0ef41Sopenharmony_ciesac])])
211cb0ef41Sopenharmony_ci
22