BadAssert.c 858 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* _BadAssertion: used for debugging purposes. It should give an error message
  7. indicated by the parameters, and then give a core dump
  8. */
  9. #include <string.h>
  10. #include <system.h>
  11. static
  12. wr_num(fd, n)
  13. File *fd;
  14. int n;
  15. {
  16. char s[2];
  17. s[1] = '\0';
  18. if (n >= 10) {
  19. wr_num(fd, n/10);
  20. }
  21. s[0] = (n % 10) + '0';
  22. sys_write(fd, s, 1);
  23. }
  24. int
  25. _BadAssertion(file, lineno, assertion)
  26. char *file, *assertion;
  27. int lineno;
  28. {
  29. sys_write(STDERR, file, strlen(file));
  30. sys_write(STDERR, ", line ", 7);
  31. wr_num(STDERR, lineno);
  32. sys_write(STDERR, ": assertion \"", 13);
  33. sys_write(STDERR, assertion, strlen(assertion));
  34. sys_write(STDERR, "\" failed\n", 9);
  35. sys_stop(S_ABORT);
  36. return 0;
  37. }