I'm doing my taxes and i have to evaluate strings like "4,54"
resulting in a number of cents.
A do a precaution, I want that numbers are only recognized
after ONLY, i.e. in the minimum search order, to prevent
executing of arbitrary strings, such
" ""rm *"" SYSTEM ".
So I begin the dotaxes word
: dotaxes ONLY ... ;
That works in my simple (own) Forth and also in gforth.
I wonder if that is a portable technique?
I'm doing my taxes and i have to evaluate strings like "4,54"
resulting in a number of cents.
A do a precaution, I want that numbers are only recognized
after ONLY
i.e. in the minimum search order, to prevent
executing of arbitrary strings, such
" ""rm *"" SYSTEM ".
So I begin the dotaxes word
: dotaxes ONLY ... ;
That works in my simple (own) Forth and also in gforth.
albert@cherry.(none) (albert) writes:
I'm doing my taxes and i have to evaluate strings like "4,54"
resulting in a number of cents.
A do a precaution, I want that numbers are only recognized
after ONLY
I assume you mean that you only want to use EVALUATE, but only
recognize numbers.
i.e. in the minimum search order, to prevent
executing of arbitrary strings, such
" ""rm *"" SYSTEM ".
So I begin the dotaxes word
: dotaxes ONLY ... ;
That works in my simple (own) Forth and also in gforth.
It's not clear what's up with the quotes in the example above, but in
Gforth you can break out of ONLY with FORTH (ONLY is not SEAL, and
even SEAL is not what you want). E.g.
only forth
s" evil-command" system
You can also break out of ONLY with FORTH in iForth, lxf, SwiftForth,
and VFX.
If you want to remove all word lists from the search order, use
0 set-order
- anton
In article <2022Apr30.193157@mips.complang.tuwien.ac.at>,[...]
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
albert@cherry.(none) (albert) writes:
I'm doing my taxes and i have to evaluate strings like "4,54"
resulting in a number of cents.
A do a precaution, I want that numbers are only recognized
after ONLY
I assume you mean that you only want to use EVALUATE, but only
recognize numbers.
Gforth you can break out of ONLY with FORTH (ONLY is not SEAL, and
even SEAL is not what you want). E.g.
only forth
s" evil-command" system
That was what I wanted to prevent. So no forth-wordlist in the
search-order containing the evil `SYSTEM command.
If you want to remove all word lists from the search order, use
0 set-order
The trick^H^H^H^H technique works in gforth and mpe forth.
: test ONLY S" 1 2 3 DROP" EVALUATE ; redefined test ok
test
*evaluated string*:-1: Undefined word
1 2 3 >>>DROP<<<
Backtrace:
...
What you recommend, works also in ciforth and gforth.
ONLY FORTH ok
: test 0 set-order S" 1 2 3 DROP" EVALUATE ; redefined test ok
test
*evaluated string*:-1: Undefined word
1 2 3 >>>DROP<<<
It works more or less in mpe forth, but you cannot recover
from `` 0 set-order '' . You can only type ^C .
`` ONLY FORTH '' doesn't help. This is certainly a
viable interpretation of the standard, making ONLY the
best portable way to have the Forth system understand numbers
("denotations") only.
In article <2022Apr30.193157@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
only forth
s" evil-command" system
That was what I wanted to prevent. So no forth-wordlist in the
search-order containing the evil `SYSTEM command.
Everybody uses
`` ONLY FORTH ''
That is not the way the standard expects it apparently.
You are supposed to do
`` forth-wordlist 1 set-order ''
because it is not guaranteed that FORTH is in the minimum search order.
(Last time I looked.)
If you want to remove all word lists from the search order, use
0 set-order
The trick^H^H^H^H technique works in gforth and mpe forth.
: test ONLY S" 1 2 3 DROP" EVALUATE ; redefined test ok
test
*evaluated string*:-1: Undefined word
1 2 3 >>>DROP<<<
Backtrace:
...
It works more or less in mpe forth, but you cannot recover
from `` 0 set-order '' .
A do a precaution, I want that numbers are only recognizedYou inspired me to implement ONLY that works with FIG vocabularies.
after ONLY, i.e. in the minimum search order, to prevent
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 55:20:46 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,394 |