diff options
Diffstat (limited to 'checks')
241 files changed, 5383 insertions, 0 deletions
diff --git a/checks/001.preprocess b/checks/001.preprocess new file mode 100644 index 00000000..b41283c1 --- /dev/null +++ b/checks/001.preprocess @@ -0,0 +1,39 @@ +dnl @ ../doc/m4.texinfo:696: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -s +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`twoline', `1 +2') +dnl @result{}#line 2 "stdin" +dnl @result{} +changecom(`/*', `*/') +dnl @result{} +define(`comment', `/*1 +2*/') +dnl @result{}#line 5 +dnl @result{} +dnl no line +hello +dnl @result{}#line 7 +dnl @result{}hello +twoline +dnl @result{}1 +dnl @result{}#line 8 +dnl @result{}2 +comment +dnl @result{}/*1 +dnl @result{}2*/ +one comment `two +three' +dnl @result{}#line 10 +dnl @result{}one /*1 +dnl @result{}2*/ two +dnl @result{}three +goodbye +dnl @result{}#line 12 +dnl @result{}goodbye diff --git a/checks/002.debugging_ b/checks/002.debugging_ new file mode 100644 index 00000000..3bca0a06 --- /dev/null +++ b/checks/002.debugging_ @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:879: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dbar=hello -tbar --debugfile= foo --debugfile - +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @result{}hello +errprint(`hi +')dnl +dnl @error{}hi +bar +dnl @error{}m4trace: -1- bar -> `hello' +dnl @result{}hello diff --git a/checks/003.command_li b/checks/003.command_li new file mode 100644 index 00000000..3594b52d --- /dev/null +++ b/checks/003.command_li @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:938: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dbar=hello foo -Dbar=world foo +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @result{}hello +dnl @result{}world diff --git a/checks/004.command_li b/checks/004.command_li new file mode 100644 index 00000000..9f3a308b --- /dev/null +++ b/checks/004.command_li @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:961: Origin of test +dnl @ expected status: 1 +dnl @ extra options: Makefile/ +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +dnl @error{}m4: cannot open `Makefile/': Not a directory diff --git a/checks/005.command_li b/checks/005.command_li new file mode 100644 index 00000000..134aa3de --- /dev/null +++ b/checks/005.command_li @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:969: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([echo | ']__program__[' >&-])dnl +dnl @error{}m4: write error: Bad file descriptor +sysval +dnl @result{}1 diff --git a/checks/006.command_li b/checks/006.command_li new file mode 100644 index 00000000..84966c2c --- /dev/null +++ b/checks/006.command_li @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:980: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([echo 'esyscmd(echo hi >&2 && echo err"print(bye +)d"nl)dnl' > tmp.m4 \ + && ']__program__[' tmp.m4 <&- >&- \ + && rm tmp.m4])sysval +dnl @error{}hi +dnl @error{}bye +dnl @result{}0 diff --git a/checks/007.command_li b/checks/007.command_li new file mode 100644 index 00000000..d82a6d5c --- /dev/null +++ b/checks/007.command_li @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:998: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([POSIXLY_CORRECT=1 ']__program__[' -Dbar=hello foo -Dbar=world foo])dnl +dnl @result{}hello +dnl @result{}world +sysval +dnl @result{}0 diff --git a/checks/008.comments b/checks/008.comments new file mode 100644 index 00000000..7d731354 --- /dev/null +++ b/checks/008.comments @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1091: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +`quoted text' # `commented text' +dnl @result{}quoted text # `commented text' +`quoting inhibits' `#' `comments' +dnl @result{}quoting inhibits # comments diff --git a/checks/009.comments b/checks/009.comments new file mode 100644 index 00000000..f418de34 --- /dev/null +++ b/checks/009.comments @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:1106: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`e', `$@')define(`q', ``$@'')define(`foo', `bar') +dnl @result{} +q(e(`one +',#two ' foo +)) +dnl @result{}`one +dnl @result{}',`#two bar +dnl @result{}'' +changecom(`<', `>')define(`n', `$#') +dnl @result{} +n(e(<`>, <'>)) +dnl @result{}1 +len(e(<`>, ,<'>)) +dnl @result{}12 diff --git a/checks/010.input_proc b/checks/010.input_proc new file mode 100644 index 00000000..1a707d69 --- /dev/null +++ b/checks/010.input_proc @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:1198: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changequote([,])dnl +define([gl_STRING_MODULE_INDICATOR], + [ + dnl comment + GNULIB_]translit([$1],[a-z],[A-Z])[=1 + ])dnl + gl_STRING_MODULE_INDICATOR([strcase]) +dnl @result{} +dnl @result{} GNULIB_strcase=1 +dnl @result{} diff --git a/checks/011.input_proc b/checks/011.input_proc new file mode 100644 index 00000000..01166ca3 --- /dev/null +++ b/checks/011.input_proc @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:1276: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changequote([,])dnl +define([gl_STRING_MODULE_INDICATOR], + [dnl comment + GNULIB_[]translit([[$1]], [a-z], [A-Z])=1dnl +])dnl + gl_STRING_MODULE_INDICATOR([strcase]) +dnl @result{} GNULIB_STRCASE=1 diff --git a/checks/012.inhibiting b/checks/012.inhibiting new file mode 100644 index 00000000..e63d146d --- /dev/null +++ b/checks/012.inhibiting @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1402: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval +dnl @result{}eval +eval(`1') +dnl @result{}1 diff --git a/checks/013.inhibiting b/checks/013.inhibiting new file mode 100644 index 00000000..c62adb83 --- /dev/null +++ b/checks/013.inhibiting @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:1418: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -P +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval +dnl @result{}eval +eval(`1') +dnl @result{}eval(1) +m4_eval +dnl @result{}m4_eval +m4_eval(`1') +dnl @result{}1 diff --git a/checks/014.inhibiting b/checks/014.inhibiting new file mode 100644 index 00000000..09b0a915 --- /dev/null +++ b/checks/014.inhibiting @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:1449: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +`divert' +dnl @result{}divert +`d'ivert +dnl @result{}divert +di`ver't +dnl @result{}divert +div`'ert +dnl @result{}divert diff --git a/checks/015.inhibiting b/checks/015.inhibiting new file mode 100644 index 00000000..5e69df15 --- /dev/null +++ b/checks/015.inhibiting @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1463: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +`'divert +dnl @result{} +divert`' +dnl @result{} diff --git a/checks/016.inhibiting b/checks/016.inhibiting new file mode 100644 index 00000000..b7c8ce00 --- /dev/null +++ b/checks/016.inhibiting @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:1480: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`cde', `CDE') +dnl @result{} +define(`x', `substr(ab') +dnl @result{} +define(`y', `cde, `1', `3')') +dnl @result{} +x`'y +dnl @result{}bCD diff --git a/checks/017.inhibiting b/checks/017.inhibiting new file mode 100644 index 00000000..2eaa0e2b --- /dev/null +++ b/checks/017.inhibiting @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1494: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`x1', `len(`$1'') +dnl @result{} +define(`y1', ``$1')') +dnl @result{} +x1(`01234567890123456789')y1(`98765432109876543210') +dnl @result{}40 diff --git a/checks/018.inhibiting b/checks/018.inhibiting new file mode 100644 index 00000000..4ecd3d2c --- /dev/null +++ b/checks/018.inhibiting @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1508: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`macro', `m') +dnl @result{} +macro(`m')macro +dnl @result{}mmacro +macro(`m')`'macro +dnl @result{}mm diff --git a/checks/019.inhibiting b/checks/019.inhibiting new file mode 100644 index 00000000..ef06fd17 --- /dev/null +++ b/checks/019.inhibiting @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1520: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`macro', `di$1') +dnl @result{} +macro(`v')`ert' +dnl @result{}divert +macro(`v')ert +dnl @result{} diff --git a/checks/020.macro_argu b/checks/020.macro_argu new file mode 100644 index 00000000..65be9330 --- /dev/null +++ b/checks/020.macro_argu @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:1552: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`macro', `$1') +dnl @result{} +macro( unquoted leading space lost) +dnl @result{}unquoted leading space lost +macro(` quoted leading space kept') +dnl @result{} quoted leading space kept +macro( + divert `unquoted space kept after expansion') +dnl @result{} unquoted space kept after expansion +macro(macro(` +')`whitespace from expansion kept') +dnl @result{} +dnl @result{}whitespace from expansion kept +macro(`unquoted trailing whitespace kept' +) +dnl @result{}unquoted trailing whitespace kept +dnl @result{} diff --git a/checks/021.macro_argu b/checks/021.macro_argu new file mode 100644 index 00000000..cf321adf --- /dev/null +++ b/checks/021.macro_argu @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:1580: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `index' +dnl @result{}0 +index(`abc',) +dnl @result{}0 +index(`abc', `b', `ignored') +dnl @error{}m4:stdin:3: Warning: excess arguments to builtin `index' ignored +dnl @result{}1 diff --git a/checks/022.macro_argu b/checks/022.macro_argu new file mode 100644 index 00000000..98ffe2dd --- /dev/null +++ b/checks/022.macro_argu @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1593: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Q +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`abc') +dnl @result{}0 +index(`abc',) +dnl @result{}0 +index(`abc', `b', `ignored') +dnl @result{}1 diff --git a/checks/023.macro_argu b/checks/023.macro_argu new file mode 100644 index 00000000..2c00ba67 --- /dev/null +++ b/checks/023.macro_argu @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1623: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`f', `1') +dnl @result{} +f(define(`f', `2')) +dnl @result{}1 +f +dnl @result{}2 diff --git a/checks/024.macro_argu b/checks/024.macro_argu new file mode 100644 index 00000000..c5c5f4ec --- /dev/null +++ b/checks/024.macro_argu @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1635: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +hello world +dnl @result{}hello world +define( +dnl @error{}m4:stdin:2: ERROR: end of file in argument list diff --git a/checks/025.quoting_ar b/checks/025.quoting_ar new file mode 100644 index 00000000..54ebfbdf --- /dev/null +++ b/checks/025.quoting_ar @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:1694: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`active', `ACT, IVE') +dnl @result{} +define(`show', `$1 $1') +dnl @result{} +show(active) +dnl @result{}ACT ACT +show(`active') +dnl @result{}ACT, IVE ACT, IVE +show(``active'') +dnl @result{}active active diff --git a/checks/026.macro_expa b/checks/026.macro_expa new file mode 100644 index 00000000..363c5784 --- /dev/null +++ b/checks/026.macro_expa @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:1722: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dbar=Hello -Dfoo=bar +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +foo +dnl @result{}Hello diff --git a/checks/027.macro_expa b/checks/027.macro_expa new file mode 100644 index 00000000..2b4a919a --- /dev/null +++ b/checks/027.macro_expa @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1737: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dfoo -Decho=$@ +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +foo +dnl @result{} +foo(`silently ignored') +dnl @result{} +echo(`1', `2') +dnl @result{}1,2 diff --git a/checks/028.define b/checks/028.define new file mode 100644 index 00000000..90de3695 --- /dev/null +++ b/checks/028.define @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1786: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Hello world.') +dnl @result{} +foo +dnl @result{}Hello world. diff --git a/checks/029.define b/checks/029.define new file mode 100644 index 00000000..654b6e1b --- /dev/null +++ b/checks/029.define @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1803: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(foo, one) +dnl @result{} +define(foo, two) +dnl @result{} +one +dnl @result{}two diff --git a/checks/030.define b/checks/030.define new file mode 100644 index 00000000..18d39c28 --- /dev/null +++ b/checks/030.define @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:1837: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`array', `defn(format(``array[%d]'', `$1'))') +dnl @result{} +define(`array_set', `define(format(``array[%d]'', `$1'), `$2')') +dnl @result{} +array_set(`4', `array element no. 4') +dnl @result{} +array_set(`17', `array element no. 17') +dnl @result{} +array(`4') +dnl @result{}array element no. 4 +array(eval(`10 + 7')) +dnl @result{}array element no. 17 diff --git a/checks/031.arguments b/checks/031.arguments new file mode 100644 index 00000000..1b5b3f4b --- /dev/null +++ b/checks/031.arguments @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1871: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`exch', `$2, $1') +dnl @result{} +exch(`arg1', `arg2') +dnl @result{}arg2, arg1 diff --git a/checks/032.arguments b/checks/032.arguments new file mode 100644 index 00000000..1db2f74d --- /dev/null +++ b/checks/032.arguments @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1881: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`exch', `$2, $1') +dnl @result{} +define(exch(``expansion text'', ``macro'')) +dnl @result{} +macro +dnl @result{}expansion text diff --git a/checks/033.arguments b/checks/033.arguments new file mode 100644 index 00000000..787f132f --- /dev/null +++ b/checks/033.arguments @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1897: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`test', ``Macro name: $0'') +dnl @result{} +test +dnl @result{}Macro name: test diff --git a/checks/034.arguments b/checks/034.arguments new file mode 100644 index 00000000..9aa83e96 --- /dev/null +++ b/checks/034.arguments @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:1907: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `This is macro `foo'.') +dnl @result{} +foo +dnl @result{}This is macro foo. diff --git a/checks/035.arguments b/checks/035.arguments new file mode 100644 index 00000000..f2d65efc --- /dev/null +++ b/checks/035.arguments @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:1942: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `single quoted $`'{1} output') +dnl @result{} +define(`bar', ``double quoted $'`{2} output'') +dnl @result{} +foo(`a', `b') +dnl @result{}single quoted ${1} output +bar(`a', `b') +dnl @result{}double quoted ${2} output diff --git a/checks/036.arguments b/checks/036.arguments new file mode 100644 index 00000000..cb0b6247 --- /dev/null +++ b/checks/036.arguments @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:1964: Origin of test +dnl @ expected status: 0 +dnl @ extra options: --warn-macro-sequence +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `$001 ${1} $1') +dnl @error{}m4:stdin:1: Warning: definition of `foo' contains sequence `$001' +dnl @error{}m4:stdin:1: Warning: definition of `foo' contains sequence `${1}' +dnl @result{} +foo(`bar') +dnl @result{}bar ${1} bar diff --git a/checks/037.pseudo_arg b/checks/037.pseudo_arg new file mode 100644 index 00000000..c594d013 --- /dev/null +++ b/checks/037.pseudo_arg @@ -0,0 +1,24 @@ +dnl @ ../doc/m4.texinfo:1990: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`nargs', `$#') +dnl @result{} +nargs +dnl @result{}0 +nargs() +dnl @result{}1 +nargs(`arg1', `arg2', `arg3') +dnl @result{}3 +nargs(`commas can be quoted, like this') +dnl @result{}1 +nargs(arg1#inside comments, commas do not separate arguments +still arg1) +dnl @result{}1 +nargs((unquoted parentheses, like this, group arguments)) +dnl @result{}1 diff --git a/checks/038.pseudo_arg b/checks/038.pseudo_arg new file mode 100644 index 00000000..04f355d8 --- /dev/null +++ b/checks/038.pseudo_arg @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:2012: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl Attempt to define a macro to just `$#' +define(underquoted, $#) +oops) +dnl @result{} +underquoted +dnl @result{}0) +dnl @result{}oops diff --git a/checks/039.pseudo_arg b/checks/039.pseudo_arg new file mode 100644 index 00000000..375006f1 --- /dev/null +++ b/checks/039.pseudo_arg @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:2025: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$*') +dnl @result{} +echo(arg1, arg2, arg3 , arg4) +dnl @result{}arg1,arg2,arg3 ,arg4 diff --git a/checks/040.pseudo_arg b/checks/040.pseudo_arg new file mode 100644 index 00000000..dd5c6577 --- /dev/null +++ b/checks/040.pseudo_arg @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:2036: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$@') +dnl @result{} +echo(arg1, arg2, arg3 , arg4) +dnl @result{}arg1,arg2,arg3 ,arg4 diff --git a/checks/041.pseudo_arg b/checks/041.pseudo_arg new file mode 100644 index 00000000..0b566da3 --- /dev/null +++ b/checks/041.pseudo_arg @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:2046: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo1', `$*') +dnl @result{} +define(`echo2', `$@') +dnl @result{} +define(`foo', `This is macro `foo'.') +dnl @result{} +echo1(foo) +dnl @result{}This is macro This is macro foo.. +echo1(`foo') +dnl @result{}This is macro foo. +echo2(foo) +dnl @result{}This is macro foo. +echo2(`foo') +dnl @result{}foo diff --git a/checks/042.pseudo_arg b/checks/042.pseudo_arg new file mode 100644 index 00000000..6bf36adc --- /dev/null +++ b/checks/042.pseudo_arg @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:2068: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo1', `$*') +dnl @result{} +define(`echo2', `$@') +dnl @result{} +define(`foo', `bar') +dnl @result{} +echo1(#foo'foo +foo) +dnl @result{}#foo'foo +dnl @result{}bar +echo2(#foo'foo +foo) +dnl @result{}#foobar +dnl @result{}bar' diff --git a/checks/043.pseudo_arg b/checks/043.pseudo_arg new file mode 100644 index 00000000..fbeb31ba --- /dev/null +++ b/checks/043.pseudo_arg @@ -0,0 +1,29 @@ +dnl @ ../doc/m4.texinfo:2090: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$@')dnl +echo(echo(`01234567890123456789', `01234567890123456789') +echo(`98765432109876543210', `98765432109876543210')) +dnl @result{}01234567890123456789,01234567890123456789 +dnl @result{}98765432109876543210,98765432109876543210 +len((echo(`01234567890123456789', + `01234567890123456789')echo(`98765432109876543210', + `98765432109876543210'))) +dnl @result{}84 +indir(`echo', indir(`echo', `01234567890123456789', + `01234567890123456789') +indir(`echo', `98765432109876543210', `98765432109876543210')) +dnl @result{}01234567890123456789,01234567890123456789 +dnl @result{}98765432109876543210,98765432109876543210 +define(`argn', `$#')dnl +define(`echo1', `-$@-')define(`echo2', `,$@,')dnl +echo1(`1', `2', `3') argn(echo1(`1', `2', `3')) +dnl @result{}-1,2,3- 3 +echo2(`1', `2', `3') argn(echo2(`1', `2', `3')) +dnl @result{},1,2,3, 5 diff --git a/checks/044.pseudo_arg b/checks/044.pseudo_arg new file mode 100644 index 00000000..91664ee2 --- /dev/null +++ b/checks/044.pseudo_arg @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:2118: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `$$$ hello $$$') +dnl @result{} +foo +dnl @result{}$$$ hello $$$ diff --git a/checks/045.pseudo_arg b/checks/045.pseudo_arg new file mode 100644 index 00000000..6fa1a7a0 --- /dev/null +++ b/checks/045.pseudo_arg @@ -0,0 +1,29 @@ +dnl @ ../doc/m4.texinfo:2134: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `no nested quote: $1') +dnl @result{} +foo(`arg') +dnl @result{}no nested quote: arg +define(`foo', `nested quote around $: `$'1') +dnl @result{} +foo(`arg') +dnl @result{}nested quote around $: $1 +define(`foo', `nested empty quote after $: $`'1') +dnl @result{} +foo(`arg') +dnl @result{}nested empty quote after $: $1 +define(`foo', `nested quote around next character: $`1'') +dnl @result{} +foo(`arg') +dnl @result{}nested quote around next character: $1 +define(`foo', `nested quote around both: `$1'') +dnl @result{} +foo(`arg') +dnl @result{}nested quote around both: arg diff --git a/checks/046.undefine b/checks/046.undefine new file mode 100644 index 00000000..37485ec2 --- /dev/null +++ b/checks/046.undefine @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:2173: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +foo bar blah +dnl @result{}foo bar blah +define(`foo', `some')define(`bar', `other')define(`blah', `text') +dnl @result{} +foo bar blah +dnl @result{}some other text +undefine(`foo') +dnl @result{} +foo bar blah +dnl @result{}foo other text +undefine(`bar', `blah') +dnl @result{} +foo bar blah +dnl @result{}foo bar blah diff --git a/checks/047.undefine b/checks/047.undefine new file mode 100644 index 00000000..87410a7c --- /dev/null +++ b/checks/047.undefine @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:2193: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`f', ``$0':$1') +dnl @result{} +f(f(f(undefine(`f')`hello world'))) +dnl @result{}f:f:f:hello world +f(`bye') +dnl @result{}f(bye) diff --git a/checks/048.defn b/checks/048.defn new file mode 100644 index 00000000..fc763898 --- /dev/null +++ b/checks/048.defn @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:2236: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`zap', defn(`undefine')) +dnl @result{} +zap(`undefine') +dnl @result{} +undefine(`zap') +dnl @result{}undefine(zap) diff --git a/checks/049.defn b/checks/049.defn new file mode 100644 index 00000000..b55b22bb --- /dev/null +++ b/checks/049.defn @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:2253: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `This is `$0'') +dnl @result{} +define(`bar', defn(`foo')) +dnl @result{} +bar +dnl @result{}This is bar diff --git a/checks/050.defn b/checks/050.defn new file mode 100644 index 00000000..726d375f --- /dev/null +++ b/checks/050.defn @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:2265: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`string', `The macro dnl is very useful +') +dnl @result{} +string +dnl @result{}The macro +defn(`string') +dnl @result{}The macro dnl is very useful +dnl @result{} diff --git a/checks/051.defn b/checks/051.defn new file mode 100644 index 00000000..f10f6b25 --- /dev/null +++ b/checks/051.defn @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:2284: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', a'a) +dnl @result{} +define(`a', `A') +dnl @result{} +define(`echo', `$@') +dnl @result{} +foo +dnl @result{}A'A +defn(`foo') +dnl @result{}aA' +echo(foo) +dnl @result{}AA' diff --git a/checks/052.defn b/checks/052.defn new file mode 100644 index 00000000..f49a2154 --- /dev/null +++ b/checks/052.defn @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:2308: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`l', `<[>')define(`r', `<]>') +dnl @result{} +changequote(`[', `]') +dnl @result{} +defn([l])defn([r]) +]) +dnl @result{}<[>]defn([r]) +dnl @result{}) +defn([l], [r]) +dnl @result{}<[>][<]> diff --git a/checks/053.defn b/checks/053.defn new file mode 100644 index 00000000..08e8b74c --- /dev/null +++ b/checks/053.defn @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:2327: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +defn(`defn') +dnl @result{} +define(defn(`divnum'), `cannot redefine a builtin token') +dnl @error{}m4:stdin:2: Warning: define: invalid macro name ignored +dnl @result{} +divnum +dnl @result{}0 +len(defn(`divnum')) +dnl @result{}0 diff --git a/checks/054.defn b/checks/054.defn new file mode 100644 index 00000000..854824f0 --- /dev/null +++ b/checks/054.defn @@ -0,0 +1,25 @@ +dnl @ ../doc/m4.texinfo:2344: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`a', `A')define(`AA', `b') +dnl @result{} +traceon(`defn', `define') +dnl @result{} +defn(`a', `divnum', `a') +dnl @error{}m4:stdin:3: Warning: cannot concatenate builtin `divnum' +dnl @error{}m4trace: -1- defn(`a', `divnum', `a') -> ``A'`A'' +dnl @result{}AA +define(`mydivnum', defn(`divnum', `divnum'))mydivnum +dnl @error{}m4:stdin:4: Warning: cannot concatenate builtin `divnum' +dnl @error{}m4:stdin:4: Warning: cannot concatenate builtin `divnum' +dnl @error{}m4trace: -2- defn(`divnum', `divnum') +dnl @error{}m4trace: -1- define(`mydivnum', `') +dnl @result{} +traceoff(`defn', `define') +dnl @result{} diff --git a/checks/055.pushdef b/checks/055.pushdef new file mode 100644 index 00000000..8b26fd84 --- /dev/null +++ b/checks/055.pushdef @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:2396: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Expansion one.') +dnl @result{} +foo +dnl @result{}Expansion one. +pushdef(`foo', `Expansion two.') +dnl @result{} +foo +dnl @result{}Expansion two. +pushdef(`foo', `Expansion three.') +dnl @result{} +pushdef(`foo', `Expansion four.') +dnl @result{} +popdef(`foo') +dnl @result{} +foo +dnl @result{}Expansion three. +popdef(`foo', `foo') +dnl @result{} +foo +dnl @result{}Expansion one. +popdef(`foo') +dnl @result{} +foo +dnl @result{}foo diff --git a/checks/056.pushdef b/checks/056.pushdef new file mode 100644 index 00000000..b41ff025 --- /dev/null +++ b/checks/056.pushdef @@ -0,0 +1,25 @@ +dnl @ ../doc/m4.texinfo:2433: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Expansion one.') +dnl @result{} +foo +dnl @result{}Expansion one. +pushdef(`foo', `Expansion two.') +dnl @result{} +foo +dnl @result{}Expansion two. +define(`foo', `Second expansion two.') +dnl @result{} +foo +dnl @result{}Second expansion two. +undefine(`foo') +dnl @result{} +foo +dnl @result{}foo diff --git a/checks/057.indir b/checks/057.indir new file mode 100644 index 00000000..80f9ecb1 --- /dev/null +++ b/checks/057.indir @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:2482: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`$$internal$macro', `Internal macro (name `$0')') +dnl @result{} +$$internal$macro +dnl @result{}$$internal$macro +indir(`$$internal$macro') +dnl @result{}Internal macro (name $$internal$macro) diff --git a/checks/058.indir b/checks/058.indir new file mode 100644 index 00000000..80045448 --- /dev/null +++ b/checks/058.indir @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:2502: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`f', `1') +dnl @result{} +f(define(`f', `2')) +dnl @result{}1 +indir(`f', define(`f', `3')) +dnl @result{}3 +indir(`f', undefine(`f')) +dnl @error{}m4:stdin:4: undefined macro `f' +dnl @result{} diff --git a/checks/059.indir b/checks/059.indir new file mode 100644 index 00000000..4be21e58 --- /dev/null +++ b/checks/059.indir @@ -0,0 +1,22 @@ +dnl @ ../doc/m4.texinfo:2520: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +indir(defn(`defn'), `divnum') +dnl @error{}m4:stdin:1: Warning: indir: invalid macro name ignored +dnl @result{} +indir(`define', defn(`defn'), `divnum') +dnl @error{}m4:stdin:2: Warning: define: invalid macro name ignored +dnl @result{} +indir(`define', `foo', defn(`divnum')) +dnl @result{} +foo +dnl @result{}0 +indir(`divert', defn(`foo')) +dnl @error{}m4:stdin:5: empty string treated as 0 in builtin `divert' +dnl @result{} diff --git a/checks/060.builtin b/checks/060.builtin new file mode 100644 index 00000000..cc90a983 --- /dev/null +++ b/checks/060.builtin @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:2558: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +pushdef(`define', `hidden') +dnl @result{} +undefine(`undefine') +dnl @result{} +define(`foo', `bar') +dnl @result{}hidden +foo +dnl @result{}foo +builtin(`define', `foo', defn(`divnum')) +dnl @result{} +foo +dnl @result{}0 +builtin(`define', `foo', `BAR') +dnl @result{} +foo +dnl @result{}BAR +undefine(`foo') +dnl @result{}undefine(foo) +foo +dnl @result{}BAR +builtin(`undefine', `foo') +dnl @result{} +foo +dnl @result{}foo diff --git a/checks/061.builtin b/checks/061.builtin new file mode 100644 index 00000000..079a4306 --- /dev/null +++ b/checks/061.builtin @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:2591: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -P +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +m4_builtin(`divnum') +dnl @result{}0 +m4_builtin(`m4_divnum') +dnl @error{}m4:stdin:2: undefined builtin `m4_divnum' +dnl @result{} +m4_indir(`divnum') +dnl @error{}m4:stdin:3: undefined macro `divnum' +dnl @result{} +m4_indir(`m4_divnum') +dnl @result{}0 diff --git a/checks/062.builtin b/checks/062.builtin new file mode 100644 index 00000000..78161893 --- /dev/null +++ b/checks/062.builtin @@ -0,0 +1,28 @@ +dnl @ ../doc/m4.texinfo:2609: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +builtin +dnl @result{}builtin +builtin() +dnl @error{}m4:stdin:2: undefined builtin `' +dnl @result{} +builtin(`builtin') +dnl @error{}m4:stdin:3: Warning: too few arguments to builtin `builtin' +dnl @result{} +builtin(`builtin',) +dnl @error{}m4:stdin:4: undefined builtin `' +dnl @result{} +builtin(`builtin', ``' +') +dnl @error{}m4:stdin:5: undefined builtin ``' +dnl @error{}' +dnl @result{} +indir(`index') +dnl @error{}m4:stdin:7: Warning: too few arguments to builtin `index' +dnl @result{} diff --git a/checks/063.builtin b/checks/063.builtin new file mode 100644 index 00000000..77c462e2 --- /dev/null +++ b/checks/063.builtin @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:2636: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +builtin(`include', `foo')dnl +dnl @result{}bar diff --git a/checks/064.builtin b/checks/064.builtin new file mode 100644 index 00000000..839bd2c7 --- /dev/null +++ b/checks/064.builtin @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:2643: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`s', `builtin(`shift', $@)')dnl +define(`loop', `ifelse(`$2', `', `-', `$1$2: $0(`$1', s(s($@)))')')dnl +loop(`1') +dnl @result{}- +loop(`1', `2') +dnl @result{}12: - +loop(`1', `2', `3') +dnl @result{}12: 13: - +loop(`1', `2', `3', `4') +dnl @result{}12: 13: 14: - +loop(`1', `2', `3', `4', `5') +dnl @result{}12: 13: 14: 15: - diff --git a/checks/065.ifdef b/checks/065.ifdef new file mode 100644 index 00000000..2fe71118 --- /dev/null +++ b/checks/065.ifdef @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:2694: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`foo', ``foo' is defined', ``foo' is not defined') +dnl @result{}foo is not defined +define(`foo', `') +dnl @result{} +ifdef(`foo', ``foo' is defined', ``foo' is not defined') +dnl @result{}foo is defined +ifdef(`no_such_macro', `yes', `no', `extra argument') +dnl @error{}m4:stdin:4: Warning: excess arguments to builtin `ifdef' ignored +dnl @result{}no diff --git a/checks/066.ifelse b/checks/066.ifelse new file mode 100644 index 00000000..55836dc1 --- /dev/null +++ b/checks/066.ifelse @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:2742: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifelse(`some comments') +dnl @result{} +ifelse(`foo', `bar') +dnl @error{}m4:stdin:2: Warning: too few arguments to builtin `ifelse' +dnl @result{} diff --git a/checks/067.ifelse b/checks/067.ifelse new file mode 100644 index 00000000..aa342b56 --- /dev/null +++ b/checks/067.ifelse @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:2752: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifelse(`foo', `bar', `true') +dnl @result{} +ifelse(`foo', `foo', `true') +dnl @result{}true +define(`foo', `bar') +dnl @result{} +ifelse(foo, `bar', `true', `false') +dnl @result{}true +ifelse(foo, `foo', `true', `false') +dnl @result{}false diff --git a/checks/068.ifelse b/checks/068.ifelse new file mode 100644 index 00000000..5d52d62e --- /dev/null +++ b/checks/068.ifelse @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:2772: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `ifelse(`$#', `0', ``$0'', `arguments:$#')') +dnl @result{} +foo +dnl @result{}foo +foo() +dnl @result{}arguments:1 +foo(`a', `b', `c') +dnl @result{}arguments:3 diff --git a/checks/069.ifelse b/checks/069.ifelse new file mode 100644 index 00000000..dc074ebb --- /dev/null +++ b/checks/069.ifelse @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:2796: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifelse(`foo', `bar', `third', `gnu', `gnats') +dnl @error{}m4:stdin:1: Warning: excess arguments to builtin `ifelse' ignored +dnl @result{}gnu +ifelse(`foo', `bar', `third', `gnu', `gnats', `sixth') +dnl @result{} +ifelse(`foo', `bar', `third', `gnu', `gnats', `sixth', `seventh') +dnl @result{}seventh +ifelse(`foo', `bar', `3', `gnu', `gnats', `6', `7', `8') +dnl @error{}m4:stdin:4: Warning: excess arguments to builtin `ifelse' ignored +dnl @result{}7 diff --git a/checks/070.ifelse b/checks/070.ifelse new file mode 100644 index 00000000..2a7bdd00 --- /dev/null +++ b/checks/070.ifelse @@ -0,0 +1,59 @@ +dnl @ ../doc/m4.texinfo:2814: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`e', `$@')define(`long', `01234567890123456789') +dnl @result{} +ifelse(long, `01234567890123456789', `yes', `no') +dnl @result{}yes +ifelse(`01234567890123456789', long, `yes', `no') +dnl @result{}yes +ifelse(long, `01234567890123456789-', `yes', `no') +dnl @result{}no +ifelse(`01234567890123456789-', long, `yes', `no') +dnl @result{}no +ifelse(e(long), `01234567890123456789', `yes', `no') +dnl @result{}yes +ifelse(`01234567890123456789', e(long), `yes', `no') +dnl @result{}yes +ifelse(e(long), `01234567890123456789-', `yes', `no') +dnl @result{}no +ifelse(`01234567890123456789-', e(long), `yes', `no') +dnl @result{}no +ifelse(-e(long), `-01234567890123456789', `yes', `no') +dnl @result{}yes +ifelse(-`01234567890123456789', -e(long), `yes', `no') +dnl @result{}yes +ifelse(-e(long), `-01234567890123456789-', `yes', `no') +dnl @result{}no +ifelse(`-01234567890123456789-', -e(long), `yes', `no') +dnl @result{}no +ifelse(-e(long)-, `-01234567890123456789-', `yes', `no') +dnl @result{}yes +ifelse(-`01234567890123456789-', -e(long)-, `yes', `no') +dnl @result{}yes +ifelse(-e(long)-, `-01234567890123456789', `yes', `no') +dnl @result{}no +ifelse(`-01234567890123456789', -e(long)-, `yes', `no') +dnl @result{}no +ifelse(`-'e(long), `-01234567890123456789', `yes', `no') +dnl @result{}yes +ifelse(-`01234567890123456789', `-'e(long), `yes', `no') +dnl @result{}yes +ifelse(`-'e(long), `-01234567890123456789-', `yes', `no') +dnl @result{}no +ifelse(`-01234567890123456789-', `-'e(long), `yes', `no') +dnl @result{}no +ifelse(`-'e(long)`-', `-01234567890123456789-', `yes', `no') +dnl @result{}yes +ifelse(-`01234567890123456789-', `-'e(long)`-', `yes', `no') +dnl @result{}yes +ifelse(`-'e(long)`-', `-01234567890123456789', `yes', `no') +dnl @result{}no +ifelse(`-01234567890123456789', `-'e(long)`-', `yes', `no') +dnl @result{}no diff --git a/checks/071.shift b/checks/071.shift new file mode 100644 index 00000000..b707b6b8 --- /dev/null +++ b/checks/071.shift @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:2895: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +shift +dnl @result{}shift +shift(`bar') +dnl @result{} +shift(`foo', `bar', `baz') +dnl @result{}bar,baz diff --git a/checks/072.shift b/checks/072.shift new file mode 100644 index 00000000..015c294b --- /dev/null +++ b/checks/072.shift @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:2914: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`reverse', `ifelse(`$#', `0', , `$#', `1', ``$1'', + `reverse(shift($@)), `$1'')') +dnl @result{} +reverse +dnl @result{} +reverse(`foo') +dnl @result{}foo +reverse(`foo', `bar', `gnats', `and gnus') +dnl @result{}and gnus, gnats, bar, foo diff --git a/checks/073.shift b/checks/073.shift new file mode 100644 index 00000000..365ab2f7 --- /dev/null +++ b/checks/073.shift @@ -0,0 +1,42 @@ +dnl @ ../doc/m4.texinfo:2949: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`cond', +`ifelse(`$#', `1', `$1', + `ifelse($1, `$2', `$3', + `$0(shift(shift(shift($@))))')')')dnl +define(`side', `define(`counter', incr(counter))$1')dnl +define(`example1', +`define(`counter', `0')dnl +ifelse(side(`$1'), `yes', `one comparison: ', + side(`$1'), `no', `two comparisons: ', + side(`$1'), `maybe', `three comparisons: ', + `side(`default answer: ')')counter')dnl +define(`example2', +`define(`counter', `0')dnl +cond(`side(`$1')', `yes', `one comparison: ', + `side(`$1')', `no', `two comparisons: ', + `side(`$1')', `maybe', `three comparisons: ', + `side(`default answer: ')')counter')dnl +example1(`yes') +dnl @result{}one comparison: 3 +example1(`no') +dnl @result{}two comparisons: 3 +example1(`maybe') +dnl @result{}three comparisons: 3 +example1(`feeling rather indecisive today') +dnl @result{}default answer: 4 +example2(`yes') +dnl @result{}one comparison: 1 +example2(`no') +dnl @result{}two comparisons: 2 +example2(`maybe') +dnl @result{}three comparisons: 3 +example2(`feeling rather indecisive today') +dnl @result{}default answer: 4 diff --git a/checks/074.shift b/checks/074.shift new file mode 100644 index 00000000..989a4241 --- /dev/null +++ b/checks/074.shift @@ -0,0 +1,30 @@ +dnl @ ../doc/m4.texinfo:3004: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`join.m4') +dnl @result{} +join,join(`-'),join(`-', `'),join(`-', `', `') +dnl @result{},,, +joinall,joinall(`-'),joinall(`-', `'),joinall(`-', `', `') +dnl @result{},,,- +join(`-', `1') +dnl @result{}1 +join(`-', `1', `2', `3') +dnl @result{}1-2-3 +join(`', `1', `2', `3') +dnl @result{}123 +join(`-', `', `1', `', `', `2', `') +dnl @result{}1-2 +joinall(`-', `', `1', `', `', `2', `') +dnl @result{}-1---2- +join(`,', `1', `2', `3') +dnl @result{}1,2,3 +define(`nargs', `$#')dnl +nargs(join(`,', `1', `2', `3')) +dnl @result{}1 diff --git a/checks/075.shift b/checks/075.shift new file mode 100644 index 00000000..1564138b --- /dev/null +++ b/checks/075.shift @@ -0,0 +1,25 @@ +dnl @ ../doc/m4.texinfo:3033: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`join.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# join(sep, args) - join each non-empty ARG into a single +dnl @result{}# string, with each element separated by SEP +dnl @result{}define(`join', +dnl @result{}`ifelse(`$#', `2', ``$2'', +dnl @result{} `ifelse(`$2', `', `', ``$2'_')$0(`$1', shift(shift($@)))')') +dnl @result{}define(`_join', +dnl @result{}`ifelse(`$#$2', `2', `', +dnl @result{} `ifelse(`$2', `', `', ``$1$2'')$0(`$1', shift(shift($@)))')') +dnl @result{}# joinall(sep, args) - join each ARG, including empty ones, +dnl @result{}# into a single string, with each element separated by SEP +dnl @result{}define(`joinall', ``$2'_$0(`$1', shift($@))') +dnl @result{}define(`_joinall', +dnl @result{}`ifelse(`$#', `2', `', ``$1$3'$0(`$1', shift(shift($@)))')') +dnl @result{}divert`'dnl diff --git a/checks/076.shift b/checks/076.shift new file mode 100644 index 00000000..2f8be4e0 --- /dev/null +++ b/checks/076.shift @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:3111: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`quote.m4') +dnl @result{} +-quote-dquote-dquote_elt- +dnl @result{}---- +-quote()-dquote()-dquote_elt()- +dnl @result{}--`'-`'- +-quote(`1')-dquote(`1')-dquote_elt(`1')- +dnl @result{}-1-`1'-`1'- +-quote(`1', `2')-dquote(`1', `2')-dquote_elt(`1', `2')- +dnl @result{}-1,2-`1',`2'-`1',`2'- +define(`n', `$#')dnl +-n(quote(`1', `2'))-n(dquote(`1', `2'))-n(dquote_elt(`1', `2'))- +dnl @result{}-1-1-2- +dquote(dquote_elt(`1', `2')) +dnl @result{}``1'',``2'' +dquote_elt(dquote(`1', `2')) +dnl @result{}``1',`2'' diff --git a/checks/077.shift b/checks/077.shift new file mode 100644 index 00000000..1a835469 --- /dev/null +++ b/checks/077.shift @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:3144: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`quote.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# quote(args) - convert args to single-quoted string +dnl @result{}define(`quote', `ifelse(`$#', `0', `', ``$*'')') +dnl @result{}# dquote(args) - convert args to quoted list of quoted strings +dnl @result{}define(`dquote', ``$@'') +dnl @result{}# dquote_elt(args) - convert args to list of double-quoted strings +dnl @result{}define(`dquote_elt', `ifelse(`$#', `0', `', `$#', `1', ```$1''', +dnl @result{} ```$1'',$0(shift($@))')') +dnl @result{}divert`'dnl diff --git a/checks/078.shift b/checks/078.shift new file mode 100644 index 00000000..e9dfa903 --- /dev/null +++ b/checks/078.shift @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:3177: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`argn', `ifelse(`$1', 1, ``$2'', + `argn(decr(`$1'), shift(shift($@)))')') +dnl @result{} +argn(`1', `a') +dnl @result{}a +define(`foo', `argn(`11', $@)') +dnl @result{} +foo(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k', `l') +dnl @result{}k diff --git a/checks/079.forloop b/checks/079.forloop new file mode 100644 index 00000000..94f60b24 --- /dev/null +++ b/checks/079.forloop @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:3209: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop.m4') +dnl @result{} +forloop(`i', `1', `8', `i ') +dnl @result{}1 2 3 4 5 6 7 8 diff --git a/checks/080.forloop b/checks/080.forloop new file mode 100644 index 00000000..b406fe40 --- /dev/null +++ b/checks/080.forloop @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:3220: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop.m4') +dnl @result{} +forloop(`i', `1', `4', `forloop(`j', `1', `8', ` (i, j)') +') +dnl @result{} (1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6) (1, 7) (1, 8) +dnl @result{} (2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (2, 6) (2, 7) (2, 8) +dnl @result{} (3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (3, 6) (3, 7) (3, 8) +dnl @result{} (4, 1) (4, 2) (4, 3) (4, 4) (4, 5) (4, 6) (4, 7) (4, 8) +dnl @result{} diff --git a/checks/081.forloop b/checks/081.forloop new file mode 100644 index 00000000..ef628e43 --- /dev/null +++ b/checks/081.forloop @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:3248: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`forloop.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# forloop(var, from, to, stmt) - simple version +dnl @result{}define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')') +dnl @result{}define(`_forloop', +dnl @result{} `$4`'ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')') +dnl @result{}divert`'dnl diff --git a/checks/082.foreach b/checks/082.foreach new file mode 100644 index 00000000..d98a9135 --- /dev/null +++ b/checks/082.foreach @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:3295: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreach.m4') +dnl @result{} +foreach(`x', (foo, bar, foobar), `Word was: x +')dnl +dnl @result{}Word was: foo +dnl @result{}Word was: bar +dnl @result{}Word was: foobar +include(`foreachq.m4') +dnl @result{} +foreachq(`x', `foo, bar, foobar', `Word was: x +')dnl +dnl @result{}Word was: foo +dnl @result{}Word was: bar +dnl @result{}Word was: foobar diff --git a/checks/083.foreach b/checks/083.foreach new file mode 100644 index 00000000..2cda84ba --- /dev/null +++ b/checks/083.foreach @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:3318: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreach.m4') +dnl @result{} +define(`_case', ` $1) + $2=" $1";; +')dnl +define(`_cat', `$1$2')dnl +case $`'1 in +dnl @result{}case $1 in +foreach(`x', `(`(`a', `vara')', `(`b', `varb')', `(`c', `varc')')', + `_cat(`_case', x)')dnl +dnl @result{} a) +dnl @result{} vara=" a";; +dnl @result{} b) +dnl @result{} varb=" b";; +dnl @result{} c) +dnl @result{} varc=" c";; +esac +dnl @result{}esac diff --git a/checks/084.foreach b/checks/084.foreach new file mode 100644 index 00000000..cdb6c55b --- /dev/null +++ b/checks/084.foreach @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:3348: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`foreach.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreach(x, (item_1, item_2, ..., item_n), stmt) +dnl @result{}# parenthesized list, simple version +dnl @result{}define(`foreach', `pushdef(`$1')_foreach($@)popdef(`$1')') +dnl @result{}define(`_arg1', `$1') +dnl @result{}define(`_foreach', `ifelse(`$2', `()', `', +dnl @result{} `define(`$1', _arg1$2)$3`'$0(`$1', (shift$2), `$3')')') +dnl @result{}divert`'dnl diff --git a/checks/085.foreach b/checks/085.foreach new file mode 100644 index 00000000..41f53686 --- /dev/null +++ b/checks/085.foreach @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:3375: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`a', `1')define(`b', `2')define(`c', `3') +dnl @result{} +include(`foreach.m4') +dnl @result{} +include(`foreachq.m4') +dnl @result{} +foreach(`x', `(``a'', ``(b'', ``c)'')', `x +') +dnl @result{}1 +dnl @result{}(2)1 +dnl @result{} +dnl @result{}, x +dnl @result{}) +foreachq(`x', ```a'', ``(b'', ``c)''', `x +')dnl +dnl @result{}a +dnl @result{}(b +dnl @result{}c) diff --git a/checks/086.foreach b/checks/086.foreach new file mode 100644 index 00000000..aff7cbe0 --- /dev/null +++ b/checks/086.foreach @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:3400: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`foreachq.m4')dnl +dnl @result{}include(`quote.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreachq(x, `item_1, item_2, ..., item_n', stmt) +dnl @result{}# quoted list, simple version +dnl @result{}define(`foreachq', `pushdef(`$1')_foreachq($@)popdef(`$1')') +dnl @result{}define(`_arg1', `$1') +dnl @result{}define(`_foreachq', `ifelse(quote($2), `', `', +dnl @result{} `define(`$1', `_arg1($2)')$3`'$0(`$1', `shift($2)', `$3')')') +dnl @result{}divert`'dnl diff --git a/checks/087.foreach b/checks/087.foreach new file mode 100644 index 00000000..24379da6 --- /dev/null +++ b/checks/087.foreach @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:3427: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreach.m4')include(`foreachq.m4') +dnl @result{} +foreach(`name', `(`a', `b')', ` defn(`name')') +dnl @result{} a b +foreachq(`name', ``a', `b'', ` defn(`name')') +dnl @result{} _arg1(`a', `b') _arg1(shift(`a', `b')) diff --git a/checks/088.stacks b/checks/088.stacks new file mode 100644 index 00000000..f291f9f8 --- /dev/null +++ b/checks/088.stacks @@ -0,0 +1,24 @@ +dnl @ ../doc/m4.texinfo:3468: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`stack.m4') +dnl @result{} +pushdef(`a', `1')pushdef(`a', `2')pushdef(`a', `3') +dnl @result{} +define(`show', ``$1' +') +dnl @result{} +stack_foreach(`a', `show')dnl +dnl @result{}1 +dnl @result{}2 +dnl @result{}3 +stack_foreach_lifo(`a', `show')dnl +dnl @result{}3 +dnl @result{}2 +dnl @result{}1 diff --git a/checks/089.stacks b/checks/089.stacks new file mode 100644 index 00000000..6228ffd1 --- /dev/null +++ b/checks/089.stacks @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:3504: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`stack.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# stack_foreach(macro, action) +dnl @result{}# Invoke ACTION with a single argument of each definition +dnl @result{}# from the definition stack of MACRO, starting with the oldest. +dnl @result{}define(`stack_foreach', +dnl @result{}`_stack_reverse(`$1', `tmp-$1')'dnl +dnl @result{}`_stack_reverse(`tmp-$1', `$1', `$2(defn(`$1'))')') +dnl @result{}# stack_foreach_lifo(macro, action) +dnl @result{}# Invoke ACTION with a single argument of each definition +dnl @result{}# from the definition stack of MACRO, starting with the newest. +dnl @result{}define(`stack_foreach_lifo', +dnl @result{}`_stack_reverse(`$1', `tmp-$1', `$2(defn(`$1'))')'dnl +dnl @result{}`_stack_reverse(`tmp-$1', `$1')') +dnl @result{}define(`_stack_reverse', +dnl @result{}`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0($@)')') +dnl @result{}divert`'dnl diff --git a/checks/090.compositio b/checks/090.compositio new file mode 100644 index 00000000..ddfb4ed8 --- /dev/null +++ b/checks/090.compositio @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:3567: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`define_blind', `ifelse(`$#', `0', ``$0'', +`_$0(`$1', `$2', `$'`#', `$'`0')')') +dnl @result{} +define(`_define_blind', `define(`$1', +`ifelse(`$3', `0', ``$4'', `$2')')') +dnl @result{} +define_blind +dnl @result{}define_blind +define_blind(`foo', `arguments were $*') +dnl @result{} +foo +dnl @result{}foo +foo(`bar') +dnl @result{}arguments were bar +define(`blah', defn(`foo')) +dnl @result{} +blah +dnl @result{}blah +blah(`a', `b') +dnl @result{}arguments were a,b +defn(`blah') +dnl @result{}ifelse(`$#', `0', ``$0'', `arguments were $*') diff --git a/checks/091.compositio b/checks/091.compositio new file mode 100644 index 00000000..50215022 --- /dev/null +++ b/checks/091.compositio @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:3614: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`curry.m4')include(`stack.m4') +dnl @result{} +define(`reverse', `ifelse(`$#', `0', , `$#', `1', ``$1'', + `reverse(shift($@)), `$1'')') +dnl @result{} +pushdef(`a', `1')pushdef(`a', `2')pushdef(`a', `3') +dnl @result{} +stack_foreach(`a', `:curry(`reverse', `4')') +dnl @result{}:1, 4:2, 4:3, 4 +curry(`curry', `reverse', `1')(`2')(`3') +dnl @result{}3, 2, 1 diff --git a/checks/092.compositio b/checks/092.compositio new file mode 100644 index 00000000..166725dc --- /dev/null +++ b/checks/092.compositio @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:3639: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`curry.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# curry(macro, args) +dnl @result{}# Expand to a macro call that takes one argument, then invoke +dnl @result{}# macro(args, extra). +dnl @result{}define(`curry', `$1(shift($@,)_$0') +dnl @result{}define(`_curry', ``$1')') +dnl @result{}divert`'dnl diff --git a/checks/093.compositio b/checks/093.compositio new file mode 100644 index 00000000..4048b2a3 --- /dev/null +++ b/checks/093.compositio @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:3678: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`curry.m4')include(`stack.m4') +dnl @result{} +define(`rename', `copy($@)undefine(`$1')')dnl +define(`copy', `ifdef(`$2', `errprint(`$2 already defined +')m4exit(`1')', + `stack_foreach(`$1', `curry(`pushdef', `$2')')')')dnl +pushdef(`a', `1')pushdef(`a', defn(`divnum'))pushdef(`a', `2') +dnl @result{} +copy(`a', `b') +dnl @result{} +rename(`b', `c') +dnl @result{} +a b c +dnl @result{}2 b 2 +popdef(`a', `c')c a +dnl @result{} 0 +popdef(`a', `c')a c +dnl @result{}1 1 diff --git a/checks/094.dumpdef b/checks/094.dumpdef new file mode 100644 index 00000000..c74a7f04 --- /dev/null +++ b/checks/094.dumpdef @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:3736: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Hello world.') +dnl @result{} +dumpdef(`foo') +dnl @error{}foo: `Hello world.' +dnl @result{} +dumpdef(`define') +dnl @error{}define: <define> +dnl @result{} diff --git a/checks/095.dumpdef b/checks/095.dumpdef new file mode 100644 index 00000000..5d254cd6 --- /dev/null +++ b/checks/095.dumpdef @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:3753: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +pushdef(`f', ``$0'1')pushdef(`f', ``$0'2') +dnl @result{} +f(popdef(`f')dumpdef(`f')) +dnl @error{}f: ``$0'1' +dnl @result{}f2 +f(popdef(`f')dumpdef(`f')) +dnl @error{}m4:stdin:3: undefined macro `f' +dnl @result{}f1 diff --git a/checks/096.trace b/checks/096.trace new file mode 100644 index 00000000..b3775e5c --- /dev/null +++ b/checks/096.trace @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:3796: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Hello World.') +dnl @result{} +define(`echo', `$@') +dnl @result{} +traceon(`foo', `echo') +dnl @result{} +foo +dnl @error{}m4trace: -1- foo -> `Hello World.' +dnl @result{}Hello World. +echo(`gnus', `and gnats') +dnl @error{}m4trace: -1- echo(`gnus', `and gnats') -> ``gnus',`and gnats'' +dnl @result{}gnus,and gnats diff --git a/checks/097.trace b/checks/097.trace new file mode 100644 index 00000000..b175946a --- /dev/null +++ b/checks/097.trace @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:3824: Origin of test +dnl @ expected status: 1 +dnl @ extra options: -dp -L3 -tifelse +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifelse(`one level') +dnl @error{}m4trace: -1- ifelse +dnl @result{} +ifelse(ifelse(ifelse(`three levels'))) +dnl @error{}m4trace: -3- ifelse +dnl @error{}m4trace: -2- ifelse +dnl @error{}m4trace: -1- ifelse +dnl @result{} +ifelse(ifelse(ifelse(ifelse(`four levels')))) +dnl @error{}m4:stdin:3: recursion limit of 3 exceeded, use -L<N> to change it diff --git a/checks/098.trace b/checks/098.trace new file mode 100644 index 00000000..c64ec2c6 --- /dev/null +++ b/checks/098.trace @@ -0,0 +1,38 @@ +dnl @ ../doc/m4.texinfo:3842: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +traceoff(`foo') +dnl @result{} +traceon(`foo') +dnl @result{} +foo +dnl @result{}foo +defn(`foo') +dnl @result{} +define(`foo', `bar') +dnl @result{} +foo +dnl @error{}m4trace: -1- foo -> `bar' +dnl @result{}bar +undefine(`foo') +dnl @result{} +ifdef(`foo', `yes', `no') +dnl @result{}no +indir(`foo') +dnl @error{}m4:stdin:9: undefined macro `foo' +dnl @result{} +define(`foo', `blah') +dnl @result{} +foo +dnl @error{}m4trace: -1- foo -> `blah' +dnl @result{}blah +traceoff +dnl @result{} +foo +dnl @result{}blah diff --git a/checks/099.trace b/checks/099.trace new file mode 100644 index 00000000..f23cb191 --- /dev/null +++ b/checks/099.trace @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:3878: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +traceon(`traceon') +dnl @result{} +traceon(`traceoff') +dnl @error{}m4trace: -1- traceon(`traceoff') +dnl @result{} +traceoff(`traceoff') +dnl @error{}m4trace: -1- traceoff(`traceoff') +dnl @result{} +traceoff(`traceon') +dnl @result{} +traceon(`eval', `m4_divnum') +dnl @result{} +define(`m4_eval', defn(`eval')) +dnl @result{} +define(`m4_divnum', defn(`divnum')) +dnl @result{} +eval(divnum) +dnl @error{}m4trace: -1- eval(`0') -> `0' +dnl @result{}0 +m4_eval(m4_divnum) +dnl @error{}m4trace: -2- m4_divnum -> `0' +dnl @result{}0 diff --git a/checks/100.trace b/checks/100.trace new file mode 100644 index 00000000..4531163c --- /dev/null +++ b/checks/100.trace @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:3912: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -de --trace ifelse +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`e', `ifelse(`$1', `$2', `ifelse(`$1', `$2', `e(shift($@))')')') +dnl @result{} +e(`1', `1') +dnl @error{}m4trace: -1- ifelse -> ifelse(`1', `1', `e(shift(`1',`1'))') +dnl @error{}m4trace: -1- ifelse -> e(shift(`1',`1')) +dnl @error{}m4trace: -1- ifelse +dnl @result{} diff --git a/checks/101.debug_leve b/checks/101.debug_leve new file mode 100644 index 00000000..a7afd0be --- /dev/null +++ b/checks/101.debug_leve @@ -0,0 +1,28 @@ +dnl @ ../doc/m4.texinfo:4018: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -dp +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `FOO') +dnl @result{} +traceon(`foo') +dnl @result{} +debugmode() +dnl @result{} +foo +dnl @error{}m4trace: -1- foo -> `FOO' +dnl @result{}FOO +debugmode +dnl @result{} +foo +dnl @error{}m4trace: -1- foo +dnl @result{}FOO +debugmode(`+l') +dnl @result{} +foo +dnl @error{}m4trace:8: -1- foo +dnl @result{}FOO diff --git a/checks/102.debug_leve b/checks/102.debug_leve new file mode 100644 index 00000000..731add68 --- /dev/null +++ b/checks/102.debug_leve @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:4047: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -l6 +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$@')debugmode(`+t') +dnl @result{} +echo(`1', `long string') +dnl @error{}m4trace: -1- echo(`1', `long s...') -> ``1',`l...' +dnl @result{}1,long string +indir(`echo', defn(`changequote')) +dnl @error{}m4trace: -2- defn(`change...') +dnl @error{}m4trace: -1- indir(`echo', <changequote>) -> ``'' +dnl @result{} diff --git a/checks/103.debug_leve b/checks/103.debug_leve new file mode 100644 index 00000000..cd4ae3e5 --- /dev/null +++ b/checks/103.debug_leve @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:4065: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -dip +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @error{}m4debug: input read from stdin +include(`foo')dnl +dnl @error{}m4debug: path search for `foo' found `examples/foo' +dnl @error{}m4debug: input read from examples/foo +dnl @result{}bar +dnl @error{}m4debug: input reverted to stdin, line 1 +dnl @error{}m4debug: input exhausted diff --git a/checks/104.debug_outp b/checks/104.debug_outp new file mode 100644 index 00000000..af951213 --- /dev/null +++ b/checks/104.debug_outp @@ -0,0 +1,25 @@ +dnl @ ../doc/m4.texinfo:4100: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +traceon(`divnum') +dnl @result{} +divnum(`extra') +dnl @error{}m4:stdin:2: Warning: excess arguments to builtin `divnum' ignored +dnl @error{}m4trace: -1- divnum(`extra') -> `0' +dnl @result{}0 +debugfile() +dnl @result{} +divnum(`extra') +dnl @error{}m4:stdin:4: Warning: excess arguments to builtin `divnum' ignored +dnl @result{}0 +debugfile +dnl @result{} +divnum +dnl @error{}m4trace: -1- divnum -> `0' +dnl @result{}0 diff --git a/checks/105.dnl b/checks/105.dnl new file mode 100644 index 00000000..f57f930e --- /dev/null +++ b/checks/105.dnl @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:4153: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Macro `foo'.')dnl A very simple macro, indeed. +foo +dnl @result{}Macro foo. diff --git a/checks/106.dnl b/checks/106.dnl new file mode 100644 index 00000000..82011b91 --- /dev/null +++ b/checks/106.dnl @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:4171: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl(`args are ignored, but side effects occur', +define(`foo', `like this')) while this text is ignored: undefine(`foo') +dnl @error{}m4:stdin:1: Warning: excess arguments to builtin `dnl' ignored +See how `foo' was defined, foo? +dnl @result{}See how foo was defined, like this? diff --git a/checks/107.dnl b/checks/107.dnl new file mode 100644 index 00000000..30e43d77 --- /dev/null +++ b/checks/107.dnl @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:4182: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +m4wrap(`m4wrap(`2 hi +')0 hi dnl 1 hi') +dnl @result{} +define(`hi', `HI') +dnl @result{} +dnl @error{}m4:stdin:1: Warning: end of file treated as newline +dnl @result{}0 HI 2 HI diff --git a/checks/108.changequot b/checks/108.changequot new file mode 100644 index 00000000..593c84cb --- /dev/null +++ b/checks/108.changequot @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:4213: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changequote(`[', `]') +dnl @result{} +define([foo], [Macro [foo].]) +dnl @result{} +foo +dnl @result{}Macro foo. diff --git a/checks/109.changequot b/checks/109.changequot new file mode 100644 index 00000000..ebbf9d56 --- /dev/null +++ b/checks/109.changequot @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:4228: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`a', `b') +dnl @result{} +«a» +dnl @result{}«b» +changequote(`«', `»') +dnl @result{} +«a» +dnl @result{}a diff --git a/checks/110.changequot b/checks/110.changequot new file mode 100644 index 00000000..44c733c5 --- /dev/null +++ b/checks/110.changequot @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:4243: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changequote(`[[[', `]]]') +dnl @result{} +define([[[foo]]], [[[Macro [[[[[foo]]]]].]]]) +dnl @result{} +foo +dnl @result{}Macro [[foo]]. diff --git a/checks/111.changequot b/checks/111.changequot new file mode 100644 index 00000000..a4aff71a --- /dev/null +++ b/checks/111.changequot @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:4265: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `Macro `FOO'.') +dnl @result{} +changequote(`', `') +dnl @result{} +foo +dnl @result{}Macro `FOO'. +`foo' +dnl @result{}`Macro `FOO'.' +changequote(`,) +dnl @result{} +foo +dnl @result{}Macro FOO. diff --git a/checks/112.changequot b/checks/112.changequot new file mode 100644 index 00000000..8975c26c --- /dev/null +++ b/checks/112.changequot @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:4298: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$@') +dnl @result{} +define(`hi', `HI') +dnl @result{} +changequote(`q', `Q') +dnl @result{} +q hi Q hi +dnl @result{}q HI Q HI +echo(hi) +dnl @result{}qHIQ +changequote +dnl @result{} +changequote(`-', `EOF') +dnl @result{} +- hi EOF hi +dnl @result{} hi HI +changequote +dnl @result{} +changequote(`1', `2') +dnl @result{} +hi1hi2 +dnl @result{}hi1hi2 +hi 1hi2 +dnl @result{}HI hi diff --git a/checks/113.changequot b/checks/113.changequot new file mode 100644 index 00000000..2ab84470 --- /dev/null +++ b/checks/113.changequot @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:4331: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$#:$@:') +dnl @result{} +define(`hi', `HI') +dnl @result{} +changequote(`(',`)') +dnl @result{} +echo(hi) +dnl @result{}0::hi +changequote +dnl @result{} +changequote(`((', `))') +dnl @result{} +echo(hi) +dnl @result{}1:HI: +echo((hi)) +dnl @result{}0::hi +changequote +dnl @result{} +changequote(`,', `)') +dnl @result{} +echo(hi,hi)bye) +dnl @result{}1:HIhibye: diff --git a/checks/114.changequot b/checks/114.changequot new file mode 100644 index 00000000..71edda28 --- /dev/null +++ b/checks/114.changequot @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:4370: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changequote(`[', `]')dnl +define([a], [1, (b)])dnl +define([b], [2])dnl +define([quote], [[$*]])dnl +define([expand], [_$0(($1))])dnl +define([_expand], + [changequote([(], [)])$1changequote`'changequote(`[', `]')])dnl +expand([a, a, [a, a], [[a, a]]]) +dnl @result{}1, (2), 1, (2), a, a, [a, a] +quote(a, a, [a, a], [[a, a]]) +dnl @result{}1,(2),1,(2),a, a,[a, a] diff --git a/checks/115.changequot b/checks/115.changequot new file mode 100644 index 00000000..7a087b47 --- /dev/null +++ b/checks/115.changequot @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:4391: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`hi', `HI') +dnl @result{} +changequote(`""', `"') +dnl @result{} +""hi"""hi" +dnl @result{}hihi +""hi" ""hi" +dnl @result{}hi hi +""hi"" "hi" +dnl @result{}hi" "HI" +changequote +dnl @result{} +`hi`hi'hi' +dnl @result{}hi`hi'hi +changequote(`"', `"') +dnl @result{} +"hi"hi"hi" +dnl @result{}hiHIhi diff --git a/checks/116.changequot b/checks/116.changequot new file mode 100644 index 00000000..2e74406c --- /dev/null +++ b/checks/116.changequot @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:4414: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`aaaaaaaaaaaaaaaaaaaa', `A')define(`q', `"$@"') +dnl @result{} +changequote(`"', `"') +dnl @result{} +q(q("aaaaaaaaaaaaaaaaaaaa", "a")) +dnl @result{}A,a diff --git a/checks/117.changequot b/checks/117.changequot new file mode 100644 index 00000000..a506f7b0 --- /dev/null +++ b/checks/117.changequot @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:4427: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +`hello world' +dnl @result{}hello world +`dangling quote +dnl @error{}m4:stdin:2: ERROR: end of file in string diff --git a/checks/118.changequot b/checks/118.changequot new file mode 100644 index 00000000..9f3877b7 --- /dev/null +++ b/checks/118.changequot @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:4436: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifelse(`dangling quote +dnl @error{}m4:stdin:1: ERROR: end of file in string diff --git a/checks/119.changecom b/checks/119.changecom new file mode 100644 index 00000000..ceed82db --- /dev/null +++ b/checks/119.changecom @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:4461: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`comment', `COMMENT') +dnl @result{} +# A normal comment +dnl @result{}# A normal comment +changecom(`/*', `*/') +dnl @result{} +# Not a comment anymore +dnl @result{}# Not a COMMENT anymore +But: /* this is a comment now */ while this is not a comment +dnl @result{}But: /* this is a comment now */ while this is not a COMMENT diff --git a/checks/120.changecom b/checks/120.changecom new file mode 100644 index 00000000..72b88d45 --- /dev/null +++ b/checks/120.changecom @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:4488: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`comment', `COMMENT') +dnl @result{} +changecom +dnl @result{} +# Not a comment anymore +dnl @result{}# Not a COMMENT anymore +changecom(`#', `') +dnl @result{} +# comment again +dnl @result{}# comment again diff --git a/checks/121.changecom b/checks/121.changecom new file mode 100644 index 00000000..020ec7c5 --- /dev/null +++ b/checks/121.changecom @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:4507: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`a', `b') +dnl @result{} +«a» +dnl @result{}«b» +changecom(`«', `»') +dnl @result{} +«a» +dnl @result{}«a» diff --git a/checks/122.changecom b/checks/122.changecom new file mode 100644 index 00000000..814234b6 --- /dev/null +++ b/checks/122.changecom @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:4530: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`hi', `HI') +dnl @result{} +define(`hi1hi2', `hello') +dnl @result{} +changecom(`q', `Q') +dnl @result{} +q hi Q hi +dnl @result{}q hi Q HI +changecom(`1', `2') +dnl @result{} +hi1hi2 +dnl @result{}hello +hi 1hi2 +dnl @result{}HI 1hi2 diff --git a/checks/123.changecom b/checks/123.changecom new file mode 100644 index 00000000..1151c94b --- /dev/null +++ b/checks/123.changecom @@ -0,0 +1,35 @@ +dnl @ ../doc/m4.texinfo:4553: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$#:$*:$@:') +dnl @result{} +define(`hi', `HI') +dnl @result{} +changecom(`(',`)') +dnl @result{} +echo(hi) +dnl @result{}0:::(hi) +changecom +dnl @result{} +changecom(`((', `))') +dnl @result{} +echo(hi) +dnl @result{}1:HI:HI: +echo((hi)) +dnl @result{}0:::((hi)) +changecom(`,', `)') +dnl @result{} +echo(hi,hi)bye) +dnl @result{}1:HI,hi)bye:HI,hi)bye: +changecom +dnl @result{} +echo(hi,`,`'hi',hi) +dnl @result{}3:HI,,HI,HI:HI,,`'hi,HI: +echo(hi,`,`'hi',hi`'changecom(`,,', `hi')) +dnl @result{}3:HI,,`'hi,HI:HI,,`'hi,HI: diff --git a/checks/124.changecom b/checks/124.changecom new file mode 100644 index 00000000..b8868e6a --- /dev/null +++ b/checks/124.changecom @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:4585: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +changecom(`/*', `*/') +dnl @result{} +/*dangling comment +dnl @error{}m4:stdin:2: ERROR: end of file in comment diff --git a/checks/125.changeword b/checks/125.changeword new file mode 100644 index 00000000..64f12ac2 --- /dev/null +++ b/checks/125.changeword @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:4639: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +changeword(`[_a-zA-Z0-9]+') +dnl @result{} +define(`1', `0')1 +dnl @result{}0 diff --git a/checks/126.changeword b/checks/126.changeword new file mode 100644 index 00000000..ca724916 --- /dev/null +++ b/checks/126.changeword @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:4652: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +define(`_indir', defn(`indir')) +dnl @result{} +changeword(`_[_a-zA-Z0-9]*') +dnl @result{} +esyscmd(`foo') +dnl @result{}esyscmd(foo) +_indir(`esyscmd', `echo hi') +dnl @result{}hi +dnl @result{} diff --git a/checks/127.changeword b/checks/127.changeword new file mode 100644 index 00000000..f69b5b97 --- /dev/null +++ b/checks/127.changeword @@ -0,0 +1,41 @@ +dnl @ ../doc/m4.texinfo:4671: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +define(`foo +', `bar +') +dnl @result{} +dnl This example wants to recognize changeword, dnl, and `foo\n'. +dnl First, we check that our regexp will match. +regexp(`changeword', `[cd][a-z]*\|foo[ +]') +dnl @result{}0 +regexp(`foo +', `[cd][a-z]*\|foo[ +]') +dnl @result{}0 +regexp(`f', `[cd][a-z]*\|foo[ +]') +dnl @result{}-1 +foo +dnl @result{}foo +changeword(`[cd][a-z]*\|foo[ +]') +dnl @result{} +dnl Even though `foo\n' matches, we forgot to allow `f'. +foo +dnl @result{}foo +changeword(`[cd][a-z]*\|fo*[ +]?') +dnl @result{} +dnl Now we can call `foo\n'. +foo +dnl @result{}bar diff --git a/checks/128.changeword b/checks/128.changeword new file mode 100644 index 00000000..3ff1a5a4 --- /dev/null +++ b/checks/128.changeword @@ -0,0 +1,39 @@ +dnl @ ../doc/m4.texinfo:4713: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +define(`bar +', defn(`dnl'))dnl +define(`baz', `dnl +include(`foo') ignored +dnl')dnl +changeword(`\([_a-zA-Z][_a-zA-Z0-9]*\|bar +\)') +dnl @result{} +__file__:__line__ +dnl @result{}stdin:10 +include(`foo') ignored +__file__:__line__ +dnl @result{}stdin:12 +baz ignored +__file__:__line__ +dnl @result{}stdin:14 +define(`bar +', defn(`__file__')) +dnl @result{} +include(`foo') +dnl @result{}examples/foo +define(`bar +', defn(`__line__')) +dnl @result{} +include(`foo') +dnl @result{}1 +__file__:__line__ +dnl @result{}stdin:21 diff --git a/checks/129.changeword b/checks/129.changeword new file mode 100644 index 00000000..318b54c7 --- /dev/null +++ b/checks/129.changeword @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:4751: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changecom(`/*', `*/')dnl +define(`foo', `bar')dnl +changeword(`#\([_a-zA-Z0-9]*\)') +dnl @result{} +#esyscmd(`echo foo \#foo') +dnl @result{}foo bar +dnl @result{} diff --git a/checks/130.changeword b/checks/130.changeword new file mode 100644 index 00000000..afcf7112 --- /dev/null +++ b/checks/130.changeword @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:4788: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`changeword', `', `errprint(` skipping: no changeword support +')m4exit(`77')')dnl +define(`a', `errprint(`Hello')')dnl +changeword(`@\([_a-zA-Z0-9]*\)') +dnl @result{} +@a +dnl @result{}errprint(Hello) diff --git a/checks/131.m4wrap b/checks/131.m4wrap new file mode 100644 index 00000000..c86cb703 --- /dev/null +++ b/checks/131.m4wrap @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:4841: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`cleanup', `This is the `cleanup' action. +') +dnl @result{} +m4wrap(`cleanup') +dnl @result{} +This is the first and last normal input line. +dnl @result{}This is the first and last normal input line. +dnl @result{}This is the cleanup action. diff --git a/checks/132.m4wrap b/checks/132.m4wrap new file mode 100644 index 00000000..69e5a99a --- /dev/null +++ b/checks/132.m4wrap @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:4873: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`wrapfifo.m4')dnl +dnl @result{}dnl Redefine m4wrap to have FIFO semantics. +dnl @result{}define(`_m4wrap_level', `0')dnl +dnl @result{}define(`m4wrap', +dnl @result{}`ifdef(`m4wrap'_m4wrap_level, +dnl @result{} `define(`m4wrap'_m4wrap_level, +dnl @result{} defn(`m4wrap'_m4wrap_level)`$1')', +dnl @result{} `builtin(`m4wrap', `define(`_m4wrap_level', +dnl @result{} incr(_m4wrap_level))dnl +dnl @result{}m4wrap'_m4wrap_level)dnl +dnl @result{}define(`m4wrap'_m4wrap_level, `$1')')')dnl +include(`wrapfifo.m4') +dnl @result{} +m4wrap(`a`'m4wrap(`c +', `d')')m4wrap(`b') +dnl @result{} +dnl @result{}abc diff --git a/checks/133.m4wrap b/checks/133.m4wrap new file mode 100644 index 00000000..2815487f --- /dev/null +++ b/checks/133.m4wrap @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:4903: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`wraplifo.m4')dnl +dnl @result{}dnl Redefine m4wrap to have LIFO semantics. +dnl @result{}define(`_m4wrap_level', `0')dnl +dnl @result{}define(`_m4wrap', defn(`m4wrap'))dnl +dnl @result{}define(`m4wrap', +dnl @result{}`ifdef(`m4wrap'_m4wrap_level, +dnl @result{} `define(`m4wrap'_m4wrap_level, +dnl @result{} `$1'defn(`m4wrap'_m4wrap_level))', +dnl @result{} `_m4wrap(`define(`_m4wrap_level', incr(_m4wrap_level))dnl +dnl @result{}m4wrap'_m4wrap_level)dnl +dnl @result{}define(`m4wrap'_m4wrap_level, `$1')')')dnl +include(`wraplifo.m4') +dnl @result{} +m4wrap(`a`'m4wrap(`c +', `d')')m4wrap(`b') +dnl @result{} +dnl @result{}bac diff --git a/checks/134.m4wrap b/checks/134.m4wrap new file mode 100644 index 00000000..e9cdab74 --- /dev/null +++ b/checks/134.m4wrap @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:4928: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`f', `ifelse(`$1', `0', `Answer: 0!=1 +', eval(`$1>1'), `0', `Answer: $2$1=eval(`$2$1') +', `m4wrap(`f(decr(`$1'), `$2$1*')')')') +dnl @result{} +f(`10') +dnl @result{} +dnl @result{}Answer: 10*9*8*7*6*5*4*3*2*1=3628800 diff --git a/checks/135.m4wrap b/checks/135.m4wrap new file mode 100644 index 00000000..7e2b7464 --- /dev/null +++ b/checks/135.m4wrap @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:4942: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`aa', `AA +') +dnl @result{} +m4wrap(`a')m4wrap(`a') +dnl @result{} +dnl @result{}AA diff --git a/checks/136.m4wrap b/checks/136.m4wrap new file mode 100644 index 00000000..00d36174 --- /dev/null +++ b/checks/136.m4wrap @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:4957: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +m4wrap(`m4wrap(`)')len(abc') +dnl @result{} +dnl @error{}m4:stdin:1: ERROR: end of file in argument list diff --git a/checks/137.include b/checks/137.include new file mode 100644 index 00000000..7980dbb4 --- /dev/null +++ b/checks/137.include @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:5000: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`none') +dnl @error{}m4:stdin:1: cannot open `none': No such file or directory +dnl @result{} +include() +dnl @error{}m4:stdin:2: cannot open `': No such file or directory +dnl @result{} +sinclude(`none') +dnl @result{} +sinclude() +dnl @result{} diff --git a/checks/138.include b/checks/138.include new file mode 100644 index 00000000..fd8b2578 --- /dev/null +++ b/checks/138.include @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:5033: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `FOO') +dnl @result{} +include(`incl.m4') +dnl @result{}Include file start +dnl @result{}FOO +dnl @result{}Include file end +dnl @result{} diff --git a/checks/139.include b/checks/139.include new file mode 100644 index 00000000..a62f485a --- /dev/null +++ b/checks/139.include @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:5050: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`bar', include(`incl.m4')) +dnl @result{} +This is `bar': >>bar<< +dnl @result{}This is bar: >>Include file start +dnl @result{}foo +dnl @result{}Include file end +dnl @result{}<< diff --git a/checks/140.include b/checks/140.include new file mode 100644 index 00000000..d4ea3af9 --- /dev/null +++ b/checks/140.include @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5079: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +include(`Makefile/') +dnl @error{}m4:stdin:1: cannot open `Makefile/': Not a directory +dnl @result{} diff --git a/checks/141.include b/checks/141.include new file mode 100644 index 00000000..ba88a75f --- /dev/null +++ b/checks/141.include @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5092: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +include(`.') +dnl @error{}m4:stdin:1: cannot open `.': Is a directory +dnl @result{} diff --git a/checks/142.include b/checks/142.include new file mode 100644 index 00000000..87081e44 --- /dev/null +++ b/checks/142.include @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5100: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +sinclude(`Makefile/') +dnl @result{} +sinclude(`.') +dnl @result{} diff --git a/checks/143.diversions b/checks/143.diversions new file mode 100644 index 00000000..0005549a --- /dev/null +++ b/checks/143.diversions @@ -0,0 +1,40 @@ +dnl @ ../doc/m4.texinfo:5157: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`-1')define(`f', `.') +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +divert`'dnl +len(f) +dnl @result{}1048576 +divert(`1') +f +divert(`2') +f +divert(`-1')undivert +divert(`1')bye +dnl @result{}bye diff --git a/checks/144.diversions b/checks/144.diversions new file mode 100644 index 00000000..f55e70b0 --- /dev/null +++ b/checks/144.diversions @@ -0,0 +1,36 @@ +dnl @ ../doc/m4.texinfo:5194: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`-1')define(`f', `.') +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +define(`f', defn(`f')defn(`f')) +divert`'dnl +len(f) +dnl @result{}1048576 +divert(`1') +f +m4exit diff --git a/checks/145.diversions b/checks/145.diversions new file mode 100644 index 00000000..3f8822b2 --- /dev/null +++ b/checks/145.diversions @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:5226: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([echo 'divert(1)hi +format(%1000000d, 1)' | ']__program__[' | sed -n 1p])dnl +dnl @result{}hi +sysval +dnl @result{}0 diff --git a/checks/146.diversions b/checks/146.diversions new file mode 100644 index 00000000..10ad4ca7 --- /dev/null +++ b/checks/146.diversions @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5242: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop2.m4')dnl +divert(`1')format(`%10000s', `')dnl +forloop(`i', `1', `10000', + `divert(incr(i))undivert(i)')dnl +divert(`9001')format(`%1000000s', `')dnl +forloop(`i', `9001', `10000', + `divert(incr(i))undivert(i)')dnl +divert(`-1')undivert diff --git a/checks/147.divert b/checks/147.divert new file mode 100644 index 00000000..f9718833 --- /dev/null +++ b/checks/147.divert @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5289: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1') +This text is diverted. +divert +dnl @result{} +This text is not diverted. +dnl @result{}This text is not diverted. +dnl @result{} +dnl @result{}This text is diverted. diff --git a/checks/148.divert b/checks/148.divert new file mode 100644 index 00000000..063354f2 --- /dev/null +++ b/checks/148.divert @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5305: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`text', `TEXT') +dnl @result{} +divert(`1')`diverted text.' +divert +dnl @result{} +m4wrap(`Wrapped text precedes ') +dnl @result{} +dnl @result{}Wrapped TEXT precedes diverted text. diff --git a/checks/149.divert b/checks/149.divert new file mode 100644 index 00000000..141b5cba --- /dev/null +++ b/checks/149.divert @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:5324: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`-1') +define(`foo', `Macro `foo'.') +define(`bar', `Macro `bar'.') +divert +dnl @result{} diff --git a/checks/150.divert b/checks/150.divert new file mode 100644 index 00000000..c4fdc2e3 --- /dev/null +++ b/checks/150.divert @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5338: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(eval(`1<<28'))world +divert(`2')hello +dnl @result{}hello +dnl @result{}world diff --git a/checks/151.divert b/checks/151.divert new file mode 100644 index 00000000..f4e14be4 --- /dev/null +++ b/checks/151.divert @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:5353: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +We decided to divert the stream for irrigation. +dnl @result{}We decided to the stream for irrigation. +define(`divert', `ifelse(`$#', `0', ``$0'', `builtin(`$0', $@)')') +dnl @result{} +divert(`-1') +Ignored text. +divert(`0') +dnl @result{} +We decided to divert the stream for irrigation. +dnl @result{}We decided to divert the stream for irrigation. diff --git a/checks/152.undivert b/checks/152.undivert new file mode 100644 index 00000000..31f02dcf --- /dev/null +++ b/checks/152.undivert @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:5387: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1') +This text is diverted. +divert +dnl @result{} +This text is not diverted. +dnl @result{}This text is not diverted. +undivert(`1') +dnl @result{} +dnl @result{}This text is diverted. +dnl @result{} diff --git a/checks/153.undivert b/checks/153.undivert new file mode 100644 index 00000000..edbf19f3 --- /dev/null +++ b/checks/153.undivert @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:5410: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1')diverted text +divert +dnl @result{} +undivert() +dnl @result{} +undivert(`0') +dnl @result{} +undivert +dnl @result{}diverted text +dnl @result{} +divert(`1')more +divert(`2')undivert(`1')diverted text`'divert +dnl @result{} +undivert(`1') +dnl @result{} +undivert(`2') +dnl @result{}more +dnl @result{}diverted text diff --git a/checks/154.undivert b/checks/154.undivert new file mode 100644 index 00000000..9a6d8149 --- /dev/null +++ b/checks/154.undivert @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:5434: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1') +This text is diverted first. +divert(`0')undivert(`1')dnl +dnl @result{} +dnl @result{}This text is diverted first. +undivert(`1') +dnl @result{} +divert(`1') +This text is also diverted but not appended. +divert(`0')undivert(`1')dnl +dnl @result{} +dnl @result{}This text is also diverted but not appended. diff --git a/checks/155.undivert b/checks/155.undivert new file mode 100644 index 00000000..617261e9 --- /dev/null +++ b/checks/155.undivert @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5453: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1')one +divert(`2')two +divert(`3')three +divert(`2')undivert`'dnl +divert`'undivert`'dnl +dnl @result{}two +dnl @result{}one +dnl @result{}three diff --git a/checks/156.undivert b/checks/156.undivert new file mode 100644 index 00000000..40f61ac1 --- /dev/null +++ b/checks/156.undivert @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5482: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`bar', `BAR') +dnl @result{} +undivert(`foo') +dnl @result{}bar +dnl @result{} +include(`foo') +dnl @result{}BAR +dnl @result{} diff --git a/checks/157.undivert b/checks/157.undivert new file mode 100644 index 00000000..276cb0f8 --- /dev/null +++ b/checks/157.undivert @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:5497: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1')diversion one +divert(`2')undivert(`foo')dnl +divert(`3')diversion three +divert`'dnl +undivert(`1', `2', `foo', `3')dnl +dnl @result{}diversion one +dnl @result{}bar +dnl @result{}bar +dnl @result{}diversion three diff --git a/checks/158.divnum b/checks/158.divnum new file mode 100644 index 00000000..bcaa1204 --- /dev/null +++ b/checks/158.divnum @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:5519: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +Initial divnum +dnl @result{}Initial 0 +divert(`1') +Diversion one: divnum +divert(`2') +Diversion two: divnum +dnl @result{} +dnl @result{}Diversion one: 1 +dnl @result{} +dnl @result{}Diversion two: 2 diff --git a/checks/159.cleardiver b/checks/159.cleardiver new file mode 100644 index 00000000..9efcc044 --- /dev/null +++ b/checks/159.cleardiver @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:5545: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(`1') +Diversion one: divnum +divert(`2') +Diversion two: divnum +divert(`-1') +undivert diff --git a/checks/160.cleardiver b/checks/160.cleardiver new file mode 100644 index 00000000..027ef2f4 --- /dev/null +++ b/checks/160.cleardiver @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:5564: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`cleardivert', +`pushdef(`_n', divnum)divert(`-1')undivert($@)divert(_n)popdef(`_n')') +dnl @result{} diff --git a/checks/161.len b/checks/161.len new file mode 100644 index 00000000..8d1efa1f --- /dev/null +++ b/checks/161.len @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5604: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +len() +dnl @result{}0 +len(`abcdef') +dnl @result{}6 diff --git a/checks/162.index_macr b/checks/162.index_macr new file mode 100644 index 00000000..bc5f5d2e --- /dev/null +++ b/checks/162.index_macr @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5626: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`gnus, gnats, and armadillos', `nat') +dnl @result{}7 +index(`gnus, gnats, and armadillos', `dag') +dnl @result{}-1 diff --git a/checks/163.index_macr b/checks/163.index_macr new file mode 100644 index 00000000..4a086549 --- /dev/null +++ b/checks/163.index_macr @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:5636: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `index' +dnl @result{}0 +index(`abc', `') +dnl @result{}0 +index(`abc', `b') +dnl @result{}1 diff --git a/checks/164.index_macr b/checks/164.index_macr new file mode 100644 index 00000000..ca8772bd --- /dev/null +++ b/checks/164.index_macr @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:5650: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`;:11-:12-:12-:12-:12-:12-:12-:12-:12.:12.:12.:12.:12.:12.:12.:12.:12-', +`:12-:12-:12-:12-:12-:12-:12-:12-') +dnl @result{}-1 diff --git a/checks/165.index_macr b/checks/165.index_macr new file mode 100644 index 00000000..6adc8d7b --- /dev/null +++ b/checks/165.index_macr @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:5659: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +index(`..wi.d.', `.d.') +dnl @result{}4 diff --git a/checks/166.regexp b/checks/166.regexp new file mode 100644 index 00000000..53e312b7 --- /dev/null +++ b/checks/166.regexp @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5708: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +regexp(`GNUs not Unix', `\<[a-z]\w+') +dnl @result{}5 +regexp(`GNUs not Unix', `\<Q\w*') +dnl @result{}-1 +regexp(`GNUs not Unix', `\w\(\w+\)$', `*** \& *** \1 ***') +dnl @result{}*** Unix *** nix *** +regexp(`GNUs not Unix', `\<Q\w*', `*** \& *** \1 ***') +dnl @result{} diff --git a/checks/167.regexp b/checks/167.regexp new file mode 100644 index 00000000..1a7ff27b --- /dev/null +++ b/checks/167.regexp @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:5721: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +regexp(`abc', `\(b\)', `\\\10\a') +dnl @result{}\b0a +regexp(`abc', `b', `\1\') +dnl @error{}m4:stdin:2: Warning: sub-expression 1 not present +dnl @error{}m4:stdin:2: Warning: trailing \ ignored in replacement +dnl @result{} +regexp(`abc', `\(\(d\)?\)\(c\)', `\1\2\3\4\5\6') +dnl @error{}m4:stdin:3: Warning: sub-expression 4 not present +dnl @error{}m4:stdin:3: Warning: sub-expression 5 not present +dnl @error{}m4:stdin:3: Warning: sub-expression 6 not present +dnl @result{}c diff --git a/checks/168.regexp b/checks/168.regexp new file mode 100644 index 00000000..560b12db --- /dev/null +++ b/checks/168.regexp @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:5738: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +regexp(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `regexp' +dnl @result{}0 +regexp(`abc', `') +dnl @result{}0 +regexp(`abc', `', `\\def') +dnl @result{}\def diff --git a/checks/169.substr b/checks/169.substr new file mode 100644 index 00000000..696425bb --- /dev/null +++ b/checks/169.substr @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:5766: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +substr(`gnus, gnats, and armadillos', `6') +dnl @result{}gnats, and armadillos +substr(`gnus, gnats, and armadillos', `6', `5') +dnl @result{}gnats diff --git a/checks/170.substr b/checks/170.substr new file mode 100644 index 00000000..2f2e70b0 --- /dev/null +++ b/checks/170.substr @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:5775: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +substr(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `substr' +dnl @result{}abc +substr(`abc',) +dnl @error{}m4:stdin:2: empty string treated as 0 in builtin `substr' +dnl @result{}abc diff --git a/checks/171.translit b/checks/171.translit new file mode 100644 index 00000000..00167fef --- /dev/null +++ b/checks/171.translit @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:5820: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +translit(`GNUs not Unix', `A-Z') +dnl @result{}s not nix +translit(`GNUs not Unix', `a-z', `A-Z') +dnl @result{}GNUS NOT UNIX +translit(`GNUs not Unix', `A-Z', `z-a') +dnl @result{}tmfs not fnix +translit(`+,-12345', `+--1-5', `<;>a-c-a') +dnl @result{}<;>abcba +translit(`abcdef', `aabdef', `bcged') +dnl @result{}bgced diff --git a/checks/172.translit b/checks/172.translit new file mode 100644 index 00000000..e7cfc1a9 --- /dev/null +++ b/checks/172.translit @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:5847: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +translit(`«abc~', `~-»') +dnl @result{}abc diff --git a/checks/173.translit b/checks/173.translit new file mode 100644 index 00000000..7519f725 --- /dev/null +++ b/checks/173.translit @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:5854: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +translit(`abcdeabcde', `a') +dnl @result{}bcdebcde +translit(`abcdeabcde', `ab') +dnl @result{}cdecde +translit(`abcdeabcde', `a', `f') +dnl @result{}fbcdefbcde +translit(`abcdeabcde', `a', `f') +dnl @result{}fbcdefbcde +translit(`abcdeabcde', `a', `fg') +dnl @result{}fbcdefbcde +translit(`abcdeabcde', `ab', `f') +dnl @result{}fcdefcde +translit(`abcdeabcde', `ab', `fg') +dnl @result{}fgcdefgcde +translit(`abcdeabcde', `ab', `ba') +dnl @result{}bacdebacde +translit(`abcdeabcde', `e', `f') +dnl @result{}abcdfabcdf +translit(`abc', `', `cde') +dnl @result{}abc +translit(`', `a', `bc') +dnl @result{} diff --git a/checks/174.translit b/checks/174.translit new file mode 100644 index 00000000..1cbfab19 --- /dev/null +++ b/checks/174.translit @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:5882: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +translit(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `translit' +dnl @result{}abc diff --git a/checks/175.patsubst b/checks/175.patsubst new file mode 100644 index 00000000..0ec1f2b2 --- /dev/null +++ b/checks/175.patsubst @@ -0,0 +1,22 @@ +dnl @ ../doc/m4.texinfo:5926: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +patsubst(`GNUs not Unix', `^', `OBS: ') +dnl @result{}OBS: GNUs not Unix +patsubst(`GNUs not Unix', `\<', `OBS: ') +dnl @result{}OBS: GNUs OBS: not OBS: Unix +patsubst(`GNUs not Unix', `\w*', `(\&)') +dnl @result{}(GNUs)() (not)() (Unix)() +patsubst(`GNUs not Unix', `\w+', `(\&)') +dnl @result{}(GNUs) (not) (Unix) +patsubst(`GNUs not Unix', `[A-Z][a-z]+') +dnl @result{}GN not +patsubst(`GNUs not Unix', `not', `NOT\') +dnl @error{}m4:stdin:6: Warning: trailing \ ignored in replacement +dnl @result{}GNUs NOT Unix diff --git a/checks/176.patsubst b/checks/176.patsubst new file mode 100644 index 00000000..0b63aad9 --- /dev/null +++ b/checks/176.patsubst @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:5959: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`capitalize.m4') +dnl @result{} +upcase(`GNUs not Unix') +dnl @result{}GNUS NOT UNIX +downcase(`GNUs not Unix') +dnl @result{}gnus not unix +capitalize(`GNUs not Unix') +dnl @result{}Gnus Not Unix diff --git a/checks/177.patsubst b/checks/177.patsubst new file mode 100644 index 00000000..51b8da56 --- /dev/null +++ b/checks/177.patsubst @@ -0,0 +1,22 @@ +dnl @ ../doc/m4.texinfo:5979: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`capitalize.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# upcase(text) +dnl @result{}# downcase(text) +dnl @result{}# capitalize(text) +dnl @result{}# change case of text, simple version +dnl @result{}define(`upcase', `translit(`$*', `a-z', `A-Z')') +dnl @result{}define(`downcase', `translit(`$*', `A-Z', `a-z')') +dnl @result{}define(`_capitalize', +dnl @result{} `regexp(`$1', `^\(\w\)\(\w*\)', +dnl @result{} `upcase(`\1')`'downcase(`\2')')') +dnl @result{}define(`capitalize', `patsubst(`$1', `\w+', `_$0(`\&')')') +dnl @result{}divert`'dnl diff --git a/checks/178.patsubst b/checks/178.patsubst new file mode 100644 index 00000000..75e2bcd2 --- /dev/null +++ b/checks/178.patsubst @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:6000: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`patreg', +`patsubst($@) +regexp($@)')dnl +patreg(`bar foo baz Foo', `foo\|Foo', `FOO') +dnl @result{}bar FOO baz FOO +dnl @result{}FOO +patreg(`aba abb 121', `\(.\)\(.\)\1', `\2\1\2') +dnl @result{}bab abb 212 +dnl @result{}bab diff --git a/checks/179.patsubst b/checks/179.patsubst new file mode 100644 index 00000000..668862bc --- /dev/null +++ b/checks/179.patsubst @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:6015: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +patsubst(`abc') +dnl @error{}m4:stdin:1: Warning: too few arguments to builtin `patsubst' +dnl @result{}abc +patsubst(`abc', `') +dnl @result{}abc +patsubst(`abc', `', `\\-') +dnl @result{}\-a\-b\-c\- diff --git a/checks/180.format b/checks/180.format new file mode 100644 index 00000000..f05fb3de --- /dev/null +++ b/checks/180.format @@ -0,0 +1,29 @@ +dnl @ ../doc/m4.texinfo:6046: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `The brown fox jumped over the lazy dog') +dnl @result{} +format(`The string "%s" uses %d characters', foo, len(foo)) +dnl @result{}The string "The brown fox jumped over the lazy dog" uses 38 characters +format(`%*.*d', `-1', `-1', `1') +dnl @result{}1 +format(`%.0f', `56789.9876') +dnl @result{}56790 +len(format(`%-*X', `5000', `1')) +dnl @result{}5000 +ifelse(format(`%010F', `infinity'), ` INF', `success', + format(`%010F', `infinity'), ` INFINITY', `success', + format(`%010F', `infinity')) +dnl @result{}success +ifelse(format(`%.1A', `1.999'), `0X1.0P+1', `success', + format(`%.1A', `1.999'), `0X2.0P+0', `success', + format(`%.1A', `1.999')) +dnl @result{}success +format(`%g', `0xa.P+1') +dnl @result{}20 diff --git a/checks/181.format b/checks/181.format new file mode 100644 index 00000000..5228cc97 --- /dev/null +++ b/checks/181.format @@ -0,0 +1,24 @@ +dnl @ ../doc/m4.texinfo:6073: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop.m4') +dnl @result{} +forloop(`i', `1', `10', `format(`%6d squared is %10d +', i, eval(i**2))') +dnl @result{} 1 squared is 1 +dnl @result{} 2 squared is 4 +dnl @result{} 3 squared is 9 +dnl @result{} 4 squared is 16 +dnl @result{} 5 squared is 25 +dnl @result{} 6 squared is 36 +dnl @result{} 7 squared is 49 +dnl @result{} 8 squared is 64 +dnl @result{} 9 squared is 81 +dnl @result{} 10 squared is 100 +dnl @result{} diff --git a/checks/182.format b/checks/182.format new file mode 100644 index 00000000..9baa166f --- /dev/null +++ b/checks/182.format @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:6114: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +format(`%p', `0') +dnl @error{}m4:stdin:1: Warning: unrecognized specifier in `%p' +dnl @result{} diff --git a/checks/183.format b/checks/183.format new file mode 100644 index 00000000..ba9e4e0a --- /dev/null +++ b/checks/183.format @@ -0,0 +1,12 @@ +dnl @ ../doc/m4.texinfo:6126: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +format(`%'format(`%c', `128')) +dnl @result{} diff --git a/checks/184.incr b/checks/184.incr new file mode 100644 index 00000000..d9db64d5 --- /dev/null +++ b/checks/184.incr @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:6164: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +incr(`4') +dnl @result{}5 +decr(`7') +dnl @result{}6 +incr() +dnl @error{}m4:stdin:3: empty string treated as 0 in builtin `incr' +dnl @result{}1 +decr() +dnl @error{}m4:stdin:4: empty string treated as 0 in builtin `decr' +dnl @result{}-1 diff --git a/checks/185.eval b/checks/185.eval new file mode 100644 index 00000000..f21e194a --- /dev/null +++ b/checks/185.eval @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:6241: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval(`2 = 2') +dnl @error{}m4:stdin:1: Warning: recommend ==, not =, for equality operator +dnl @result{}1 +eval(`++0') +dnl @error{}m4:stdin:2: invalid operator in eval: ++0 +dnl @result{} +eval(`0 |= 1') +dnl @error{}m4:stdin:3: invalid operator in eval: 0 |= 1 +dnl @result{} diff --git a/checks/186.eval b/checks/186.eval new file mode 100644 index 00000000..646907df --- /dev/null +++ b/checks/186.eval @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:6274: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval(`1 == 2 > 0') +dnl @result{}1 +eval(`(1 == 2) > 0') +dnl @result{}0 +eval(`! 0 * 2') +dnl @result{}2 +eval(`! (0 * 2)') +dnl @result{}1 +eval(`1 | 1 ^ 1') +dnl @result{}1 +eval(`(1 | 1) ^ 1') +dnl @result{}0 +eval(`+ + - ~ ! ~ 0') +dnl @result{}1 +eval(`2 || 1 / 0') +dnl @result{}1 +eval(`0 || 1 / 0') +dnl @error{}m4:stdin:9: divide by zero in eval: 0 || 1 / 0 +dnl @result{} +eval(`0 && 1 % 0') +dnl @result{}0 +eval(`2 && 1 % 0') +dnl @error{}m4:stdin:11: modulo by zero in eval: 2 && 1 % 0 +dnl @result{} diff --git a/checks/187.eval b/checks/187.eval new file mode 100644 index 00000000..6c006147 --- /dev/null +++ b/checks/187.eval @@ -0,0 +1,23 @@ +dnl @ ../doc/m4.texinfo:6307: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval(`2 ** 3 ** 2') +dnl @result{}512 +eval(`(2 ** 3) ** 2') +dnl @result{}64 +eval(`0 ** 1') +dnl @result{}0 +eval(`2 ** 0') +dnl @result{}1 +eval(`0 ** 0') +dnl @result{} +dnl @error{}m4:stdin:5: divide by zero in eval: 0 ** 0 +eval(`4 ** -2') +dnl @error{}m4:stdin:6: negative exponent in eval: 4 ** -2 +dnl @result{} diff --git a/checks/188.eval b/checks/188.eval new file mode 100644 index 00000000..0f8d2d67 --- /dev/null +++ b/checks/188.eval @@ -0,0 +1,34 @@ +dnl @ ../doc/m4.texinfo:6343: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval(`-3 * 5') +dnl @result{}-15 +eval(`-99 / 10') +dnl @result{}-9 +eval(`-99 % 10') +dnl @result{}-9 +eval(`99 % -10') +dnl @result{}9 +eval(index(`Hello world', `llo') >= 0) +dnl @result{}1 +eval(`0r1:0111 + 0b100 + 0r3:12') +dnl @result{}12 +define(`square', `eval(`($1) ** 2')') +dnl @result{} +square(`9') +dnl @result{}81 +square(square(`5')` + 1') +dnl @result{}676 +define(`foo', `666') +dnl @result{} +eval(`foo / 6') +dnl @error{}m4:stdin:11: bad expression in eval: foo / 6 +dnl @result{} +eval(foo / 6) +dnl @result{}111 diff --git a/checks/189.eval b/checks/189.eval new file mode 100644 index 00000000..c61c05cb --- /dev/null +++ b/checks/189.eval @@ -0,0 +1,27 @@ +dnl @ ../doc/m4.texinfo:6382: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`max_int', eval(`0x7fffffff')) +dnl @result{} +define(`min_int', incr(max_int)) +dnl @result{} +eval(min_int` < 0') +dnl @result{}1 +eval(max_int` > 0') +dnl @result{}1 +ifelse(eval(min_int` / -1'), min_int, `overflow occurred') +dnl @result{}overflow occurred +min_int +dnl @result{}-2147483648 +eval(`0x80000000 % -1') +dnl @result{}0 +eval(`-4 >> 1') +dnl @result{}-2 +eval(`-4 >> 33') +dnl @result{}-2 diff --git a/checks/190.eval b/checks/190.eval new file mode 100644 index 00000000..08e9bde5 --- /dev/null +++ b/checks/190.eval @@ -0,0 +1,34 @@ +dnl @ ../doc/m4.texinfo:6415: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +eval(`666', `10') +dnl @result{}666 +eval(`666', `11') +dnl @result{}556 +eval(`666', `6') +dnl @result{}3030 +eval(`666', `6', `10') +dnl @result{}0000003030 +eval(`-666', `6', `10') +dnl @result{}-0000003030 +eval(`10', `', `0') +dnl @result{}10 +`0r1:'eval(`10', `1', `11') +dnl @result{}0r1:01111111111 +eval(`10', `16') +dnl @result{}a +eval(`1', `37') +dnl @error{}m4:stdin:9: radix 37 in builtin `eval' out of range +dnl @result{} +eval(`1', , `-1') +dnl @error{}m4:stdin:10: negative width to builtin `eval' +dnl @result{} +eval() +dnl @error{}m4:stdin:11: empty string treated as 0 in builtin `eval' +dnl @result{}0 diff --git a/checks/191.platform_m b/checks/191.platform_m new file mode 100644 index 00000000..888e3795 --- /dev/null +++ b/checks/191.platform_m @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:6496: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +__gnu__ +dnl @result{} +__gnu__(`ignored') +dnl @result{} +Extensions are ifdef(`__gnu__', `active', `inactive') +dnl @result{}Extensions are active diff --git a/checks/192.platform_m b/checks/192.platform_m new file mode 100644 index 00000000..67dc1b6d --- /dev/null +++ b/checks/192.platform_m @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:6507: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -G +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +__gnu__ +dnl @result{}__gnu__ +__gnu__(`ignored') +dnl @result{}__gnu__(ignored) +Extensions are ifdef(`__gnu__', `active', `inactive') +dnl @result{}Extensions are inactive diff --git a/checks/193.platform_m b/checks/193.platform_m new file mode 100644 index 00000000..d385ffb7 --- /dev/null +++ b/checks/193.platform_m @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:6530: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`provided', `0') +dnl @result{} +ifdef(`__unix__', `define(`provided', incr(provided))') +dnl @result{} +ifdef(`__windows__', `define(`provided', incr(provided))') +dnl @result{} +ifdef(`__os2__', `define(`provided', incr(provided))') +dnl @result{} +provided +dnl @result{}1 diff --git a/checks/194.syscmd b/checks/194.syscmd new file mode 100644 index 00000000..be2ae133 --- /dev/null +++ b/checks/194.syscmd @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:6572: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `FOO') +dnl @result{} +syscmd(`echo foo') +dnl @result{}foo +dnl @result{} diff --git a/checks/195.syscmd b/checks/195.syscmd new file mode 100644 index 00000000..12446166 --- /dev/null +++ b/checks/195.syscmd @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:6601: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +m4wrap(`syscmd(`cat')') +dnl @result{} diff --git a/checks/196.esyscmd b/checks/196.esyscmd new file mode 100644 index 00000000..af4e7435 --- /dev/null +++ b/checks/196.esyscmd @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:6649: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `FOO') +dnl @result{} +esyscmd(`echo foo') +dnl @result{}FOO +dnl @result{} diff --git a/checks/197.sysval b/checks/197.sysval new file mode 100644 index 00000000..cf5900a7 --- /dev/null +++ b/checks/197.sysval @@ -0,0 +1,35 @@ +dnl @ ../doc/m4.texinfo:6679: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +sysval +dnl @result{}0 +syscmd(`false') +dnl @result{} +ifelse(sysval, `0', `zero', `non-zero') +dnl @result{}non-zero +syscmd(`exit 2') +dnl @result{} +sysval +dnl @result{}2 +syscmd(`true') +dnl @result{} +sysval +dnl @result{}0 +esyscmd(`false') +dnl @result{} +ifelse(sysval, `0', `zero', `non-zero') +dnl @result{}non-zero +esyscmd(`echo dnl && exit 127') +dnl @result{} +sysval +dnl @result{}127 +esyscmd(`true') +dnl @result{} +sysval +dnl @result{}0 diff --git a/checks/198.sysval b/checks/198.sysval new file mode 100644 index 00000000..67b1ccbc --- /dev/null +++ b/checks/198.sysval @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:6729: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl This test assumes kill is a shell builtin, and that signals are +dnl recognizable. +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +syscmd(`kill -9 $$') +dnl @result{} +sysval +dnl @result{}2304 +syscmd() +dnl @result{} +sysval +dnl @result{}0 +esyscmd(`kill -9 $$') +dnl @result{} +sysval +dnl @result{}2304 diff --git a/checks/199.mkstemp b/checks/199.mkstemp new file mode 100644 index 00000000..1f65d602 --- /dev/null +++ b/checks/199.mkstemp @@ -0,0 +1,32 @@ +dnl @ ../doc/m4.texinfo:6823: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `errprint(`oops')') +dnl @result{} +syscmd(`rm -f foo-??????')sysval +dnl @result{}0 +define(`file1', maketemp(`foo-XXXXXX'))dnl +ifelse(esyscmd(`echo \` foo-?????? \''), ` foo-?????? ', + `no file', `created') +dnl @result{}created +define(`file2', maketemp(`foo-XX'))dnl +define(`file3', mkstemp(`foo-XXXXXX'))dnl +ifelse(len(defn(`file1')), len(defn(`file2')), + `same length', `different') +dnl @result{}same length +ifelse(defn(`file1'), defn(`file2'), `same', `different file') +dnl @result{}different file +ifelse(defn(`file2'), defn(`file3'), `same', `different file') +dnl @result{}different file +ifelse(defn(`file1'), defn(`file3'), `same', `different file') +dnl @result{}different file +syscmd(`rm 'defn(`file1') defn(`file2') defn(`file3')) +dnl @result{} +sysval +dnl @result{}0 diff --git a/checks/200.mkstemp b/checks/200.mkstemp new file mode 100644 index 00000000..2d0984af --- /dev/null +++ b/checks/200.mkstemp @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:6854: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +syscmd(`rm -rf foodir')sysval +dnl @result{}0 +syscmd(`mkdir foodir')sysval +dnl @result{}0 +len(mkstemp(`foodir/fooXXXXX')) +dnl @result{}16 +syscmd(`rm -r foodir')sysval +dnl @result{}0 diff --git a/checks/201.mkstemp b/checks/201.mkstemp new file mode 100644 index 00000000..5aa3256c --- /dev/null +++ b/checks/201.mkstemp @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:6869: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -G +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +syscmd(`rm -f foo-*')sysval +dnl @result{}0 +len(maketemp(`foo-XXXXX')) +dnl @error{}m4:stdin:2: recommend using mkstemp instead +dnl @result{}9 +define(`abc', `def') +dnl @result{} +maketemp(`foo-abc') +dnl @result{}foo-def +dnl @error{}m4:stdin:4: recommend using mkstemp instead +syscmd(`test -f foo-*')ifelse(sysval, `0', `0', `1') +dnl @result{}1 diff --git a/checks/202.errprint b/checks/202.errprint new file mode 100644 index 00000000..b08942b7 --- /dev/null +++ b/checks/202.errprint @@ -0,0 +1,17 @@ +dnl @ ../doc/m4.texinfo:6915: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +errprint(`Invalid arguments to forloop +') +dnl @error{}Invalid arguments to forloop +dnl @result{} +errprint(`1')errprint(`2',`3 +') +dnl @error{}12 3 +dnl @result{} diff --git a/checks/203.location b/checks/203.location new file mode 100644 index 00000000..4754f494 --- /dev/null +++ b/checks/203.location @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:6952: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +errprint(__program__:__file__:__line__: `input error +') +dnl @error{}m4:stdin:1: input error +dnl @result{} diff --git a/checks/204.location b/checks/204.location new file mode 100644 index 00000000..23861700 --- /dev/null +++ b/checks/204.location @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:6972: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', ``$0' called at __file__:__line__') +dnl @result{} +foo +dnl @result{}foo called at stdin:2 +include(`incl.m4') +dnl @result{}Include file start +dnl @result{}foo called at examples/incl.m4:2 +dnl @result{}Include file end +dnl @result{} diff --git a/checks/205.location b/checks/205.location new file mode 100644 index 00000000..8ed7a25a --- /dev/null +++ b/checks/205.location @@ -0,0 +1,36 @@ +dnl @ ../doc/m4.texinfo:6993: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`echo', `$@') +dnl @result{} +define(`foo', `echo(__line__ +__line__)') +dnl @result{} +echo(__line__ +__line__) +dnl @result{}4 +dnl @result{}5 +m4wrap(`foo +') +dnl @result{} +foo(errprint(__line__ +__line__ +)) +dnl @error{}8 +dnl @error{}9 +dnl @result{}8 +dnl @result{}8 +__line__ +dnl @result{}11 +m4wrap(`__line__ +') +dnl @result{} +dnl @result{}12 +dnl @result{}6 +dnl @result{}6 diff --git a/checks/206.m4exit b/checks/206.m4exit new file mode 100644 index 00000000..9fc746d5 --- /dev/null +++ b/checks/206.m4exit @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:7050: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +m4wrap(`This text is lost due to `m4exit'.') +dnl @result{} +divert(`1') So is this. +divert +dnl @result{} +m4exit And this is never read. diff --git a/checks/207.m4exit b/checks/207.m4exit new file mode 100644 index 00000000..981f84e8 --- /dev/null +++ b/checks/207.m4exit @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:7068: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`fatal_error', + `errprint(__program__:__file__:__line__`: fatal error: $* +')m4exit(`1')') +dnl @result{} +fatal_error(`this is a BAD one, buster') +dnl @error{}m4:stdin:4: fatal error: this is a BAD one, buster diff --git a/checks/208.using_froz b/checks/208.using_froz new file mode 100644 index 00000000..52068eaa --- /dev/null +++ b/checks/208.using_froz @@ -0,0 +1,10 @@ +dnl @ ../doc/m4.texinfo:7204: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -F /dev/null +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +traceon(`undefined')dnl diff --git a/checks/209.using_froz b/checks/209.using_froz new file mode 100644 index 00000000..6d3398bd --- /dev/null +++ b/checks/209.using_froz @@ -0,0 +1,20 @@ +dnl @ ../doc/m4.texinfo:7210: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +ifdef(`__unix__', , + `errprint(` skipping: syscmd does not have unix semantics +')m4exit(`77')')dnl +changequote(`[', `]')dnl +syscmd([echo 'changequote([,])pushdef([divnum],[hi])dnl' \ + | ']__program__[' -F in.m4f \ + && echo 'divnum popdef([divnum])divnum' \ + | ']__program__[' -R in.m4f \ + && rm in.m4f])status sysval +dnl @result{}hi 0 +dnl @result{}status 0 diff --git a/checks/210.using_froz b/checks/210.using_froz new file mode 100644 index 00000000..91e578b1 --- /dev/null +++ b/checks/210.using_froz @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:7230: Origin of test +dnl @ expected status: 1 +dnl @ extra options: -F /none/such +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +dnl @ expected error: ignore +dnl @error{}m4: cannot open `/none/such': No such file or directory diff --git a/checks/211.extensions b/checks/211.extensions new file mode 100644 index 00000000..abc78bce --- /dev/null +++ b/checks/211.extensions @@ -0,0 +1,26 @@ +dnl @ ../doc/m4.texinfo:7366: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`a1', `A1') +dnl @result{} +dnl First argument, concatenated with 1 +define(`_1', `$1')define(`first1', `_1($@)1') +dnl @result{} +dnl Eleventh argument, portable +define(`_9', `$9')define(`eleventh', `_9(shift(shift($@)))') +dnl @result{} +dnl Eleventh argument, GNU style +define(`Eleventh', `$11') +dnl @result{} +first1(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') +dnl @result{}A1 +eleventh(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') +dnl @result{}k +Eleventh(`a', `b', `c', `d', `e', `f', `g', `h', `i', `j', `k') +dnl @result{}k diff --git a/checks/212.other_inco b/checks/212.other_inco new file mode 100644 index 00000000..e2bf638d --- /dev/null +++ b/checks/212.other_inco @@ -0,0 +1,18 @@ +dnl @ ../doc/m4.texinfo:7660: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -s +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +divert(2)2 +divert(1)1 +divert`'0 +dnl @result{}#line 3 "stdin" +dnl @result{}0 +dnl @result{}#line 2 "stdin" +dnl @result{}1 +dnl @result{}#line 1 "stdin" +dnl @result{}2 diff --git a/checks/213.other_inco b/checks/213.other_inco new file mode 100644 index 00000000..6e45290b --- /dev/null +++ b/checks/213.other_inco @@ -0,0 +1,13 @@ +dnl @ ../doc/m4.texinfo:7685: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`x', `x') +dnl @result{} +define(`x', `x ') +dnl @result{} diff --git a/checks/214.improved_e b/checks/214.improved_e new file mode 100644 index 00000000..1fb79140 --- /dev/null +++ b/checks/214.improved_e @@ -0,0 +1,15 @@ +dnl @ ../doc/m4.texinfo:7739: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`exch', ``$2', `$1'') +dnl @result{} +define(exch(`expansion text', `macro')) +dnl @result{} +macro +dnl @result{}expansion text diff --git a/checks/215.improved_f b/checks/215.improved_f new file mode 100644 index 00000000..002d4818 --- /dev/null +++ b/checks/215.improved_f @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:7761: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +undivert(`forloop2.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# forloop(var, from, to, stmt) - improved version: +dnl @result{}# works even if VAR is not a strict macro name +dnl @result{}# performs sanity check that FROM is larger than TO +dnl @result{}# allows complex numerical expressions in TO and FROM +dnl @result{}define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1', +dnl @result{} `pushdef(`$1')_$0(`$1', eval(`$2'), +dnl @result{} eval(`$3'), `$4')popdef(`$1')')') +dnl @result{}define(`_forloop', +dnl @result{} `define(`$1', `$2')$4`'ifelse(`$2', `$3', `', +dnl @result{} `$0(`$1', incr(`$2'), `$3', `$4')')') +dnl @result{}divert`'dnl +include(`forloop2.m4') +dnl @result{} +forloop(`i', `2', `1', `no iteration occurs') +dnl @result{} +forloop(`', `1', `2', ` odd iterator name') +dnl @result{} odd iterator name odd iterator name +forloop(`i', `5 + 5', `0xc', ` 0x`'eval(i, `16')') +dnl @result{} 0xa 0xb 0xc +forloop(`i', `a', `b', `non-numeric bounds') +dnl @error{}m4:stdin:6: bad expression in eval (bad input): (a) <= (b) +dnl @result{} diff --git a/checks/216.improved_f b/checks/216.improved_f new file mode 100644 index 00000000..cb4bb9df --- /dev/null +++ b/checks/216.improved_f @@ -0,0 +1,34 @@ +dnl @ ../doc/m4.texinfo:7802: Origin of test +dnl @ expected status: 1 +dnl @ extra options: -L9 +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`arg1', `$1')include(`forloop2.m4')include(`quote.m4') +dnl @result{} +define(`double', `define(`$1'`2', + arg1(patsubst(dquote(defn(`$1')), `[`']', `\&\&')))') +dnl @result{} +double(`forloop')double(`_forloop')defn(`forloop2') +dnl @result{}ifelse(eval(``($2) <= ($3)''), ``1'', +dnl @result{} ``pushdef(``$1'')_$0(``$1'', eval(``$2''), +dnl @result{} eval(``$3''), ``$4'')popdef(``$1'')'') +forloop(i, 1, 5, `ifelse(')forloop(i, 1, 5, `)') +dnl @result{} +changequote(`[', `]')changequote([``], ['']) +dnl @result{} +forloop2(i, 1, 5, ``ifelse('')forloop2(i, 1, 5, ``)'') +dnl @result{} +changequote`'include(`forloop.m4') +dnl @result{} +double(`forloop')double(`_forloop')defn(`forloop2') +dnl @result{}pushdef(``$1'', ``$2'')_forloop($@)popdef(``$1'') +forloop(i, 1, 5, `ifelse(')forloop(i, 1, 5, `)') +dnl @result{} +changequote(`[', `]')changequote([``], ['']) +dnl @result{} +forloop2(i, 1, 5, ``ifelse('')forloop2(i, 1, 5, ``)'') +dnl @error{}m4:stdin:12: recursion limit of 9 exceeded, use -L<N> to change it diff --git a/checks/217.improved_f b/checks/217.improved_f new file mode 100644 index 00000000..68ad0376 --- /dev/null +++ b/checks/217.improved_f @@ -0,0 +1,43 @@ +dnl @ ../doc/m4.texinfo:7845: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop3.m4') +dnl @result{} +undivert(`forloop3.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# forloop_arg(from, to, macro) - invoke MACRO(value) for +dnl @result{}# each value between FROM and TO, without define overhead +dnl @result{}define(`forloop_arg', `ifelse(eval(`($1) <= ($2)'), `1', +dnl @result{} `_forloop(`$1', eval(`$2'), `$3(', `)')')') +dnl @result{}# forloop(var, from, to, stmt) - refactored to share code +dnl @result{}define(`forloop', `ifelse(eval(`($2) <= ($3)'), `1', +dnl @result{} `pushdef(`$1')_forloop(eval(`$2'), eval(`$3'), +dnl @result{} `define(`$1',', `)$4')popdef(`$1')')') +dnl @result{}define(`_forloop', +dnl @result{} `$3`$1'$4`'ifelse(`$1', `$2', `', +dnl @result{} `$0(incr(`$1'), `$2', `$3', `$4')')') +dnl @result{}divert`'dnl +forloop(`i', `1', `3', ` i') +dnl @result{} 1 2 3 +define(`echo', `$@') +dnl @result{} +forloop_arg(`1', `3', ` echo') +dnl @result{} 1 2 3 +include(`curry.m4') +dnl @result{} +forloop_arg(`1', `3', `curry(`pushdef', `a')') +dnl @result{} +a +dnl @result{}3 +popdef(`a')a +dnl @result{}2 +popdef(`a')a +dnl @result{}1 +popdef(`a')a +dnl @result{}a diff --git a/checks/218.improved_f b/checks/218.improved_f new file mode 100644 index 00000000..36e85d40 --- /dev/null +++ b/checks/218.improved_f @@ -0,0 +1,35 @@ +dnl @ ../doc/m4.texinfo:7896: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreachq.m4') +dnl @result{} +traceon(`shift')debugmode(`aq') +dnl @result{} +foreachq(`x', ``1', `2', `3', `4'', `x +')dnl +dnl @result{}1 +dnl @error{}m4trace: -3- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -2- shift(`1', `2', `3', `4') +dnl @result{}2 +dnl @error{}m4trace: -4- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -3- shift(`2', `3', `4') +dnl @error{}m4trace: -3- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -2- shift(`2', `3', `4') +dnl @result{}3 +dnl @error{}m4trace: -5- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -4- shift(`2', `3', `4') +dnl @error{}m4trace: -3- shift(`3', `4') +dnl @error{}m4trace: -4- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -3- shift(`2', `3', `4') +dnl @error{}m4trace: -2- shift(`3', `4') +dnl @result{}4 +dnl @error{}m4trace: -6- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -5- shift(`2', `3', `4') +dnl @error{}m4trace: -4- shift(`3', `4') +dnl @error{}m4trace: -3- shift(`4') diff --git a/checks/219.improved_f b/checks/219.improved_f new file mode 100644 index 00000000..b9237fce --- /dev/null +++ b/checks/219.improved_f @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:7938: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreachq2.m4') +dnl @result{} +undivert(`foreachq2.m4')dnl +dnl @result{}include(`quote.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreachq(x, `item_1, item_2, ..., item_n', stmt) +dnl @result{}# quoted list, improved version +dnl @result{}define(`foreachq', `pushdef(`$1')_$0($@)popdef(`$1')') +dnl @result{}define(`_arg1q', ``$1'') +dnl @result{}define(`_rest', `ifelse(`$#', `1', `', `dquote(shift($@))')') +dnl @result{}define(`_foreachq', `ifelse(`$2', `', `', +dnl @result{} `define(`$1', _arg1q($2))$3`'$0(`$1', _rest($2), `$3')')') +dnl @result{}divert`'dnl +traceon(`shift')debugmode(`aq') +dnl @result{} +foreachq(`x', ``1', `2', `3', `4'', `x +')dnl +dnl @result{}1 +dnl @error{}m4trace: -3- shift(`1', `2', `3', `4') +dnl @result{}2 +dnl @error{}m4trace: -3- shift(`2', `3', `4') +dnl @result{}3 +dnl @error{}m4trace: -3- shift(`3', `4') +dnl @result{}4 diff --git a/checks/220.improved_f b/checks/220.improved_f new file mode 100644 index 00000000..98eeb4bf --- /dev/null +++ b/checks/220.improved_f @@ -0,0 +1,49 @@ +dnl @ ../doc/m4.texinfo:7991: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreachq3.m4') +dnl @result{} +undivert(`foreachq3.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreachq(x, `item_1, item_2, ..., item_n', stmt) +dnl @result{}# quoted list, alternate improved version +dnl @result{}define(`foreachq', `ifelse(`$2', `', `', +dnl @result{} `pushdef(`$1')_$0(`$1', `$3', `', $2)popdef(`$1')')') +dnl @result{}define(`_foreachq', `ifelse(`$#', `3', `', +dnl @result{} `define(`$1', `$4')$2`'$0(`$1', `$2', +dnl @result{} shift(shift(shift($@))))')') +dnl @result{}divert`'dnl +traceon(`shift')debugmode(`aq') +dnl @result{} +foreachq(`x', ``1', `2', `3', `4'', `x +')dnl +dnl @result{}1 +dnl @error{}m4trace: -4- shift(`x', `x +dnl @error{}', `', `1', `2', `3', `4') +dnl @error{}m4trace: -3- shift(`x +dnl @error{}', `', `1', `2', `3', `4') +dnl @error{}m4trace: -2- shift(`', `1', `2', `3', `4') +dnl @result{}2 +dnl @error{}m4trace: -4- shift(`x', `x +dnl @error{}', `1', `2', `3', `4') +dnl @error{}m4trace: -3- shift(`x +dnl @error{}', `1', `2', `3', `4') +dnl @error{}m4trace: -2- shift(`1', `2', `3', `4') +dnl @result{}3 +dnl @error{}m4trace: -4- shift(`x', `x +dnl @error{}', `2', `3', `4') +dnl @error{}m4trace: -3- shift(`x +dnl @error{}', `2', `3', `4') +dnl @error{}m4trace: -2- shift(`2', `3', `4') +dnl @result{}4 +dnl @error{}m4trace: -4- shift(`x', `x +dnl @error{}', `3', `4') +dnl @error{}m4trace: -3- shift(`x +dnl @error{}', `3', `4') +dnl @error{}m4trace: -2- shift(`3', `4') diff --git a/checks/221.improved_f b/checks/221.improved_f new file mode 100644 index 00000000..d76cbf8a --- /dev/null +++ b/checks/221.improved_f @@ -0,0 +1,33 @@ +dnl @ ../doc/m4.texinfo:8078: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreachq4.m4') +dnl @result{} +undivert(`foreachq4.m4')dnl +dnl @result{}include(`forloop2.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreachq(x, `item_1, item_2, ..., item_n', stmt) +dnl @result{}# quoted list, version based on forloop +dnl @result{}define(`foreachq', +dnl @result{}`ifelse(`$2', `', `', `_$0(`$1', `$3', $2)')') +dnl @result{}define(`_foreachq', +dnl @result{}`pushdef(`$1', forloop(`$1', `3', `$#', +dnl @result{} `$0_(`1', `2', indir(`$1'))')`popdef( +dnl @result{} `$1')')indir(`$1', $@)') +dnl @result{}define(`_foreachq_', +dnl @result{}``define(`$$1', `$$3')$$2`''') +dnl @result{}divert`'dnl +traceon(`shift')debugmode(`aq') +dnl @result{} +foreachq(`x', ``1', `2', `3', `4'', `x +')dnl +dnl @result{}1 +dnl @result{}2 +dnl @result{}3 +dnl @result{}4 diff --git a/checks/222.improved_f b/checks/222.improved_f new file mode 100644 index 00000000..8dbe6a28 --- /dev/null +++ b/checks/222.improved_f @@ -0,0 +1,37 @@ +dnl @ ../doc/m4.texinfo:8114: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreach2.m4') +dnl @result{} +undivert(`foreach2.m4')dnl +dnl @result{}include(`quote.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# foreach(x, (item_1, item_2, ..., item_n), stmt) +dnl @result{}# parenthesized list, improved version +dnl @result{}define(`foreach', `pushdef(`$1')_$0(`$1', +dnl @result{} (dquote(dquote_elt$2)), `$3')popdef(`$1')') +dnl @result{}define(`_arg1', `$1') +dnl @result{}define(`_foreach', `ifelse(`$2', `(`')', `', +dnl @result{} `define(`$1', _arg1$2)$3`'$0(`$1', (dquote(shift$2)), `$3')')') +dnl @result{}divert`'dnl +traceon(`shift')debugmode(`aq') +dnl @result{} +foreach(`x', `(`1', `2', `3', `4')', `x +')dnl +dnl @error{}m4trace: -4- shift(`1', `2', `3', `4') +dnl @error{}m4trace: -4- shift(`2', `3', `4') +dnl @error{}m4trace: -4- shift(`3', `4') +dnl @result{}1 +dnl @error{}m4trace: -3- shift(``1'', ``2'', ``3'', ``4'') +dnl @result{}2 +dnl @error{}m4trace: -3- shift(``2'', ``3'', ``4'') +dnl @result{}3 +dnl @error{}m4trace: -3- shift(``3'', ``4'') +dnl @result{}4 +dnl @error{}m4trace: -3- shift(``4'') diff --git a/checks/223.improved_f b/checks/223.improved_f new file mode 100644 index 00000000..61802cd3 --- /dev/null +++ b/checks/223.improved_f @@ -0,0 +1,77 @@ +dnl @ ../doc/m4.texinfo:8168: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`foreach2.m4') +dnl @result{} +include(`foreachq2.m4') +dnl @result{} +dnl 0-element list: +foreach(`x', `', `<x>') / foreachq(`x', `', `<x>') +dnl @result{} / +dnl 1-element list of empty element +foreach(`x', `()', `<x>') / foreachq(`x', ``'', `<x>') +dnl @result{}<> / <> +dnl 2-element list of empty elements +foreach(`x', `(`',`')', `<x>') / foreachq(`x', ``',`'', `<x>') +dnl @result{}<><> / <><> +dnl 1-element list of a comma +foreach(`x', `(`,')', `<x>') / foreachq(`x', ``,'', `<x>') +dnl @result{}<,> / <,> +dnl 2-element list of unbalanced parentheses +foreach(`x', `(`(', `)')', `<x>') / foreachq(`x', ``(', `)'', `<x>') +dnl @result{}<(><)> / <(><)> +define(`ab', `oops')dnl using defn(`iterator') +foreach(`x', `(`a', `b')', `defn(`x')') /dnl + foreachq(`x', ``a', `b'', `defn(`x')') +dnl @result{}ab / ab +define(`active', `ACT, IVE') +dnl @result{} +traceon(`active') +dnl @result{} +dnl list of unquoted macros; expansion occurs before recursion +foreach(`x', `(active, active)', `<x> +')dnl +dnl @error{}m4trace: -4- active -> `ACT, IVE' +dnl @error{}m4trace: -4- active -> `ACT, IVE' +dnl @result{}<ACT> +dnl @result{}<IVE> +dnl @result{}<ACT> +dnl @result{}<IVE> +foreachq(`x', `active, active', `<x> +')dnl +dnl @error{}m4trace: -3- active -> `ACT, IVE' +dnl @error{}m4trace: -3- active -> `ACT, IVE' +dnl @result{}<ACT> +dnl @error{}m4trace: -3- active -> `ACT, IVE' +dnl @error{}m4trace: -3- active -> `ACT, IVE' +dnl @result{}<IVE> +dnl @result{}<ACT> +dnl @result{}<IVE> +dnl list of quoted macros; expansion occurs during recursion +foreach(`x', `(`active', `active')', `<x> +')dnl +dnl @error{}m4trace: -1- active -> `ACT, IVE' +dnl @result{}<ACT, IVE> +dnl @error{}m4trace: -1- active -> `ACT, IVE' +dnl @result{}<ACT, IVE> +foreachq(`x', ``active', `active'', `<x> +')dnl +dnl @error{}m4trace: -1- active -> `ACT, IVE' +dnl @result{}<ACT, IVE> +dnl @error{}m4trace: -1- active -> `ACT, IVE' +dnl @result{}<ACT, IVE> +dnl list of double-quoted macro names; no expansion +foreach(`x', `(``active'', ``active'')', `<x> +')dnl +dnl @result{}<active> +dnl @result{}<active> +foreachq(`x', ```active'', ``active''', `<x> +')dnl +dnl @result{}<active> +dnl @result{}<active> diff --git a/checks/224.improved_f b/checks/224.improved_f new file mode 100644 index 00000000..c3c7d0be --- /dev/null +++ b/checks/224.improved_f @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:8249: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dlimit=10 -Dverbose +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`loop.m4')dnl +dnl @result{} 1 2 3 4 5 6 7 8 9 10 diff --git a/checks/225.improved_f b/checks/225.improved_f new file mode 100644 index 00000000..74cba9d8 --- /dev/null +++ b/checks/225.improved_f @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:8259: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dlimit=10 -Dverbose -Dalt +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`loop.m4')dnl +dnl @result{} 1 2 3 4 5 6 7 8 9 10 diff --git a/checks/226.improved_f b/checks/226.improved_f new file mode 100644 index 00000000..8d403346 --- /dev/null +++ b/checks/226.improved_f @@ -0,0 +1,11 @@ +dnl @ ../doc/m4.texinfo:8269: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dlimit=10 -Dverbose -Dalt=4 +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`loop.m4')dnl +dnl @result{} 1 2 3 4 5 6 7 8 9 10 diff --git a/checks/227.improved_f b/checks/227.improved_f new file mode 100644 index 00000000..8d19ed9b --- /dev/null +++ b/checks/227.improved_f @@ -0,0 +1,10 @@ +dnl @ ../doc/m4.texinfo:8277: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dlimit=2500 -Dalt=4 +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`loop.m4')dnl diff --git a/checks/228.improved_f b/checks/228.improved_f new file mode 100644 index 00000000..384ccb99 --- /dev/null +++ b/checks/228.improved_f @@ -0,0 +1,14 @@ +dnl @ ../doc/m4.texinfo:8284: Origin of test +dnl @ expected status: 0 +dnl @ extra options: -Dlimit=10000 -Dalt=4 +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`foo', `divert`'len(popdef(`_foreachq')_foreachq($@))')dnl +define(`debug', `pushdef(`_foreachq', defn(`foo'))') +dnl @result{} +include(`loop.m4')dnl +dnl @result{}48894 diff --git a/checks/229.improved_c b/checks/229.improved_c new file mode 100644 index 00000000..7e1f47fd --- /dev/null +++ b/checks/229.improved_c @@ -0,0 +1,46 @@ +dnl @ ../doc/m4.texinfo:8347: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`stack_sep.m4') +dnl @result{} +define(`copy', `ifdef(`$2', `errprint(`$2 already defined +')m4exit(`1')', + `stack_foreach_sep(`$1', `pushdef(`$2',', `)')')')dnl +pushdef(`a', `1')pushdef(`a', defn(`divnum')) +dnl @result{} +copy(`a', `b') +dnl @result{} +b +dnl @result{}0 +popdef(`b') +dnl @result{} +b +dnl @result{}1 +pushdef(`c', `1')pushdef(`c', `2') +dnl @result{} +stack_foreach_sep_lifo(`c', `', `', `, ') +dnl @result{}2, 1 +undivert(`stack_sep.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# stack_foreach_sep(macro, pre, post, sep) +dnl @result{}# Invoke PRE`'defn`'POST with a single argument of each definition +dnl @result{}# from the definition stack of MACRO, starting with the oldest, and +dnl @result{}# separated by SEP between definitions. +dnl @result{}define(`stack_foreach_sep', +dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1')'dnl +dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1', `$2`'defn(`$1')$3', `$4`'')') +dnl @result{}# stack_foreach_sep_lifo(macro, pre, post, sep) +dnl @result{}# Like stack_foreach_sep, but starting with the newest definition. +dnl @result{}define(`stack_foreach_sep_lifo', +dnl @result{}`_stack_reverse_sep(`$1', `tmp-$1', `$2`'defn(`$1')$3', `$4`'')'dnl +dnl @result{}`_stack_reverse_sep(`tmp-$1', `$1')') +dnl @result{}define(`_stack_reverse_sep', +dnl @result{}`ifdef(`$1', `pushdef(`$2', defn(`$1'))$3`'popdef(`$1')$0( +dnl @result{} `$1', `$2', `$4$3')')') +dnl @result{}divert`'dnl diff --git a/checks/230.improved_c b/checks/230.improved_c new file mode 100644 index 00000000..9e2c178b --- /dev/null +++ b/checks/230.improved_c @@ -0,0 +1,16 @@ +dnl @ ../doc/m4.texinfo:8393: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`forloop3.m4')include(`stack_sep.m4')dnl +forloop(`i', `1', `10000', `pushdef(`s', i)') +dnl @result{} +define(`colon', `:')define(`dash', `-') +dnl @result{} +len(stack_foreach_sep(`s', `dash', `', `colon')) +dnl @result{}58893 diff --git a/checks/231.improved_m b/checks/231.improved_m new file mode 100644 index 00000000..2d7e7513 --- /dev/null +++ b/checks/231.improved_m @@ -0,0 +1,19 @@ +dnl @ ../doc/m4.texinfo:8416: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`wraplifo.m4') +dnl @result{} +m4wrap(`define(`foo', ``$0:'-$1-$*-$#-')foo(`a', `b') +') +dnl @result{} +builtin(`m4wrap', ``'define(`bar', ``$0:'-$1-$*-$#-')bar(`a', `b') +') +dnl @result{} +dnl @result{}bar:-a-a,b-2- +dnl @result{}m4wrap0:---0- diff --git a/checks/232.improved_m b/checks/232.improved_m new file mode 100644 index 00000000..52dc1880 --- /dev/null +++ b/checks/232.improved_m @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:8449: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`wraplifo2.m4') +dnl @result{} +undivert(`wraplifo2.m4')dnl +dnl @result{}dnl Redefine m4wrap to have LIFO semantics, improved example. +dnl @result{}include(`join.m4')dnl +dnl @result{}define(`_m4wrap', defn(`m4wrap'))dnl +dnl @result{}define(`_arg1', `$1')dnl +dnl @result{}define(`m4wrap', +dnl @result{}`ifdef(`_$0_text', +dnl @result{} `define(`_$0_text', joinall(` ', $@)defn(`_$0_text'))', +dnl @result{} `_$0(`_arg1(defn(`_$0_text')undefine(`_$0_text'))')dnl +dnl @result{}define(`_$0_text', joinall(` ', $@))')')dnl +m4wrap(`define(`foo', ``$0:'-$1-$*-$#-')foo(`a', `b') +') +dnl @result{} +m4wrap(`lifo text +m4wrap(`nested', `', `$@ +')') +dnl @result{} +dnl @result{}lifo text +dnl @result{}foo:-a-a,b-2- +dnl @result{}nested $@ diff --git a/checks/233.improved_c b/checks/233.improved_c new file mode 100644 index 00000000..69367148 --- /dev/null +++ b/checks/233.improved_c @@ -0,0 +1,31 @@ +dnl @ ../doc/m4.texinfo:8485: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`cleardivert', + `pushdef(`_n', divnum)divert(`-1')undivert($@)divert(_n)popdef(`_n')') +dnl @result{} +divert(`1')one +divert +dnl @result{} +cleardivert +dnl @result{} +undivert +dnl @result{}one +dnl @result{} +define(`cleardivert', + `pushdef(`_num', divnum)divert(`-1')ifelse(`$#', `0', + `undivert`'', `undivert($@)')divert(_num)popdef(`_num')') +dnl @result{} +divert(`2')two +divert +dnl @result{} +cleardivert +dnl @result{} +undivert +dnl @result{} diff --git a/checks/234.improved_c b/checks/234.improved_c new file mode 100644 index 00000000..ff30cc38 --- /dev/null +++ b/checks/234.improved_c @@ -0,0 +1,37 @@ +dnl @ ../doc/m4.texinfo:8521: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`capitalize.m4')dnl +define(`active', `act1, ive')dnl +define(`Active', `Act2, Ive')dnl +define(`ACTIVE', `ACT3, IVE')dnl +upcase(active) +dnl @result{}ACT1,IVE +upcase(`active') +dnl @result{}ACT3, IVE +upcase(``active'') +dnl @result{}ACTIVE +downcase(ACTIVE) +dnl @result{}act3,ive +downcase(`ACTIVE') +dnl @result{}act1, ive +downcase(``ACTIVE'') +dnl @result{}active +capitalize(active) +dnl @result{}Act1 +capitalize(`active') +dnl @result{}Active +capitalize(``active'') +dnl @result{}_capitalize(`active') +define(`A', `OOPS') +dnl @result{} +capitalize(active) +dnl @result{}OOPSct1 +capitalize(`active') +dnl @result{}OOPSctive diff --git a/checks/235.improved_c b/checks/235.improved_c new file mode 100644 index 00000000..bdaf7e94 --- /dev/null +++ b/checks/235.improved_c @@ -0,0 +1,36 @@ +dnl @ ../doc/m4.texinfo:8598: Origin of test +dnl @ expected status: 0 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +include(`capitalize2.m4')dnl +define(`active', `act1, ive')dnl +define(`Active', `Act2, Ive')dnl +define(`ACTIVE', `ACT3, IVE')dnl +define(`A', `OOPS')dnl +capitalize(active; `active'; ``active''; ```actIVE''') +dnl @result{}Act1,Ive; Act2, Ive; Active; `Active' +undivert(`capitalize2.m4')dnl +dnl @result{}divert(`-1') +dnl @result{}# upcase(text) +dnl @result{}# downcase(text) +dnl @result{}# capitalize(text) +dnl @result{}# change case of text, improved version +dnl @result{}define(`upcase', `translit(`$*', `a-z', `A-Z')') +dnl @result{}define(`downcase', `translit(`$*', `A-Z', `a-z')') +dnl @result{}define(`_arg1', `$1') +dnl @result{}define(`_to_alt', `changequote(`<<[', `]>>')') +dnl @result{}define(`_from_alt', `changequote(<<[`]>>, <<[']>>)') +dnl @result{}define(`_upcase_alt', `translit(<<[$*]>>, <<[a-z]>>, <<[A-Z]>>)') +dnl @result{}define(`_downcase_alt', `translit(<<[$*]>>, <<[A-Z]>>, <<[a-z]>>)') +dnl @result{}define(`_capitalize_alt', +dnl @result{} `regexp(<<[$1]>>, <<[^\(\w\)\(\w*\)]>>, +dnl @result{} <<[_upcase_alt(<<[<<[\1]>>]>>)_downcase_alt(<<[<<[\2]>>]>>)]>>)') +dnl @result{}define(`capitalize', +dnl @result{} `_arg1(_to_alt()patsubst(<<[<<[$*]>>]>>, <<[\w+]>>, +dnl @result{} _from_alt()`]>>_$0_alt(<<[\&]>>)<<['_to_alt())_from_alt())') +dnl @result{}divert`'dnl diff --git a/checks/236.improved_f b/checks/236.improved_f new file mode 100644 index 00000000..907b1c2a --- /dev/null +++ b/checks/236.improved_f @@ -0,0 +1,21 @@ +dnl @ ../doc/m4.texinfo:8642: Origin of test +dnl @ expected status: 1 +dnl @ extra options: +dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software +dnl @ Foundation, Inc. +dnl @ This file is free software; the Free Software Foundation +dnl @ gives unlimited permission to copy and/or distribute it +dnl @ with or without modifications, as long as this notice +dnl @ is preserved. +define(`fatal_error', + `errprint(ifdef(`__program__', `__program__', ``m4'')'dnl +`:ifelse(__line__, `0', `', + `__file__:__line__:')` fatal error: $* +')m4exit(`1')') +dnl @result{} +m4wrap(`divnum(`demo of internal message') +fatal_error(`inside wrapped text')') +dnl @result{} +dnl @error{}m4:stdin:6: Warning: excess arguments to builtin `divnum' ignored +dnl @result{}0 +dnl @error{}m4:stdin:6: fatal error: inside wrapped text diff --git a/checks/Makefile.in b/checks/Makefile.in new file mode 100644 index 00000000..7f6f7645 --- /dev/null +++ b/checks/Makefile.in @@ -0,0 +1,93 @@ +## Makefile.in - template for building Makefile for M4 testsuite. +## +## Copyright (C) 1992-1994, 2006-2011 Free Software Foundation, Inc. +## +## This file is part of GNU M4. +## +## GNU M4 is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## GNU M4 is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. + +@SET_MAKE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = @SHELL@ + +bindir = @bindir@ +exec_prefix = @exec_prefix@ +prefix = @prefix@ +srcdir = @srcdir@ +VPATH = @srcdir@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +program_transform_name = @program_transform_name@ + +# Should be GNU awk, for the get-them script. +AWK = @AWK@ + +# Vern says that the first star is required around an Alpha make bug. +DOC_CHECKS = $(srcdir)/*[0-9][0-9][0-9].* +CHECKS = $(DOC_CHECKS) $(srcdir)/stackovf.test +# Makefile.in is automatically distributed by automake. +DISTFILES = $(srcdir)/get-them $(srcdir)/check-them $(srcdir)/stamp-checks \ + $(srcdir)/stackovf.test + +all: $(srcdir)/stamp-checks + +$(srcdir)/stamp-checks: $(srcdir)/get-them $(srcdir)/../doc/m4.texinfo + rm -f $(DOC_CHECKS) + cd $(srcdir) && AWK=$(AWK) ./get-them ../doc/m4.texinfo + touch $(srcdir)/stamp-checks + +install: + +dvi pdf ps html info: +install-dvi install-pdf install-ps install-html install-info: + +uninstall: + +check: $(srcdir)/stamp-checks + PATH=`pwd`/../src"$(PATH_SEPARATOR)"$$PATH; export PATH; \ + $(srcdir)/check-them -I $(srcdir)/../examples $(CHECKS) + +installcheck: $(srcdir)/stamp-checks + PATH='$(bindir)'"$(PATH_SEPARATOR)"$$PATH; export PATH; \ + $(srcdir)/check-them -I $(srcdir)/../examples \ + -m "`echo m4 | sed '$(program_transform_name)'`" $(CHECKS) + +tags: + +mostlyclean: + +clean: mostlyclean + +distclean: clean + rm -f Makefile + +maintainer-clean realclean: distclean + rm -f $(DOC_CHECKS) $(srcdir)/stamp-checks + +distdir: dist + +dist: $(DISTFILES) + @echo "Copying distribution files" + @for file in $(DISTFILES) $(DOC_CHECKS); do \ + ln $$file ../$(PACKAGE)-$(VERSION)/checks 2> /dev/null \ + || cp -p $$file ../$(PACKAGE)-$(VERSION)/checks; \ + done + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && ./config.status checks/$@ + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/checks/check-them b/checks/check-them new file mode 100755 index 00000000..b936a2ad --- /dev/null +++ b/checks/check-them @@ -0,0 +1,191 @@ +#!/bin/sh +# Check GNU m4 against examples from the manual source. +# Copyright (C) 1992, 2006-2011 Free Software Foundation, Inc. +# +# This file is part of GNU M4. +# +# GNU M4 is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU M4 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Clean up temp files on exit +pwd=`pwd` +tmp=m4-tmp.$$ +trap 'stat=$?; cd "$pwd"; rm -rf $tmp && exit $stat' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +# Create scratch dir +framework_failure=0 +mkdir $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +out=$tmp/m4-out +err=$tmp/m4-err +xout=$tmp/m4-xout +xerr=$tmp/m4-xerr +failed= +skipped= +strip_needed=false +diffopts=-c + +# Allow user to select sed +: ${SED=sed} + +# Find out where the examples live. +examples=. +if test "x$1" = x-I ; then + examples="$2" + shift; shift +fi + +# Find out how to run m4. +m4=m4 +if test "x$1" = x-m ; then + m4="$2" + shift; shift +fi + +# Find out how the executable prints argv[0] +m4name=`"$m4" --help | ${SED} -e 's/Usage: \(.*\) \[OPTION.*/\1/' \ + -e 's/\\\\/\\\\\\\\/g' -e 1q` + +# Find out if we should strip \r in the output +"$m4" --version | tee $out +"$m4" --version | tr -d '\015' > $xout +if cmp -s $out $xout; then + : +else + echo "Ignoring carriage returns" + strip_needed=: +fi + +# Find out if diff supports useful options. +if diff -u /dev/null /dev/null 2>/dev/null ; then + diffopts="-u" +fi +if diff -a /dev/null /dev/null 2>/dev/null ; then + diffopts="$diffopts -a" +fi + +# Run the tests. +for file +do + test -f "$file" || { + echo "No such file: $file" + continue + } + echo "Checking $file" + + case $file in + *stackovf.test) + "$file" "$m4" + case $? in + 77) skipped="$skipped $file";; + 0) ;; + *) failed="$failed $file" + esac + continue ;; + esac + + options=`${SED} -ne '3s/^dnl @ extra options: //p;3q' "$file"` + ${SED} -e '/^dnl @/d' -e '/^\^D$/q' "$file" \ + | LC_MESSAGES=C M4PATH=$examples "$m4" -d $options - >$out 2>$err + stat=$? + + xstat=`${SED} -ne '2s/^dnl @ expected status: //p;2q' "$file"` + case $stat in + 77) + skipped="$skipped $file" + cat $err + continue + ;; + $xstat) ;; + *) + failed="$failed $file:status" + echo `${SED} -e 's/^dnl //' -e 1q $file` + echo "$file: status was $stat, expected $xstat" + ;; + esac + + xoutfile=`${SED} -n 's/^dnl @ expected output: //p' "$file"` + if test -z "$xoutfile" ; then + ${SED} -e '/^dnl @result{}/!d' -e 's///' -e "s|examples/|$examples/|" \ + "$file" > $xout + else + cp "$examples/$xoutfile" $xout + fi + + xerrfile=`${SED} -n 's/^dnl @ expected error: //p' "$file"` + case $xerrfile in + ignore) + cp $err $xerr ;; + '') + ${SED} '/^dnl @error{}/!d + s///; '"s|^m4:|$m4name:|; s|examples/|$examples/|" \ + "$file" > $xerr ;; + *) + ${SED} "s|^m4:|$m4name:|; s|examples/|$examples/|" \ + "$examples/$xerrfile" > $xerr ;; + esac + + # For the benefit of mingw, normalize \r\n line endings + if $strip_needed ; then + tr -d '\015' < $out > $out.t + mv $out.t $out + tr -d '\015' < $xout > $xout.t + mv $xout.t $xout + tr -d '\015' < $err > $err.t + mv $err.t $err + tr -d '\015' < $xerr > $xerr.t + mv $xerr.t $xerr + fi + + if cmp -s $out $xout; then + : + else + failed="$failed $file:out" + echo `${SED} -e 's/^dnl //' -e 1q $file` + echo "$file: stdout mismatch" + diff $diffopts $xout $out + fi + + if cmp -s $err $xerr; then + : + else + failed="$failed $file:err" + echo `${SED} -e 's/^dnl //' -e 1q $file` + echo "$file: stderr mismatch" + diff $diffopts $xerr $err + fi + +done + +rm -f $out $err $xout $xerr + +echo +if test -n "$skipped"; then + echo "Skipped checks were:" + echo " $skipped" +fi +if test -z "$failed"; then + echo "All checks successful" + stat=0 +else + echo "Failed checks were:" + echo " $failed" + stat=1 +fi +(exit $stat); exit $stat diff --git a/checks/get-them b/checks/get-them new file mode 100755 index 00000000..8f953b72 --- /dev/null +++ b/checks/get-them @@ -0,0 +1,137 @@ +#!/bin/sh +# -*- AWK -*- +# Extract all examples from the manual source. +# Copyright (C) 1992, 2005-2011 Free Software Foundation, Inc. +# +# This file is part of GNU M4. +# +# GNU M4 is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU M4 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This script was designed under GNU awk, but hopefully portable to +# other implementations. + +FILE=${1-/dev/null} +: ${AWK=awk} + +$AWK ' + +BEGIN { + node = ""; + seq = -1; + count = 0; + file = "NONE"; + status = 0; + options = ""; + xout = ""; + xerr = ""; +} + +/^@node / { + if (seq > 0) + printf(" -- %d file%s", seq, seq == 1 ? "" : "s"); + if (seq >= 0) + printf("\n"); + + split($0, tmp, ","); + node = substr(tmp[1], 7); + if (length(node) > 10) + printf("Node: %s - truncated", node); + else + printf("Node: %s ", node); + gsub(" ", "_", node); + node = tolower(substr(node, 1, 10)); + seq = 0; +} + +/^@comment ignore$/ { + getline; + status = 0; + options = ""; + xout = ""; + xout = ""; + next; +} + +/^@comment status: / { + status = $3; +} + +/^@comment options: / { + options = $0; + gsub ("@comment options:", "", options); +} + +/^@comment xout: / { + xout = $0; + gsub ("@comment xout: ", "", xout); +} + +/^@comment xerr: / { + xerr = $0; + gsub ("@comment xerr: ", "", xerr); +} + +/^@example$/, /^@end example$/ { + if (seq < 0) + next; + if ($0 ~ /^@example$/) { + if (count > 0) + close (file); + seq++; + count++; + file = sprintf("%03d.%s", count, node); + printf("dnl @ %s:%d: Origin of test\n"\ + "dnl @ expected status: %d\n"\ + "dnl @ extra options: %s\n"\ + "dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software\n"\ + "dnl @ Foundation, Inc.\n"\ + "dnl @ This file is free software; the Free Software Foundation\n"\ + "dnl @ gives unlimited permission to copy and/or distribute it\n"\ + "dnl @ with or without modifications, as long as this notice\n"\ + "dnl @ is preserved.\n", FILENAME, NR, status, options) > file; + if (xout) + printf("dnl @ expected output: %s\n", xout) > file; + if (xerr) + printf("dnl @ expected error: %s\n", xerr) > file; + status = 0; + options = ""; + xout = ""; + xerr = ""; + next; + } + if ($0 ~ /^@end example$/) { + next; + } + if ($0 ~ /^\^D$/) + next; + if ($0 ~ /^\$ @kbd/) + next; + if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/) + prefix = "dnl "; + else + prefix = ""; + gsub("@@", "@", $0); + gsub("@[{]", "{", $0); + gsub("@}", "}", $0); + gsub("@w[{] }", " ", $0); + gsub("@tabchar[{]}", "\t", $0); + printf("%s%s\n", prefix, $0) >> file; +} + +END { + printf("\n"); + if (count > 0) + close(file); +} +' $FILE diff --git a/checks/stackovf.test b/checks/stackovf.test new file mode 100755 index 00000000..4b8e1399 --- /dev/null +++ b/checks/stackovf.test @@ -0,0 +1,99 @@ +#!/bin/sh +# This file is part of the GNU m4 testsuite +# Copyright (C) 2000, 2003, 2007-2011 Free Software Foundation, Inc. +# +# This file is part of GNU M4. +# +# GNU M4 is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GNU M4 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Script to verify that stack overflow is diagnosed properly when +# there is infinite macro call nesting, provided the OS supports it. + +m4="$1" + +# Skip this test if -L defaults to 1024 instead of 0, as that is our +# indicator that the OS does not support stack overflow detection. +("$m4" --help | grep 'nesting.*\[0\]') >/dev/null 2>&1 \ + || { + echo "$0: skipping test, no stack overflow support detected in $m4" + exit 77 + } + +# On some systems the ulimit command is available in ksh or bash but not sh +(exec 2>/dev/null; ulimit -Ss 300) || { + for altshell in bash bsh ksh zsh ; do + if (exec >/dev/null 2>&1; $altshell -c 'ulimit -Ss 300') && test -z "$2" + then + echo "Using $altshell because it supports ulimit" + exec $altshell "$0" "$@" running-with-$altshell + exit 1 + fi + done +} + +tmpdir= +trap 'st=$?; rm -rf "$tmpdir" && exit $st' 0 +trap '(exit $?); exit $?' 1 2 3 15 + +# Create a temporary subdirectory $tmpdir in $TMPDIR (default /tmp). +# Use mktemp if possible; otherwise fall back on mkdir, +# with $RANDOM to make collisions less likely. +: ${TMPDIR=/tmp} +{ + tmpdir=` + (umask 077 && mktemp -d "$TMPDIR/m4stk-XXXXXX") 2>/dev/null + ` && + test -n "$tmpdir" && test -d "$tmpdir" +} || { + tmpdir=$TMPDIR/m4stk-$$-$RANDOM + (umask 077 && mkdir "$tmpdir") +} || exit $? +tmpfile="$tmpdir"/m4.out + +# Limit the stack size if the shell we are running permits it +if (exec 2>/dev/null; ulimit -Ss 300) +then + ulimit -Ss 300 + echo "Stack soft limit set to `ulimit -s`K"; +else + echo "Can't reset stack limit - this may take a while..." +fi + +# Induce stack overflow. +echo 'define(a,a(a))a' | "$m4" > "$tmpfile" 2>&1 +result=$? + +exitcode=1 +if test $result -eq 0 ; then + echo "Failure - $m4 did not abort" +else + # See if stack overflow was diagnosed. + case `cat "$tmpfile"` in + *stack\ overflow*) + case `echo "$tmpdir"/*` in + $tmpfile) + echo "Pass" + exitcode=0 ;; + *) echo "Failure - $m4 created unexpected core dump" + ls -l "$tmpdir" ;; + esac ;; + *) echo "Failure - $m4 aborted unexpectedly"; + ;; + esac +fi + +test $exitcode = 0 || + { echo "Output from $m4:"; cat $tmpfile; } + +exit $exitcode diff --git a/checks/stamp-checks b/checks/stamp-checks new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/checks/stamp-checks |