Fresh IDE . Check-in [8da41cc13f]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:HTML encoded link definitions should work the proper way.
Timelines: family | ancestors | descendants | both | FreshLibDev
Files: files | file ages | folders
SHA1:8da41cc13f6cada4963d43b0d2a01ab08a03a09d
User & Date: johnfound 2018-12-08 15:41:00
Context
2018-12-09
14:14
Check for end of the text in order to not miss it. check-in: 89738f4ec5 user: johnfound tags: FreshLibDev
2018-12-08
15:41
HTML encoded link definitions should work the proper way. check-in: 8da41cc13f user: johnfound tags: FreshLibDev
00:56
The new MiniMag parser added to the library. A minor fix to the BBCode parser. Also, all markup parsers excluded from the data/all.asm and have to be included manually in order to not be processed when not needed. check-in: 61bfb9f52c user: johnfound tags: FreshLibDev
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/data/minimag.asm.

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
143
144
145
146
147
148
149
150
151




















152
153
154
155
156
157
158
...
177
178
179
180
181
182
183
184
185
186









187
188
189
190
191
192
193
...
240
241
242
243
244
245
246




247
248
249
250
251
252
253
....
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
....
1362
1363
1364
1365
1366
1367
1368









1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381


1382


1383

1384
1385
1386
1387

1388
1389

1390
1391
1392
1393
1394
1395



1396
1397
1398
1399
1400
1401
1402
1403
1404

        mov     ecx, [edx+TText.GapEnd]
        dec     ecx
        jmp     .fp_skip_eol


.link_def_found:

        mov     eax, ecx
        sub     eax, [edx+TText.GapEnd]
        add     eax, [edx+TText.GapBegin]

        stdcall TextMoveGap, edx, eax   ; move the gap to the beginning of the link.

        lea     edi, [ecx+1]  ; the start of the label.
................................................................................
        je      .end_of_lbl

        test    al, al
        js      .add_hash

        mov     al, [tbl_html+eax]
        test    al, al
        js      .do_encode   ; not a valid link definition!
        jz      .fp_skip_eol





















.add_hash:
        xor     esi, eax
        movzx   esi, byte [tpl_func + esi]
        jmp     .hash_loop

.end_of_lbl:
................................................................................
        cmp     esi, $ff
        ja      .fp_skip_eol

        lea     edi, [edx+edi]

        stdcall StrNew
        stdcall StrCharCat, eax, esi
        stdcall StrCatMem, eax, edi, esi
        mov     [.tmp_link], eax










.link_url_start:
        inc     ecx
        cmp     ecx, [edx+TText.Length]
        jae     .free_link

        mov     al, [edx+ecx]
        test    al, al
................................................................................
.end_found:
        sub     esi, edi
        jz      .free_link

        lea     edi, [edx+edi]
        stdcall StrCatMemHTML, [.tmp_link], edi, esi





        mov     eax, [.lbl_hash]
        mov     edi, [.pLinks]
        mov     esi, [.tmp_link]

.hash_search_slot:                      ; resolve possible hash collisions.
        xchg    esi, [edi+4*eax]
        test    esi, esi
................................................................................
        pop     esi ecx eax
        retn

endp





proc DumpStack, .pStack
begin
        pushad

        mov     esi, [.pStack]
        xor     ecx, ecx
................................................................................

proc StrCatMemHTML, .dest, .psource, .length
begin
        pushad

        mov     esi, [.psource]
        mov     ecx, [.length]









        xor     eax, eax

.loop:
        dec     ecx
        js      .finish

        lodsb
        test    al, al
        js      .store

        mov     al, [tbl_html+eax]
        test    al, al
        jz      .loop


        jns     .store




        push    esi ecx

        lea     esi, [eax+tbl_html]
        lodsb


        stdcall StrCatMem, [.dest], esi, eax

        pop     ecx esi
        jmp     .loop

.store:
        stdcall StrCharCat, [.dest], eax
        jmp     .loop




.finish:
        popad
        return
endp











<







 







<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|


>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







|







 







>
>
>
>
>
>
>
>
>













>
>
|
>
>

>



|
>

<
>



|
|
|
>
>
>

<







115
116
117
118
119
120
121

122
123
124
125
126
127
128
...
142
143
144
145
146
147
148

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
....
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
....
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434

1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445

1446
1447
1448
1449
1450
1451
1452

        mov     ecx, [edx+TText.GapEnd]
        dec     ecx
        jmp     .fp_skip_eol


.link_def_found:

        mov     eax, ecx
        sub     eax, [edx+TText.GapEnd]
        add     eax, [edx+TText.GapBegin]

        stdcall TextMoveGap, edx, eax   ; move the gap to the beginning of the link.

        lea     edi, [ecx+1]  ; the start of the label.
................................................................................
        je      .end_of_lbl

        test    al, al
        js      .add_hash

        mov     al, [tbl_html+eax]
        test    al, al

        jz      .fp_skip_eol    ;????????????
        jns     .add_hash

        push    ecx edx

        mov     edx, esi
        mov     esi, eax
        add     esi, tbl_html

        lodsb
        mov     ecx, eax

.html_hash:
        lodsb
        xor     edx, eax
        mov     dl, [tpl_func + edx]
        loop    .html_hash

        mov     esi, edx
        pop     edx ecx
        jmp     .hash_loop

.add_hash:
        xor     esi, eax
        movzx   esi, byte [tpl_func + esi]
        jmp     .hash_loop

.end_of_lbl:
................................................................................
        cmp     esi, $ff
        ja      .fp_skip_eol

        lea     edi, [edx+edi]

        stdcall StrNew
        stdcall StrCharCat, eax, esi
        stdcall StrCatMemHTML, eax, edi, esi
        mov     [.tmp_link], eax

; fix the label length.
        stdcall StrPtr, eax
        mov     esi, eax
        mov     eax, [esi+string.len]
        dec     eax
        cmp     eax, $ff
        ja      .free_link
        mov     byte [esi], al

.link_url_start:
        inc     ecx
        cmp     ecx, [edx+TText.Length]
        jae     .free_link

        mov     al, [edx+ecx]
        test    al, al
................................................................................
.end_found:
        sub     esi, edi
        jz      .free_link

        lea     edi, [edx+edi]
        stdcall StrCatMemHTML, [.tmp_link], edi, esi

; for debugging links handing;
;        stdcall FileWriteString, [STDERR], [.tmp_link]
;        stdcall FileWriteString, [STDERR], <txt 13, 10>

        mov     eax, [.lbl_hash]
        mov     edi, [.pLinks]
        mov     esi, [.tmp_link]

.hash_search_slot:                      ; resolve possible hash collisions.
        xchg    esi, [edi+4*eax]
        test    esi, esi
................................................................................
        pop     esi ecx eax
        retn

endp



; Debug procedure. Not used in production.

proc DumpStack, .pStack
begin
        pushad

        mov     esi, [.pStack]
        xor     ecx, ecx
................................................................................

proc StrCatMemHTML, .dest, .psource, .length
begin
        pushad

        mov     esi, [.psource]
        mov     ecx, [.length]

        stdcall StrLen, [.dest]
        lea     edx, [eax+8*ecx+4]

        stdcall StrSetCapacity, [.dest], edx
        mov     edi, eax
        mov     ebx, eax
        add     edi, [edi+string.len]

        xor     eax, eax

.loop:
        dec     ecx
        js      .finish

        lodsb
        test    al, al
        js      .store

        mov     al, [tbl_html+eax]
        test    al, al
        jz      .loop
        js      .encode

.store:
        stosb
        jmp     .loop

.encode:
        push    esi ecx

        lea     esi, [eax+tbl_html]
        movzx   ecx, byte [esi]
        inc     esi


        rep movsb
        pop     ecx esi
        jmp     .loop

.finish:
        mov     ecx, edi
        xor     eax, eax
        sub     ecx, ebx
        stosd
        mov     [ebx+string.len], ecx


        popad
        return
endp