@@ -884,7 +884,6 @@ int Interp::init()
884884 fprintf (stderr," Unable to open inifile:%s:\n " , iniFileName);
885885 } else {
886886 bool opt;
887- std::optional<const char *> inistring;
888887
889888 inifile.Find (&_setup.tool_change_at_g30 , " TOOL_CHANGE_AT_G30" , " EMCIO" );
890889 inifile.Find (&_setup.tool_change_quill_up , " TOOL_CHANGE_QUILL_UP" , " EMCIO" );
@@ -920,14 +919,14 @@ int Interp::init()
920919 inifile.Find (&opt, " OWORD_WARNONLY" , " RS274NGC" );
921920 if (opt) _setup.feature_set |= FEATURE_OWORD_WARNONLY;
922921
923- if (( inistring =inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_A" ) )) {
924- _setup.a_indexer_jnum = atol (* inistring);
922+ if (auto inistring = inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_A" )) {
923+ _setup.a_indexer_jnum = atol (inistring-> c_str () );
925924 }
926- if (( inistring =inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_B" ) )) {
927- _setup.b_indexer_jnum = atol (* inistring);
925+ if (auto inistring = inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_B" )) {
926+ _setup.b_indexer_jnum = atol (inistring-> c_str () );
928927 }
929- if (( inistring =inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_C" ) )) {
930- _setup.c_indexer_jnum = atol (* inistring);
928+ if (auto inistring = inifile.Find (" LOCKING_INDEXER_JOINT" , " AXIS_C" )) {
929+ _setup.c_indexer_jnum = atol (inistring-> c_str () );
931930 }
932931 inifile.Find (&_setup.orient_offset , " ORIENT_OFFSET" , " RS274NGC" );
933932 inifile.Find (&_setup.parameter_g73_peck_clearance , " G73_PECK_CLEARANCE" , " RS274NGC" );
@@ -937,18 +936,18 @@ int Interp::init()
937936
938937 _setup.debugmask |= EMC_DEBUG_UNCONDITIONAL;
939938
940- if (( inistring = inifile.Find (" LOG_LEVEL" , " RS274NGC" ) ))
939+ if (auto inistring = inifile.Find (" LOG_LEVEL" , " RS274NGC" ))
941940 {
942- _setup.loggingLevel = atol (* inistring);
941+ _setup.loggingLevel = atol (inistring-> c_str () );
943942 }
944943
945944 // default the log_file to stderr.
946- if (( inistring = inifile.Find (" LOG_FILE" , " RS274NGC" ) ))
945+ if (auto inistring = inifile.Find (" LOG_FILE" , " RS274NGC" ))
947946 {
948- if ((log_file = fopen (* inistring, " a" )) == NULL ) {
947+ if ((log_file = fopen (inistring-> c_str () , " a" )) == NULL ) {
949948 log_file = stderr;
950949 logDebug ( " (%d): Unable to open log file:%s, using stderr" ,
951- getpid (), * inistring);
950+ getpid (), inistring-> c_str () );
952951 }
953952 } else {
954953 log_file = stderr;
@@ -957,38 +956,38 @@ int Interp::init()
957956 _setup.use_lazy_close = 1 ;
958957
959958 _setup.wizard_root [0 ] = 0 ;
960- if (( inistring = inifile.Find (" WIZARD_ROOT" , " WIZARD" ) ))
959+ if (auto inistring = inifile.Find (" WIZARD_ROOT" , " WIZARD" ))
961960 {
962- logDebug (" [WIZARD]WIZARD_ROOT:%s" , * inistring);
963- if (realpath (* inistring, _setup.wizard_root ) == NULL ) {
961+ logDebug (" [WIZARD]WIZARD_ROOT:%s" , inistring-> c_str () );
962+ if (realpath (inistring-> c_str () , _setup.wizard_root ) == NULL ) {
964963 // realpath didn't find the file
965- logDebug (" realpath failed to find wizard_root:%s:" , * inistring);
964+ logDebug (" realpath failed to find wizard_root:%s:" , inistring-> c_str () );
966965 }
967966 }
968967 logDebug (" _setup.wizard_root:%s:" , _setup.wizard_root );
969968
970969 _setup.program_prefix [0 ] = 0 ;
971- if (( inistring = inifile.Find (" PROGRAM_PREFIX" , " DISPLAY" ) ))
970+ if (auto inistring = inifile.Find (" PROGRAM_PREFIX" , " DISPLAY" ))
972971 {
973972 // found it
974973 char expandinistring[LINELEN];
975- if (inifile.TildeExpansion (* inistring,expandinistring,sizeof (expandinistring))) {
976- logDebug (" TildeExpansion failed for: %s" ,* inistring);
974+ if (inifile.TildeExpansion (inistring-> c_str () ,expandinistring,sizeof (expandinistring))) {
975+ logDebug (" TildeExpansion failed for: %s" ,inistring-> c_str () );
977976 }
978977 if (realpath (expandinistring, _setup.program_prefix ) == NULL ){
979978 // realpath didn't find the file
980- logDebug (" realpath failed to find program_prefix:%s:" , * inistring);
979+ logDebug (" realpath failed to find program_prefix:%s:" , inistring-> c_str () );
981980 }
982981 logDebug (" program prefix:%s: prefix:%s:" ,
983- * inistring, _setup.program_prefix );
982+ inistring-> c_str () , _setup.program_prefix );
984983 }
985984 else
986985 {
987986 logDebug (" PROGRAM_PREFIX not found" );
988987 }
989988 logDebug (" _setup.program_prefix:%s:" , _setup.program_prefix );
990989
991- if (( inistring = inifile.Find (" SUBROUTINE_PATH" , " RS274NGC" ) ))
990+ if (auto inistring = inifile.Find (" SUBROUTINE_PATH" , " RS274NGC" ))
992991 {
993992 // found it
994993 int dct;
@@ -999,7 +998,7 @@ int Interp::init()
999998 _setup.subroutines [dct] = NULL ;
1000999 }
10011000
1002- rtapi_strxcpy (tmpdirs,* inistring);
1001+ rtapi_strxcpy (tmpdirs,inistring-> c_str () );
10031002 nextdir = strtok (tmpdirs," :" ); // first token
10041003 dct = 0 ;
10051004 while (1 ) {
@@ -1031,15 +1030,15 @@ int Interp::init()
10311030 }
10321031 // subroutine to execute on aborts - for instance to retract
10331032 // toolchange HAL pins
1034- if (( inistring = inifile.Find (" ON_ABORT_COMMAND" , " RS274NGC" ) )) {
1035- _setup.on_abort_command = strstore (* inistring);
1033+ if (auto inistring = inifile.Find (" ON_ABORT_COMMAND" , " RS274NGC" )) {
1034+ _setup.on_abort_command = strstore (inistring-> c_str () );
10361035 logDebug (" _setup.on_abort_command=%s" , _setup.on_abort_command );
10371036 } else {
10381037 _setup.on_abort_command = NULL ;
10391038 }
10401039
10411040 // initialize the Python plugin singleton
1042- if ((inistring = inifile.Find (" TOPLEVEL" , " PYTHON" ) )) {
1041+ if (inifile.Find (" TOPLEVEL" , " PYTHON" )) {
10431042 int status = python_plugin->configure (iniFileName," PYTHON" );
10441043 if (status != PLUGIN_OK) {
10451044 Error (" Python plugin configure() failed, status = %d" , status);
@@ -1051,10 +1050,10 @@ int Interp::init()
10511050 _setup.g_remapped .clear ();
10521051 _setup.m_remapped .clear ();
10531052 _setup.remaps .clear ();
1054- while (( inistring = inifile.Find (" REMAP" , " RS274NGC" ,
1055- n, &lineno))) {
1053+ while (auto inistring = inifile.Find (" REMAP" , " RS274NGC" ,
1054+ n, &lineno)) {
10561055
1057- CHP (parse_remap ( * inistring, lineno));
1056+ CHP (parse_remap ( inistring-> c_str () , lineno));
10581057 n++;
10591058 }
10601059
@@ -2513,7 +2512,6 @@ VARIABLE_FILE = rs274ngc.var
25132512int Interp::ini_load (const char *filename)
25142513{
25152514 IniFile inifile;
2516- std::optional<const char *> inistring;
25172515
25182516 // open it
25192517 if (inifile.Open (filename) == false ) {
@@ -2525,12 +2523,13 @@ int Interp::ini_load(const char *filename)
25252523
25262524
25272525 char parameter_file_name[LINELEN]={};
2528- if (( inistring = inifile.Find (" PARAMETER_FILE" , " RS274NGC" ) )) {
2529- if (strlen (* inistring) >= sizeof (parameter_file_name)) {
2526+ if (auto inistring = inifile.Find (" PARAMETER_FILE" , " RS274NGC" )) {
2527+ if (inistring-> length ( ) >= sizeof (parameter_file_name)) {
25302528 logDebug (" %s:[RS274NGC]PARAMETER_FILE is too long (max len %zu)" ,
25312529 filename, sizeof (parameter_file_name)-1 );
25322530 } else {
2533- strncpy (parameter_file_name, *inistring, sizeof (parameter_file_name));
2531+ strncpy (parameter_file_name, inistring->c_str (), sizeof (parameter_file_name)-1 );
2532+ parameter_file_name[sizeof (parameter_file_name)-1 ] = ' \0 ' ;
25342533 logDebug (" found PARAMETER_FILE:%s:" , parameter_file_name);
25352534 }
25362535 } else {
0 commit comments