/contrib/groff/src/devices/xditview/ad2c

https://bitbucket.org/freebsd/freebsd-head/ · Shell · 64 lines · 23 code · 1 blank · 40 comment · 0 complexity · 3a406eb7cf9974b9b3605dd34ae6458a MD5 · raw file

  1. #! /bin/sh
  2. #
  3. # ad2c : Convert app-defaults file to C strings decls.
  4. #
  5. # George Ferguson, ferguson@cs.rcohester.edu, 12 Nov 1990.
  6. # 19 Mar 1991: gf
  7. # Made it self-contained.
  8. # 6 Jan 1992: mycroft@gnu.ai.mit.edu (Charles Hannum)
  9. # Removed use of "-n" and ":read" label since Gnu and
  10. # IBM sed print pattern space on "n" command. Still works
  11. # with Sun sed, of course.
  12. # 7 Jan 1992: matthew@sunpix.East.Sun.COM (Matthew Stier)
  13. # Escape quotes after escaping backslashes.
  14. # 8 Jul 1992: Version 1.6
  15. # Manpage fixes.
  16. # 19 Apr 1993: Version 1.7
  17. # Remove comments that were inside the sed command since
  18. # some versions of sed don't like them. The comments are
  19. # now given here in the header.
  20. # 31 May 2004: Werner Lemberg <wl@gnu.org>
  21. # Force casts to `String'.
  22. #
  23. # Comments on the script by line:
  24. # /^!/d Remove comments
  25. # /^$/d Remove blanks
  26. # s/\\/\\\\/g Escape backslashes...
  27. # s/\\$//g ...except the line continuation ones
  28. # s/"/\\"/g Escape quotes
  29. # s/^/"/ Add leading quote and cast
  30. # : test Establish label for later branch
  31. # /\\$/b slash Branch to label "slash" if line ends in backslash
  32. # s/$/",/ Otherwise add closing quote and comma...
  33. # p ...output the line...
  34. # d ...and clear the pattern space so it's not printed again
  35. # : slash Branch comes here if line ends in backslash
  36. # n Read next line, append to pattern space
  37. # [...] The "d" and "s" commands that follow just delete
  38. # comments and blank lines and escape control sequences
  39. # b test Branch up to see if the line ends in backslash or not
  40. #
  41. sed '
  42. /^!/d
  43. /^$/d
  44. s/\\/\\\\/g
  45. s/\\$//g
  46. s/"/\\"/g
  47. s/^/(String)"/
  48. : test
  49. /\\$/b slash
  50. s/$/",/
  51. p
  52. d
  53. : slash
  54. n
  55. /^!/d
  56. /^$/d
  57. s/"/\\"/g
  58. s/\\\\/\\/g
  59. s/\\n/\\\\n/g
  60. s/\\t/\\\\t/g
  61. s/\\f/\\\\f/g
  62. s/\\b/\\\\b/g
  63. b test' "$@"