File: mime.sl

package info (click to toggle)
jed 1%3A0.99.19-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,368 kB
  • ctags: 5,809
  • sloc: ansic: 48,117; sh: 2,977; makefile: 518
file content (77 lines) | stat: -rw-r--r-- 1,201 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Parse buffer full of MIME noise
% Note:  This is very primitive and should be fixed

define mime_parse_this_qp ()
{
   variable str;
   
   str = strcat ("0x", char (what_char ()));
   del ();
   str = strcat (str, char (what_char ()));
   del ();
   if (Integer_Type == _slang_guess_type (str))
     {
	insert_char (integer(str));
	return;
     }
   insert (str);
}

define mime_rfc1522_parse_buffer ()
{
   variable qpre;
   variable len;
   variable charset, str;
   
   % Look for things like =?iso-8859-1?Q?=E1end?=
   qpre = "=\\?\\([-_a-zA-Z0-9]+\\)\\?Q\\?\\([^ \t]+\\)\\?=";
   
   push_spot ();
   bob ();
   while (len = re_fsearch (qpre), len)
     {
	len--;
	charset = regexp_nth_match (1);
	str = regexp_nth_match (2);
	push_mark ();
	go_right (len);
	del_region ();
	push_mark ();
	insert (str);
	narrow_to_region ();
	
	bob ();
	replace ("_", " ");
	while (fsearch ("="))
	  {
	     del ();
	     mime_parse_this_qp ();
	  }
	eob ();
	widen_region ();
     }
   pop_spot ();
}

define mime_qp_parse_buffer ()
{
   bob ();
   while (fsearch ("="))
     {
	del ();
	if (eolp ())
	  {
	     del ();
	     continue;
	  }
	
	mime_parse_this_qp ();
     }
}