From 76c5e99d92cd0e4bf6ac8fe6067ecb8e5c2b017f Mon Sep 17 00:00:00 2001 From: midipix Date: Feb 17 2024 05:21:44 +0000 Subject: ar mode: utility: armap symbol printing: added the -Wregex switch. --- diff --git a/src/arbits/output/slbt_ar_output_symbols.c b/src/arbits/output/slbt_ar_output_symbols.c index b709755..cfd0be8 100644 --- a/src/arbits/output/slbt_ar_output_symbols.c +++ b/src/arbits/output/slbt_ar_output_symbols.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -24,13 +25,26 @@ static int slbt_ar_output_symbols_posix( const struct slbt_fd_ctx * fdctx) { int fdout; + const char * regex; const char ** symv; + regex_t regctx; + regmatch_t pmatch[2] = {0}; fdout = fdctx->fdout; + if ((regex = dctx->cctx->regex)) + if (regcomp(®ctx,regex,REG_NEWLINE)) + return SLBT_CUSTOM_ERROR( + dctx, + SLBT_ERR_FLOW_ERROR); + for (symv=mctx->symstrv; *symv; symv++) - if (slbt_dprintf(fdout,"%s\n",*symv) < 0) - return SLBT_SYSTEM_ERROR(dctx,0); + if (!regex || !regexec(®ctx,*symv,1,pmatch,0)) + if (slbt_dprintf(fdout,"%s\n",*symv) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + if (regex) + regfree(®ctx); return 0; } diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 17cb290..848aa94 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -89,6 +89,7 @@ enum app_tags { TAG_AR_VERSION, TAG_AR_CHECK, TAG_AR_PRINT, + TAG_AR_REGEX, TAG_AR_PRETTY, TAG_AR_POSIX, TAG_AR_YAML, diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c index c808421..8f6016f 100644 --- a/src/logic/slbt_exec_ar.c +++ b/src/logic/slbt_exec_ar.c @@ -235,6 +235,10 @@ int slbt_exec_ar( break; + case TAG_AR_REGEX: + ictx->cctx.regex = entry->arg; + break; + case TAG_AR_PRETTY: if (!strcmp(entry->arg,"yaml")) { ictx->cctx.fmtflags &= ~(uint64_t)SLBT_PRETTY_FLAGS; diff --git a/src/skin/slbt_skin_ar.c b/src/skin/slbt_skin_ar.c index a02372b..58059aa 100644 --- a/src/skin/slbt_skin_ar.c +++ b/src/skin/slbt_skin_ar.c @@ -36,6 +36,11 @@ const struct argv_option slbt_ar_options[] = { "print out information pertaining to each archive file " "and its various internal elements"}, + {"Wregex", 0,TAG_AR_REGEX,ARGV_OPTARG_REQUIRED, + ARGV_OPTION_HYBRID_ONLY|ARGV_OPTION_HYBRID_SPACE, + 0,"", + "filter armap symbols using the specified %s."}, + {"Wpretty", 0,TAG_AR_PRETTY,ARGV_OPTARG_REQUIRED, ARGV_OPTION_HYBRID_EQUAL, "posix|yaml|hexdata",0,