1
#---------------------------------------------------------------------------
5
# Copyright (c) 2011 Daniel Stenberg <daniel@haxx.se>
7
# Permission to use, copy, modify, and distribute this software for any
8
# purpose with or without fee is hereby granted, provided that the above
9
# copyright notice and this permission notice appear in all copies.
11
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
#---------------------------------------------------------------------------
21
# File version for 'aclocal' use. Keep it a single number.
25
dnl XC_SH_TR_SH (expression)
26
dnl -------------------------------------------------
27
dnl Shell execution time transliteration of 'expression'
28
dnl argument, where all non-alfanumeric characters are
29
dnl converted to the underscore '_' character.
30
dnl Normal shell expansion and substitution takes place
31
dnl for given 'expression' at shell execution time before
32
dnl transliteration is applied to it.
34
AC_DEFUN([XC_SH_TR_SH],
35
[`echo "$1" | sed 's/[[^a-zA-Z0-9_]]/_/g'`])
38
dnl XC_SH_TR_SH_EX (expression, [extra])
39
dnl -------------------------------------------------
40
dnl Like XC_SH_TR_SH but transliterating characters
41
dnl given in 'extra' argument to lowercase 'p'. For
42
dnl example [*+], [*], and [+] are valid 'extra' args.
44
AC_DEFUN([XC_SH_TR_SH_EX],
47
[`echo "$1" | sed 's/[[$2]]/p/g' | sed 's/[[^a-zA-Z0-9_]]/_/g'`])])
50
dnl XC_M4_TR_SH (expression)
51
dnl -------------------------------------------------
52
dnl m4 execution time transliteration of 'expression'
53
dnl argument, where all non-alfanumeric characters are
54
dnl converted to the underscore '_' character.
56
AC_DEFUN([XC_M4_TR_SH],
57
[patsubst(XC_QPATSUBST(XC_QUOTE($1),
58
[[^a-zA-Z0-9_]], [_]),
59
[\(_\(.*\)_\)], [\2])])
62
dnl XC_M4_TR_SH_EX (expression, [extra])
63
dnl -------------------------------------------------
64
dnl Like XC_M4_TR_SH but transliterating characters
65
dnl given in 'extra' argument to lowercase 'p'. For
66
dnl example [*+], [*], and [+] are valid 'extra' args.
68
AC_DEFUN([XC_M4_TR_SH_EX],
71
[patsubst(XC_QPATSUBST(XC_QPATSUBST(XC_QUOTE($1),
74
[[^a-zA-Z0-9_]], [_]),
75
[\(_\(.*\)_\)], [\2])])])
78
dnl XC_SH_TR_CPP (expression)
79
dnl -------------------------------------------------
80
dnl Shell execution time transliteration of 'expression'
81
dnl argument, where all non-alfanumeric characters are
82
dnl converted to the underscore '_' character and alnum
83
dnl characters are converted to uppercase.
84
dnl Normal shell expansion and substitution takes place
85
dnl for given 'expression' at shell execution time before
86
dnl transliteration is applied to it.
88
AC_DEFUN([XC_SH_TR_CPP],
90
sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl
91
sed 's/[[^A-Z0-9_]]/_/g'`])
94
dnl XC_SH_TR_CPP_EX (expression, [extra])
95
dnl -------------------------------------------------
96
dnl Like XC_SH_TR_CPP but transliterating characters
97
dnl given in 'extra' argument to uppercase 'P'. For
98
dnl example [*+], [*], and [+] are valid 'extra' args.
100
AC_DEFUN([XC_SH_TR_CPP_EX],
102
[XC_SH_TR_CPP([$1])],
104
sed 's/[[$2]]/P/g' | dnl
105
sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl
106
sed 's/[[^A-Z0-9_]]/_/g'`])])
109
dnl XC_M4_TR_CPP (expression)
110
dnl -------------------------------------------------
111
dnl m4 execution time transliteration of 'expression'
112
dnl argument, where all non-alfanumeric characters are
113
dnl converted to the underscore '_' character and alnum
114
dnl characters are converted to uppercase.
116
AC_DEFUN([XC_M4_TR_CPP],
117
[patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QUOTE($1),
118
[abcdefghijklmnopqrstuvwxyz],
119
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
121
[\(_\(.*\)_\)], [\2])])
124
dnl XC_M4_TR_CPP_EX (expression, [extra])
125
dnl -------------------------------------------------
126
dnl Like XC_M4_TR_CPP but transliterating characters
127
dnl given in 'extra' argument to uppercase 'P'. For
128
dnl example [*+], [*], and [+] are valid 'extra' args.
130
AC_DEFUN([XC_M4_TR_CPP_EX],
132
[XC_M4_TR_CPP([$1])],
133
[patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QPATSUBST(XC_QUOTE($1),
136
[abcdefghijklmnopqrstuvwxyz],
137
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
139
[\(_\(.*\)_\)], [\2])])])
142
dnl XC_QUOTE (expression)
143
dnl -------------------------------------------------
144
dnl Expands to quoted result of 'expression' expansion.
150
dnl XC_QPATSUBST (string, regexp[, repl])
151
dnl -------------------------------------------------
152
dnl Expands to quoted result of 'patsubst' expansion.
154
AC_DEFUN([XC_QPATSUBST],
155
[XC_QUOTE(patsubst([$1], [$2], [$3]))])
158
dnl XC_QTRANSLIT (string, chars, repl)
159
dnl -------------------------------------------------
160
dnl Expands to quoted result of 'translit' expansion.
162
AC_DEFUN([XC_QTRANSLIT],
163
[XC_QUOTE(translit([$1], [$2], [$3]))])