57 lines
1.2 KiB
Text
57 lines
1.2 KiB
Text
$NetBSD: patch-ai,v 1.2 1998/08/07 11:10:15 agc Exp $
|
|
|
|
--- util.c.orig Fri Jan 23 17:37:13 1998
|
|
+++ util.c Fri Jan 23 17:37:12 1998
|
|
@@ -361,3 +361,52 @@
|
|
}
|
|
}
|
|
#endif
|
|
+
|
|
+int strwidth(const char *p)
|
|
+{
|
|
+ int i = 0, len, incr;
|
|
+ const char *start, *s, *s1, *s2;
|
|
+
|
|
+ for (start = s = p; ; start = (s += incr)) {
|
|
+ s1 = strchr(s, '\n');
|
|
+ s2 = strstr(s, "\\n");
|
|
+ if (s2 == NULL)
|
|
+ s = s1;
|
|
+ else if (s1 == NULL)
|
|
+ s = s2;
|
|
+ else
|
|
+ s = MIN(s1, s2);
|
|
+ if (s == NULL)
|
|
+ break;
|
|
+ incr = 1 + (s == s2);
|
|
+ len = s - start;
|
|
+ if (len > i)
|
|
+ i = len;
|
|
+ }
|
|
+ len = strlen(start);
|
|
+ if (len > i)
|
|
+ i = len;
|
|
+ return i;
|
|
+}
|
|
+
|
|
+int strheight(const char *p)
|
|
+{
|
|
+ int i = 1, incr;
|
|
+ const char *s, *s1, *s2;
|
|
+
|
|
+ for (s = p; ; s += incr) {
|
|
+ s1 = strchr(s, '\n');
|
|
+ s2 = strstr(s, "\\n");
|
|
+ if (s2 == NULL)
|
|
+ s = s1;
|
|
+ else if (s1 == NULL)
|
|
+ s = s2;
|
|
+ else
|
|
+ s = MIN(s1, s2);
|
|
+ if (s == NULL)
|
|
+ break;
|
|
+ incr = 1 + (s == s2);
|
|
+ i++;
|
|
+ }
|
|
+ return i;
|
|
+}
|