#!/usr/bin/gawk -f # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: misc/tools-source/smart_wrapper.awk # Copyright (C) 2020 - 2023 The T2 SDE Project # Copyright (C) 1998 - 2003 ROCK Linux Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- BEGIN { speedargidx = 0; sizeargidx = 0; ishot = 0; } # argument 1, read in smart profile db, 2nd form for POSIXLY_CORRECT ARGIND == 1 || (!ARGIND && FILENAME != "-") { hotlist[$2] = 1; # printf("hot db: '%s'\n", $2) > "/dev/stderr" } # argument 2, read command list from stdin, 2nd form for POSIXLY_CORRECT ARGIND == 2 || (!ARGIND && FILENAME == "-") { if (gsub("^-HOT", "") == 1) speedarg[speedargidx++] = $0; else { speedarg[speedargidx++] = $0; sizearg[sizeargidx++] = $0; # remove path prefix, and lookup hot file if (match($0, "^[^-]")) { gsub(".*/", "") #printf("arg: %s\n", $1) > "/dev/stderr" if (hotlist[$0] == 1) { # printf("hot file: '%s'\n", $0) > "/dev/stderr" ishot = 1; } } } } END { if (ishot) for (i = 0; i < speedargidx; i++) print speedarg[i]; else for (i = 0; i < sizeargidx; i++) print sizearg[i]; }