Skip to content

Commit

Permalink
Commit 35
Browse files Browse the repository at this point in the history
* New macro `n4_bind()`, has been created in `not-m4sugar.m4`
* Code review (macro `n4_burn_out()` in `not-m4sugar.m4`; macro `n4_sp()` in
  `not-fancy-texts.m4`; macro `NR_CONFIG_FILES()` in `not-autoreconf.m4`;
  macros `NC_MSG_ERRORBOX()` and `NC_MSG_FAILUREBOX()` in `not-ac-messages.m4`)
* Documentation
  • Loading branch information
madmurphy committed Oct 6, 2021
1 parent 5111008 commit 4fe79e3
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 162 deletions.
18 changes: 15 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@ Change Log
==========


2.1.0
-----

Changes:

* New macro `n4_bind()`, has been created in `not-m4sugar.m4`
* Code review (macro `n4_burn_out()` in `not-m4sugar.m4`; macro `n4_sp()` in
`not-fancy-texts.m4`; macro `NR_CONFIG_FILES()` in `not-autoreconf.m4`;
macros `NC_MSG_ERRORBOX()` and `NC_MSG_FAILUREBOX()` in `not-ac-messages.m4`)
* Documentation


2.0.0
------
-----

Changes:

Expand Down Expand Up @@ -67,7 +79,7 @@ Changes:


1.1.0
------
-----

Changes:

Expand All @@ -81,7 +93,7 @@ Changes:


1.0.0
------
-----

Changes:

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 @@ -12,7 +12,7 @@
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' \
-exec grep -oPHn '(?<=^dnl )\w+\(\)?' '{}' ';') | \
sed 's/()$//g;s/($/()/g;s,\([^:]\+\):\([^:]\+\):\([^(]\+\(()\)\?\)$,* [\3](\1#L\2),g'
sed 's/()$//g;s/($/()/g;s,\([^:]\+\):\([^:]\+\):\([^(]\+\(()\)\?\)$,* [`\3`](\1#L\2),g'
echo
} > ../macro-index.md

22 changes: 12 additions & 10 deletions m4/not-ac-messages.m4
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ dnl This macro may be invoked only after having invoked `AC_INIT()`.
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([NC_MSG_ERRORBOX],
[AC_MSG_ERROR([m4_text_wrap([$1 --------------------------------------------------------------------],
[ | ],
[-------------------------------------------------------------],
[79])]m4_if(m4_eval([$# > 1]), [1], [, [$2]]))])
[m4_if([$#], [0], [],
[AC_MSG_ERROR([m4_text_wrap([$1 --------------------------------------------------------------------],
[ | ],
[-------------------------------------------------------------],
[79])]m4_if([$#], [1], [], [, [$2]]))])])


dnl NC_MSG_FAILUREBOX(error-description[, exit-status])
Expand All @@ -93,15 +94,16 @@ dnl This macro may be invoked only after having invoked `AC_INIT()`.
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([NC_MSG_FAILUREBOX],
[AC_MSG_FAILURE([m4_text_wrap([$1 --------------------------------------------------------------------],
[ | ],
[-------------------------------------------------------------],
[79])]m4_if(m4_eval([$# > 1]), [1], [, [$2]]))])
[m4_if([$#], [0], [],
[AC_MSG_FAILURE([m4_text_wrap([$1 --------------------------------------------------------------------],
[ | ],
[-------------------------------------------------------------],
[79])]m4_if([$#], [1], [], [, [$2]]))])])



Expand Down
4 changes: 2 additions & 2 deletions m4/not-autoreconf.m4
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal (void)
dnl Requires: nothing
dnl Version: 1.0.0
dnl Version: 1.0.1
dnl Author: madmurphy
dnl
dnl **************************************************************************
AC_DEFUN([NR_CONFIG_FILES],
[m4_ifnblank([$1], [m4_pushdef([_sep_idx_], m4_quote(m4_bregexp([$1], [:])))m4_syscmd([cat << 'NA_END_OF_FILE' > ']m4_if(_sep_idx_, [-1], m4_normalize([[$1]]), [m4_normalize(m4_quote(m4_substr([$1], [0], _sep_idx_)))])[']m4_newline()m4_quote(m4_include(m4_if(_sep_idx_, [-1], m4_normalize([[$1.m4]]), [m4_normalize(m4_quote(m4_substr([$1], m4_eval(_sep_idx_[ + 1]))))])))[NA_END_OF_FILE])m4_popdef([_sep_idx_])])m4_if([$#], [1], [], [NR_CONFIG_FILES(m4_shift($@))])])
[m4_ifnblank([$1], [m4_pushdef([_sep_idx_], m4_quote(m4_bregexp([$1], [:])))m4_syscmd([cat << 'NA_END_OF_FILE' > ']m4_if(_sep_idx_, [-1], m4_normalize([[$1]]), [m4_normalize(m4_quote(m4_substr([$1], [0], _sep_idx_)))])[']m4_newline()m4_quote(m4_include(m4_if(_sep_idx_, [-1], m4_normalize([[$1.m4]]), [m4_normalize(m4_quote(m4_substr([$1], m4_incr(_sep_idx_))))])))[NA_END_OF_FILE])m4_popdef([_sep_idx_])])m4_if([$#], [1], [], [NR_CONFIG_FILES(m4_shift($@))])])


dnl NR_PROG_VERSION(program)
Expand Down
20 changes: 19 additions & 1 deletion m4/not-autoversion.m4
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,21 @@ dnl the latest release event (typically `CURRENT`), while
dnl `NR_HISTORY_CURRENT_VSTATE` and `NR_HISTORY_ROOT_VSTATE`
dnl contain the earliest and the latest version states available.
dnl
dnl NOTE: If your package installs different independent libraries, using the
dnl `NR_LIBTOOL_VERSION_INFO` literal might become problematic. You
dnl will have to choose whether using the same version info for all
dnl your libraries (in this case you can use `NR_LIBTOOL_VERSION_INFO`
dnl for it), or versioning each module differently by hand (and in this
dnl case you will have to either ignore `NR_LIBTOOL_VERSION_INFO`, or
dnl use it only for a module that you consider to be the main module of
dnl the package). The `NR_BINARY_VERSION` literal instead will never be
dnl affected by the presence of independent modules, as this literal
dnl always refers collectively to all the binaries shipped by your
dnl package (i.e. it is never the version of one single module, but of
dnl the entire set of binaries that your package generates altogether).
dnl The changes that you write in your history must in any case refer
dnl to the entire package as a whole.
dnl
dnl If used in conjunction with `NC_CONFIG_SHADOW_DIR()` (see
dnl `m4/not-extended-config.m4`), this framework literally makes it possible
dnl continuously to publish releases _without ever having to write a single
Expand Down Expand Up @@ -539,7 +554,7 @@ dnl


dnl NR_BUMP_VSTATE(project-major, project-minor, project-micro, current,
dnl revision, age, source-age, change1, change2, ... changeN)
dnl revision, age, source-age, change-list)
dnl **************************************************************************
dnl
dnl Applies one or more changes to a version state
Expand All @@ -548,6 +563,9 @@ dnl This macro is mainly intended to be used internally by
dnl `NR_RECORD_HISTORY()`; you will hardly ever need it. For the definition of
dnl a `change`, please refer to `NR_RECORD_HISTORY()`.
dnl
dnl The `change-list` argument corresponds to an `event` without its first
dnl member (i.e. without the event's name).
dnl
dnl This macro may be invoked before `AC_INIT()`.
dnl
dnl Expansion type: literal
Expand Down
6 changes: 3 additions & 3 deletions m4/not-fancy-texts.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ dnl Prints an arbitrary number of white spaces
dnl
dnl Expansion type: literal
dnl Requires: nothing
dnl Version: 1.0.0
dnl Version: 1.0.1
dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_sp],
[m4_if(m4_eval([$1 > 0]), [1],
[n4_sp(m4_eval([$1 - 1]))[ ]])])
[n4_sp(m4_decr([$1]))[ ]])])


dnl n4_newlines(text1[, text2[, text3[, ... textN]]])
dnl **************************************************************************
dnl
dnl Calls `m4_normalize()` for each argument, then returns all the results
dnl Calls `m4_normalize()` for each argument, then returns the results
dnl separated by a new line.
dnl
dnl For example,
Expand Down
83 changes: 79 additions & 4 deletions m4/not-m4sugar.m4
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,11 @@ dnl Author: madmurphy
dnl
dnl **************************************************************************
m4_define([n4_redepth],
[m4_len(m4_bpatsubst(m4_bpatsubst([$1], [\(\\\|)\|\([^\\]\|^\)\(\\\\\)*(\)\|\(\\\)(\|,], [\4]), [[^\\]], []))])
[m4_len(m4_bpatsubst(m4_bpatsubst([$1],
[\(\\\|)\|\([^\\]\|^\)\(\\\\\)*(\)\|\(\\\)(\|,],
[\4]),
[[^\\]],
[]))])
dnl n4_for_each_match(string, regexp, macro)
Expand Down Expand Up @@ -1053,7 +1057,7 @@ dnl
dnl m4_define([WTF], [a test])
dnl n4_burn_out([[[[[This is [[[WTF]]]. Bye!]]]]])
dnl
dnl expands to:
dnl expands to
dnl
dnl This is a test. Bye!
dnl
Expand All @@ -1071,16 +1075,87 @@ dnl
dnl m4_count(m4_unquote(n4_burn_out([Hi, how [[[[are]]]] [[you]]?])))
dnl => 2
dnl
dnl Each expansion happens once. It is thus possible to pass macros that
dnl re-define themselves each time they are invoked without generating
dnl infinite recursions.
dnl
dnl For example,
dnl
dnl n4_set_counter([my_counter])
dnl m4_define([test_macro], [another counter: my_counter...])
dnl
dnl my_counter
dnl n4_burn_out([my_counter... [[[my_counter]... [[[[my_counter... [[test_macro]]]]]]]]],
dnl [my_counter],
dnl my_counter[, ]my_counter)
dnl my_counter
dnl
dnl expands to
dnl
dnl 0
dnl 3... 5... 6... another counter: 7...,4,1, 2
dnl 8
dnl
dnl
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 **************************************************************************
m4_define([n4_burn_out],
[m4_pushdef([_tmp_], m4_dquote(m4_expand(m4_expand([$*]))))[]m4_if(($*), (_tmp_), [_tmp_[]m4_popdef([_tmp_])], [n4_burn_out(_tmp_[]m4_popdef([_tmp_]))])])
[m4_pushdef([_tmp_], m4_dquote(m4_expand([$*])))[]m4_if([$@], m4_dquote(_tmp_),
[_tmp_],
[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)
Expand Down
Loading

0 comments on commit 4fe79e3

Please sign in to comment.