Subversion Repositories Kolibri OS

Rev

Rev 9174 | Rev 9200 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9174 Rev 9180
Line 31... Line 31...
31
 
31
 
Line 32... Line 32...
32
    BUF_SIZE = 65536;
32
    BUF_SIZE = 65536;
Line 33... Line 33...
33
 
33
 
Line 34... Line 34...
34
    NAME_LEN = 1024;
34
    NAME_LEN = 1024;
Line 35... Line 35...
35
 
35
 
Line 43... Line 43...
43
    tEOL = ARRAY 3 OF WCHAR;
43
    tEOL = ARRAY 3 OF WCHAR;
Line 44... Line 44...
44
 
44
 
45
    tInput* = POINTER TO RECORD
45
    tInput* = POINTER TO RECORD
46
        buffer:   INTEGER;
46
        buffer:   INTEGER;
47
        pos, cnt: INTEGER;
-
 
48
        enc:      INTEGER;
47
        pos, cnt: INTEGER;
49
        CR:       BOOLEAN;
48
        CR:       BOOLEAN;
50
        clipbrd:  BOOLEAN;
49
        clipbrd:  BOOLEAN;
51
        getChar:  PROCEDURE (file: tInput): INTEGER
50
        getChar:  PROCEDURE (file: tInput): INTEGER
Line 61... Line 60...
61
 
60
 
Line 62... Line 61...
62
 
61
 
-
 
62
VAR
Line 63... Line 63...
63
VAR
63
 
64
 
64
    eol*: ARRAY 3 OF tEOL;
65
    eol*: ARRAY 3 OF tEOL;
65
    eolNames*: ARRAY 3, 16 OF WCHAR;
Line 294... Line 294...
294
    END
294
    END
295
    RETURN res
295
    RETURN res
296
END detectEncoding;
296
END detectEncoding;
Line -... Line 297...
-
 
297
 
-
 
298
 
-
 
299
PROCEDURE detectEOL (text: tInput): INTEGER;
-
 
300
VAR
-
 
301
	pos, cnt, c, res: INTEGER;
-
 
302
BEGIN
-
 
303
	res := -1;
-
 
304
	pos := text.pos;
-
 
305
	cnt := text.cnt;
-
 
306
	WHILE (text.cnt > 0) & (res = -1) DO
-
 
307
		c := text.getChar(text);
-
 
308
		IF c = 10 THEN
-
 
309
			res := EOL_LF
-
 
310
		ELSIF c = 13 THEN
-
 
311
			IF text.getChar(text) = 10 THEN
-
 
312
				res := EOL_CRLF
-
 
313
			ELSE
-
 
314
				res := EOL_CR
-
 
315
			END
-
 
316
		END
-
 
317
	END;
-
 
318
	text.cnt := cnt;
-
 
319
	text.pos := pos;
-
 
320
	IF res = -1 THEN
-
 
321
		res := EOL_CRLF
-
 
322
	END
-
 
323
	RETURN res
-
 
324
END detectEOL;
297
 
325
 
298
 
326
 
299
PROCEDURE load* (name: tFileName; VAR enc: INTEGER): tInput;
327
PROCEDURE load* (name: tFileName; VAR enc, eol: INTEGER): tInput;
300
VAR
328
VAR
301
    res: tInput;
329
    res: tInput;
302
    fsize: INTEGER;
330
    fsize: INTEGER;
Line 323... Line 351...
323
        ELSIF enc = E.CP866 THEN
351
        ELSIF enc = E.CP866 THEN
324
            res.getChar := getCharCP866
352
            res.getChar := getCharCP866
325
        ELSIF enc = E.W1251 THEN
353
        ELSIF enc = E.W1251 THEN
326
            res.getChar := getCharW1251
354
            res.getChar := getCharW1251
327
        END;
355
        END;
328
        res.enc := enc
356
        eol := detectEOL(res)
329
    END
357
    END
330
    RETURN res
358
    RETURN res
331
END load;
359
END load;
Line 338... Line 366...
338
    NEW(res);
366
    NEW(res);
339
    res.pos := 0;
367
    res.pos := 0;
340
    res.CR := FALSE;
368
    res.CR := FALSE;
341
    res.clipbrd := TRUE;
369
    res.clipbrd := TRUE;
342
    res.getChar := NIL;
370
    res.getChar := NIL;
343
    res.enc := E.CP866;
-
 
344
    res.getChar := getCharCP866;
371
    res.getChar := getCharCP866;
345
    res.buffer := CB.get(res.cnt);
372
    res.buffer := CB.get(res.cnt);
346
    IF res.buffer = 0 THEN
373
    IF res.buffer = 0 THEN
347
        DISPOSE(res)
374
        DISPOSE(res)
348
    END
375
    END
Line 522... Line 549...
522
    END
549
    END
523
END destroy;
550
END destroy;
Line 524... Line 551...
524
 
551
 
525
 
-
 
526
BEGIN
552
 
-
 
553
BEGIN
527
    eol[EOL_LF] := LF;
554
    eol[EOL_CRLF] := CR + LF;
-
 
555
    eol[EOL_LF] := LF;
-
 
556
    eol[EOL_CR] := CR;
-
 
557
    eolNames[EOL_CRLF] := "CRLF";
528
    eol[EOL_CRLF] := CR + LF;
558
    eolNames[EOL_LF] := "LF";
529
    eol[EOL_CR] := CR
559
    eolNames[EOL_CR] := "CR"