-
Notifications
You must be signed in to change notification settings - Fork 26
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
utl/spdemo: set default value for string-based parameter. #116
Conversation
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.
This would work for spdemo, but shall we find FIND_PAR_S macro instead?
It may be better to fix the macro so that we will not stumble on this issue again. A condition that checks that prevents the strcpy if the pointers are the same should work fine:
#define FIND_PAR_S(p,msg,i,dft) \
{ if (i != dft) { strcpy(i,(argc>p)?argv[p]:dft);}\
fprintf (stderr,"%s%s\n",msg,i); }
I would be in favor of removing the macros but it looks like it was necessary for some of the old compilers. We need to find out which platform was problematic and whether we still want to support them. Shall we keep this task for STL2019? These macros/functions would probably not be needed anymore the day we look into #8. |
I will fix the macro tomorrow. You are right removing the macros should be done after STL2018. |
4136a89
to
6fcf0a2
Compare
Fixed macro as well. @ludomal Could you test it and merge if ready? |
6fcf0a2
to
73111d3
Compare
Rebased to include Travis4MacOS. |
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.
-- moved --
@@ -183,7 +183,7 @@ | |||
fprintf (stderr,"%s%c\n",msg,C);} | |||
|
|||
#define FIND_PAR_S(p,msg,i,dft) \ | |||
{ strcpy(i,(argc>p)?argv[p]:dft);\ | |||
{ memmove(i,(argc>p)?argv[p]:dft, strlen((argc>p)?argv[p]:dft));\ |
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.
That works.
3f1f401
to
ab538b5
Compare
Now only fixing |
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.
Rebased to only include changes to src/utl/ugstdemo.h
src/utl/spdemo.c
Outdated
@@ -535,7 +535,7 @@ int main (int argc, char *argv[]) { | |||
FIND_PAR_L (6, "_No. of Blocks: .............. ", N2, N2); | |||
FIND_PAR_L (7, "_Resolution of input data: ... ", resolution, resolution); | |||
FIND_PAR_I (8, "_Sync header? (1=Yes,0=No) ... ", sync, sync); | |||
FIND_PAR_S (9, "_Left of right adjusted? ..... ", just, just); | |||
FIND_PAR_S (9, "_Left of right adjusted? ..... ", just, "right"); |
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.
just
has a default value set at declaration (right
).
This change should be reverted as it overwrites the justification set with -left
switch.
src/utl/scaldemo.c
Outdated
@@ -287,6 +287,7 @@ int main (int argc, char *argv[]) { | |||
/* Read parameters for processing */ | |||
GET_PAR_S (1, "_Input File: ........................... ", FileIn); | |||
GET_PAR_S (2, "_Output File: .......................... ", FileOut); | |||
|
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.
Are these changes necessary?
ATTENTION: This solution is just a guess and needs testing (especially on MacOS).
This might be a fix for #46.
Potential explanation:
I believe the issue results from using
strcpy
onsrc
==dst
.This is not allowed as
src
anddst
should not overlap.