forked from pool/psmisc
124 lines
3.3 KiB
Diff
124 lines
3.3 KiB
Diff
Index: psmisc-21.5/src/pstree.c
|
|
================================================================================
|
|
--- psmisc-21.7/po/Makefile.in.in
|
|
+++ psmisc-21.7/po/Makefile.in.in
|
|
@@ -29,7 +29,6 @@
|
|
INSTALL = @INSTALL@
|
|
INSTALL_DATA = @INSTALL_DATA@
|
|
MKINSTALLDIRS = @MKINSTALLDIRS@
|
|
-mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
|
|
|
|
GMSGFMT = @GMSGFMT@
|
|
MSGFMT = @MSGFMT@
|
|
--- psmisc-21.7/src/pstree.c
|
|
+++ psmisc-21.7/src/pstree.c
|
|
@@ -63,6 +63,7 @@
|
|
#define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */
|
|
|
|
#define VT_BEG "\033(0\017" /* use graphic chars */
|
|
+#define VT_BEG_LEN 4
|
|
#define VT_END "\033(B" /* back to normal char set */
|
|
#define VT_V "x" /* see UTF definitions above */
|
|
#define VT_VR "t"
|
|
@@ -113,13 +114,21 @@
|
|
UTF_VR UTF_H,
|
|
|
|
UTF_V " ",
|
|
- UTF_UR UTF_H, UTF_H UTF_H UTF_H, UTF_H UTF_HD UTF_H}, sym_vt100 =
|
|
+ UTF_UR UTF_H, UTF_H UTF_H UTF_H, UTF_H UTF_HD UTF_H}
|
|
+
|
|
+, sym_vt100 =
|
|
+/*
|
|
+ * For the vt100 line drawing fix: Do not append VT_END here
|
|
+ * because we may need to end the line drawing prematurely and
|
|
+ * we have to turn off line drawing mode by sending VT_END
|
|
+ * then anyway. That's why VT_END is sent by out_sym().
|
|
+ */
|
|
{
|
|
" ",
|
|
- VT_BEG VT_VR VT_H VT_END,
|
|
- VT_BEG VT_V VT_END " ",
|
|
- VT_BEG VT_UR VT_H VT_END,
|
|
- VT_BEG VT_H VT_H VT_H VT_END, VT_BEG VT_H VT_HD VT_H VT_END}
|
|
+ VT_BEG VT_VR VT_H,
|
|
+ VT_BEG VT_V " ",
|
|
+ VT_BEG VT_UR VT_H,
|
|
+ VT_BEG VT_H VT_H VT_H, VT_BEG VT_H VT_HD VT_H}
|
|
|
|
, *sym = &sym_ascii;
|
|
|
|
@@ -144,9 +153,13 @@
|
|
putchar (c);
|
|
if (cur_x == output_width + 1 && trunc && ((c & 0xc0) != 0x80))
|
|
{
|
|
- if (last_char || (c & 0x80))
|
|
+ if (last_char || (c & 0x80)) {
|
|
+/*
|
|
+ * pstree: UTF-8: never draw >1 '+' at end of line(no change for ASCII):
|
|
+ */
|
|
+ cur_x++;
|
|
putchar ('+');
|
|
- else
|
|
+ } else
|
|
{
|
|
last_char = c;
|
|
cur_x--;
|
|
@@ -163,6 +176,26 @@
|
|
out_char (*str++);
|
|
}
|
|
|
|
+/*
|
|
+ * Only affects vt100 line drawing mode: Do not count the strlen of
|
|
+ * VT_BEG to prevent doing end-of-line way too early:
|
|
+ */
|
|
+static void
|
|
+out_sym (const char *str)
|
|
+{
|
|
+ int seq = 0;
|
|
+ if (sym == &sym_vt100 && *str == '\033') {
|
|
+ seq = 1;
|
|
+ if (cur_x <= output_width || !trunc)
|
|
+ cur_x -= VT_BEG_LEN;
|
|
+ }
|
|
+ out_string(str);
|
|
+ if (seq) {
|
|
+ str = VT_END;
|
|
+ while (*str)
|
|
+ putchar (*str++);
|
|
+ }
|
|
+}
|
|
|
|
static int
|
|
out_int (int x) /* non-negative integers only */
|
|
@@ -379,7 +412,11 @@
|
|
{
|
|
for (i = width[lvl] + 1; i; i--)
|
|
out_char (' ');
|
|
- out_string (lvl == level - 1 ? last ? sym->last_2 : sym->branch_2 :
|
|
+ /*
|
|
+ * Replace all three symbol-drawing calls with calls to out_sym()
|
|
+ * to handle VT100 line drawing sequences if VT100 mode is active:
|
|
+ */
|
|
+ out_sym (lvl == level - 1 ? last ? sym->last_2 : sym->branch_2 :
|
|
more[lvl + 1] ? sym->vert_2 : sym->empty_2);
|
|
}
|
|
if (rep < 2)
|
|
@@ -489,7 +526,7 @@
|
|
width[level] = comm_len + cur_x - offset + add;
|
|
if (cur_x >= output_width && trunc)
|
|
{
|
|
- out_string (sym->first_3);
|
|
+ out_sym (sym->first_3);
|
|
out_string ("+");
|
|
out_newline ();
|
|
}
|
|
@@ -516,7 +553,7 @@
|
|
}
|
|
if (first)
|
|
{
|
|
- out_string (next ? sym->first_3 : sym->single_3);
|
|
+ out_sym (next ? sym->first_3 : sym->single_3);
|
|
first = 0;
|
|
}
|
|
dump_tree (walk->child, level + 1, count + 1,
|