Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
5e100e18
Commit
5e100e18
authored
18 years ago
by
Christopher J. Morrone
Browse files
Options
Downloads
Patches
Plain Diff
Better way to handle comments under #SBATCH
parent
bbf83475
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbatch/opt.c
+5
-29
5 additions, 29 deletions
src/sbatch/opt.c
with
5 additions
and
29 deletions
src/sbatch/opt.c
+
5
−
29
View file @
5e100e18
...
...
@@ -1115,35 +1115,11 @@ static char *_next_line(const void *buf, int size, void **state)
return
line
;
}
/* Strip comments from a line by terminating the string
* where the comment begins.
* Everything after a non-escaped "#" is a comment.
*/
static
void
_strip_comments
(
char
*
line
)
{
int
i
;
int
len
=
strlen
(
line
);
int
bs_count
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
/* if # character is preceded by an even number of
* escape characters '\' */
if
(
line
[
i
]
==
'#'
&&
(
bs_count
%
2
)
==
0
)
{
line
[
i
]
=
'\0'
;
break
;
}
else
if
(
line
[
i
]
==
'\\'
)
{
bs_count
++
;
}
else
{
bs_count
=
0
;
}
}
}
/*
* _get_argument - scans a line for something that looks like a command line
* argument, and return an xmalloc'ed string containing the argument.
* Quotes can be used to group characters, including whitespace.
* Quotes can be included in an argument be escaping the quotes
;
* Quotes can be included in an argument be escaping the quotes
,
* preceding the quote with a backslash (\").
*
* IN - line
...
...
@@ -1170,8 +1146,6 @@ static char *_get_argument(const char *line, int *skipped)
if
(
*
ptr
==
'\0'
)
return
NULL
;
_strip_comments
(
ptr
);
/* copy argument into "argument" buffer, */
i
=
0
;
while
((
no_isspace_check
||
!
isspace
(
*
ptr
))
...
...
@@ -1190,6 +1164,9 @@ static char *_get_argument(const char *line, int *skipped)
/* toggle the no_isspace_check flag */
no_isspace_check
=
no_isspace_check
?
false
:
true
;
ptr
++
;
}
else
if
(
*
ptr
==
'#'
)
{
/* found an un-escaped #, rest of line is a comment */
break
;
}
else
{
argument
[
i
]
=
*
ptr
;
ptr
++
;
...
...
@@ -1237,8 +1214,7 @@ static void _opt_batch_script(const void *body, int size)
/* this line starts with the magic word */
ptr
=
line
+
strlen
(
magic_word
);
while
((
option
=
_get_argument
(
ptr
,
&
skipped
))
!=
NULL
)
{
debug2
(
"
\t
Found argument
\"
%s
\"
skipped = %d"
,
option
,
skipped
);
debug2
(
"Found in script, argument
\"
%s
\"
"
,
option
);
argc
+=
1
;
xrealloc
(
argv
,
sizeof
(
char
*
)
*
argc
);
argv
[
argc
-
1
]
=
option
;
...
...
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