Skip to content

Commit 12aaa8f

Browse files
committed
make enable builtin use register_builtins()
1 parent a3f3842 commit 12aaa8f

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

builtins/common.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,10 +1099,7 @@ set_expand_once (int nval, int uwp)
10991099
}
11001100
#endif
11011101

1102-
#if defined (BUILD_LIBRARY)
1103-
/* Register a given array of new builtins into the internal list.
1104-
* (Mostly copied from the enable builtin used when loading dynamic builtins.)
1105-
*/
1102+
/* Register a given array of new builtins into the internal list. */
11061103
int
11071104
register_builtins (struct builtin **new_builtins, size_t num_new_builtins)
11081105
{
@@ -1133,4 +1130,3 @@ register_builtins (struct builtin **new_builtins, size_t num_new_builtins)
11331130

11341131
return (EXECUTION_SUCCESS);
11351132
}
1136-
#endif

builtins/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ extern int no_options (WORD_LIST *);
9191

9292
#if defined (BUILD_LIBRARY)
9393
/* scallop extensions */
94-
extern int register_builtins (struct builtin **, size_t);
9594
extern int scallop_source_file (const char *);
9695
extern int scallop_evalstring (const char *, int);
9796
#endif
@@ -149,6 +148,7 @@ extern sh_builtin_func_t *find_shell_builtin (const char *);
149148
extern sh_builtin_func_t *builtin_address (const char *);
150149
extern sh_builtin_func_t *find_special_builtin (const char *);
151150
extern void initialize_shell_builtins (void);
151+
extern int register_builtins (struct builtin **, size_t);
152152

153153
#if defined (ARRAY_VARS)
154154
extern int set_expand_once (int, int);

builtins/enable.def

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -472,29 +472,7 @@ dyn_load_builtin (WORD_LIST *list, int flags, char *filename)
472472
}
473473

474474
if (new)
475-
{
476-
total = num_shell_builtins + new;
477-
size = (total + 1) * sizeof (struct builtin);
478-
479-
new_shell_builtins = (struct builtin *)xmalloc (size);
480-
FASTCOPY ((char *)shell_builtins, (char *)new_shell_builtins,
481-
num_shell_builtins * sizeof (struct builtin));
482-
for (replaced = 0; replaced < new; replaced++)
483-
FASTCOPY ((char *)new_builtins[replaced],
484-
(char *)&new_shell_builtins[num_shell_builtins + replaced],
485-
sizeof (struct builtin));
486-
487-
new_shell_builtins[total].name = (char *)0;
488-
new_shell_builtins[total].function = (sh_builtin_func_t *)0;
489-
new_shell_builtins[total].flags = 0;
490-
491-
if (shell_builtins != static_shell_builtins)
492-
free (shell_builtins);
493-
494-
shell_builtins = new_shell_builtins;
495-
num_shell_builtins = total;
496-
initialize_shell_builtins ();
497-
}
475+
register_builtins(new_builtins, new);
498476

499477
free (new_builtins);
500478
return (EXECUTION_SUCCESS);

0 commit comments

Comments
 (0)