Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get (in String; out Item; out Last) in many IO packages for null records is incorrect. #35

Open
darkestkhan opened this issue Jul 17, 2015 · 10 comments
Labels
Milestone

Comments

@darkestkhan
Copy link
Contributor

Last is always set to negative value, which under certain circumstances may lead to incorrect results.

-- could quickly write up another, less obscure, example resulting in Constraint_Error
declare     
   High : Integer := 0; -- should be called Low, but whatever
   Last : Integer := 0;     
   Var  : String (1 .. 100);        
   Prep : Preposition_Record;       
   Conj : Interjection_Record;      
   Noun : Noun_Record;      
begin       
   Preposition_Record_IO.Get (Var, Prep, High);     
   Interjection_Record_IO.Get (Var (High .. Var'Last), Conj, Last);     
   High := High + Last; -- High now is equal to High - 1;, thus     
   -- Noun_Record is 'Get' from Var last char of Preposition_Record!        
   Noun_Record_IO.Get (Var (High .. Var'Last), Noun, Last);     
end;        

Last should be set into position of last character in String that was processed inside Get.
In case of Inflections_Package.Interjection_Record_IO (among others) it is set to -1 in all cases (should be 0).
Unfortunately Interjection_Record_IO.Get can't be fixed at the moment due to different bug somewhere between makeinfl.adb and Inflections_Package.Ending_Record_IO.

@mk270 mk270 added the bug label Jul 17, 2015
@mk270
Copy link
Owner

mk270 commented Jul 18, 2015

Thanks for taking the time to create the ticket; I appreciate this duplicates work you'd already done writing this up in a comment in the code.

Is the third argument ("Last") part of an Ada standard/convention, or something created by Whitaker?

@darkestkhan
Copy link
Contributor Author

@mk270 His various IO packages are based upon Ada.Text_IO. These particular subprograms are based on: http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-10-1.html paragraph 49; http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-10-7.html paragraphs 18-20.

@mk270
Copy link
Owner

mk270 commented Jul 18, 2015

Ok, and presumably we should stick to that convention? (and the code currently violates it?)

@darkestkhan
Copy link
Contributor Author

It would be better to stick to this convention, especially when you consider that calling this Get () subprogram may give you unexpected results. Generally standard Ada subprograms return 0 as position if nothing was processed/found (e.g. Strings.Fixed.Index, Vectors.Find_Index etc.). If these definitions were not based on standard definitions I would ignore it - alas they are, and this can cause confusion.
But as I wrote in issue - it can't be completely fixed atm, due to obscure bug in makeinfl.

@mk270
Copy link
Owner

mk270 commented Jul 18, 2015

Ok, I shall try to sort out makeinfl; the bugs I think are actually in routines that makeinfl calls.

The bad news is that these routines are also called from the src/tools subdirectory, which we've been ignoring.

@darkestkhan
Copy link
Contributor Author

Now that I think about it - we should have gprfile for src/tools too. I will add one in a moment and do pull request.

@mk270
Copy link
Owner

mk270 commented Jul 18, 2015

Ah good, thanks. There is some documentation somewhere about these tools - I am not sure if they are still necessary/useful, but they may well be.

@darkestkhan
Copy link
Contributor Author

There is howto file in src/tools. Just checked how build looks for them - many warnings... all over again :(

@mk270 mk270 modified the milestone: v1.99 Jul 19, 2015
@mk270
Copy link
Owner

mk270 commented Jul 21, 2015

Now that we have all the callers of get_non_comment_line(), one of which was in tools/ , I have fixed get_non_comment_line() such that it no longer throws exceptions in makeinfl - does this get us any further forward?

@darkestkhan
Copy link
Contributor Author

Yes, but in different issue (in fact this should fix #36 ). And it does get us further - maybe the entire thing was cause by this. I will check in a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants