Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TP-shell-student
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
gc_courses
sys-exploit
TP-shell-student
Commits
3a5af2fa
Commit
3a5af2fa
authored
2 years ago
by
Guillaume Chanel
Browse files
Options
Downloads
Patches
Plain Diff
Handle inputs made of delimiters only
parent
0ef49334
No related branches found
No related tags found
No related merge requests found
Pipeline
#19934
failed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
interface.c
+16
-0
16 additions, 0 deletions
interface.c
with
16 additions
and
0 deletions
interface.c
+
16
−
0
View file @
3a5af2fa
...
...
@@ -109,6 +109,18 @@ int parse_command(char *user_input, cmd_t *cmd) {
return
0
;
}
//Check is a string is composed only of a set of characters
//OUT:
// str: the string to check (does it contains some chars ?)
// of: a string containing the set of characters to verify
// return: true is the string str is made only of chars in of, false otherwise
static
bool
str_made_only_of
(
const
char
*
str
,
const
char
*
of
)
{
while
(
*
str
)
if
(
strchr
(
of
,
*
str
++
)
==
NULL
)
return
false
;
return
true
;
}
//Wait for the user input and return it
//OUT:
// user_input: a string with the user input. The user should take care of the
...
...
@@ -123,6 +135,10 @@ int ask_user_input(char* user_input) {
//Ensure that the end of line chars are removed
user_input
[
strcspn
(
user_input
,
"
\r\n
"
)]
=
0
;
// if string is only made of delimiters -> replace by empty string
if
(
str_made_only_of
(
user_input
,
DELIMIERS
))
user_input
[
0
]
=
'\0'
;
return
user_input
[
0
];
}
...
...
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