Skip to content

Commit c020f96

Browse files
committed
Simplified 'logic' for fopen_ext(), fixing errors with Docker and NEOfixer.
Configuration and temporary files are opened in Find_Orb via fopen_ext(). Its logic has become increasingly illogical over the years; the new version is considerably easier to figure out and fixes problems mentioned in issue #57 and by CSS. Also took the opportunity to sync some command line options between 'fo' and Find_Orb.
1 parent 3d89b2a commit c020f96

File tree

4 files changed

+116
-109
lines changed

4 files changed

+116
-109
lines changed

elem_out.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ int save_ephemeris_settings( const ephem_option_t ephemeris_output_options,
165165
int load_ephemeris_settings( ephem_option_t *ephemeris_output_options,
166166
int *n_steps, char *obscode, char *step_size, char *ephem_start,
167167
const char *config); /* elem_out.cpp */
168+
char *default_config_dir_name( char *oname, const char *iname); /* miscell.c */
168169
double generate_mc_variant_from_covariance( double *var_orbit,
169170
const double *orbit); /* orb_func.c */
170171
void rotate_state_vector_to_current_frame( double *state_vect,
@@ -4058,7 +4059,6 @@ int get_defaults( ephem_option_t *ephemeris_output_options, int *element_format,
40584059
const char *language = get_environment_ptr( "LANGUAGE");
40594060
extern double minimum_jd, maximum_jd;
40604061
extern double maximum_observation_span;
4061-
extern int use_config_directory;
40624062
extern double automatic_outlier_rejection_limit;
40634063
extern double default_automatic_outlier_rejection_limit;
40644064
extern unsigned max_n_sr_orbits;
@@ -4073,6 +4073,7 @@ int get_defaults( ephem_option_t *ephemeris_output_options, int *element_format,
40734073
const char *outlier_limit = get_environment_ptr( "OUTLIER_REJECTION_LIMIT");
40744074
const char *output_dir = get_environment_ptr( "OUTPUT_DIR");
40754075
extern const char *output_directory;
4076+
char cospar_name[255];
40764077

40774078
if( !output_directory && *output_dir)
40784079
output_directory = output_dir;
@@ -4137,13 +4138,9 @@ int get_defaults( ephem_option_t *ephemeris_output_options, int *element_format,
41374138

41384139
combine_all_observations = "";
41394140
}
4140-
if( use_config_directory)
4141-
{
4142-
char cospar_name[255];
41434141

4144-
make_config_dir_name( cospar_name, "cospar.txt");
4145-
load_cospar_file( cospar_name);
4146-
}
4142+
default_config_dir_name( cospar_name, "cospar.txt");
4143+
load_cospar_file( cospar_name);
41474144
max_n_sr_orbits = atoi( get_environment_ptr( "MAX_SR_ORBITS"));
41484145
if( !max_n_sr_orbits)
41494146
max_n_sr_orbits = 500;

findorb.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,7 +4042,6 @@ int main( int argc, const char **argv)
40424042
extern int monte_carlo_object_count;
40434043
extern char default_comet_magnitude_type;
40444044
extern double max_monte_rms;
4045-
extern int use_config_directory; /* miscell.c */
40464045
double max_residual_for_filtering = 2.5;
40474046
bool show_commented_elements = false;
40484047
bool drop_single_obs = true;
@@ -4054,10 +4053,6 @@ int main( int argc, const char **argv)
40544053
mmask_t button = 0;
40554054

40564055
random_seed = get_random_seed( );
4057-
if( !strcmp( argv[0], "find_orb"))
4058-
use_config_directory = true;
4059-
else
4060-
use_config_directory = false;
40614056
ensure_config_directory_exists();
40624057
if( !setlocale( LC_ALL, "C.UTF-8"))
40634058
setlocale( LC_ALL, "en_US.utf8");
@@ -4238,6 +4233,13 @@ int main( int argc, const char **argv)
42384233
}
42394234
break;
42404235
case 'x':
4236+
{
4237+
extern const char *alt_config_directory;
4238+
4239+
alt_config_directory = arg;
4240+
}
4241+
break;
4242+
case 'X':
42414243
{
42424244
extern bool saving_elements_for_reuse;
42434245

@@ -4251,14 +4253,6 @@ int main( int argc, const char **argv)
42514253
n_extra_full_steps = atoi( arg);
42524254
}
42534255
break;
4254-
case 'z':
4255-
{
4256-
extern const char *alt_config_directory;
4257-
4258-
use_config_directory = true;
4259-
alt_config_directory = arg;
4260-
}
4261-
break;
42624256
default:
42634257
printf( "Unknown command-line option '%s'\n", argv[i]);
42644258
return( -1);

fo.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ static int unlink_config_file( const char *filename)
173173
{
174174
char buff[255];
175175
int err_code;
176-
extern int use_config_directory; /* miscell.c */
177176
extern const char *output_directory;
178177

179178
get_file_name( buff, filename);
@@ -188,7 +187,7 @@ static int unlink_config_file( const char *filename)
188187
if( err_code)
189188
fprintf( stderr, "Failed unlinking '%s' ('%s')\n", filename, buff);
190189
}
191-
else if( use_config_directory)
190+
else
192191
{
193192
char cpath[255];
194193

@@ -197,8 +196,6 @@ static int unlink_config_file( const char *filename)
197196
if( err_code)
198197
fprintf( stderr, "Failed unlinking '%s'\n", cpath);
199198
}
200-
else
201-
err_code = UNLINK( buff);
202199
if( err_code)
203200
fprintf( stderr, "Failed unlinking '%s' ('%s')\n", filename, buff);
204201
return( err_code);
@@ -536,7 +533,6 @@ int main( int argc, const char **argv)
536533
FILE *summary_ofile = NULL;
537534
extern int forced_central_body;
538535
int override_forced_central_body = 0; /* by default, all orbits are heliocentric */
539-
extern int use_config_directory; /* miscell.c */
540536
int element_precision = 5;
541537
bool use_colors = true;
542538
bool show_processing_steps = true;
@@ -553,10 +549,6 @@ int main( int argc, const char **argv)
553549
int child_status;
554550
#endif
555551

556-
if( !strcmp( argv[0], "fo"))
557-
use_config_directory = true;
558-
else
559-
use_config_directory = false;
560552
ensure_config_directory_exists();
561553
*mpc_codes = '\0';
562554
if( reset_astrometry_filename( &argc, argv))
@@ -778,7 +770,6 @@ int main( int argc, const char **argv)
778770
{
779771
extern const char *alt_config_directory;
780772

781-
use_config_directory = true;
782773
alt_config_directory = arg;
783774
}
784775
break;
@@ -796,9 +787,6 @@ int main( int argc, const char **argv)
796787
n_extra_full_steps = atoi( arg);
797788
}
798789
break;
799-
case 'z':
800-
use_config_directory = true;
801-
break;
802790
default:
803791
printf( "Unknown command-line option '%s'\n", argv[i]);
804792
return( -1);

0 commit comments

Comments
 (0)