#!/bin/bash # # Copyright, the authors of the Linux man-pages project # SPDX-License-Identifier: GPL-3.0-or-later set -Eefuo pipefail; # Defaults: t='no'; t_e='no'; t_fp='no'; t_fd='no'; t_flp='no'; t_fld='no'; t_fgp='no'; t_fgd_libm='no'; t_fgd_libio='no'; t_mf='no'; t_mo='no'; t_t_braced='no'; t_t_td_simple='no'; t_t_td_braced='no'; t_t_td_func='no'; t_ue='no'; t_uf_def='no'; t_uf_linux_def='no'; t_umf='no'; t_umo='no'; t_ut_su='no'; t_ut_td_simple='no'; grepc_err() { >&2 printf '%s\n' "$(basename "$0"): error: $*"; exit 1; } while getopts "t:" opt; do case "$opt" in t) case "$OPTARG" in e) t_e='yes'; ;;& f | fp) t_fp='yes'; ;;& f | fd) t_fd='yes'; ;;& f | fl | flp) t_flp='yes'; ;;& f | fl | fld) t_fld='yes'; ;;& f | fg | fgp) t_fgp='yes'; ;;& f | fg | fgd) t_fgd_libm='yes'; t_fgd_libio='yes'; ;;& m | mf) t_mf='yes'; ;;& m | mo) t_mo='yes'; ;;& t) t_t_braced='yes'; t_t_td_simple='yes'; t_t_td_braced='yes'; t_t_td_func='yes'; ;;& u | ue) t_ue='yes'; ;;& u | uf) t_uf_def='yes'; t_uf_linux_def='yes'; ;;& u | um) t_umf='yes'; t_umo='yes'; ;;& u | ut) t_ut_su='yes'; t_ut_td_simple='yes'; ;;& [efmtu] | f[pdlg] | fl[pd] | fg[pd] | m[fo] | u[efmt]) t='yes'; ;; *) grepc_err "-$opt: $OPTARG: Unknown argument."; ;; esac; ;; \? | *) exit 1; ;; esac; done; shift $((OPTIND-1)); if test $# -lt 1; then grepc_err "Missing identifier."; fi; identifier="$1"; shift; if test $# -gt 0; then grepc_err "$1: Unexpected argument."; fi; if test "$t" = 'no'; then t_e='yes'; t_fp='yes'; t_fd='yes'; t_flp='yes'; t_fld='yes'; t_fgp='yes'; t_fgd_libm='yes'; t_fgd_libio='yes'; t_mf='yes'; t_mo='yes'; t_t_braced='yes'; t_t_td_simple='yes'; t_t_td_braced='yes'; t_t_td_func='yes'; fi; grepc_c_t_sue_decl_() { printf '%s' '(?s)^(?:[\w[](?:[\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(?:'"$1"')\b[\w \t[\]:]*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))'; } grepc_c_f_decl_() { grepc_c_f_return_; printf '%s' '\(?'"$1"'\)?'; grepc_c_f_params_; } grepc_c_body_() { printf '%s' '[ \t]*\n*(?[ \t]*){.*?^\k}'; } grepc_c_u_body_() { printf '%s' '[ \t]*\n*(?[ \t]*){(?:(?!^\k?}).)*'"$1"'.*?^\k}'; } grepc_c_fld_decl_() { printf '%s' '(?s)^(?:COMPAT_)?SYSCALL_DEFINE.\('"$1"'\b[\w\s,;[\]*\?:+-]*\)'; } grepc_c_m_decl_() { printf '%s' '(?s)^[ \t]*#\s*define\s[\s\\]*'"$1"'\b'; } grepc_c_mf_decl_() { grepc_c_m_decl_ "$1"; printf '%s' '\([^\(]*\)'; } grepc_c_mo_decl_() { grepc_c_m_decl_ "$1"; printf '%s' '(?!\()'; } grepc_c_m_repl_() { printf '%s' '(?:(?![^\\]$).)*'"$1"'.*?(?