Skip to content

Commit

Permalink
Commit 36
Browse files Browse the repository at this point in the history
- New macros `n4_rshift()`, `n4_rshift2()` and `n4_rshift3()` have been created
  in `not-m4sugar.m4`
- Code review (macro `NA_HELP_STRINGS()` in `not-autotools.m4`; macros
  `NS_TEST_AEQ()` and `NS_TEST_NAE()` in `not-autoshell.m4`)
- Documentation
  • Loading branch information
madmurphy committed Oct 20, 2021
1 parent 4fe79e3 commit 99e7642
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 92 deletions.
12 changes: 12 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ Change Log
==========


2.2.0
-----

Changes:

* New macros `n4_rshift()`, `n4_rshift2()` and `n4_rshift3()` have been created
in `not-m4sugar.m4`
* Code review (macro `NA_HELP_STRINGS()` in `not-autotools.m4`; macros
`NS_TEST_AEQ()` and `NS_TEST_NAE()` in `not-autoshell.m4`)
* Documentation


2.1.0
-----

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ most of the macros are independent from each other, so you can just copy and
paste what you need. The few cases where a macro depends on a helper macro are
documented.

Each macro is versioned. If you copy and paste one or more macros, please do
come back once in a while and check if newer versions are available. The
version strings express semantic versioning, thus if a major version number has
changed the newer macro will likely require some manual intervention in the
caller's code. Minor changes and bug fixes instead will work out of the box.

For the complete list of the macros released by the **Not Autotools** project,
please see [`macro-index.md`][1].
please refer to [`macro-index.md`][1].

Feel free to contribute. For any questions, [drop a message][2].

Expand Down
2 changes: 1 addition & 1 deletion collection-utils/macro-index-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
echo '==========================='
echo
echo 'This is the complete list of macros released by the **Not Autotools** project.'
(cd .. && find 'm4' -type f -name '*.m4' -printf '\n\n## `%p`\n\n' \
(cd .. && find 'm4' -type f -name '*.m4' -printf '\n\n## [`%p`](%p)\n\n' \
-exec grep -oPHn '(?<=^dnl )\w+\(\)?' '{}' ';') | \
sed 's/()$//g;s/($/()/g;s,\([^:]\+\):\([^:]\+\):\([^(]\+\(()\)\?\)$,* [`\3`](\1#L\2),g'
echo
Expand Down
2 changes: 1 addition & 1 deletion m4/not-ac-messages.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dnl **************************************************************************


dnl **************************************************************************
dnl M E S S A G E B O X E S F O R A U T O C O N F
dnl M E S S A G E B O X E S F O R G N U A U T O C O N F
dnl **************************************************************************


Expand Down
8 changes: 4 additions & 4 deletions m4/not-autoshell.m4
Original file line number Diff line number Diff line change
Expand Up @@ -554,13 +554,13 @@ dnl test "?two?three?four" != "?one?one?one"
dnl
dnl Expansion type: shell code
dnl Requires: nothing
dnl Version: 1.0.1
dnl Version: 1.0.2
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NS_TEST_AEQ],
[m4_if([$#], [0], [:], [$#], [1], [:],
[test "_AS_QUOTE(m4_dquote(?[]m4_joinall(?, m4_shift($@))))" = "_AS_QUOTE(m4_dquote(m4_for([], [2], [$#], [1], [[?$1]])))"])])
[test "_AS_QUOTE(m4_dquote([?]m4_joinall([?], m4_shift($@))))" = "_AS_QUOTE(m4_dquote(m4_for([], [2], [$#], [1], [[?$1]])))"])])


dnl NS_TEST_NAE(string1, string2[, string3[, ... stringN]])
Expand Down Expand Up @@ -598,13 +598,13 @@ dnl test "?two?three?four" != "?one?one?one"
dnl
dnl Expansion type: shell code
dnl Requires: nothing
dnl Version: 1.0.1
dnl Version: 1.0.2
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NS_TEST_NAE],
[m4_if([$#], [0], [:], [$#], [1], [:],
[test "_AS_QUOTE(m4_dquote(?[]m4_joinall(?, m4_shift($@))))" != "_AS_QUOTE(m4_dquote(m4_for([], [2], [$#], [1], [[?$1]])))"])])
[test "_AS_QUOTE(m4_dquote([?]m4_joinall([?], m4_shift($@))))" != "_AS_QUOTE(m4_dquote(m4_for([], [2], [$#], [1], [[?$1]])))"])])


dnl NS_TEXT_WRAP(text[, max-width=79])
Expand Down
6 changes: 3 additions & 3 deletions m4/not-autotools.m4
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,13 @@ dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Version: 1.0.1
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NA_HELP_STRINGS],
[m4_if(m4_count($1), [1],
[m4_if([$#], [0], [], [$#], [1],
[m4_if([$#], [0], [], m4_count($1), [1],
[m4_if([$#], [1],
[m4_text_wrap($1, [ ])],
[AS_HELP_STRING(m4_normalize($1), [$2])m4_if([$#], [2], [], [m4_newline()NA_HELP_STRINGS(m4_shift2($@))])])],
[m4_text_wrap(m4_car($1)[,], [ ])m4_newline()NA_HELP_STRINGS(m4_dquote(m4_shift($1))m4_if([$#], [1], [], [, m4_shift($@)]))])])
Expand Down
12 changes: 6 additions & 6 deletions m4/not-autoversion.m4
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ dnl # `Hello world!` and `GUITAR` will be ignored
dnl [[a94d2aa],
dnl [IMPLEMENTATION],
dnl [Hello world!],
dnl [MISCELLANEA],
dnl [MILESTONE],
dnl [GUITAR]]
dnl
dnl The advantage of this approach is that you won't have to worry about
Expand Down Expand Up @@ -235,9 +235,9 @@ dnl * `NR_HISTORY_CURRENT_EVENT_NAME`
dnl * `NR_HISTORY_CURRENT_VSTATE`
dnl * `NR_HISTORY_ROOT_VSTATE`
dnl
dnl A project's documentation is not versioned by this framework (hence why
dnl the generic `MISCELLANEA` token must be used for referring to it), as
dnl there are no known mechanical rules for versioning a documentation.
dnl The documentation will not be versioned by this framework (hence why the
dnl generic `MISCELLANEA` token must be used for referring to it), as there
dnl are no known mechanical rules for versioning a documentation.
dnl
dnl The first ten macros expand to positive integers. In particular,
dnl
Expand Down Expand Up @@ -299,15 +299,15 @@ dnl NC_AUTOVERSION_SUBSTITUTIONS
dnl ...
dnl AC_OUTPUT
dnl
dnl The substitutions will have names identical to their M4 counterparts, but
dnl The substitutions will have names identical to their m4 counterparts, but
dnl will not have the `NR_` prefix -- more or less like the `AC_PACKAGE_NAME`
dnl literal produces a `PACKAGE_NAME` `configure` substitution, without the
dnl `AC_` prefix. For example, `NR_PROJECT_MAJVER`'s substitution will be
dnl named `PROJECT_MAJVER`.
dnl
dnl If you don't need the whole group of literals, you can manually pick up
dnl only the literals that you need instead of invoking
dnl `NC_AUTOVERSION_SUBSTITUTIONS`, thus creating a smaller set of targeted
dnl `NC_AUTOVERSION_SUBSTITUTIONS`, and create a smaller set of targeted
dnl substitutions:
dnl
dnl
Expand Down
176 changes: 129 additions & 47 deletions m4/not-m4sugar.m4
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,88 @@ m4_define([n4_arg_index],
[n4_list_index([$1], m4_dquote(m4_shift($@)))])


dnl n4_rshift(arg1[, arg2[, arg3[, ... argN]]])
dnl **************************************************************************
dnl
dnl Reversed shift -- like `m4_reverse(m4_shift(m4_reverse(arg1, ... argN)))`,
dnl but more efficient
dnl
dnl For example,
dnl
dnl n4_rshift([one], [two], [three], [four], [five])
dnl
dnl expands to
dnl
dnl one, two, three, four
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_rshift],
[m4_if([$#], [0], [], [$#], [1], [], [$#], [2], [[$1]],
[[$1], n4_rshift(m4_shift($@))])])


dnl n4_rshift2(arg1[, arg2[, arg3[, ... argN]]])
dnl **************************************************************************
dnl
dnl Like `n4_rshift()`, but trimming two arguments instead of one
dnl
dnl For example,
dnl
dnl n4_rshift2([one], [two], [three], [four], [five])
dnl
dnl expands to
dnl
dnl one, two, three
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_rshift2],
[m4_if([$#], [0], [], [$#], [1], [], [$#], [2], [], [$#], [3], [[$1]],
[[$1], n4_rshift2(m4_shift($@))])])


dnl n4_rshift3(arg1[, arg2[, arg3[, ... argN]]])
dnl **************************************************************************
dnl
dnl Like `n4_rshift()`, but trimming three arguments instead of one
dnl
dnl For example,
dnl
dnl n4_rshift3([one], [two], [three], [four], [five])
dnl
dnl expands to
dnl
dnl one, two
dnl
dnl For wider shifts please use `m4_shiftn()` + `m4_reverse()` -- i.e.
dnl `m4_reverse(m4_shiftn(num, m4_reverse(arg1, arg2, arg3, ... argN)))`.
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_rshift3],
[m4_if([$#], [0], [], [$#], [1], [], [$#], [2], [], [$#], [3], [], [$#], [4], [[$1]],
[[$1], n4_rshift3(m4_shift($@))])])


dnl n4_set_counter(counter-name[, initial-value = 0[, default-increase = 1]])
dnl **************************************************************************
dnl
Expand Down Expand Up @@ -756,6 +838,53 @@ m4_define([n4_nquote],
[m4_dquote(n4_nquote(m4_decr([$1]), m4_shift($@)))])])])
dnl n4_bind(original-macro, new-macro, arg1[, arg2[, arg3[, ... argN]]])
dnl **************************************************************************
dnl
dnl Creates a new macro that invokes `original-macro` with `arg1`, `arg2` ...
dnl `argN` as initial arguments
dnl
dnl This macro is the m4 version of ECMAScript `Function.prototype.bind()`.
dnl
dnl For example,
dnl
dnl m4_define([MY_UNBOUND_MACRO], [
dnl First argument is: `$1`
dnl Second argument is: `$2`
dnl Third argument is: `$3`
dnl Fourth argument is: `$4`])
dnl
dnl n4_bind([MY_UNBOUND_MACRO],
dnl [MY_BOUND_MACRO], [foo], [bar])
dnl
dnl MY_UNBOUND_MACRO([hello], [world])
dnl MY_BOUND_MACRO([hello], [world])
dnl
dnl expands to
dnl
dnl First argument is: `hello`
dnl Second argument is: `world`
dnl Third argument is: ``
dnl Fourth argument is: ``
dnl
dnl First argument is: `foo`
dnl Second argument is: `bar`
dnl Third argument is: `hello`
dnl Fourth argument is: `world`
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal (void)
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_bind],
[m4_define([$2],
[$1(]m4_dquote(m4_shift2($@))[m4_if(]m4_dquote([$][#])[, [0], [], ]m4_dquote([, $][@])[))])])
dnl n4_expanded_once(placeholder, macro[, arg1[, arg2[, ... argN ]]])
dnl **************************************************************************
dnl
Expand Down Expand Up @@ -1111,53 +1240,6 @@ m4_define([n4_burn_out],
[n4_burn_out(_tmp_)])[]m4_popdef([_tmp_])])
dnl n4_bind(original-macro, new-macro, arg1[, arg2[, arg3[, ... argN]]])
dnl **************************************************************************
dnl
dnl Creates a new macro that invokes `original-macro` with `arg1`, `arg2` ...
dnl `argN` as initial arguments
dnl
dnl This macro is the m4 version of ECMAScript `Function.prototype.bind()`.
dnl
dnl For example,
dnl
dnl m4_define([MY_UNBOUND_MACRO], [
dnl First argument is: `$1`
dnl Second argument is: `$2`
dnl Third argument is: `$3`
dnl Fourth argument is: `$4`])
dnl
dnl n4_bind([MY_UNBOUND_MACRO],
dnl [MY_BOUND_MACRO], [foo], [bar])
dnl
dnl MY_UNBOUND_MACRO([hello], [world])
dnl MY_BOUND_MACRO([hello], [world])
dnl
dnl expands to
dnl
dnl First argument is: `hello`
dnl Second argument is: `world`
dnl Third argument is: ``
dnl Fourth argument is: ``
dnl
dnl First argument is: `foo`
dnl Second argument is: `bar`
dnl Third argument is: `hello`
dnl Fourth argument is: `world`
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal (void)
dnl Requires: nothing
dnl Version: 1.0.0
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_bind],
[m4_define([$2],
[$1(]m4_dquote(m4_shift2($@))[m4_if(]m4_dquote([$][#])[, [0], [], ]m4_dquote([, $][@])[))])])
dnl n4_includedir(directory)
dnl **************************************************************************
dnl
Expand Down
Loading

0 comments on commit 99e7642

Please sign in to comment.