113498266Sopenharmony_ci#--------------------------------------------------------------------------- 213498266Sopenharmony_ci# 313498266Sopenharmony_ci# xc-translit.m4 413498266Sopenharmony_ci# 513498266Sopenharmony_ci# Copyright (C), Daniel Stenberg <daniel@haxx.se> 613498266Sopenharmony_ci# 713498266Sopenharmony_ci# Permission to use, copy, modify, and distribute this software for any 813498266Sopenharmony_ci# purpose with or without fee is hereby granted, provided that the above 913498266Sopenharmony_ci# copyright notice and this permission notice appear in all copies. 1013498266Sopenharmony_ci# 1113498266Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1213498266Sopenharmony_ci# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1313498266Sopenharmony_ci# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1413498266Sopenharmony_ci# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1513498266Sopenharmony_ci# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1613498266Sopenharmony_ci# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1713498266Sopenharmony_ci# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1813498266Sopenharmony_ci# 1913498266Sopenharmony_ci# SPDX-License-Identifier: ISC 2013498266Sopenharmony_ci# 2113498266Sopenharmony_ci#--------------------------------------------------------------------------- 2213498266Sopenharmony_ci 2313498266Sopenharmony_ci# File version for 'aclocal' use. Keep it a single number. 2413498266Sopenharmony_ci# serial 2 2513498266Sopenharmony_ci 2613498266Sopenharmony_ci 2713498266Sopenharmony_cidnl XC_SH_TR_SH (expression) 2813498266Sopenharmony_cidnl ------------------------------------------------- 2913498266Sopenharmony_cidnl Shell execution time transliteration of 'expression' 3013498266Sopenharmony_cidnl argument, where all non-alfanumeric characters are 3113498266Sopenharmony_cidnl converted to the underscore '_' character. 3213498266Sopenharmony_cidnl Normal shell expansion and substitution takes place 3313498266Sopenharmony_cidnl for given 'expression' at shell execution time before 3413498266Sopenharmony_cidnl transliteration is applied to it. 3513498266Sopenharmony_ci 3613498266Sopenharmony_ciAC_DEFUN([XC_SH_TR_SH], 3713498266Sopenharmony_ci[`echo "$1" | sed 's/[[^a-zA-Z0-9_]]/_/g'`]) 3813498266Sopenharmony_ci 3913498266Sopenharmony_ci 4013498266Sopenharmony_cidnl XC_SH_TR_SH_EX (expression, [extra]) 4113498266Sopenharmony_cidnl ------------------------------------------------- 4213498266Sopenharmony_cidnl Like XC_SH_TR_SH but transliterating characters 4313498266Sopenharmony_cidnl given in 'extra' argument to lowercase 'p'. For 4413498266Sopenharmony_cidnl example [*+], [*], and [+] are valid 'extra' args. 4513498266Sopenharmony_ci 4613498266Sopenharmony_ciAC_DEFUN([XC_SH_TR_SH_EX], 4713498266Sopenharmony_ci[ifelse([$2], [], 4813498266Sopenharmony_ci [XC_SH_TR_SH([$1])], 4913498266Sopenharmony_ci [`echo "$1" | sed 's/[[$2]]/p/g' | sed 's/[[^a-zA-Z0-9_]]/_/g'`])]) 5013498266Sopenharmony_ci 5113498266Sopenharmony_ci 5213498266Sopenharmony_cidnl XC_M4_TR_SH (expression) 5313498266Sopenharmony_cidnl ------------------------------------------------- 5413498266Sopenharmony_cidnl m4 execution time transliteration of 'expression' 5513498266Sopenharmony_cidnl argument, where all non-alfanumeric characters are 5613498266Sopenharmony_cidnl converted to the underscore '_' character. 5713498266Sopenharmony_ci 5813498266Sopenharmony_ciAC_DEFUN([XC_M4_TR_SH], 5913498266Sopenharmony_ci[patsubst(XC_QPATSUBST(XC_QUOTE($1), 6013498266Sopenharmony_ci [[^a-zA-Z0-9_]], [_]), 6113498266Sopenharmony_ci [\(_\(.*\)_\)], [\2])]) 6213498266Sopenharmony_ci 6313498266Sopenharmony_ci 6413498266Sopenharmony_cidnl XC_M4_TR_SH_EX (expression, [extra]) 6513498266Sopenharmony_cidnl ------------------------------------------------- 6613498266Sopenharmony_cidnl Like XC_M4_TR_SH but transliterating characters 6713498266Sopenharmony_cidnl given in 'extra' argument to lowercase 'p'. For 6813498266Sopenharmony_cidnl example [*+], [*], and [+] are valid 'extra' args. 6913498266Sopenharmony_ci 7013498266Sopenharmony_ciAC_DEFUN([XC_M4_TR_SH_EX], 7113498266Sopenharmony_ci[ifelse([$2], [], 7213498266Sopenharmony_ci [XC_M4_TR_SH([$1])], 7313498266Sopenharmony_ci [patsubst(XC_QPATSUBST(XC_QPATSUBST(XC_QUOTE($1), 7413498266Sopenharmony_ci [[$2]], 7513498266Sopenharmony_ci [p]), 7613498266Sopenharmony_ci [[^a-zA-Z0-9_]], [_]), 7713498266Sopenharmony_ci [\(_\(.*\)_\)], [\2])])]) 7813498266Sopenharmony_ci 7913498266Sopenharmony_ci 8013498266Sopenharmony_cidnl XC_SH_TR_CPP (expression) 8113498266Sopenharmony_cidnl ------------------------------------------------- 8213498266Sopenharmony_cidnl Shell execution time transliteration of 'expression' 8313498266Sopenharmony_cidnl argument, where all non-alfanumeric characters are 8413498266Sopenharmony_cidnl converted to the underscore '_' character and alnum 8513498266Sopenharmony_cidnl characters are converted to uppercase. 8613498266Sopenharmony_cidnl Normal shell expansion and substitution takes place 8713498266Sopenharmony_cidnl for given 'expression' at shell execution time before 8813498266Sopenharmony_cidnl transliteration is applied to it. 8913498266Sopenharmony_ci 9013498266Sopenharmony_ciAC_DEFUN([XC_SH_TR_CPP], 9113498266Sopenharmony_ci[`echo "$1" | dnl 9213498266Sopenharmony_cised 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl 9313498266Sopenharmony_cised 's/[[^A-Z0-9_]]/_/g'`]) 9413498266Sopenharmony_ci 9513498266Sopenharmony_ci 9613498266Sopenharmony_cidnl XC_SH_TR_CPP_EX (expression, [extra]) 9713498266Sopenharmony_cidnl ------------------------------------------------- 9813498266Sopenharmony_cidnl Like XC_SH_TR_CPP but transliterating characters 9913498266Sopenharmony_cidnl given in 'extra' argument to uppercase 'P'. For 10013498266Sopenharmony_cidnl example [*+], [*], and [+] are valid 'extra' args. 10113498266Sopenharmony_ci 10213498266Sopenharmony_ciAC_DEFUN([XC_SH_TR_CPP_EX], 10313498266Sopenharmony_ci[ifelse([$2], [], 10413498266Sopenharmony_ci [XC_SH_TR_CPP([$1])], 10513498266Sopenharmony_ci [`echo "$1" | dnl 10613498266Sopenharmony_cised 's/[[$2]]/P/g' | dnl 10713498266Sopenharmony_cised 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl 10813498266Sopenharmony_cised 's/[[^A-Z0-9_]]/_/g'`])]) 10913498266Sopenharmony_ci 11013498266Sopenharmony_ci 11113498266Sopenharmony_cidnl XC_M4_TR_CPP (expression) 11213498266Sopenharmony_cidnl ------------------------------------------------- 11313498266Sopenharmony_cidnl m4 execution time transliteration of 'expression' 11413498266Sopenharmony_cidnl argument, where all non-alfanumeric characters are 11513498266Sopenharmony_cidnl converted to the underscore '_' character and alnum 11613498266Sopenharmony_cidnl characters are converted to uppercase. 11713498266Sopenharmony_ci 11813498266Sopenharmony_ciAC_DEFUN([XC_M4_TR_CPP], 11913498266Sopenharmony_ci[patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QUOTE($1), 12013498266Sopenharmony_ci [abcdefghijklmnopqrstuvwxyz], 12113498266Sopenharmony_ci [ABCDEFGHIJKLMNOPQRSTUVWXYZ]), 12213498266Sopenharmony_ci [[^A-Z0-9_]], [_]), 12313498266Sopenharmony_ci [\(_\(.*\)_\)], [\2])]) 12413498266Sopenharmony_ci 12513498266Sopenharmony_ci 12613498266Sopenharmony_cidnl XC_M4_TR_CPP_EX (expression, [extra]) 12713498266Sopenharmony_cidnl ------------------------------------------------- 12813498266Sopenharmony_cidnl Like XC_M4_TR_CPP but transliterating characters 12913498266Sopenharmony_cidnl given in 'extra' argument to uppercase 'P'. For 13013498266Sopenharmony_cidnl example [*+], [*], and [+] are valid 'extra' args. 13113498266Sopenharmony_ci 13213498266Sopenharmony_ciAC_DEFUN([XC_M4_TR_CPP_EX], 13313498266Sopenharmony_ci[ifelse([$2], [], 13413498266Sopenharmony_ci [XC_M4_TR_CPP([$1])], 13513498266Sopenharmony_ci [patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QPATSUBST(XC_QUOTE($1), 13613498266Sopenharmony_ci [[$2]], 13713498266Sopenharmony_ci [P]), 13813498266Sopenharmony_ci [abcdefghijklmnopqrstuvwxyz], 13913498266Sopenharmony_ci [ABCDEFGHIJKLMNOPQRSTUVWXYZ]), 14013498266Sopenharmony_ci [[^A-Z0-9_]], [_]), 14113498266Sopenharmony_ci [\(_\(.*\)_\)], [\2])])]) 14213498266Sopenharmony_ci 14313498266Sopenharmony_ci 14413498266Sopenharmony_cidnl XC_QUOTE (expression) 14513498266Sopenharmony_cidnl ------------------------------------------------- 14613498266Sopenharmony_cidnl Expands to quoted result of 'expression' expansion. 14713498266Sopenharmony_ci 14813498266Sopenharmony_ciAC_DEFUN([XC_QUOTE], 14913498266Sopenharmony_ci[[$@]]) 15013498266Sopenharmony_ci 15113498266Sopenharmony_ci 15213498266Sopenharmony_cidnl XC_QPATSUBST (string, regexp[, repl]) 15313498266Sopenharmony_cidnl ------------------------------------------------- 15413498266Sopenharmony_cidnl Expands to quoted result of 'patsubst' expansion. 15513498266Sopenharmony_ci 15613498266Sopenharmony_ciAC_DEFUN([XC_QPATSUBST], 15713498266Sopenharmony_ci[XC_QUOTE(patsubst([$1], [$2], [$3]))]) 15813498266Sopenharmony_ci 15913498266Sopenharmony_ci 16013498266Sopenharmony_cidnl XC_QTRANSLIT (string, chars, repl) 16113498266Sopenharmony_cidnl ------------------------------------------------- 16213498266Sopenharmony_cidnl Expands to quoted result of 'translit' expansion. 16313498266Sopenharmony_ci 16413498266Sopenharmony_ciAC_DEFUN([XC_QTRANSLIT], 16513498266Sopenharmony_ci[XC_QUOTE(translit([$1], [$2], [$3]))]) 166