diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-16 14:55:48 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-01-16 14:55:48 +0100 |
| commit | 3b11b9d4f3eee5faa656d7ee61077e80726bdc36 (patch) | |
| tree | 7817c036843c18eac0012298ec7808d795411f58 /tools/openings.sh | |
| parent | b7667d1d40045ecd840b9b192c2740e5f83e7eba (diff) | |
Improve openings database code
Diffstat (limited to 'tools/openings.sh')
| -rwxr-xr-x | tools/openings.sh | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/tools/openings.sh b/tools/openings.sh index b0f1e04..40a0620 100755 --- a/tools/openings.sh +++ b/tools/openings.sh @@ -10,21 +10,32 @@ dst="${wai}/../src/binres/" # Fetch database git clone "$urldb" "$tmp" - -# Generate c_str from database cd $tmp -wxbin2c a.tsv a_tsv.hpp -wxbin2c b.tsv b_tsv.hpp -wxbin2c c.tsv c_tsv.hpp -wxbin2c d.tsv d_tsv.hpp -wxbin2c e.tsv e_tsv.hpp - -# Combine c_str files -cat a_tsv.hpp > openings.hpp -cat b_tsv.hpp >> openings.hpp -cat c_tsv.hpp >> openings.hpp -cat d_tsv.hpp >> openings.hpp -cat e_tsv.hpp >> openings.hpp + +# a.tsv +echo -n "static const char a_tsv[] =" > openings.hpp +sed -i '1d' a.tsv # remove header +cat a.tsv | sed -e "s/^/\"/g" -e "s/$/\\\n\"/g" -e '$ s/\\n"/";/g' >> openings.hpp; + +# b.tsv +echo -n "static const char b_tsv[] =" >> openings.hpp +sed -i '1d' b.tsv +cat b.tsv | sed -e "s/^/\"/g" -e "s/$/\\\n\"/g" -e '$ s/\\n"/";/g' >> openings.hpp; + +# c.tsv +echo -n "static const char c_tsv[] =" >> openings.hpp +sed -i '1d' c.tsv +cat c.tsv | sed -e "s/^/\"/g" -e "s/$/\\\n\"/g" -e '$ s/\\n"/";/g' >> openings.hpp; + +# d.tsv +echo -n "static const char d_tsv[] =" >> openings.hpp +sed -i '1d' d.tsv +cat d.tsv | sed -e "s/^/\"/g" -e "s/$/\\\n\"/g" -e '$ s/\\n"/";/g' >> openings.hpp; + +# e.tsv +echo -n "static const char e_tsv[] =" >> openings.hpp +sed -i '1d' e.tsv +cat e.tsv | sed -e "s/^/\"/g" -e "s/$/\\\n\"/g" -e '$ s/\\n"/";/g' >> openings.hpp; # Save mv openings.hpp "$dst" |
