Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Project Purple Stallion
Pintos
Commits
76fb9ae7
Verified
Commit
76fb9ae7
authored
5 years ago
by
ja3-saxby
Browse files
Options
Downloads
Patches
Plain Diff
Remove debugging code
parent
79d1b7f2
No related branches found
No related tags found
1 merge request
!4
Implement parse_arguments()
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
userprog/parse_arguments.c
+0
-3
0 additions, 3 deletions
userprog/parse_arguments.c
userprog/process.c
+0
-5
0 additions, 5 deletions
userprog/process.c
with
0 additions
and
8 deletions
userprog/parse_arguments.c
+
0
−
3
View file @
76fb9ae7
...
@@ -5,19 +5,16 @@
...
@@ -5,19 +5,16 @@
int
parse_arguments
(
const
char
*
command_line
,
char
**
argv
)
{
int
parse_arguments
(
const
char
*
command_line
,
char
**
argv
)
{
printf
(
"parse_arguments(command_line) = '%s'
\n
"
,
command_line
);
int
argc
=
0
;
int
argc
=
0
;
// the state pointer required by strtok_r() for use between calls
// the state pointer required by strtok_r() for use between calls
char
*
state_pointer
;
char
*
state_pointer
;
// first call to strtok_r() is the only one where string to parse is passed
// first call to strtok_r() is the only one where string to parse is passed
argv
[
0
]
=
strtok_r
(
command_line
,
" "
,
&
state_pointer
);
argv
[
0
]
=
strtok_r
(
command_line
,
" "
,
&
state_pointer
);
printf
(
"parse_arguments(): argv[0] = '%s'
\n
"
,
argv
[
0
]);
argc
++
;
argc
++
;
// now, parse token-by-token for any additional arguments
// now, parse token-by-token for any additional arguments
char
*
token
=
strtok_r
(
NULL
,
" "
,
&
state_pointer
);
char
*
token
=
strtok_r
(
NULL
,
" "
,
&
state_pointer
);
while
(
token
!=
NULL
)
{
while
(
token
!=
NULL
)
{
argv
[
argc
]
=
token
;
argv
[
argc
]
=
token
;
printf
(
"parse_arguments(): argv[%d] = '%s'
\n
"
,
argc
,
argv
[
argc
]);
argc
++
;
argc
++
;
token
=
strtok_r
(
NULL
,
" "
,
&
state_pointer
);
token
=
strtok_r
(
NULL
,
" "
,
&
state_pointer
);
}
}
...
...
This diff is collapsed.
Click to expand it.
userprog/process.c
+
0
−
5
View file @
76fb9ae7
...
@@ -234,16 +234,11 @@ load (const char *command, void (**eip) (void), void **esp)
...
@@ -234,16 +234,11 @@ load (const char *command, void (**eip) (void), void **esp)
// extract arguments (including file name)
// extract arguments (including file name)
// NOTE: decide how many arguments we want --is 255 the standard number?
// NOTE: decide how many arguments we want --is 255 the standard number?
char
*
argv
[
255
];
char
*
argv
[
255
];
printf
(
"load(command) = '%s'
\n
"
,
command
);
// copy the command string so we have a separate copy to manipulate
// copy the command string so we have a separate copy to manipulate
// generous length limit based on 255 arguments that are 15 chars long each
// generous length limit based on 255 arguments that are 15 chars long each
char
command_copy
[
255
];
char
command_copy
[
255
];
strlcpy
(
command_copy
,
command
,
255
);
strlcpy
(
command_copy
,
command
,
255
);
printf
(
"load(): command_copy = '%s'
\n
"
,
command_copy
);
int
argc
=
parse_arguments
(
command_copy
,
argv
);
int
argc
=
parse_arguments
(
command_copy
,
argv
);
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
{
printf
(
"load(): argv[%d] = '%s'
\n
"
,
i
,
argv
[
i
]);
}
char
*
file_name
=
argv
[
0
];
// file name is always argument 0
char
*
file_name
=
argv
[
0
];
// file name is always argument 0
/* Allocate and activate page directory. */
/* Allocate and activate page directory. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment