summaryrefslogtreecommitdiff
path: root/usr.bin/less/charset.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-17 20:00:57 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-17 20:00:57 +0000
commit08337072153a5b68b8ec5c672d746886de8f2485 (patch)
treed9cc5df1ab0cfdb3dcfac8b67032992df6337413 /usr.bin/less/charset.c
parent6923c3b18f326de40f918b7dcd9533f0a1c258bf (diff)
Hard-code charset if SMALL
Diffstat (limited to 'usr.bin/less/charset.c')
-rw-r--r--usr.bin/less/charset.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/usr.bin/less/charset.c b/usr.bin/less/charset.c
index 8f4a9c31ad2..cf731c60189 100644
--- a/usr.bin/less/charset.c
+++ b/usr.bin/less/charset.c
@@ -22,6 +22,7 @@
public int utf_mode = 0;
+#if !SMALL
/*
* Predefined character sets,
* selected by the LESSCHARSET environment variable.
@@ -334,3 +335,56 @@ prchar(c)
snprintf(buf, sizeof(buf), binfmt, c);
return (buf);
}
+
+#else /* SMALL */
+
+public int binattr = AT_STANDOUT;
+
+ public void
+init_charset()
+{
+ return;
+}
+
+/*
+ * Is a given character a "binary" character?
+ */
+ public int
+binary_char(c)
+ unsigned char c;
+{
+ return (!isprint(c));
+}
+
+/*
+ * Is a given character a "control" character?
+ */
+ public int
+control_char(c)
+ int c;
+{
+ return (iscntrl(c));
+}
+
+/*
+ * Return the printable form of a character.
+ * For example, in the "ascii" charset '\3' is printed as "^C".
+ */
+ public char *
+prchar(c)
+ int c;
+{
+ static char buf[8];
+
+ c &= 0377;
+ if (!iscntrl(c))
+ snprintf(buf, sizeof(buf), "%c", c);
+ else if (c == ESC)
+ snprintf(buf, sizeof(buf), "ESC");
+ else if (c < 128 && !iscntrl(c ^ 0100))
+ snprintf(buf, sizeof(buf), "^%c", c ^ 0100);
+ else
+ snprintf(buf, sizeof(buf), "*s<%X>", c);
+ return (buf);
+}
+#endif /* SMALL */