Information and documentation on building an embedded board test lab.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

75 Zeilen
1.3 KiB

  1. #!/bin/sh
  2. fname=$(mktemp foobar.XXXXX)
  3. cat > "$fname"
  4. awk '
  5. maxline == 1 {
  6. if (maxlength < length)
  7. maxlength = length
  8. }
  9. function printtop () {
  10. blank = sprintf("%*s", maxlength + 4, "")
  11. gsub(" ", "*", blank)
  12. printf("%s\n", blank)
  13. }
  14. function printline(a)
  15. {
  16. printf("* %s%*s *\n", a, maxlength - length(a), "")
  17. }
  18. # return the string a, with the character at pos, replaced with chr
  19. function replace(a, pos, chr)
  20. {
  21. return substr(a, 1, pos - 1) chr substr(a, pos + 1)
  22. }
  23. output == 1 && FNR == 1 {
  24. printtop()
  25. printf("* %*s *\n", maxlength, "")
  26. prevline = $0
  27. next
  28. }
  29. output == 1 {
  30. # fix up horizontal issues
  31. gsub("\\|-", "+-", prevline)
  32. gsub("\\| -", "+--", prevline)
  33. gsub("-\\|", "-+", prevline)
  34. gsub("- \\|", "--+", prevline)
  35. # Fix up vertical issues
  36. # first fix edges from below
  37. r = split($0, a, "|")
  38. pos = 0
  39. for (i = 2; i <= r; i++) {
  40. pos += length(a[i - 1]) + 1
  41. if (substr(prevline, pos, 1) == "-")
  42. prevline = replace(prevline, pos, "+")
  43. }
  44. # fix edges from above
  45. r = split(prevline, a, "|")
  46. pos = 0
  47. for (i = 2; i <= r; i++) {
  48. pos += length(a[i - 1]) + 1
  49. if (substr($0, pos, 1) == "-")
  50. $0 = replace($0, pos, "+")
  51. }
  52. printline(prevline)
  53. prevline = $0
  54. }
  55. END {
  56. printline(prevline)
  57. printf("* %*s *\n", maxlength, "")
  58. printtop()
  59. }
  60. ' maxline=1 "$fname" maxline=0 output=1 "$fname"
  61. rm "$fname"