Skip to content

Commit 3446461

Browse files
committed
FIX: do not allow make a task! if not compiled with INCLUDE_TASK define
1 parent 44b13f8 commit 3446461

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/core/c-task.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
*/
5959

6060
#include "sys-core.h"
61-
//#define INCLUDE_TASK
6261

6362
#ifdef INCLUDE_TASK
6463
/***********************************************************************
@@ -99,8 +98,6 @@
9998
{
10099
#ifdef INCLUDE_TASK
101100
OS_CREATE_THREAD((void*)Launch_Task, task, 50000);
102-
#else
103-
puts("** Build using INCLUDE_TASK define to experiment with task!");
104-
Trap0(RE_FEATURE_NA);
105101
#endif
106102
}
103+

src/core/t-object.c

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ static REBSER *Trim_Object(REBSER *obj)
315315

316316
// make task! [init]
317317
if (type == REB_TASK) {
318+
#ifdef INCLUDE_TASK
318319
// Does it include a spec?
319320
VAL_SET(value, REB_TASK);
320321
if (IS_BLOCK(VAL_BLK(arg))) {
@@ -328,6 +329,9 @@ static REBSER *Trim_Object(REBSER *obj)
328329
}
329330
VAL_MOD_FRAME(value) = obj;
330331
DS_RET_VALUE(value);
332+
#else
333+
Trap0(RE_FEATURE_NA);
334+
#endif
331335
return R_RET;
332336
}
333337
}

src/include/sys-core.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define HAS_SHA1 // allow it
5050
#define HAS_SHA2 // allow SHA 256/384/512
5151
#define HAS_MD5 // allow it
52+
//#define INCLUDE_TASK
5253

5354
// External system includes:
5455
#include <stdlib.h>

src/tests/units/task-test.r3

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ Rebol [
99
~~~start-file~~~ "TASK!"
1010

1111
===start-group=== "task"
12-
--test-- "issues-47"
13-
;@@ https://github.com/Oldes/Rebol-issues/issues/47
14-
--assert error? try [do make task! [2 / 0]] ; trying to evaluate a task should not crash!
12+
if any [
13+
not error? test-task: try [make task! []] ; task may be disabled
14+
test-task/id <> 'feature-na
15+
][
16+
--test-- "empty task"
17+
--assert task? do test-task
18+
19+
--test-- "issues-47"
20+
;@@ https://github.com/Oldes/Rebol-issues/issues/47
21+
--assert task? do make task! [1 / 0] ; trying to evaluate a task should not crash!
22+
]
1523

1624
===end-group===
1725

0 commit comments

Comments
 (0)