Skip to content

Commit f28349e

Browse files
committed
Revert "interpeter: allow full paths with o words and remaps"
This reverts commit f036526. It broke Fanuc subs - more work needed
1 parent f036526 commit f28349e

3 files changed

Lines changed: 20 additions & 62 deletions

File tree

src/emc/rs274ngc/interp_o_word.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,9 @@ int Interp::control_back_to( block_pointer block, // pointer to block
546546
offset_map_iterator it;
547547
offset_pointer op;
548548

549-
logOword("Entered:%s %s", name,basename(block->o_name));
549+
logOword("Entered:%s %s", name,block->o_name);
550550

551-
it = settings->offset_map.find(basename(block->o_name));
552-
553-
// #1 already defined
551+
it = settings->offset_map.find(block->o_name);
554552
if (it != settings->offset_map.end()) {
555553
op = &it->second;
556554
if ((settings->filename[0] != 0) &
@@ -587,8 +585,6 @@ int Interp::control_back_to( block_pointer block, // pointer to block
587585
settings->sequence_number = op->sequence_number;
588586
return INTERP_OK;
589587
}
590-
591-
// #2 open the File
592588
newFP = find_ngc_file(settings, block->o_name, newFileName);
593589

594590
if (newFP) {
@@ -611,8 +607,8 @@ int Interp::control_back_to( block_pointer block, // pointer to block
611607
free(dirname);
612608
}
613609

614-
settings->skipping_o = basename(block->o_name); // start skipping
615-
settings->skipping_to_sub = basename(block->o_name); // start skipping
610+
settings->skipping_o = block->o_name; // start skipping
611+
settings->skipping_to_sub = block->o_name; // start skipping
616612
settings->skipping_start = settings->sequence_number;
617613
return INTERP_OK;
618614
}

src/emc/rs274ngc/interp_remap.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,13 @@ int Interp::parse_remap(const char *inistring, int lineno)
446446
errored = true;
447447
continue;
448448
}
449-
FILE *fp = find_ngc_file(&_setup, arg);
449+
FILE *fp = find_ngc_file(&_setup,arg);
450450
if (fp) {
451451
r.remap_ngc = strstore(arg);
452452
fclose(fp);
453453
} else {
454-
fprintf(stderr,"INTERP_REMAP: NGC file not found: ngc=%s\nREMAP INI Line:%d = %s\n",
455-
arg, lineno, inistring);
454+
Error("NGC file not found: ngc=%s - %d:REMAP = %s",
455+
arg, lineno,inistring);
456456
errored = true;
457457
}
458458
continue;
@@ -465,7 +465,7 @@ int Interp::parse_remap(const char *inistring, int lineno)
465465
continue;
466466
}
467467
if (!PYUSABLE) {
468-
fprintf(stderr,"iNTERP_REMAP: Python plugin required for python=, but not available:\nREMAP INI line:%d = %s\n",
468+
Error("Python plugin required for python=, but not available: %d:REMAP = %s",
469469
lineno,inistring);
470470
errored = true;
471471
continue;

src/emc/rs274ngc/rs274ngc_pre.cc

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ include an option for suppressing superfluous commands.
9898
#include "interp_internal.hh" // interpreter private definitions
9999
#include "interp_queue.hh"
100100
#include "rs274ngc_interp.hh"
101-
#include <wordexp.h>
101+
102102
#include "units.h"
103103

104104
#include <unordered_set>
@@ -2651,59 +2651,32 @@ int Interp::on_abort(int reason, const char *message)
26512651

26522652
// spun out from interp_o_word so we can use it to test ngc file accessibility during
26532653
// config file parsing (REMAP... ngc=<basename>)
2654-
// Will expand ~ to user's home path
2655-
// searchs this sequence until it finds a match:
2656-
// 1) checks if path is already the full path
2657-
// 2) tries adding the INI defined program prefix to path
2658-
// 3) tries adding the INI defined subroutine prefix to path
2659-
// 4) tries adding the INI defined whizard prefix to path
26602654
FILE *Interp::find_ngc_file(setup_pointer settings,const char *basename, char *foundhere )
26612655
{
26622656
FILE *newFP = NULL;
26632657
char tmpFileName[PATH_MAX+1];
26642658
char newFileName[PATH_MAX+1];
26652659
char foundPlace[PATH_MAX+1];
26662660
int dct;
2667-
wordexp_t exp_result;
2668-
2669-
// #1 check if this is the full path already
2670-
2671-
// expand user path
2672-
wordexp(basename, &exp_result, 0);
2673-
// add .ngc to expanded path
2674-
snprintf(tmpFileName, sizeof(tmpFileName), "%s.ngc", exp_result.we_wordv[0]);
2675-
2676-
// copy to newFileName - in case this is the one...
2677-
size_t chk = snprintf(newFileName, sizeof(newFileName), "%s", tmpFileName);
2678-
2679-
// found a file we can open?
2680-
if (chk < sizeof(newFileName)){
2681-
newFP = fopen(newFileName, "r");
2682-
}
26832661

2684-
// #2 then look in the program_prefix place
2685-
if (!newFP) {
2662+
// look for a new file
2663+
snprintf(tmpFileName, sizeof(tmpFileName), "%s.ngc", basename);
26862664

2687-
// expand '~' into user path
2688-
wordexp(settings->program_prefix, &exp_result, 0);
2689-
chk = snprintf(newFileName, sizeof(newFileName), "%s/%s", exp_result.we_wordv[0], tmpFileName);
2665+
// find subroutine by search: program_prefix, subroutines, wizard_root
2666+
// use first file found
26902667

2691-
// found a file we can open?
2668+
// first look in the program_prefix place
2669+
size_t chk = snprintf(newFileName, sizeof(newFileName), "%s/%s", settings->program_prefix, tmpFileName);
26922670
if (chk < sizeof(newFileName)){
26932671
newFP = fopen(newFileName, "r");
26942672
}
26952673

2696-
// #3 then look in the list of subroutines prefixes
2674+
// then look in the subroutines place
26972675
if (!newFP) {
26982676
for (dct = 0; dct < MAX_SUB_DIRS; dct++) {
26992677
if (!settings->subroutines[dct])
27002678
continue;
2701-
2702-
// expand '~' into user path
2703-
wordexp(settings->subroutines[dct], &exp_result, 0);
2704-
chk = snprintf(newFileName, sizeof(newFileName), "%s/%s", exp_result.we_wordv[0], tmpFileName);
2705-
2706-
// found a file we can open?
2679+
chk = snprintf(newFileName, sizeof(newFileName), "%s/%s", settings->subroutines[dct], tmpFileName);
27072680
if (chk < sizeof(newFileName)){
27082681
newFP = fopen(newFileName, "r");
27092682
if (newFP) {
@@ -2713,31 +2686,20 @@ FILE *Interp::find_ngc_file(setup_pointer settings,const char *basename, char *f
27132686
}
27142687
}
27152688
}
2716-
2717-
// #4 if still not found, search the wizard tree
2689+
// if not found, search the wizard tree
27182690
if (!newFP) {
27192691
int ret;
2720-
// expand '~' into user path
2721-
wordexp(settings->wizard_root, &exp_result, 0);
2722-
ret = findFile(exp_result.we_wordv[0], tmpFileName, foundPlace);
2692+
ret = findFile(settings->wizard_root, tmpFileName, foundPlace);
27232693

27242694
if (INTERP_OK == ret) {
27252695
// create the long name
27262696
chk = snprintf(newFileName, sizeof(newFileName), "%s/%s",
27272697
foundPlace, tmpFileName);
2728-
2729-
// found a file we can open?
2730-
if (chk < sizeof(newFileName)){
2731-
newFP = fopen(newFileName, "r");
2732-
}
2698+
if (chk < sizeof(newFileName)) newFP = fopen(newFileName, "r");
27332699
}
27342700
}
2735-
}
27362701
if (foundhere && (newFP != NULL))
27372702
strcpy(foundhere, newFileName);
2738-
2739-
// Not sure this is needed but the internet told me
2740-
wordfree(&exp_result);
27412703
return newFP;
27422704
}
27432705

0 commit comments

Comments
 (0)