debug.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Copyright 2014, 2015 Free Software Foundation, Inc.
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  12. #include <stdarg.h>
  13. #include <stdio.h>
  14. /* Whether to dump debugging output on stderr. */
  15. int debug_output = 0;
  16. void
  17. debug (char *s, ...)
  18. {
  19. va_list v;
  20. if (!debug_output)
  21. return;
  22. va_start (v, s);
  23. vfprintf (stderr, s, v);
  24. fputc ('\n', stderr);
  25. }
  26. void
  27. debug_nonl (char *s, ...)
  28. {
  29. va_list v;
  30. if (!debug_output)
  31. return;
  32. va_start (v, s);
  33. vfprintf (stderr, s, v);
  34. }