On Thu, Sep 03, 2020 at 09:26:04AM +0200, peterz@xxxxxxxxxxxxx wrote: > On Thu, Sep 03, 2020 at 11:07:28AM +0900, Masahiro Yamada wrote: > > Will re-implementing your sorting logic > > in bash look cleaner? > > Possibly, I can try, we'll see. It is somewhat cleaner, but it is _abysmally_ slow. Bash sucks :-( It is still broken in all the same ways as before, I figured I'd get it 'working' first. --- diff --git a/scripts/tags.sh b/scripts/tags.sh index 32d3f53af10b..ec2688b3441a 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -239,10 +239,65 @@ setup_regex() done } +sort_tags() +{ + export LC_ALL=C + + # start concurrent sort + coproc sort + # HACK, clone sort output into 3 to ensure we can still read it + # after sort terminates + exec 3<&${COPROC[0]} + + while read tag file rest; + do + local tmp=${rest#*;\"} + + case "${tmp:1:1}" in # Precedence for 'C' kinds + + c) order="A";; # classes + s) order="B";; # structure names + t) order="C";; # typedefs + g) order="D";; # enumeration names + u) order="E";; # union names + n) order="F";; # namespaces + + f) order="G";; # function definitions + p) order="H";; # function prototypes + d) order="I";; # macro definitions + + e) order="J";; # enumerators (values inside an enumeration) + m) order="K";; # class, struct and union members + v) order="L";; # variable definitions + + l) order="M";; # local variables [off] + x) order="N";; # external and forward variable declarations + + *) order="Z";; + + esac + + # write to sort with a new sort-key prepended + echo "${tag}${order} ${tag} ${file} ${rest}" >&${COPROC[1]} + done + + # close sort input + exec {COPROC[1]}>&- + + # consume sort output + while read -u 3 key line; + do + # strip the sort-key + echo "${line}" + done +} + exuberant() { + ( + setup_regex exuberant asm c - all_target_sources | xargs $1 -a \ + all_target_sources | xargs $1 \ -I __initdata,__exitdata,__initconst,__ro_after_init \ -I __initdata_memblock \ -I __refdata,__attribute,__maybe_unused,__always_unused \ @@ -256,12 +311,16 @@ exuberant() -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ -I static,const \ --extra=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \ + --sort=no -o - \ "${regex[@]}" setup_regex exuberant kconfig - all_kconfigs | xargs $1 -a \ + all_kconfigs | xargs $1 \ + --sort=no -o - \ --langdef=kconfig --language-force=kconfig "${regex[@]}" + ) | sort_tags > tags + } emacs()