File: fixgoswig.sh

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (27 lines) | stat: -rwxr-xr-x 458 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# fixgoswig.sh - Fix ut64 consts and convert std::vector into slice

FILE=$1
sed -n '
1h
1!H
$ {
	g
	s/\(\n\t[^\n(]*([^\n)]*)\) \([a-zA-Z0-9]\+\)Vector/\1 []\2/g
	s/\(\nfunc ([^\n]*\) \([a-zA-Z0-9]\+\)Vector {\n\treturn \([^\n]*\)\n}/\1 []\2 {\
	v := \3\
	n := v.Size()\
	if n  <= 0 {\
		return nil\
	}\
	s := make([]\2, n)\
	for i := 0; i < n; i++ {\
		it := v.Get(i)\
		s[i]=it;\
	}\
	return s\
}/g
	p
}
' $FILE > $FILE.fix
mv -f $FILE.fix $FILE