digest-doc.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Give this program DOC-mm.nn.oo as standard input and it outputs to
  2. standard output a file of nroff output containing the doc strings.
  3. Copyright (C) 1987, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
  4. 2008, 2009, 2010 Free Software Foundation, Inc.
  5. This file is part of GNU Emacs.
  6. GNU Emacs is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. GNU Emacs is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. See also sorted-doc.c, which produces similar output
  17. but in texinfo format and sorted by function/variable name. */
  18. #include <stdio.h>
  19. #ifdef DOS_NT
  20. #include <fcntl.h> /* for O_BINARY */
  21. #include <io.h> /* for setmode */
  22. #endif
  23. int
  24. main ()
  25. {
  26. register int ch;
  27. register int notfirst = 0;
  28. #ifdef DOS_NT
  29. /* DOC is a binary file. */
  30. if (!isatty (fileno (stdin)))
  31. setmode (fileno (stdin), O_BINARY);
  32. #endif
  33. printf (".TL\n");
  34. printf ("Command Summary for GNU Emacs\n");
  35. printf (".AU\nRichard M. Stallman\n");
  36. while ((ch = getchar ()) != EOF)
  37. {
  38. if (ch == '\037')
  39. {
  40. if (notfirst)
  41. printf ("\n.DE");
  42. else
  43. notfirst = 1;
  44. printf ("\n.SH\n");
  45. ch = getchar ();
  46. printf (ch == 'F' ? "Function " : "Variable ");
  47. while ((ch = getchar ()) != '\n') /* Changed this line */
  48. {
  49. if (ch != EOF)
  50. putchar (ch);
  51. else
  52. {
  53. ungetc (ch, stdin);
  54. break;
  55. }
  56. }
  57. printf ("\n.DS L\n");
  58. }
  59. else
  60. putchar (ch);
  61. }
  62. return 0;
  63. }
  64. /* arch-tag: 2ba2c9b0-4157-4eba-bd9f-967e3677e35f
  65. (do not change this comment) */