modula-2.c 786 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* $Header$ */
  2. /* Language dependant support; this one is for Modula-2 */
  3. #include <stdio.h>
  4. #include "langdep.h"
  5. extern FILE *db_out;
  6. static int
  7. print_string();
  8. static long
  9. array_elsize();
  10. static struct langdep m2 = {
  11. "%ld",
  12. "%loB",
  13. "%lXH",
  14. "%lu",
  15. "%lXH",
  16. "%g",
  17. "%oC",
  18. "[",
  19. "]",
  20. "(",
  21. ")",
  22. "{",
  23. "}",
  24. print_string,
  25. array_elsize
  26. };
  27. struct langdep *m2_dep = &m2;
  28. static int
  29. print_string(s)
  30. char *s;
  31. {
  32. register char *str = s;
  33. int delim = '\'';
  34. while (*str) {
  35. if (*str++ == '\'') delim = '"';
  36. }
  37. fprintf(db_out, "%c%s%c", delim, s, delim);
  38. }
  39. extern long int_size;
  40. static long
  41. array_elsize(size)
  42. long size;
  43. {
  44. if (! (int_size % size)) return size;
  45. if (! (size % int_size)) return size;
  46. return ((size + int_size - 1) / int_size) * int_size;
  47. }