From 503a7e5169b4a18e2ad2569daeb9e13a99f21070 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 10 Dec 2019 01:21:43 +0000 Subject: [PATCH] Syntax: Introduce &. and friends Incompatible change. Signed-off-by: Ian Jackson --- README | 18 ++++++++++++------ generate | 12 ++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README b/README index 006b57f..67ce6cc 100644 --- a/README +++ b/README @@ -218,27 +218,33 @@ empty string). The assumption is that filenames are usually lowercase and variables usually uppercase. Otherwise, use another syntax: +&/ => sub/dir/ or nothing &_ => sub_dir_ or TOP_ -&=_ => sub_dir or TOP +&. => sub/dir or . + (This implies that `&./' works roughly like `&/', although + it can produce a needless `./') -&/ => sub/dir/ or nothing -&=/ => sub/dir or . +&= => sub_dir or TOP &^lc => $(top_srcdir)/sub/dir/lc &^/ => $(top_srcdir)/sub/dir/ +&^. => $(top_srcdir)/sub/dir &~lc => $(top_srcdir)/lc &~/ => $(top_srcdir)/ +&~. => $(top_srcdir) In general: - = return subdir without delimiter (not allowed with `^' `~') ^ pathname of this subdirectory in source tree ~ pathname of top level of source tree - / terminates the escape (needed if next is not lwsp or space) + / terminates the path escape } needed if next is + _ terminates the var escape } not lwsp or space) + . terminates path escape giving dir name (excluding /) + = terminates var escape giving only prefix part (rarely needed) lwsp starts multi-word processing (see below) So pathname syntax is a subset of: - '&' [ '^' | '~' ] [ lc | '/' ] + '&' [ '^' | '~' ] [ lc | '/' | '.' | '=' ] && => && for convenience in shell runes \& => & general escaping mechanism diff --git a/generate b/generate index ca54f94..ba66f86 100755 --- a/generate +++ b/generate @@ -137,11 +137,14 @@ sub process_input_mk ($$$$$$$$$) { } $input_files{$f}++; + my %srcdirmap = ( + '^' => "\$(top_srcdir)${dir_suffix}", + '~' => "\$(top_srcdir)", + ); my %pfxmap = ( '' => $dir_prefix, - '^' => "\$(top_srcdir)${dir_suffix}/", - '~' => "\$(top_srcdir)/", ); + $pfxmap{$_} = $srcdirmap{$_}.'/' foreach keys %srcdirmap; while (<$input>) { if (s#^\s*$esc\:##) { @@ -161,9 +164,10 @@ sub process_input_mk ($$$$$$$$$) { elsif (m{^(?=$caps_re)}) { o $var_prefix } elsif (s{^([~^]?)(?=$lc_re)}{}) { o $pfxmap{$1} } elsif (s{^_}{}) { o $var_prefix } - elsif (s{^=_}{}) { o $var_prefix } + elsif (s{^=}{}) { o $var_prefix_name } elsif (s{^([~^]?)/}{}) { o $pfxmap{$1} } - elsif (s{^=/}{}) { o $dir_name } + elsif (s{^\.}{}) { o $dir_name } + elsif (s{^([~^])\.}{}) { o $srcdirmap{$1} } elsif (s{^([~^]?)(?=[ \t])}{}) { my $prefix = $pfxmap{$1} // die; my $after=''; -- 2.30.2