BadAssert.c 869 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* $Header$ */
  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 <system.h>
  10. static
  11. wr_num(fd, n)
  12. File *fd;
  13. int n;
  14. {
  15. char s[2];
  16. s[1] = '\0';
  17. if (n >= 10) {
  18. wr_num(fd, n/10);
  19. }
  20. s[0] = (n % 10) + '0';
  21. (void) sys_write(fd, s, 1);
  22. }
  23. _BadAssertion(file, lineno, assertion)
  24. char *file, *assertion;
  25. int lineno;
  26. {
  27. (void) sys_write(STDERR, file, strlen(file));
  28. (void) sys_write(STDERR, ", line ", 7);
  29. wr_num(STDERR, lineno);
  30. (void) sys_write(STDERR, ": assertion \"", 13);
  31. (void) sys_write(STDERR, assertion, strlen(assertion));
  32. (void) sys_write(STDERR, "\" failed\n", 9);
  33. sys_stop(S_ABORT);
  34. }