Previous Thread
Next Thread
Print Thread
Fn'To'Host$ conversion issue #29052 29 Jun 18 12:21 PM
Joined: Aug 2016
Posts: 371
J
John Andreasen Offline OP
Member
OP Offline
Member
J
Joined: Aug 2016
Posts: 371
Hello,

It would seem that Fn'To'Host$() has an issue when passed a filename without an extension. Looking at the code, it looks like this is partially handled before calling xcall MIAMEX, MX_FSPEC. I issue appears to be that in the case the extension was never found, the entire filename is removed from the return of the function. This can be seen with this code:
Code
Trace.Print Fn'To'Host$("DSK5:INV12")     ! Returns /vm/miame/dsk5/170001 on my system
Thanks,
John

Re: Fn'To'Host$ conversion issue #29053 29 Jun 18 12:53 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794
I'm able to reproduce the problem, although in some ways the preferred solution would seem (to me) to switch to Fn'FQFS$() instead. I'm not exactly sure why there are two functions which do approximately the same thing, but looking at the edit histories, clearly Fn'FQFS$() has enjoyed(?) a lot more editing attention over the years...

Fn'To'Host$:
Code
!VEDIT=101
![101] March 6, 2013 07:54 AM        Edited by Stephen Funkhouser
!	only convert if it's not already a host path
!VEDIT=100
![100] June 26, 2007 05:23 PM        Edited by joaquin
Fn'FQFS$:
Code
!Edit History
![110] 07-Dec-17 / jdm / Add FNTF_ABSOLUTE flag 
![109] 26-Sep-17 / jdm / Add FNTF_NOREGEX (workaround for old systems with
!                           non-functioning pcre)
![108] 10-Aug-17 / jdm / Misc cleanup/modernization
![107] 08-Aug-16 / jdm / Add flags argument
![106] 04-Nov-15 / jdm / Workaround bug where returned filespec 
!                            started with ./ or .\
![105] 13-May-15 / jdm / Preserve a trailing '.' on end of input spec
![104] 10-Aug-15 / jdm / Handle directory formats:
!                          dev:  or  ersatz:
!                          [p,pn]  or  p,pn
!                          dev:[p,pn]
![103] 23-Oct-14 / jdm / Add ++ifdef
![102] 17-Sep-11 / jdm / Don't apply [101] to native specs with dirseps
![101] 19-Feb-09 / jdm / Fix problems with file.ext > 10.3
![101] 30-Dec-07 / jdm / Created
You might be able to just switch from one to the other using DEFALIAS Fn\'To\'Host$() = Fn\'FQFS$() . But, although the parameter lists are nearly the same, the have different flags values, so if you're using any of those flags, that would be a problem.

Another solution would be to reformulate Fn'To'Host$() as a front-end to Fn'FQFS$(), assuming that after examining the two routines, you decide that Fn'FQFS$() already does everything you want, and then some.

But (and this is probably the reason why there are two routines rather than one), there was less than 100% certainty of upward compatibility, then the only solution would appear to be to make the fix to Fn'To'Host$(). I'm happy to do that, but am less clear on whether it makes sense to stop there or consider some or all of the other updates in Fn'FQFS$().

Note that all three approaches will require a complete recompile of the affected programs.

Re: Fn'To'Host$ conversion issue #29054 29 Jun 18 02:30 PM
Joined: Aug 2016
Posts: 371
J
John Andreasen Offline OP
Member
OP Offline
Member
J
Joined: Aug 2016
Posts: 371
Jack,

I am glad you mentioned Fn'FQFS$(). I did not realize this potentially superior function existed. I will discuss the possibility of using Fn'FQFS$() in the particular place where this issue arose, which is in a function used in several places in our code.

Thanks,
John


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3