forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Small issue with get_command_argument

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Thu Nov 03, 2016 9:17 am    Post subject: Small issue with get_command_argument Reply with quote

In the following code, status should be returned as -1 with the following command line, but 0 is returned.

anon.exe 123456789

Code:

program anon

   integer :: k, l
   character(len=8) :: buffer
   
   call get_command_argument(1, buffer, length=l, status=k)
   
   print *, 'status = ', k,' Should be -1 but isn''t!'
   print *, 'length = ', l,' Should be 9 and is!'
   
end program anon


The character array buffer contains the correct values (first 8 characters); it is just the status that is incorrect.

I can work around this by testing the length value, but probably this should be fixed. This may be a hang-over from the early days as this error also occurs in the F2KCLI code. Later compilers nagfor, ifort, gfortran don't have this issue.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Nov 03, 2016 6:29 pm    Post subject: Reply with quote

Thanks for the feedback. The 64 bit version is OK. The 32 bit version needs to be fixed.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Nov 04, 2016 11:13 am    Post subject: Reply with quote

This bug has now been fixed for the next release. There was also a different bug in 64 bit mode and this has also been fixed.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Nov 04, 2016 12:25 pm    Post subject: Reply with quote

Paul,

Thanks very much for looking at this.

Could you also increase the internal size limit from 256 to 260 (just another 4 characters).

This will allow the maximum file path names to be read (The maximum path in windows is MAX_PATH - 1 where MAX_PATH=260. I have allowed an additional character above).

Also the length argument seems to be the limited by the size limit, but this may be harder to fix.

See this example:

Code:

program example

   integer :: l
   
   ! String 1 bigger than the size limit (currently 256)
   character(len=257) :: arg
   
   call get_command_argument(1, arg, length=l)

   print *, arg

   print *, 'length = ', l, ' should be 257 but isn''t'
   
end program example


which I run with a batch file like this:

Code:

set path=1234567890 ... 123456X
CheckMate\Win32\anon.exe %path%


where ... is enough characters to create 257 character name
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Nov 04, 2016 2:42 pm    Post subject: Reply with quote

I have increased the buffer size to 260.
The other issue requires the unravelling of lots of old code.
It might be simpler for us to use the code for 64 bit mode if that is working OK.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Fri Nov 04, 2016 3:42 pm    Post subject: Reply with quote

Don't worry about the other issue.

If the limit has been increased to 260 I should be able to detect when more than 259 characters are entered, which is all I need.

Thanks again.
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group