Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107280176
D36363.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D36363.diff
View Options
diff --git a/stand/common/interp.c b/stand/common/interp.c
--- a/stand/common/interp.c
+++ b/stand/common/interp.c
@@ -152,6 +152,19 @@
free(pr);
}
+static struct bootblk_command *
+interp_lookup_cmd(const char *cmd)
+{
+ struct bootblk_command **cmdp;
+
+ /* search the command set for the command */
+ SET_FOREACH(cmdp, Xcommand_set) {
+ if (((*cmdp)->c_name != NULL) && !strcmp(cmd, (*cmdp)->c_name))
+ return (*cmdp);
+ }
+ return (NULL);
+}
+
/*
* Perform a builtin command
*/
@@ -159,27 +172,21 @@
interp_builtin_cmd(int argc, char *argv[])
{
int result;
- struct bootblk_command **cmdp;
- bootblk_cmd_t *cmd;
+ struct bootblk_command *cmd;
if (argc < 1)
- return(CMD_OK);
+ return (CMD_OK);
/* set return defaults; a successful command will override these */
command_errmsg = command_errbuf;
strcpy(command_errbuf, "no error message");
- cmd = NULL;
result = CMD_ERROR;
- /* search the command set for the command */
- SET_FOREACH(cmdp, Xcommand_set) {
- if (((*cmdp)->c_name != NULL) && !strcmp(argv[0], (*cmdp)->c_name))
- cmd = (*cmdp)->c_fn;
- }
- if (cmd != NULL) {
- result = (cmd)(argc, argv);
+ cmd = interp_lookup_cmd(argv[0]);
+ if (cmd != NULL && cmd->c_fn) {
+ result = cmd->c_fn(argc, argv);
} else {
command_errmsg = "unknown command";
}
- return(result);
+ return (result);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 10:03 PM (21 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773185
Default Alt Text
D36363.diff (1 KB)
Attached To
Mode
D36363: stand: separate the command lookup from the command execution
Attached
Detach File
Event Timeline
Log In to Comment