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