Release v4.18994 - Backdoor
[RRG-proxmark3.git] / client / deps / get_linenoise.sh
blob4bb6dbc812e53ec16659975e997da6b3fec12c34
1 #!/bin/bash
3 # Can be used if Readline is unavailable or explicitely disabled
4 # Note that ConvertUTF.cpp is under redis-only license therefore
5 # if you are maintainer, think twice before including it
7 version=1.0.1
8 mkdir -p linenoise
9 ZP=linenoise-ng-$version
10 if [ ! -f "${ZP}.zip" ]; then
11 wget -O "${ZP}.zip" https://github.com/arangodb/linenoise-ng/archive/v$version.zip
13 unzip -o -j "${ZP}.zip" $ZP/src/ConvertUTF.cpp $ZP/src/ConvertUTF.h $ZP/LICENSE $ZP/src/linenoise.cpp $ZP/include/linenoise.h $ZP/README.md $ZP/src/wcwidth.cpp -d linenoise
14 #echo "Please do make style"
16 echo "Generating linenoise.cmake..."
17 cat > linenoise.cmake << EOF
18 add_library(pm3rrg_rdv4_linenoise STATIC
19 linenoise/ConvertUTF.cpp
20 linenoise/linenoise.cpp
21 linenoise/wcwidth.cpp
24 target_compile_definitions(pm3rrg_rdv4_linenoise PRIVATE NDEBUG)
25 target_include_directories(pm3rrg_rdv4_linenoise INTERFACE linenoise)
26 target_compile_options(pm3rrg_rdv4_linenoise PRIVATE -Wall -Werror -O3)
27 set_property(TARGET pm3rrg_rdv4_linenoise PROPERTY POSITION_INDEPENDENT_CODE ON)
28 EOF
30 cd linenoise
31 echo "Generating linenoise/Makefile..."
32 cat > Makefile << EOF
33 MYSRCPATHS =
34 MYINCLUDES =
35 MYCXXFLAGS = -DNDEBUG -std=c++11 -fomit-frame-pointer
36 MYDEFS =
37 MYCXXSRCS = ConvertUTF.cpp linenoise.cpp wcwidth.cpp
39 LIB_A = liblinenoise.a
41 include ../../../Makefile.host
42 EOF
44 # Patch to get proper autocompletion of subcommands
45 patch << EOF
46 diff -Naur linenoise.cpp linenoise.cpp
47 +++ linenoise.cpp 2017-03-06 17:01:33.000000000 +0100
48 --- linenoise.cpp 2022-01-29 10:37:19.656202922 +0100
49 @@ -1956,7 +1956,7 @@
50 // character and
51 // extract a copy to parse. we also handle the case where tab is hit while
52 // not at end-of-line.
53 - int startIndex = pos;
54 + int startIndex = 0;
55 while (--startIndex >= 0) {
56 if (strchr(breakChars, buf32[startIndex])) {
57 break;
58 EOF