textaddr.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. # textaddr.sh - multi-language support low level script
  3. # for compiling progmem1.var and lang_en.txt files
  4. # to textaddr.txt file (mapping of progmem addreses to text idenifiers)
  5. #
  6. # Input files:
  7. # progmem1.var
  8. # lang_en.txt
  9. #
  10. # Output files:
  11. # textaddr.txt
  12. #
  13. #
  14. # Dscription of process:
  15. # check if input files exists
  16. # create sorted list of strings from progmem1.var and lang_en.txt
  17. # lines from progmem1.var will contain addres (8 chars) and english text
  18. # lines from lang_en.txt will contain linenumber and english text
  19. # after sort this will generate pairs of lines (line from progmem1 first)
  20. # result of sort is compiled with simple script and stored into file textaddr.txt
  21. #
  22. echo "textaddr.sh started" >&2
  23. if [ ! -e progmem1.var ]; then echo 'textaddr.sh - file progmem1.var not found!' >&2; exit 1; fi
  24. if [ ! -e lang_en.txt ]; then echo 'textaddr.sh - file lang_en.txt not found!' >&2; exit 1; fi
  25. addr=''
  26. text=''
  27. (cat progmem1.var | sed -E "s/^([^ ]*) ([^ ]*) (.*)/\1 \"\3\"/";\
  28. cat lang_en.txt | sed "/^$/d;/^#/d" | sed = | sed '{N;s/\n/ /}') |\
  29. sort -k2 |\
  30. sed "s/\\\/\\\\\\\/g" | while read num txt; do
  31. if [ ${#num} -eq 8 ]; then
  32. if [ -z "$addr" ]; then
  33. addr=$num
  34. else
  35. if [ "$text" == "$txt" ]; then
  36. addr="$addr $num"
  37. else
  38. echo "ADDR NF $addr $text"
  39. addr=$num
  40. fi
  41. fi
  42. text=$txt
  43. else
  44. if [ -z "$addr" ]; then
  45. echo "TEXT NF $num $txt"
  46. else
  47. if [ "$text" == "$txt" ]; then
  48. if [ ${#addr} -eq 8 ]; then
  49. echo "ADDR OK $addr $num"
  50. else
  51. echo "$addr" | sed "s/ /\n/g" | while read ad; do
  52. echo "ADDR OK $ad $num"
  53. done
  54. fi
  55. addr=''
  56. text=''
  57. else
  58. echo "TEXT NF $num $txt"
  59. fi
  60. fi
  61. fi
  62. done > textaddr.txt
  63. echo "textaddr.sh finished" >&2
  64. exit 0