]> git.pld-linux.org Git - packages/slrn.git/blame - slrn-sort_visible_headers.patch
- rediff patches
[packages/slrn.git] / slrn-sort_visible_headers.patch
CommitLineData
33957255
JR
1diff -urNp -x '*.orig' slrn-1.0.3.org/doc/slrn.rc slrn-1.0.3/doc/slrn.rc
2--- slrn-1.0.3.org/doc/slrn.rc 2016-10-24 00:34:16.000000000 +0200
3+++ slrn-1.0.3/doc/slrn.rc 2021-10-03 22:48:59.521057945 +0200
4@@ -219,6 +219,11 @@
aff637f3 5 % display all the "X-"headers except "X-Trace:").
6 %visible_headers "From:,Subject:,Newsgroups:,Followup-To:,Reply-To:"
7
8+% If non-zero, visible headers are displayed in specific order.
9+% If 1, headers are arranged with respect to visible_headers order put above,
10+% If 2, the same as above with multiple matches sorted alphabetically.
11+%set visible_headers_sorting_method 2
12+
13 % If non-zero, #v+ and #v- will be interpreted as markers of verbatim lines.
33957255 14 %set process_verbatim_marks 1
aff637f3 15
33957255
JR
16diff -urNp -x '*.orig' slrn-1.0.3.org/src/art.h slrn-1.0.3/src/art.h
17--- slrn-1.0.3.org/src/art.h 2016-10-24 00:34:16.000000000 +0200
18+++ slrn-1.0.3/src/art.h 2021-10-03 22:48:59.521057945 +0200
19@@ -46,6 +46,7 @@ extern int Slrn_Query_Next_Group;
3d30d4f1 20 extern int Slrn_Auto_CC_To_Poster;
aff637f3 21 extern int Slrn_Score_After_XOver;
22 extern int Slrn_Use_Tmpdir;
aff637f3 23+extern int Slrn_Visible_Headers_Sorting_Mode;
aff637f3 24 extern int Slrn_Wrap_Mode;
33957255 25 extern int Slrn_Wrap_Width;
aff637f3 26 extern int Slrn_Wrap_Method;
33957255
JR
27diff -urNp -x '*.orig' slrn-1.0.3.org/src/art_misc.c slrn-1.0.3/src/art_misc.c
28--- slrn-1.0.3.org/src/art_misc.c 2016-10-24 00:34:16.000000000 +0200
29+++ slrn-1.0.3/src/art_misc.c 2021-10-03 22:48:59.524391275 +0200
30@@ -65,6 +65,8 @@ int Slrn_Wrap_Width = -1;
aff637f3 31
32 static char *Super_Cite_Regexp = "^[^A-Za-z0-9]*\"\\([-_a-zA-Z/]+\\)\" == .+";
33
34+int Slrn_Visible_Headers_Sorting_Mode = 2;
35+
36 static void hide_article_lines (Slrn_Article_Type *a, unsigned int mask) /*{{{*/
37 {
38 Slrn_Article_Line_Type *l;
33957255 39@@ -935,6 +937,157 @@ void _slrn_art_unhide_headers (Slrn_Arti
aff637f3 40
41 /*}}}*/
42
43+void _slrn_sort_visible_headers (Slrn_Article_Type *a) /*{{{*/
44+{
45+ Slrn_Article_Line_Type *l, *lnext, *sorted, *sorted_last;
46+ Slrn_Article_Line_Type *sorted_headers, *sorted_headers_last;
47+ Visible_Header_Type *sortpos, *sortpos_better;
48+ int is_better_match, sort_again;
49+ char *colon, *colon_next;
50+
51+ if (Slrn_Visible_Headers_Sorting_Mode < 1) return;
52+
53+ sorted_headers = NULL;
54+ sorted_headers_last = NULL;
55+ sortpos = Visible_Headers;
56+
57+ while (sortpos != NULL)
58+ {
59+ l = a->lines;
60+ sorted = NULL;
61+ sorted_last = NULL;
62+
63+ while ((l != NULL) && (l->flags & HEADER_LINE))
64+ {
65+ lnext = l->next;
66+ if (0 == slrn_case_strncmp ((unsigned char *)l->buf,
67+ (unsigned char *)sortpos->header,
68+ sortpos->len))
69+ {
70+ sortpos_better = sortpos->next;
71+ is_better_match = 0;
72+ while ((sortpos_better != NULL) && (is_better_match == 0))
73+ {
74+ if (0 == slrn_case_strncmp ((unsigned char *)l->buf,
75+ (unsigned char *)sortpos_better->header,
76+ sortpos_better->len))
77+ {
78+ if (sortpos_better->len >= sortpos->len)
79+ is_better_match = 1;
80+ }
81+ sortpos_better = sortpos_better->next;
82+ }
83+
84+ if (is_better_match == 0)
85+ {
86+ if (l->prev != NULL)
87+ l->prev->next = l->next;
88+ else
89+ a->lines = l->next;
90+
91+ if (l->next != NULL)
92+ l->next->prev = l->prev;
93+
94+ if (sorted == NULL)
95+ sorted = l;
96+ else
97+ {
98+ sorted_last->next = l;
99+ l->prev = sorted_last;
100+ }
101+ sorted_last = l;
102+ }
103+ }
104+ l = lnext;
105+ }
106+
107+ if (Slrn_Visible_Headers_Sorting_Mode > 1)
108+ {
109+ if (sorted != sorted_last)
110+ {
111+ sort_again = 1;
112+ while (sort_again)
113+ {
114+ sort_again = 0;
115+ sorted->prev = NULL;
116+ sorted_last->next = NULL;
117+ l = sorted;
118+ while (l != sorted_last)
119+ {
120+ lnext = l->next;
121+
3591afbc 122+ colon = slrn_strbyte (l->buf, ':');
aff637f3 123+ if (colon != NULL)
124+ *colon = 0;
125+
3591afbc 126+ colon_next = slrn_strbyte (lnext->buf, ':');
aff637f3 127+ if (colon_next != NULL)
128+ *colon_next = 0;
129+
130+ if (0 < slrn_case_strcmp ((unsigned char *)l->buf,
131+ (unsigned char *)lnext->buf))
132+ {
133+ sort_again = 1;
134+ if (l->prev != NULL)
135+ l->prev->next = lnext;
136+ else
137+ sorted = lnext;
138+
139+ lnext->prev = l->prev;
140+ l->prev = lnext;
141+ l->next = lnext->next;
142+ lnext->next = l;
143+ if (l->next != NULL)
144+ l->next->prev = l;
145+ else
146+ sorted_last = l;
147+
148+ lnext = l;
149+ }
150+
151+ if (colon != NULL)
152+ *colon = ':';
153+
154+ if (colon_next != NULL)
155+ *colon_next = ':';
156+
157+ l = lnext;
158+ }
159+ }
160+ }
161+ }
162+
163+ if (sorted != NULL)
164+ {
165+ if (sorted_headers == NULL)
166+ {
167+ sorted_headers = sorted;
168+ sorted_headers_last = sorted_last;
169+ }
170+ else
171+ {
172+ sorted_headers->prev = sorted_last;
173+ sorted_last->next = sorted_headers;
174+ sorted_headers = sorted;
175+ }
176+ }
177+ sortpos = sortpos->next;
178+ }
179+
180+ if (sorted_headers != NULL)
181+ {
182+ sorted_headers_last->next = a->lines;
183+ a->lines->prev = sorted_headers_last;
184+ a->lines = sorted_headers;
185+ a->cline = sorted_headers;
186+ sorted_headers->prev = NULL;
187+ }
188+
189+ return;
190+}
191+
192+/*}}}*/
193+
194 int _slrn_art_unfold_header_lines (Slrn_Article_Type *a) /*{{{*/
195 {
196 Slrn_Article_Line_Type *l;
33957255
JR
197@@ -979,6 +1132,9 @@ int _slrn_art_unfold_header_lines (Slrn_
198
aff637f3 199 l = l->next;
200 }
201+
202+ _slrn_sort_visible_headers (a);
203+
204 return 0;
205 }
206
33957255
JR
207diff -urNp -x '*.orig' slrn-1.0.3.org/src/startup.c slrn-1.0.3/src/startup.c
208--- slrn-1.0.3.org/src/startup.c 2021-10-03 22:48:59.367724784 +0200
209+++ slrn-1.0.3/src/startup.c 2021-10-03 22:48:59.524391275 +0200
210@@ -626,6 +626,7 @@ Slrn_Int_Var_Type Slrn_Int_Variables []
3591afbc
JB
211 {"cc_followup", &Slrn_Auto_CC_To_Poster, NULL},
212 {"use_tmpdir", &Slrn_Use_Tmpdir, NULL},
213 {"sorting_method", &Slrn_Sorting_Mode, NULL},
aff637f3 214+ {"visible_headers_sorting_method", &Slrn_Visible_Headers_Sorting_Mode},
3591afbc
JB
215 {"custom_sort_by_threads", &Slrn_Sort_By_Threads, NULL},
216 {"uncollapse_threads", &Slrn_Uncollapse_Threads, NULL},
217 {"read_active", &Slrn_List_Active_File, NULL},
This page took 0.068072 seconds and 4 git commands to generate.