Skip to content

Commit 4fe79e3

Browse files
committed
Commit 35
* 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
1 parent 5111008 commit 4fe79e3

File tree

9 files changed

+270
-162
lines changed

9 files changed

+270
-162
lines changed

ChangeLog.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@ Change Log
22
==========
33

44

5+
2.1.0
6+
-----
7+
8+
Changes:
9+
10+
* New macro `n4_bind()`, has been created in `not-m4sugar.m4`
11+
* Code review (macro `n4_burn_out()` in `not-m4sugar.m4`; macro `n4_sp()` in
12+
`not-fancy-texts.m4`; macro `NR_CONFIG_FILES()` in `not-autoreconf.m4`;
13+
macros `NC_MSG_ERRORBOX()` and `NC_MSG_FAILUREBOX()` in `not-ac-messages.m4`)
14+
* Documentation
15+
16+
517
2.0.0
6-
------
18+
-----
719

820
Changes:
921

@@ -67,7 +79,7 @@ Changes:
6779

6880

6981
1.1.0
70-
------
82+
-----
7183

7284
Changes:
7385

@@ -81,7 +93,7 @@ Changes:
8193

8294

8395
1.0.0
84-
------
96+
-----
8597

8698
Changes:
8799

collection-utils/macro-index-generator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
echo 'This is the complete list of macros released by the **Not Autotools** project.'
1313
(cd .. && find 'm4' -type f -name '*.m4' -printf '\n\n## `%p`\n\n' \
1414
-exec grep -oPHn '(?<=^dnl )\w+\(\)?' '{}' ';') | \
15-
sed 's/()$//g;s/($/()/g;s,\([^:]\+\):\([^:]\+\):\([^(]\+\(()\)\?\)$,* [\3](\1#L\2),g'
15+
sed 's/()$//g;s/($/()/g;s,\([^:]\+\):\([^:]\+\):\([^(]\+\(()\)\?\)$,* [`\3`](\1#L\2),g'
1616
echo
1717
} > ../macro-index.md
1818

m4/not-ac-messages.m4

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ dnl This macro may be invoked only after having invoked `AC_INIT()`.
7272
dnl
7373
dnl Expansion type: shell code
7474
dnl Requires: nothing
75-
dnl Version: 1.0.1
75+
dnl Version: 1.0.2
7676
dnl Author: madmurphy
7777
dnl
7878
dnl **************************************************************************
7979
AC_DEFUN([NC_MSG_ERRORBOX],
80-
[AC_MSG_ERROR([m4_text_wrap([$1 --------------------------------------------------------------------],
81-
[ | ],
82-
[-------------------------------------------------------------],
83-
[79])]m4_if(m4_eval([$# > 1]), [1], [, [$2]]))])
80+
[m4_if([$#], [0], [],
81+
[AC_MSG_ERROR([m4_text_wrap([$1 --------------------------------------------------------------------],
82+
[ | ],
83+
[-------------------------------------------------------------],
84+
[79])]m4_if([$#], [1], [], [, [$2]]))])])
8485

8586

8687
dnl NC_MSG_FAILUREBOX(error-description[, exit-status])
@@ -93,15 +94,16 @@ dnl This macro may be invoked only after having invoked `AC_INIT()`.
9394
dnl
9495
dnl Expansion type: shell code
9596
dnl Requires: nothing
96-
dnl Version: 1.0.1
97+
dnl Version: 1.0.2
9798
dnl Author: madmurphy
9899
dnl
99100
dnl **************************************************************************
100101
AC_DEFUN([NC_MSG_FAILUREBOX],
101-
[AC_MSG_FAILURE([m4_text_wrap([$1 --------------------------------------------------------------------],
102-
[ | ],
103-
[-------------------------------------------------------------],
104-
[79])]m4_if(m4_eval([$# > 1]), [1], [, [$2]]))])
102+
[m4_if([$#], [0], [],
103+
[AC_MSG_FAILURE([m4_text_wrap([$1 --------------------------------------------------------------------],
104+
[ | ],
105+
[-------------------------------------------------------------],
106+
[79])]m4_if([$#], [1], [], [, [$2]]))])])
105107

106108

107109

m4/not-autoreconf.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ dnl This macro may be invoked before `AC_INIT()`.
216216
dnl
217217
dnl Expansion type: literal (void)
218218
dnl Requires: nothing
219-
dnl Version: 1.0.0
219+
dnl Version: 1.0.1
220220
dnl Author: madmurphy
221221
dnl
222222
dnl **************************************************************************
223223
AC_DEFUN([NR_CONFIG_FILES],
224-
[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($@))])])
224+
[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($@))])])
225225

226226

227227
dnl NR_PROG_VERSION(program)

m4/not-autoversion.m4

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

540555

541556
dnl NR_BUMP_VSTATE(project-major, project-minor, project-micro, current,
542-
dnl revision, age, source-age, change1, change2, ... changeN)
557+
dnl revision, age, source-age, change-list)
543558
dnl **************************************************************************
544559
dnl
545560
dnl Applies one or more changes to a version state
@@ -548,6 +563,9 @@ dnl This macro is mainly intended to be used internally by
548563
dnl `NR_RECORD_HISTORY()`; you will hardly ever need it. For the definition of
549564
dnl a `change`, please refer to `NR_RECORD_HISTORY()`.
550565
dnl
566+
dnl The `change-list` argument corresponds to an `event` without its first
567+
dnl member (i.e. without the event's name).
568+
dnl
551569
dnl This macro may be invoked before `AC_INIT()`.
552570
dnl
553571
dnl Expansion type: literal

m4/not-fancy-texts.m4

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ dnl Prints an arbitrary number of white spaces
2828
dnl
2929
dnl Expansion type: literal
3030
dnl Requires: nothing
31-
dnl Version: 1.0.0
31+
dnl Version: 1.0.1
3232
dnl Author: madmurphy
3333
dnl
3434
dnl **************************************************************************
3535
m4_define([n4_sp],
3636
[m4_if(m4_eval([$1 > 0]), [1],
37-
[n4_sp(m4_eval([$1 - 1]))[ ]])])
37+
[n4_sp(m4_decr([$1]))[ ]])])
3838

3939

4040
dnl n4_newlines(text1[, text2[, text3[, ... textN]]])
4141
dnl **************************************************************************
4242
dnl
43-
dnl Calls `m4_normalize()` for each argument, then returns all the results
43+
dnl Calls `m4_normalize()` for each argument, then returns the results
4444
dnl separated by a new line.
4545
dnl
4646
dnl For example,

m4/not-m4sugar.m4

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,11 @@ dnl Author: madmurphy
975975
dnl
976976
dnl **************************************************************************
977977
m4_define([n4_redepth],
978-
[m4_len(m4_bpatsubst(m4_bpatsubst([$1], [\(\\\|)\|\([^\\]\|^\)\(\\\\\)*(\)\|\(\\\)(\|,], [\4]), [[^\\]], []))])
978+
[m4_len(m4_bpatsubst(m4_bpatsubst([$1],
979+
[\(\\\|)\|\([^\\]\|^\)\(\\\\\)*(\)\|\(\\\)(\|,],
980+
[\4]),
981+
[[^\\]],
982+
[]))])
979983
980984
981985
dnl n4_for_each_match(string, regexp, macro)
@@ -1053,7 +1057,7 @@ dnl
10531057
dnl m4_define([WTF], [a test])
10541058
dnl n4_burn_out([[[[[This is [[[WTF]]]. Bye!]]]]])
10551059
dnl
1056-
dnl expands to:
1060+
dnl expands to
10571061
dnl
10581062
dnl This is a test. Bye!
10591063
dnl
@@ -1071,16 +1075,87 @@ dnl
10711075
dnl m4_count(m4_unquote(n4_burn_out([Hi, how [[[[are]]]] [[you]]?])))
10721076
dnl => 2
10731077
dnl
1078+
dnl Each expansion happens once. It is thus possible to pass macros that
1079+
dnl re-define themselves each time they are invoked without generating
1080+
dnl infinite recursions.
1081+
dnl
1082+
dnl For example,
1083+
dnl
1084+
dnl n4_set_counter([my_counter])
1085+
dnl m4_define([test_macro], [another counter: my_counter...])
1086+
dnl
1087+
dnl my_counter
1088+
dnl n4_burn_out([my_counter... [[[my_counter]... [[[[my_counter... [[test_macro]]]]]]]]],
1089+
dnl [my_counter],
1090+
dnl my_counter[, ]my_counter)
1091+
dnl my_counter
1092+
dnl
1093+
dnl expands to
1094+
dnl
1095+
dnl 0
1096+
dnl 3... 5... 6... another counter: 7...,4,1, 2
1097+
dnl 8
1098+
dnl
1099+
dnl
10741100
dnl This macro may be invoked before `AC_INIT()`.
10751101
dnl
10761102
dnl Expansion type: literal
10771103
dnl Requires: nothing
1078-
dnl Version: 1.0.0
1104+
dnl Version: 1.0.1
10791105
dnl Author: madmurphy
10801106
dnl
10811107
dnl **************************************************************************
10821108
m4_define([n4_burn_out],
1083-
[m4_pushdef([_tmp_], m4_dquote(m4_expand(m4_expand([$*]))))[]m4_if(($*), (_tmp_), [_tmp_[]m4_popdef([_tmp_])], [n4_burn_out(_tmp_[]m4_popdef([_tmp_]))])])
1109+
[m4_pushdef([_tmp_], m4_dquote(m4_expand([$*])))[]m4_if([$@], m4_dquote(_tmp_),
1110+
[_tmp_],
1111+
[n4_burn_out(_tmp_)])[]m4_popdef([_tmp_])])
1112+
1113+
1114+
dnl n4_bind(original-macro, new-macro, arg1[, arg2[, arg3[, ... argN]]])
1115+
dnl **************************************************************************
1116+
dnl
1117+
dnl Creates a new macro that invokes `original-macro` with `arg1`, `arg2` ...
1118+
dnl `argN` as initial arguments
1119+
dnl
1120+
dnl This macro is the m4 version of ECMAScript `Function.prototype.bind()`.
1121+
dnl
1122+
dnl For example,
1123+
dnl
1124+
dnl m4_define([MY_UNBOUND_MACRO], [
1125+
dnl First argument is: `$1`
1126+
dnl Second argument is: `$2`
1127+
dnl Third argument is: `$3`
1128+
dnl Fourth argument is: `$4`])
1129+
dnl
1130+
dnl n4_bind([MY_UNBOUND_MACRO],
1131+
dnl [MY_BOUND_MACRO], [foo], [bar])
1132+
dnl
1133+
dnl MY_UNBOUND_MACRO([hello], [world])
1134+
dnl MY_BOUND_MACRO([hello], [world])
1135+
dnl
1136+
dnl expands to
1137+
dnl
1138+
dnl First argument is: `hello`
1139+
dnl Second argument is: `world`
1140+
dnl Third argument is: ``
1141+
dnl Fourth argument is: ``
1142+
dnl
1143+
dnl First argument is: `foo`
1144+
dnl Second argument is: `bar`
1145+
dnl Third argument is: `hello`
1146+
dnl Fourth argument is: `world`
1147+
dnl
1148+
dnl This macro may be invoked before `AC_INIT()`.
1149+
dnl
1150+
dnl Expansion type: literal (void)
1151+
dnl Requires: nothing
1152+
dnl Version: 1.0.0
1153+
dnl Author: madmurphy
1154+
dnl
1155+
dnl **************************************************************************
1156+
m4_define([n4_bind],
1157+
[m4_define([$2],
1158+
[$1(]m4_dquote(m4_shift2($@))[m4_if(]m4_dquote([$][#])[, [0], [], ]m4_dquote([, $][@])[))])])
10841159
10851160
10861161
dnl n4_includedir(directory)

0 commit comments

Comments
 (0)