- Subject: RE: Looping and composite conditions
- From: SANGOI DINO <SANGOID@xxxxxxxxxxxxxxxxx>
- Date: Thu, 19 Dec 2002 09:58:21 +0100
> -----Original Message-----
> From: Morten Bo Johansen [mailto:mojo@xxxxxxxx]
> Sent: mercoledì 18 dicembre 2002 23.09
> Subject: Looping and composite conditions
>
> Hi,
>
> I am still working on my po_mode and while trying to improve
> the search function for untranslated strings I stumbled upon
> something I don't quite understand. The functions look like this:
>
> static define untranslated ()
> {
> bol_fsearch ("msgstr") and fsearch ("\"") and
> looking_at ("\"\"")
> and down_1 () and skip_chars (" \t\n") and looking_at ("#");
> }
Uhm, skip_chars() doesn't return a value, so this function will pop a value
from stack not pushed by some of the invoked functions. You should also
remember that slang does not use short circuit evaluation when using 'and'
and 'or', so ALL the expressions on a condition will be evaluated.
>
> define find_untranslated ()
> {
> forever
> {
> if (eobp ())
> {
> message ("Not found");
> bob ();
> return;
> }
> if (1 == untranslated ()) break;
I don't know much about the slang internals, but I bet that when evaluating
'skip_chars()', it pops the the '1' pushed here.
> }
> bsearch ("\"");
> }
>
>
an easy fix may be:
static define untranslated ()
{
bol_fsearch ("msgstr") and fsearch ("\"") and looking_at ("\"\"")
and down_1 () and (skip_chars (" \t\n"), looking_at ("#"));
}
(note the ',' instead of 'and').
or maybe you can write:
define find_untranslated ()
{
variable found = 0;
while (bol_fsearch ("msgstr"))
{
if (andelse { fsearch ("\"") }
{ looking_at ("\"\"") }
{ down_1 () }
{ skip_chars (" \t\n"), looking_at ("#"))
{
found = 1;
break;
}
eol();
}
if (not found)
{
message ("Not found");
bob ();
return;
}
}
> Thanks,
>
Hope this helps.
Dino
--
In theory, there is no difference between theory and practice.
In practice, there is.
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2002 date index]
[2002 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]