From 87452e8311b8e0394be7377cdd266b96afddde83 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 5 Nov 2023 16:23:10 +0100 Subject: bin/grepc: srcfix (Remove grepc_parse_cmd()) Signed-off-by: Alejandro Colomar --- bin/grepc | 163 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 79 insertions(+), 84 deletions(-) diff --git a/bin/grepc b/bin/grepc index b30d46d..d06b0fb 100755 --- a/bin/grepc +++ b/bin/grepc @@ -43,89 +43,86 @@ grepc_err() } -grepc_parse_cmd() -{ - while getopts "A:B:C:chiklnrt:" opt; do - case "$opt" in - A) A="-A$OPTARG"; ;;& - B) B="-B$OPTARG"; ;;& - C) C="-C$OPTARG"; ;;& - c) c='-c'; ;;& - h) h='-h'; ;;& - i) i='-i'; ;;& - k | l) k='yes'; ;;& - l) l='-l'; ;;& - n) n='-n'; ;;& - r) r='yes'; ;;& +while getopts "A:B:C:chiklnrt:" opt; do + case "$opt" in + A) A="-A$OPTARG"; ;;& + B) B="-B$OPTARG"; ;;& + C) C="-C$OPTARG"; ;;& + c) c='-c'; ;;& + h) h='-h'; ;;& + i) i='-i'; ;;& + k | l) k='yes'; ;;& + l) l='-l'; ;;& + n) n='-n'; ;;& + r) r='yes'; ;;& + 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) - 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_um='yes'; ;;& - u | ut) - t_ut_su='yes'; - t_ut_td_simple='yes'; - t_ut_td_su='yes'; - ;;& - [efmtu] | f[pdlg] | fl[pd] | fg[pd] | m[fo] | u[efmt]) - t='yes'; - ;; - *) - grepc_err "-$opt: $OPTARG: Unknown argument."; - ;; - esac; - ;; - \?) - exit 1; # getopts(1) prints an error msg. - ;; + 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_um='yes'; ;;& + u | ut) + t_ut_su='yes'; + t_ut_td_simple='yes'; + t_ut_td_su='yes'; + ;;& + [efmtu] | f[pdlg] | fl[pd] | fg[pd] | m[fo] | u[efmt]) + t='yes'; + ;; + *) + grepc_err "-$opt: $OPTARG: Unknown argument."; + ;; esac; - done; - shift $((OPTIND-1)); - - test $# -lt 1 && grepc_err "Missing identifier."; - identifier=$1; - shift; - - files=$*; - - if [ "$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; -} + ;; + \?) + exit 1; # getopts(1) prints an error msg. + ;; + esac; +done; +shift $((OPTIND-1)); + +test $# -lt 1 && grepc_err "Missing identifier."; +identifier=$1; +shift; + +files=$*; + +if [ "$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_e() { echo '(?s)^([\w[]+[\w\s]*)?\benum\b[ \t]*([\w \t[\]]|::)*\n*([ \t]*){[^}]*^[ \t]*'"$1"'\b\s*[=,].*?^\3}.*?;'; } @@ -211,8 +208,6 @@ grepc_search() main() { - grepc_parse_cmd "$@"