Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit b930e52

Browse files
[[ Bug 20971 ]] Unary function parsing does not check for EOL
1 parent cd4fd5d commit b930e52

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

docs/notes/bugfix-20971.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Throw parse error when unary function has no params

engine/src/funcs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2727

2828
#include "exec.h"
2929
#include "param.h"
30+
#include "scriptpt.h"
3031

3132
////////////////////////////////////////////////////////////////////////////////
3233

@@ -93,7 +94,7 @@ class MCUnaryFunctionCtxt: public MCUnaryFunction
9394

9495
virtual Parse_stat parse(MCScriptPoint &sp, Boolean the)
9596
{
96-
if (get1param(sp, &m_expression, the) != PS_NORMAL)
97+
if (sp.is_eol() || get1param(sp, &m_expression, the) != PS_NORMAL)
9798
{
9899
MCperror -> add(ParseError, sp);
99100
return PS_ERROR;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%% Copyright (C) 2018 LiveCode Ltd.
2+
%%
3+
%% This file is part of LiveCode.
4+
%%
5+
%% LiveCode is free software; you can redistribute it and/or modify it under
6+
%% the terms of the GNU General Public License v3 as published by the Free
7+
%% Software Foundation.
8+
%%
9+
%% LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
%% WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
%% for more details.
13+
%%
14+
%% You should have received a copy of the GNU General Public License
15+
%% along with LiveCode. If not see <http://www.gnu.org/licenses/>.
16+
17+
%TEST UnaryFunctionNoParams
18+
on parse_test
19+
get the fontlanguage %{AFTER_FUNCTION}
20+
end parse_test
21+
%EXPECT PASS
22+
%ERROR PE_FONTNAMES_BADPARAM AT AFTER_FUNCTION
23+
%ENDTEST

0 commit comments

Comments
 (0)