mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-11 14:56:40 +07:00
a41794cdd7
Without the bloated cplus_demangle from binutils, i.e building with: $ make NO_DEMANGLE=1 O=~acme/git/build/perf -j3 -C tools/perf/ install Before: text data bss dec hex filename 471851 29280 4025056 4526187 45106b /home/acme/bin/perf After: [acme@doppio linux-2.6-tip]$ size ~/bin/perf text data bss dec hex filename 446886 29232 4008576 4484694 446e56 /home/acme/bin/perf So its a 5.3% size reduction in code, but the interesting part is in the git diff --stat output: 19 files changed, 20 insertions(+), 1909 deletions(-) If we ever need some of the things we got from git but weren't using, we just have to go to the git repo and get fresh, uptodate source code bits. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#include "cache.h"
|
|
#include "quote.h"
|
|
|
|
/* Help to copy the thing properly quoted for the shell safety.
|
|
* any single quote is replaced with '\'', any exclamation point
|
|
* is replaced with '\!', and the whole thing is enclosed in a
|
|
*
|
|
* E.g.
|
|
* original sq_quote result
|
|
* name ==> name ==> 'name'
|
|
* a b ==> a b ==> 'a b'
|
|
* a'b ==> a'\''b ==> 'a'\''b'
|
|
* a!b ==> a'\!'b ==> 'a'\!'b'
|
|
*/
|
|
static inline int need_bs_quote(char c)
|
|
{
|
|
return (c == '\'' || c == '!');
|
|
}
|
|
|
|
static void sq_quote_buf(struct strbuf *dst, const char *src)
|
|
{
|
|
char *to_free = NULL;
|
|
|
|
if (dst->buf == src)
|
|
to_free = strbuf_detach(dst, NULL);
|
|
|
|
strbuf_addch(dst, '\'');
|
|
while (*src) {
|
|
size_t len = strcspn(src, "'!");
|
|
strbuf_add(dst, src, len);
|
|
src += len;
|
|
while (need_bs_quote(*src)) {
|
|
strbuf_addstr(dst, "'\\");
|
|
strbuf_addch(dst, *src++);
|
|
strbuf_addch(dst, '\'');
|
|
}
|
|
}
|
|
strbuf_addch(dst, '\'');
|
|
free(to_free);
|
|
}
|
|
|
|
void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
|
|
{
|
|
int i;
|
|
|
|
/* Copy into destination buffer. */
|
|
strbuf_grow(dst, 255);
|
|
for (i = 0; argv[i]; ++i) {
|
|
strbuf_addch(dst, ' ');
|
|
sq_quote_buf(dst, argv[i]);
|
|
if (maxlen && dst->len > maxlen)
|
|
die("Too many or long arguments");
|
|
}
|
|
}
|