-
Notifications
You must be signed in to change notification settings - Fork 3
Created a History Command #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,9 @@ bool alt_mode = false; | |
| bool ctrl_mode = false; | ||
| bool super_mode = false; | ||
|
|
||
| char history_data[100][RDL_SIZE]; | ||
| uint8_t tot_cmds=0; | ||
|
|
||
| void run_cmd(char *run) { | ||
| if (!(strncmp(run, "page 0x", 7))) { | ||
| show_page_table_layout_for_address(hex2int(run+7)); | ||
|
|
@@ -135,6 +138,13 @@ void run_cmd(char *run) { | |
| } | ||
| } else if (!strncmp(run, "tree ", 5)) { | ||
| tree(run + 5); | ||
| } | ||
| else if (!strncmp(run, "history", 7)){ | ||
| for(int i=0;i<tot_cmds;i++){ | ||
| write_num(i+1); | ||
| kprintf(" %05s",history_data[i]); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use 1 kprintf for this line.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compressed my code to 1 line kprintf. |
||
| kprintf("\n"); | ||
| } | ||
| } else { | ||
| kprintf("INVALID COMMAND\n"); | ||
| } | ||
|
|
@@ -184,12 +194,17 @@ void kshell(unsigned char key) { | |
| if (up) { | ||
| int i; | ||
| kprintf("\n"); | ||
| for (i = 0; i < rdl_index; i++) | ||
| { | ||
| history_data[tot_cmds][i]=readline[i]; | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a memcpy implementation.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied data using memcpy and reduced the no. of lines. |
||
| run_cmd(readline); | ||
| rdl_index = 0; | ||
| for(i=0;i<RDL_SIZE;i++) { | ||
| readline[i] = 0; | ||
| } | ||
| kprintf("%04s", "SOS$ "); | ||
| tot_cmds++; | ||
| } | ||
| break; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer you keep this in some sort of dynamic data structure, rather than a list - not just for cleanliness, but because this implementation is rife with data overflow opportunities. - for instance, you never bounds check on tot_cmds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created a dynamic list to resolve the overflow problem.