Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Server maintenance on Tue 24.5. at 12:00.
Estimated downtime less than 30 minutes.
Open sidebar
Vesa Oikonen
tpcclib
Commits
5333777e
Commit
5333777e
authored
Jul 16, 2020
by
Vesa Oikonen
Browse files
updated argument handling
parent
07a8ee2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
v2/tacutils/taccross.c
View file @
5333777e
...
...
@@ -101,30 +101,23 @@ int main(int argc, char **argv)
status
.
verbose
=
verbose
-
5
;
/* Arguments */
for
(;
ai
<
argc
;
ai
++
)
{
if
(
!
tacfile1
[
0
])
{
strcpy
(
tacfile1
,
argv
[
ai
]);
continue
;
}
else
if
(
!
tacfile2
[
0
])
{
strcpy
(
tacfile2
,
argv
[
ai
]);
continue
;
}
else
if
(
crossLimit
==
0
)
{
crossLimit
=
atoi
(
argv
[
ai
]);
if
(
crossLimit
>
0
)
continue
;
}
fprintf
(
stderr
,
"Error: invalid argument '%s'.
\n
"
,
argv
[
ai
]);
return
(
1
);
}
if
(
ai
<
argc
)
strlcpy
(
tacfile1
,
argv
[
ai
++
],
FILENAME_MAX
);
if
(
ai
<
argc
)
strlcpy
(
tacfile2
,
argv
[
ai
++
],
FILENAME_MAX
);
if
(
ai
<
argc
)
crossLimit
=
atoi
(
argv
[
ai
++
]);
if
(
ai
<
argc
)
{
fprintf
(
stderr
,
"Error: invalid argument '%s'.
\n
"
,
argv
[
ai
]);
return
(
1
);}
/* Is something missing? */
if
(
!
tacfile2
[
0
]
||
crossLimit
<
1
)
{
tpcPrintUsage
(
argv
[
0
],
info
,
stdout
);
return
(
1
);}
if
(
!
tacfile2
[
0
]
||
crossLimit
<
1
)
{
tpcPrintUsage
(
argv
[
0
],
info
,
stdout
);
return
(
1
);}
if
(
crossLimit
<
1
)
{
fprintf
(
stderr
,
"Error: missing or invalid cross number.
\n
"
);
return
(
1
);}
/* In verbose mode print arguments and options */
if
(
verbose
>
1
)
{
for
(
ai
=
0
;
ai
<
argc
;
ai
++
)
printf
(
"%s "
,
argv
[
ai
]);
for
(
ai
=
0
;
ai
<
argc
;
ai
++
)
printf
(
"%s "
,
argv
[
ai
]);
printf
(
"
\n
"
);
printf
(
"tacfile1 := %s
\n
"
,
tacfile1
);
printf
(
"tacfile2 := %s
\n
"
,
tacfile2
);
printf
(
"crossLimit := %d
\n
"
,
crossLimit
);
fflush
(
stdout
);
}
...
...
@@ -172,8 +165,7 @@ int main(int argc, char **argv)
}
ret
=
tacYUnitConvert
(
&
tac1
,
tac2
.
cunit
,
&
status
);
if
(
ret
!=
TPCERROR_OK
)
{
fprintf
(
stderr
,
"Warning: could not convert concentrations from '%s' to '%s'.
\n
"
,
fprintf
(
stderr
,
"Warning: could not convert concentrations from '%s' to '%s'.
\n
"
,
unitName
(
tac1
.
cunit
),
unitName
(
tac2
.
cunit
));
}
...
...
@@ -196,8 +188,7 @@ int main(int argc, char **argv)
*/
int
i
,
consecNr
=
0
,
crossNr
=
0
,
above
=
0
;
i
=
0
;
if
(
tac2
.
c
[
0
].
y
[
i
]
>
tac2
.
c
[
1
].
y
[
i
])
above
=
1
;
if
(
verbose
>
2
)
printf
(
" %d: %d %g %g
\n
"
,
1
+
i
,
above
,
tac2
.
c
[
0
].
y
[
i
],
tac2
.
c
[
1
].
y
[
i
]);
if
(
verbose
>
2
)
printf
(
" %d: %d %g %g
\n
"
,
1
+
i
,
above
,
tac2
.
c
[
0
].
y
[
i
],
tac2
.
c
[
1
].
y
[
i
]);
for
(
i
=
1
;
i
<
tac2
.
sampleNr
;
i
++
)
{
if
(
tac2
.
c
[
0
].
y
[
i
]
>
tac2
.
c
[
1
].
y
[
i
])
{
// above
if
(
above
)
{
consecNr
++
;}
else
{
consecNr
=
0
;
crossNr
++
;}
...
...
@@ -206,8 +197,7 @@ int main(int argc, char **argv)
if
(
!
above
)
{
consecNr
++
;}
else
{
consecNr
=
0
;
crossNr
++
;}
above
=
0
;
}
if
(
verbose
>
2
)
printf
(
" %d: %d %g %g
\n
"
,
1
+
i
,
above
,
tac2
.
c
[
0
].
y
[
i
],
tac2
.
c
[
1
].
y
[
i
]);
if
(
verbose
>
2
)
printf
(
" %d: %d %g %g
\n
"
,
1
+
i
,
above
,
tac2
.
c
[
0
].
y
[
i
],
tac2
.
c
[
1
].
y
[
i
]);
if
(
crossNr
>
0
&&
consecNr
>=
crossLimit
)
break
;
}
if
(
crossNr
==
0
||
consecNr
<
crossLimit
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment