ioctl_redefs%.h: ioctlent%.h ioctlent0.h
sort $< > $<-t
sort ioctlent0.h | comm -23 $<-t - | \
- sed -n 's/^{ "\([^"]\+\)", \(0x[[:xdigit:]]\+\) },$$/#ifdef \1\n# undef \1\n# define \1 \2\n#endif/p' \
+ sed -r -n 's/^\{ "([^"]+)", (0x[[:xdigit:]]+) \},$$/#ifdef \1\n# undef \1\n# define \1 \2\n#endif/p' \
> $@-t
rm -f $<-t
mv $@-t $@
m%_type_defs.h: $(srcdir_mpers_source_files)
for f in $^; do \
- sed -n 's/^#include DEF_MPERS_TYPE(\([^)]\+\))/#ifdef MPERS_$(mpers_PREFIX)\1\n# define \1 MPERS_$(mpers_PREFIX)\1\n#endif/p' $$f || exit; \
+ sed -r -n 's/^#include DEF_MPERS_TYPE\(([^)]+)\)/#ifdef MPERS_$(mpers_PREFIX)\1\n# define \1 MPERS_$(mpers_PREFIX)\1\n#endif/p' $$f || exit; \
done > $@-t
echo '#undef MPERS_PRINTER_NAME' >> $@-t
echo '#define MPERS_PRINTER_NAME(printer_name) printer_name' >> $@-t
m%_funcs.h: $(srcdir_mpers_source_files)
for f in $^; do \
- sed -n 's/^SYS_FUNC(\([^)]\+\))/#undef sys_\1\n#define sys_\1 $(mpers_PREFIX)sys_\1/p' $$f || exit; \
+ sed -r -n 's/^SYS_FUNC\(([^)]+)\)/#undef sys_\1\n#define sys_\1 $(mpers_PREFIX)sys_\1/p' $$f || exit; \
done > $@-t && \
echo '#include "sys_func.h"' >> $@-t
mv $@-t $@
%.c.mpers.i: $(srcdir)/%.c
$(CPP) -P $(mpers_sh_opts) -DIN_MPERS_BOOTSTRAP $< -o $@
-mpers_printer_decl_pattern = ^MPERS_PRINTER_DECL(\([^,)]\+\),[[:space:]]*\([^,)]\+\),[[:space:]]*\([^)]\+\))$$
+mpers_printer_decl_pattern = ^MPERS_PRINTER_DECL\(([^,)]+),[[:space:]]*([^,)]+),[[:space:]]*([^)]+)\)$$
printers.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
echo 'typedef struct {' >> $@-t
for f in $^; do \
- sed -n 's/$(mpers_printer_decl_pattern)/ \1 (*\2)(\3);\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f \
+ sed -r -n 's/$(mpers_printer_decl_pattern)/ \1 (*\2)(\3);\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f \
|| exit; \
done >> $@-t
echo '} struct_printers;' >> $@-t
%_printer_decls.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
for f in $^; do \
- sed -n 's/$(mpers_printer_decl_pattern)/extern \1 $(mpers_PREFIX)\2(\3);/p' $$f \
+ sed -r -n 's/$(mpers_printer_decl_pattern)/extern \1 $(mpers_PREFIX)\2(\3);/p' $$f \
|| exit; \
done >> $@-t
mv $@-t $@
%_printer_defs.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
for f in $^; do \
- sed -n 's/$(mpers_printer_decl_pattern)/\.\2 = $(mpers_PREFIX)\2,/p' $$f \
+ sed -r -n 's/$(mpers_printer_decl_pattern)/.\2 = $(mpers_PREFIX)\2,/p' $$f \
|| exit; \
done >> $@-t
mv $@-t $@
( \
cd $(srcdir); \
sed '/^##/,$$d' CREDITS.in; \
- { sed -n '1,/^##>/d; s/ \+/\t/; s/^./&/p' CREDITS.in; \
+ { sed -n '1,/^##>/d; s/ */\t/; s/^./&/p' CREDITS.in; \
git log --pretty=format:'%aN %aE'; \
} | LC_ALL=C sort -u \
| awk -F'\t' '{printf("\t%s <%s>\n",$$1,$$2)}'; \
#!/bin/sh -e
-list="$(sed -n '/^strace_SOURCES[[:space:]]*=/,/^[[:space:]]*# end of strace_SOURCES/ s/^[[:space:]]*\([[:alnum:]][^.]*\.c\)[[:space:]]*\\$/\1/p' Makefile.am |
- xargs -r grep -lx '#[[:space:]]*include[[:space:]]\+MPERS_DEFS' |
+list="$(sed -r -n '/^strace_SOURCES[[:space:]]*=/,/^[[:space:]]*# end of strace_SOURCES/ s/^[[:space:]]*([[:alnum:]][^.]*\.c)[[:space:]]*\\$/\1/p' Makefile.am |
+ xargs -r grep -Elx '#[[:space:]]*include[[:space:]]+MPERS_DEFS' |
tr '\n' ' ')"
cat > mpers.am <<EOF
mpers_source_files = $list
EOF
-sed -n 's/^#[[:space:]]*include[[:space:]]*"xlat\/\([^."]\+\)\.h".*/extern const struct xlat \1[];/p' \
+sed -r -n 's/^#[[:space:]]*include[[:space:]]*"xlat\/([a-z][a-z_0-9]*)\.h".*/extern const struct xlat \1[];/p' \
$list > mpers_xlat.h
echo 'enum {'
echo 'SEN_printargs = 0,'
- sed -n '/printargs/! s/.*SEN(\([^)]*\)).*/\1/p' |
+ sed -r -n '/printargs/! s/.*SEN\(([^)]+)\).*/\1/p' |
sort -u |
sed 's/.*/SEN_&,/'
echo '};'
for n in n32 n64 o32; do
in="$srcdir/syscallent-$n.h"
out="$dstdir/syscallent-$n-stub.h"
- sed -n '/^#if/,/^#else/ {s/^\([^{]*{[^,]*,[^,]*,[[:space:]]*\)[^,[:space:]]\+,[[:space:]]*"\([^"]\+".*\)/\1SEN(printargs), "'$n'_\2/; s/^\[.*/&/p}' < "$in" > "$out"
+ sed -r -n '/^#if/,/^#else/ {s/^([^{]*\{[^,]*,[^,]*,[[:space:]]*)[^,[:space:]]+,[[:space:]]*"([^"]+".*)/\1SEN(printargs), "'$n':\2/; s/^\[.*/&/p}' < "$in" > "$out"
done
Binary: $(sed '/^Package:[[:space:]]*/!d;s///' debian/control |
tr '\n' ' ' | sed 's/ ./,&/g')
$(sed '/^Architecture:[[:space:]]*/!d;q' debian/control)
-Version: $(sed -n '1s/^[^(]*(\([^)]\+\)).*/\1/p' debian/changelog)
+Version: $(sed -r -n '1s/^[^(]*\(([^)]+)\).*/\1/p' debian/changelog)
$(sed '/^Maintainer:[[:space:]]*/!d;q' debian/control)
$(sed '/^Homepage:[[:space:]]*/!d;q' debian/control)
$(sed '/^Standards-Version:[[:space:]]*/!d;q' debian/control)
BITS_DIR="mpers${ARCH_FLAG}"
mkdir -p ${BITS_DIR}
-set -- $(sed -n \
- 's/^#[[:space:]]*include[[:space:]]\+DEF_MPERS_TYPE(\([^)[:space:]]*\))$/\1/p' \
+set -- $(sed -r -n \
+ 's/^#[[:space:]]*include[[:space:]]+DEF_MPERS_TYPE\(([^)[:space:]]*)\)$/\1/p' \
"${PARSER_FILE}")
for m_type; do
f_h="${BITS_DIR}/${m_type}.h"
sed -e '
/DEF_MPERS_TYPE('"${m_type}"')$/n
/DEF_MPERS_TYPE/d
- /^[[:space:]]*#[[:space:]]*include[[:space:]]\+\"xlat\//d
- /^#[[:space:]]*include[[:space:]]\+MPERS_DEFS$/ {s//'"${m_type} ${VAR_NAME}"';/;q}
+ /^[[:space:]]*#[[:space:]]*include[[:space:]]*"xlat\//d
+ /^#[[:space:]]*include[[:space:]][[:space:]]*MPERS_DEFS$/ {s//'"${m_type} ${VAR_NAME}"';/;q}
' "${PARSER_FILE}" > "${f_c}"
$CPP $CPPFLAGS "${f_c}" > "${f_i}"
grep -F -q "${m_type}.h" "${f_i}" ||
sed -i -e '/DEF_MPERS_TYPE/d' "${f_c}"
$CC $CFLAGS $ARCH_FLAG "${f_c}" -o "${f_o}"
readelf --debug-dump=info "${f_o}" > "${f_d1}"
- sed -n '
- /^[[:space:]]*<1>/,/^[[:space:]]*<1><[^>]\+>: Abbrev Number: 0/!d
- /^[[:space:]]*<[^>]\+><[^>]\+>: Abbrev Number: 0/d
- s/^[[:space:]]*<[[:xdigit:]]\+>[[:space:]]\+//
- s/^[[:space:]]*\(\(<[[:xdigit:]]\+>\)\{2\}\):[[:space:]]\+/\1\n/
- s/[[:space:]]\+$//
+ sed -r -n '
+ /^[[:space:]]*<1>/,/^[[:space:]]*<1><[^>]+>: Abbrev Number: 0/!d
+ /^[[:space:]]*<[^>]*><[^>]*>: Abbrev Number: 0/d
+ s/^[[:space:]]*<[[:xdigit:]]+>[[:space:]]+//
+ s/^[[:space:]]*((<[[:xdigit:]]+>){2}):[[:space:]]+/\1\n/
+ s/[[:space:]]+$//
p' "${f_d1}" > "${f_d2}"
gawk -v VAR_NAME="$VAR_NAME" -v ARCH_FLAG="${ARCH_FLAG#-}" \
-f "$MPERS_AWK" "${f_d2}" > "${f_h}"
ksysent.h: $(srcdir)/ksysent.sed
echo '#include <asm/unistd.h>' | \
$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM - > $@.t1
- LC_COLLATE=C sed -n -f $(srcdir)/ksysent.sed < $@.t1 > $@.t2
+ LC_COLLATE=C sed -r -n -f $(srcdir)/ksysent.sed < $@.t1 > $@.t2
mv -f $@.t2 $@
rm -f $@.t1
-#!/bin/sed -nf
+#!/bin/sed -rnf
# should not have been exported at all
-/#define[[:space:]]\+__NR_\(sys_epoll_\|arch_specific_syscall\|syscalls\|syscall_count\|syscall_max\|available\|reserved\|unused\)/d
+/#define[[:space:]]+__NR_(sys_epoll_|arch_specific_syscall|syscalls|syscall_count|syscall_max|available|reserved|unused)/d
-# should not be named this way
-s/__NR_\(arm\|xtensa\)_fadvise64_64/__NR_fadvise64_64/
+# should not have been named this way
+s/__NR_(arm|xtensa)_fadvise64_64/__NR_fadvise64_64/
# legacy names
s/__NR_get_cpu/__NR_getcpu/
s/__NR_paccept/__NR_accept4/
# generate
-s/#define[[:space:]]\+__NR_\([a-z_][^[:space:]]\+\)\([[:space:]].*\)\?$/#ifdef __NR_\1\n[__NR_\1 \& 0xffff] = "\1",\n#endif/p
+s/#define[[:space:]]+__NR_([a-z_][^[:space:]]+)([[:space:]].*)?$/#ifdef __NR_\1\n[__NR_\1 \& 0xffff] = "\1",\n#endif/p
$STRACE $args 2> "$LOG" ||
dump_log_and_fail_with "$STRACE $args failed"
-len="$(sed -n 's/^\[[[:xdigit:]]\+\] write(-1, NULL, \([[:digit:]]\{1,2\}\))[[:space:]]\+= -1 .*/\1/p' "$LOG")" &&
+len="$(sed -r -n 's/^\[[[:xdigit:]]+\] write\(-1, NULL, ([[:digit:]]{1,2})\)[[:space:]]+= -1 .*/\1/p' "$LOG")" &&
[ -n "$len" ] &&
-pid="$(sed -n 's/^\[[[:xdigit:]]\{'"$len"'\}\] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_\(KILLED\|DUMPED\), si_pid=\([[:digit:]]\+\), .*/\2/p' "$LOG")" &&
+pid="$(sed -r -n 's/^\[[[:xdigit:]]{'"$len"'}\] --- SIGCHLD \{si_signo=SIGCHLD, si_code=CLD_(KILLED|DUMPED), si_pid=([[:digit:]]+), .*/\2/p' "$LOG")" &&
[ -n "$pid" ] &&
-ip="$(sed -n 's/^\[pid \+'"$pid"'\] \[\([[:xdigit:]]\{'"$len"'\}\)] --- SIGSEGV {.*} ---$/\1/p' "$LOG")" &&
+ip="$(sed -r -n 's/^\[pid +'"$pid"'\] \[([[:xdigit:]]{'"$len"'})] --- SIGSEGV \{.*\} ---$/\1/p' "$LOG")" &&
[ -n "$ip" ] &&
-addr="$(echo "$ip" |sed 's/^0\+//')" &&
+addr="$(echo "$ip" |sed -r 's/^0+//')" &&
[ -n "$addr" ] ||
dump_log_and_fail_with
sedexpr="$1"; shift
run_strace -c -w -S "$sortby" ./readv > /dev/null
- sed -ne "$sedexpr" < "$LOG" > "$OUT"
+ sed -r -n -e "$sedexpr" < "$LOG" > "$OUT"
[ -s "$OUT" ] ||
fail_ "$STRACE $args output mismatch"
}
}
-c='[[:space:]]\+\([^[:space:]]\+\)'
-test_c calls '-n -r' '/^[[:space:]]\+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
-test_c name '' '/^[[:space:]]\+[0-9]/ s/^'"$c$c$c$c"'\([[:space:]]\+[0-9]\+\)\?'"$c"'$/\6/p'
+c='[[:space:]]+([^[:space:]]+)'
+test_c calls '-n -r' '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
+test_c name '' '/^[[:space:]]+[0-9]/ s/^'"$c$c$c$c"'([[:space:]]+[0-9]+)?'"$c"'$/\6/p'
rm -f "$OUT"
getval()
{
- sed -n 's/#define[[:space:]]*'"$1"'[[:space:]]*"\([^"]*\)".*/\1/p' ../config.h
+ sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*"([^"]*)".*/\1/p' ../config.h
}
printf "%s -- version %s\n" "$(getval PACKAGE_NAME)" "$(getval VERSION)" > "$EXP"
run_strace -e getpid -k $args
expected='getpid f3 f2 f1 f0 main '
-result=$(sed -n '1,/(main+0x[a-f0-9]\+) .*/ s/^.*(\([^+]\+\)+0x[a-f0-9]\+) .*/\1/p' "$LOG" |
+result=$(sed -r -n '1,/\(main\+0x[a-f0-9]+\) .*/ s/^.*\(([^+]+)\+0x[a-f0-9]+\) .*/\1/p' "$LOG" |
tr '\n' ' ')
test "$result" = "$expected" || {
local val
val="$(printf %s "$line" |
- sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
+ sed -r -n 's/^([^[:space:]]+).*$/\1/p')"
local def
def="$(printf %s "${line}" |
- sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
+ sed -r -n 's/^[^[:space:]]+[[:space:]]+([^[:space:]].*)$/\1/p')"
if [ -n "$def" ]; then
cat <<-EOF
local line val m def xlat
line="$1"; shift
- val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
+ val="$(printf %s "${line}" | sed -r -n 's/^([^[:space:]]+).*$/\1/p')"
m="${val%%|*}"
def="$(printf %s "${line}" |
- sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
+ sed -r -n 's/^[^[:space:]]+[[:space:]]+([^[:space:]].*)$/\1/p')"
if [ "${m}" = "${m#1<<}" ]; then
xlat="$(print_xlat "${val}")"