+ } else {
+ printf("\\0%o",c&0xff);
+ }
+}
+
+/*
+ * Print out a value for a range type (integer, char, or boolean).
+ */
+
+public printRangeVal (val, t)
+long val;
+Symbol t;
+{
+ if (t == t_boolean->type or istypename(t->type, "boolean")) {
+ if ((boolean) val) {
+ printf("true");
+ } else {
+ printf("false");
+ }
+ } else if (t == t_char->type or istypename(t->type, "char")) {
+ if (varIsSet("$hexchars")) {
+ printf("0x%lx", val);
+ } else {
+ putchar('\'');
+ printchar(val);
+ putchar('\'');
+ }
+ } else if (varIsSet("$hexints")) {
+ printf("0x%lx", val);
+ } else if (t->symvalue.rangev.lower >= 0) {
+ printf("%lu", val);
+ } else {
+ printf("%ld", val);
+ }
+}
+
+/*
+ * Print out an enumerated value by finding the corresponding
+ * name in the enumeration list.
+ */
+
+public printEnum (i, t)
+integer i;
+Symbol t;
+{
+ register Symbol e;
+
+ e = t->chain;
+ while (e != nil and e->symvalue.constval->value.lcon != i) {
+ e = e->chain;
+ }
+ if (e != nil) {
+ printf("%s", symname(e));
+ } else {
+ printf("%d", i);
+ }
+}
+
+/*
+ * Print out a null-terminated string (pointer to char)
+ * starting at the given address.
+ */
+
+public printString (addr, quotes)
+Address addr;
+boolean quotes;
+{
+ register Address a;
+ register integer i, len;
+ register boolean endofstring;
+ register int unprintables;
+#define MAXGARBAGE 4
+ union {
+ char ch[sizeof(Word)];
+ int word;
+ } u;
+
+ if (varIsSet("$hexstrings")) {
+ printf("0x%x", addr);
+ } else {
+ if (quotes) {
+ putchar('"');
+ }
+ a = addr;
+ unprintables = 0;
+ endofstring = false;
+ while (not endofstring) {
+ dread(&u, a, sizeof(u));
+ i = 0;
+ do {
+ if (u.ch[i] == '\0') {
+ endofstring = true;
+ } else {
+ printchar(u.ch[i]);
+ if (!isascii(u.ch[i]) and ++unprintables > MAXGARBAGE) {
+ endofstring = true;
+ printf("...");
+ }
+ }
+ ++i;
+ } while (i < sizeof(Word) and not endofstring);
+ a += sizeof(Word);
+ }
+ if (quotes) {
+ putchar('"');
+ }