Rev 7693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7693 | Rev 7696 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | (* |
1 | (* |
2 | BSD 2-Clause License |
2 | BSD 2-Clause License |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | Copyright (c) 2018, 2019, Anton Krotov |
4 | Copyright (c) 2018-2019, Anton Krotov |
5 | All rights reserved. |
5 | All rights reserved. |
Line 6... | Line 6... | ||
6 | *) |
6 | *) |
Line 19... | Line 19... | ||
19 | 19 | ||
Line 20... | Line 20... | ||
20 | TYPE |
20 | TYPE |
Line 21... | Line 21... | ||
21 | 21 | ||
22 | TEXT* = POINTER TO RECORD (C.ITEM) |
22 | TEXT* = POINTER TO RECORD (C.ITEM) |
23 | 23 | ||
24 | chunk: ARRAY CHUNK OF BYTE; |
24 | chunk: ARRAY CHUNK OF CHAR; |
25 | pos, size: INTEGER; |
25 | pos, size: INTEGER; |
Line 45... | Line 45... | ||
45 | IF ~text.eof THEN |
45 | IF ~text.eof THEN |
46 | text.size := FILES.read(text.file, text.chunk, LEN(text.chunk)); |
46 | text.size := FILES.read(text.file, text.chunk, LEN(text.chunk)); |
47 | text.pos := 0; |
47 | text.pos := 0; |
48 | IF text.size = 0 THEN |
48 | IF text.size = 0 THEN |
49 | text.eof := TRUE; |
49 | text.eof := TRUE; |
50 | text.chunk[0] := 0 |
50 | text.chunk[0] := 0X |
51 | END; |
51 | END; |
52 | text.peak := CHR(text.chunk[0]) |
52 | text.peak := text.chunk[0] |
53 | END |
53 | END |
54 | END load; |
54 | END load; |
Line 55... | Line 55... | ||
55 | 55 | ||
Line 59... | Line 59... | ||
59 | c: CHAR; |
59 | c: CHAR; |
Line 60... | Line 60... | ||
60 | 60 | ||
61 | BEGIN |
61 | BEGIN |
62 | IF text.pos < text.size - 1 THEN |
62 | IF text.pos < text.size - 1 THEN |
63 | INC(text.pos); |
63 | INC(text.pos); |
64 | text.peak := CHR(text.chunk[text.pos]) |
64 | text.peak := text.chunk[text.pos] |
65 | ELSE |
65 | ELSE |
66 | load(text) |
66 | load(text) |
Line 67... | Line 67... | ||
67 | END; |
67 | END; |
Line 85... | Line 85... | ||
85 | END; |
85 | END; |
86 | text.CR := FALSE |
86 | text.CR := FALSE |
87 | ELSE |
87 | ELSE |
88 | text.eol := FALSE; |
88 | text.eol := FALSE; |
89 | IF text.utf8 THEN |
89 | IF text.utf8 THEN |
90 | IF (c < 80X) OR (c > 0BFX) THEN |
90 | IF ORD(c) DIV 64 # 2 THEN |
91 | INC(text.col) |
91 | INC(text.col) |
92 | END |
92 | END |
93 | ELSE |
93 | ELSE |
94 | INC(text.col) |
94 | INC(text.col) |
95 | END; |
95 | END; |
Line 102... | Line 102... | ||
102 | 102 | ||
103 | 103 | ||
104 | PROCEDURE init (text: TEXT); |
104 | PROCEDURE init (text: TEXT); |
105 | BEGIN |
105 | BEGIN |
106 | IF (text.pos = 0) & (text.size >= 3) THEN |
106 | IF (text.pos = 0) & (text.size >= 3) THEN |
107 | IF (text.chunk[0] = 0EFH) & |
107 | IF (text.chunk[0] = 0EFX) & |
108 | (text.chunk[1] = 0BBH) & |
108 | (text.chunk[1] = 0BBX) & |
109 | (text.chunk[2] = 0BFH) THEN |
109 | (text.chunk[2] = 0BFX) THEN |
110 | text.pos := 3; |
110 | text.pos := 3; |
111 | text.utf8 := TRUE |
111 | text.utf8 := TRUE |
Line 112... | Line 112... | ||
112 | END |
112 | END |
113 | END; |
113 | END; |
114 | 114 | ||
115 | IF text.size = 0 THEN |
115 | IF text.size = 0 THEN |
116 | text.chunk[0] := 0; |
116 | text.chunk[0] := 0X; |
Line 117... | Line 117... | ||
117 | text.size := 1; |
117 | text.size := 1; |
118 | text.eof := FALSE |
118 | text.eof := FALSE |
Line 119... | Line 119... | ||
119 | END; |
119 | END; |
120 | 120 | ||
Line 121... | Line 121... | ||
121 | text.line := 1; |
121 | text.line := 1; |
122 | text.col := 1; |
122 | text.col := 1; |
Line 150... | Line 150... | ||
150 | ELSE |
150 | ELSE |
151 | text := citem(TEXT) |
151 | text := citem(TEXT) |
152 | END; |
152 | END; |
Line 153... | Line 153... | ||
153 | 153 | ||
154 | IF text # NIL THEN |
154 | IF text # NIL THEN |
155 | text.chunk[0] := 0; |
155 | text.chunk[0] := 0X; |
156 | text.pos := 0; |
156 | text.pos := 0; |
157 | text.size := 0; |
157 | text.size := 0; |
158 | text.utf8 := FALSE; |
158 | text.utf8 := FALSE; |
159 | text.CR := FALSE; |
159 | text.CR := FALSE; |