@@ -875,12 +875,30 @@ IO_stat MCDispatch::loadfile(const char *inname, MCStack *&sptr)
875875 char *openpath = NULL ;
876876 char *fname = strclone (inname);
877877 if ((stream = MCS_open (fname, IO_READ_MODE, True, False, 0 )) != NULL )
878- // SN-20015-06-01: [[ Bug 15432 ]] We want to use MCS_resolvepath to
879- // keep consistency and let '~' be resolved as it is in MCS_open
880- // MCS_resolve_path leaves a backslash-delimited path on Windows,
881- // and MCS_get_canonical_path is made to cope with this.
882- openpath = MCS_get_canonical_path (fname);
883- else
878+ {
879+ // SN-20015-06-01: [[ Bug 15432 ]] We want to resolve the path first
880+ // to get rid of any tilde or such, and then we need to apply the
881+ // old way to get the full path (MCS_get_canonical_path does not
882+ // return a canonical path on Linux...)
883+ char *t_resolved_path;
884+ t_resolved_path = MCS_get_canonical_path (fname);
885+
886+ // Make sure that the path is absolute
887+ if (t_resolved_path[0 ] != PATH_SEPARATOR && t_resolved_path[1 ] != ' :' )
888+ {
889+ char *curpath = MCS_getcurdir ();
890+ if (curpath[strlen (curpath) - 1 ] == ' /' )
891+ curpath[strlen (curpath) - 1 ] = ' \0 ' ;
892+ openpath = new char [strlen (curpath) + strlen (t_resolved_path) + 2 ];
893+ sprintf (openpath, " %s/%s" , curpath, t_resolved_path);
894+ delete curpath;
895+
896+ delete t_resolved_path;
897+ }
898+ else
899+ openpath = t_resolved_path;
900+ }
901+ else
884902 {
885903 char *tmparray = new char [strlen (fname) + 1 ];
886904 strcpy (tmparray, fname);
@@ -890,11 +908,20 @@ IO_stat MCDispatch::loadfile(const char *inname, MCStack *&sptr)
890908 else
891909 tname++;
892910 if ((stream = MCS_open (tname, IO_READ_MODE, True, False, 0 )) != NULL )
893- // SN-20015-06-01: [[ Bug 15432 ]] We want to use MCS_resolvepath to
894- // keep consistency and let '~' be resolved as it is in MCS_open
895- // MCS_resolve_path leaves a backslash-delimited path on Windows,
896- // and MCS_get_canonical_path is made to cope with this.
897- openpath = MCS_get_canonical_path (tname);
911+ {
912+ // SN-20015-06-01: [[ Bug 15432 ]] We want to resolve the path first
913+ // to get rid of any tilde or such, and then we need to apply the
914+ // old way to get the full path (MCS_get_canonical_path does not
915+ // return a canonical path on Linux...)
916+ char *t_resolved_path;
917+ t_resolved_path = MCS_get_canonical_path (tname);
918+ char *curpath = MCS_getcurdir ();
919+ openpath = new char [strlen (curpath) + strlen (t_resolved_path) + 2 ];
920+ sprintf (openpath, " %s/%s" , curpath, t_resolved_path);
921+
922+ delete curpath;
923+ delete t_resolved_path;
924+ }
898925 else
899926 {
900927 if (!openstartup (tname, &openpath, stream)
0 commit comments