+/* Apply a heuristic to decide whether an array of TYPE or a pointer
+ to TYPE should be printed as a textual string. Return non-zero if
+ it should, or zero if it should be treated as an array of integers
+ or pointer to integers. FORMAT is the current format letter,
+ or 0 if none.
+
+ We guess that "char" is a character. Explicitly signed and
+ unsigned character types are also characters. Integer data from
+ vector types is not. The user can override this by using the /s
+ format letter. */
+
+static int
+textual_element_type (struct type *type, char format)
+{
+ struct type *true_type = check_typedef (type);
+
+ if (format != 0 && format != 's')
+ return 0;
+
+ /* TYPE_CODE_CHAR is always textual. */
+ if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
+ return 1;
+
+ if (format == 's')
+ {
+ /* Print this as a string if we can manage it. For now, no
+ wide character support. */
+ if (TYPE_CODE (true_type) == TYPE_CODE_INT
+ && TYPE_LENGTH (true_type) == 1)
+ return 1;
+ }
+ else
+ {
+ /* If a one-byte TYPE_CODE_INT is missing the not-a-character
+ flag, then we treat it as text; otherwise, we assume it's
+ being used as data. */
+ if (TYPE_CODE (true_type) == TYPE_CODE_INT
+ && TYPE_LENGTH (true_type) == 1
+ && !TYPE_NOTTEXT (true_type))
+ return 1;
+ }
+
+ return 0;
+}
+
+