From 70314b3303f712a0277b80b23bc3613744e6178e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 Jun 2020 19:51:17 +0300 Subject: Add builtin weight Also invent the notion of external builtin (builtin_info::function is NULL). --- libbutl/command.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libbutl/command.cxx') diff --git a/libbutl/command.cxx b/libbutl/command.cxx index bb5287c..fadd617 100644 --- a/libbutl/command.cxx +++ b/libbutl/command.cxx @@ -227,9 +227,9 @@ namespace butl msg.c_str ()); } - builtin_function* bf (builtins.find (prog)); + const builtin_info* bi (builtins.find (prog)); - if (bf != nullptr) // Execute the builtin. + if (bi != nullptr && bi->function != nullptr) // Execute the builtin. { if (callback) { @@ -259,17 +259,17 @@ namespace butl uint8_t r; // Storage. builtin_callbacks cb; - builtin b (bf (r, - args, - nullfd /* stdin */, - move (rd) /* stdout */, - nullfd /* stderr */, - cwd, - cb)); + builtin b (bi->function (r, + args, + nullfd /* stdin */, + move (rd) /* stdout */, + nullfd /* stderr */, + cwd, + cb)); return process_exit (b.wait ()); } - else // Execute the program. + else // Execute the program. { // Strip the potential leading `^`, indicating that this is an external // program rather than a builtin. Consider only simple paths and don't -- cgit v1.1