Annotation of embedaddon/curl/m4/xc-translit.m4, revision 1.1
1.1 ! misho 1: #---------------------------------------------------------------------------
! 2: #
! 3: # xc-translit.m4
! 4: #
! 5: # Copyright (c) 2011 - 2020, Daniel Stenberg <daniel@haxx.se>
! 6: #
! 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.
! 10: #
! 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.
! 18: #
! 19: #---------------------------------------------------------------------------
! 20:
! 21: # File version for 'aclocal' use. Keep it a single number.
! 22: # serial 2
! 23:
! 24:
! 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.
! 33:
! 34: AC_DEFUN([XC_SH_TR_SH],
! 35: [`echo "$1" | sed 's/[[^a-zA-Z0-9_]]/_/g'`])
! 36:
! 37:
! 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.
! 43:
! 44: AC_DEFUN([XC_SH_TR_SH_EX],
! 45: [ifelse([$2], [],
! 46: [XC_SH_TR_SH([$1])],
! 47: [`echo "$1" | sed 's/[[$2]]/p/g' | sed 's/[[^a-zA-Z0-9_]]/_/g'`])])
! 48:
! 49:
! 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.
! 55:
! 56: AC_DEFUN([XC_M4_TR_SH],
! 57: [patsubst(XC_QPATSUBST(XC_QUOTE($1),
! 58: [[^a-zA-Z0-9_]], [_]),
! 59: [\(_\(.*\)_\)], [\2])])
! 60:
! 61:
! 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.
! 67:
! 68: AC_DEFUN([XC_M4_TR_SH_EX],
! 69: [ifelse([$2], [],
! 70: [XC_M4_TR_SH([$1])],
! 71: [patsubst(XC_QPATSUBST(XC_QPATSUBST(XC_QUOTE($1),
! 72: [[$2]],
! 73: [p]),
! 74: [[^a-zA-Z0-9_]], [_]),
! 75: [\(_\(.*\)_\)], [\2])])])
! 76:
! 77:
! 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.
! 87:
! 88: AC_DEFUN([XC_SH_TR_CPP],
! 89: [`echo "$1" | dnl
! 90: sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl
! 91: sed 's/[[^A-Z0-9_]]/_/g'`])
! 92:
! 93:
! 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.
! 99:
! 100: AC_DEFUN([XC_SH_TR_CPP_EX],
! 101: [ifelse([$2], [],
! 102: [XC_SH_TR_CPP([$1])],
! 103: [`echo "$1" | dnl
! 104: sed 's/[[$2]]/P/g' | dnl
! 105: sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' | dnl
! 106: sed 's/[[^A-Z0-9_]]/_/g'`])])
! 107:
! 108:
! 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.
! 115:
! 116: AC_DEFUN([XC_M4_TR_CPP],
! 117: [patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QUOTE($1),
! 118: [abcdefghijklmnopqrstuvwxyz],
! 119: [ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
! 120: [[^A-Z0-9_]], [_]),
! 121: [\(_\(.*\)_\)], [\2])])
! 122:
! 123:
! 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.
! 129:
! 130: AC_DEFUN([XC_M4_TR_CPP_EX],
! 131: [ifelse([$2], [],
! 132: [XC_M4_TR_CPP([$1])],
! 133: [patsubst(XC_QPATSUBST(XC_QTRANSLIT(XC_QPATSUBST(XC_QUOTE($1),
! 134: [[$2]],
! 135: [P]),
! 136: [abcdefghijklmnopqrstuvwxyz],
! 137: [ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
! 138: [[^A-Z0-9_]], [_]),
! 139: [\(_\(.*\)_\)], [\2])])])
! 140:
! 141:
! 142: dnl XC_QUOTE (expression)
! 143: dnl -------------------------------------------------
! 144: dnl Expands to quoted result of 'expression' expansion.
! 145:
! 146: AC_DEFUN([XC_QUOTE],
! 147: [[$@]])
! 148:
! 149:
! 150: dnl XC_QPATSUBST (string, regexp[, repl])
! 151: dnl -------------------------------------------------
! 152: dnl Expands to quoted result of 'patsubst' expansion.
! 153:
! 154: AC_DEFUN([XC_QPATSUBST],
! 155: [XC_QUOTE(patsubst([$1], [$2], [$3]))])
! 156:
! 157:
! 158: dnl XC_QTRANSLIT (string, chars, repl)
! 159: dnl -------------------------------------------------
! 160: dnl Expands to quoted result of 'translit' expansion.
! 161:
! 162: AC_DEFUN([XC_QTRANSLIT],
! 163: [XC_QUOTE(translit([$1], [$2], [$3]))])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>