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

Rewritten answers file writing/reading. #37

Merged
merged 6 commits into from
Feb 2, 2022
Merged

Rewritten answers file writing/reading. #37

merged 6 commits into from
Feb 2, 2022

Conversation

ilyakurdyukov
Copy link
Contributor

  1. The answers file contains no more (y/n) confirmations.

  2. Reading the answers file doesn't ask for confirmation.

  3. Reading the answers file doesn't repeat questions again, exits with an error if there were problems.

  4. Added a marker for the end of answers file and checking for its presence.

  5. Reading the answers file doesn't print hints.

  6. Fixed the echo of the lines read from the answers file.

1. The answers file contains no more (y/n) confirmations.

2. Reading the answers file doesn't ask for confirmation.

3. Reading the answers file doesn't repeat questions again, exits with an error if there were problems.

4. Added a marker for the end of answers file and checking for its presence.

5. Reading the answers file doesn't print hints.

6. Fixed the echo of the lines read from the answers file.
@ilyakurdyukov
Copy link
Contributor Author

There are some broken error codes to fix and error messages to improve.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Disclaimer: I didn't really look at the code (though I see that you wrote to the answers file after everything was done and that could work) and there could be a language barrier between us.

  • The answers file contains no more (y/n) confirmations.

The problem here is if it doesn't have the confirmations then the answers file will not work because the questions have to be answered to proceed; if the answers file no longer has them then how can the questions be answered?

  • Reading the answers file doesn't ask for confirmation.

I don't know what you mean by this: the only code that asked for confirmation was the check functions that I simply added answers to. You can add the answers later of course but the answers file didn't ask for confirmation; the tool did.

  • Reading the answers file doesn't repeat questions again, exits with an error if there were problems.

Same as above.

  • Reading the answers file doesn't print hints.

Then if they change their answers (or files that no longer have these problems) they won't be alerted to a possible problem. When something is automated at the same time as warnings being ignored the user should be alerted to the possible problem. I would argue that whenever warnings are ignored for this contest they should be alerted to a possible problem. People are used to automating things without thinking and this could result in problems.

  • Fixed the echo of the lines read from the answers file.

If this is what I think it is I like that.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Oh and answers errors should be there because if there are I/O errors on the answers file then they obviously cannot use the answers file and expect valid results. Removing that check means that the user will not be alerted to possible problems. But maybe you added that later on and I didn't see (I just took a quick glance).

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

We think @xexyl has made some valid points above.

Moreover we are not sure that avoiding the questions is a good thing. It certainly complicates the code to try and avoid them.

When we just had the "-a answers" feature, one could do this:

./mkiocccentry .. < answers

We suspect that any "-i answers" mode should simply be another way to accomplish feeding the answers file into stdin.

Yes, if someone were to edit the answers file, such as supplying a sting that is too long, or too short, etc. one would get the desired result when getting that modified answers file back on stdin (or via "-i answers"). But we don't think the code should be complicated to try and handle such a case.

Please recall that this mkiocccentry code is something an IOCCC contestant would run a few times per year. We, the IOCCC judges, have to do a lot of work for the number of entries we do receive for a given IOCCC. That is why we limit try and limit the number of entries someone can submit for a given contest. And of course the submitter has to do a huge amount of work to just write also those entries to feed into mkiocccentry!

While it is fun to polish the code, using mkiocccentry efficiently might not be a significant goal to focus on.

[[see our next comment in this thread for what we are focused on now]]

While we are still pondering this issue, we suggest that it might be better if:

./mkiocccentry -i answers work_dir ...

Behave exactly like:

./mkioccentry work_dir ... < answers

And NOT try to avoid the questions and prompts and hints, maybe?

Something to ponder. Comments welcome.

See our next comment for our current focus.

@ilyakurdyukov
Copy link
Contributor Author

I don't know what you mean by this: the only code that asked for confirmation was the check functions that I simply added answers to. You can add the answers later of course but the answers file didn't ask for confirmation; the tool did.

By confirmation, I mean asking for yes/no.

Then if they change their answers (or files that no longer have these problems) they won't be alerted to a possible problem.

No. The user receives a warning with a list of problems at the end.

Fixed the echo of the lines read from the answers file.

If this is what I think it is I like that.

The log becomes a complete unreadable mess without this fix.

./mkiocccentry .. < answers

If someone wants to use this they can use tee answers | ./mkiocccentry .. to get answers in this format.

And if there is exactly the same as stdin copy, then I don't see the point of mkioccccentry having the -a option if it just copies the existing tool.

Added a marker for the end of answers file and checking for its presence.

This is used as a form of confirmation to ensure that the answer file was read correctly.

@ilyakurdyukov
Copy link
Contributor Author

The reason I hide "hints" is because these hints are too over the top and annoying. When using automation like this, I don't want to scroll through multiple screens of things I already know looking for warnings. So I printed out a list of warnings at the end. So I can just look at the last screen in the console without scrolling to see if something bad happen or all is OK.

If someone is using saved answers, that means that person has already read all of these explanations.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Then if they change their answers (or files that no longer have these problems) they won't be alerted to a possible problem.

No. The user receives a warning with a list of problems at the end.

I see that now as I tried it. But there was no need to make this change. Functionally you removed the warnings (and warnings are good to have) and didn't do anything I didn't do (well you added the EOF marker but I mean the results are the same); you just went about it a different way. You give warnings at the end of the output rather than in the middle of it. I had warnings too and warnings are important.

The log becomes a complete unreadable mess without this fix.

./mkiocccentry .. < answers

If someone wants to use this they can use tee answers | ./mkiocccentry .. to get answers in this format.

This doesn't mean it's not good to have it built-in. I already gave reasons why it's good to have it built-in. Just because someone could use tee doesn't mean that it's not good to have it built-in.

And if there is exactly the same as stdin copy, then I don't see the point of mkioccccentry having the -a option if it just copies the existing tool.

Then why even work your changes if you don't see the point? I already gave reasons it's good to have it built-in. It takes the burden from the user: you can rely on the tool itself rather than a pipeline. Also tee will happily overwrite the file and that's easy enough to do if you do it quickly or without thinking. By having the options it ensures that this won't happen.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

The reason I hide "hints" is because these hints are too over the top and annoying. When using automation like this, I don't want to scroll through multiple screens of things I already know looking for warnings. So I printed out a list of warnings at the end. So I can just look at the last screen in the console without scrolling to see if something bad happen or all is OK.

I think this is a problem with you not being able to focus on the important bits - the warnings are important for users who ignore warnings. How far do you go? One could use your logic (below) that if they have seen it once then you shouldn't have the warnings of possibly invalid files at the end when using the answers file.

If someone is using saved answers, that means that person has already read all of these explanations.

You have far too much faith in users if you think like that! Besides that it has to be done at first for them to know it. But if you think people will remember it or they won't make a mistake when ignoring warnings you don't know users well enough. As a game developer the things I saw...

You're not likely to have to refer to the warnings because you're not likely to submit those files that trigger warnings anyway. And having warnings is always good. Always.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

While we are still pondering this issue, we suggest that it might be better if:

./mkiocccentry -i answers work_dir ...

Behave exactly like:

./mkioccentry work_dir ... < answers

And NOT try to avoid the questions and prompts and hints, maybe?

It already does. Before I added the second option that's what you could do (you could also use cat answers | ... but that's unnecessary use of cat).

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

While we are still pondering this issue, we suggest that it might be better if:
./mkiocccentry -i answers work_dir ...
Behave exactly like:
./mkioccentry work_dir ... < answers
And NOT try to avoid the questions and prompts and hints, maybe?

It already does. Before I added the second option that's what you could do (you could also use cat answers | ... but that's unnecessary use of cat).

But trying it with Ilya's code using the option works okay; however with the < I get an error:

Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: FATAL[74]: prompt: EOF while reading prompt input

...so it doesn't even form the tarball.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

One more thing I noticed is it seems that once again fclose() on answer file is done before forming the tarball.

Yesterday I moved the fclose() call to be after because freopen() makes stdin refer to the answers file and you can get bad file descriptor by closing the answers file as the function verify_entry_dir prompts for input. I did not notice this happening every time though.

Unfortunately the git log didn't show up so all you see is that I had some minor fixes (I added the bad file descriptor fix after starting the other change). I specifically stated the above part though in the git log on my branch.

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

Instead of this text being posted in this pull request, Please see this discussion: https://github.com/ioccc-src/mkiocccentry/discussions/39

Please also see these issues where help is wanted:

Thanks for your consideration and help!

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

While we are still pondering this issue, we suggest that it might be better if:
./mkiocccentry -i answers work_dir ...
Behave exactly like:
./mkioccentry work_dir ... < answers
And NOT try to avoid the questions and prompts and hints, maybe?

It already does. Before I added the second option that's what you could do (you could also use cat answers | ... but that's unnecessary use of cat).

But trying it with Ilya's code using the option works okay; however with the < I get an error:

Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: FATAL[74]: prompt: EOF while reading prompt input

...so it doesn't even form the tarball.

By "But trying it with Ilya's code" do you mean the code at the top of the master branch now, or do you mean as modified with the proposed #37 pull request as it is now?

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

Yesterday I moved the fclose() call to be after because freopen() makes stdin refer to the answers file and you can get bad file descriptor by closing the answers file as the function verify_entry_dir prompts for input. I did not notice this happening every time though.

Unfortunately the git log didn't show up so all you see is that I had some minor fixes (I added the bad file descriptor fix after starting the other change). I specifically stated the above part though in the git log on my branch.

That certainly needs to be addressed ...

(along with #37 (comment)) :-)

@ilyakurdyukov
Copy link
Contributor Author

You give warnings at the end of the output rather than in the middle of it.

No, warnings in the middle are shown just as before.

@ilyakurdyukov
Copy link
Contributor Author

But trying it with Ilya's code using the option works okay; however with the < I get an error:

With redirection to standard input without the -i option? You should not do this and should not expect it to work.

@ilyakurdyukov
Copy link
Contributor Author

ilyakurdyukov commented Jan 29, 2022

Then why even work your changes if you don't see the point?

My changes make sense because it's more than redirecting the answers to or from a file. It also makes it easier and prevents the answers from being misread if there a warnings happen/not happen. That's why it's in a slightly different format than just a copy of stdin.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

While we are still pondering this issue, we suggest that it might be better if:
./mkiocccentry -i answers work_dir ...
Behave exactly like:
./mkioccentry work_dir ... < answers
And NOT try to avoid the questions and prompts and hints, maybe?

It already does. Before I added the second option that's what you could do (you could also use cat answers | ... but that's unnecessary use of cat).

But trying it with Ilya's code using the option works okay; however with the < I get an error:

Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: Please enter either y (yes) or n (no)
Are you sure you want to submit an empty prog.c file? [yn]: FATAL[74]: prompt: EOF while reading prompt input

...so it doesn't even form the tarball.

By "But trying it with Ilya's code" do you mean the code at the top of the master branch now, or do you mean as modified with the proposed #37 pull request as it is now?

I meant his patch - #37.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Yesterday I moved the fclose() call to be after because freopen() makes stdin refer to the answers file and you can get bad file descriptor by closing the answers file as the function verify_entry_dir prompts for input. I did not notice this happening every time though.
Unfortunately the git log didn't show up so all you see is that I had some minor fixes (I added the bad file descriptor fix after starting the other change). I specifically stated the above part though in the git log on my branch.

That certainly needs to be addressed ...

(along with #37 (comment)) :-)

How do you mean? I already moved fclose() to after the form tarball function but in Ilya's patch it was moved back to before forming the tarball. Or do you mean I should make a commit so that there is a git log of it?

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

But trying it with Ilya's code using the option works okay; however with the < I get an error:

With redirection to standard input without the -i option? You should not do this and should not expect it to work.

Right but Landon suggested it has the same behaviour and yours doesn't. That's what I was saying; yours errors out because you removed the confirmations from the answers file.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Then why even work your changes if you don't see the point?

My changes make sense because it's more than redirecting the answers to or from a file. It also makes it easier and prevents the answers from being misread if there a warnings happen/not happen. That's why it's in a slightly different format than just a copy of stdin.

Mine makes just as much sense but has more warnings which is a good thing when ignoring warnings. The copy of stdin means one doesn't have to rely on the program but they can. It has the same behaviour. Your change does not make it easier: you still use the options along with the answers file. The difference is you omit confirming the warnings by the tool and that's not a good idea.

But you still have to initially answer that you want to continue anyway - after that (using the answers file) you don't have to (just as with mine).

The tarball is formed fine under most circumstances in your code but I gave one where it isn't because you changed the format (namely removing the 'y' lines).

@ilyakurdyukov
Copy link
Contributor Author

Right but Landon suggested it has the same behaviour and yours doesn't. That's what I was saying; yours errors out because you removed the confirmations from the answers file.

Since this is a fix, confirmations may appear in different numbers depending on warnings, but answers file will work in any cases now (with the -i option, using stdin is deprecated) and not depend on the warnings anymore.

@ilyakurdyukov
Copy link
Contributor Author

ilyakurdyukov commented Jan 29, 2022

How do you mean? I already moved fclose() to after the form tarball function but in Ilya's patch it was moved back to before forming the tarball. Or do you mean I should make a commit so that there is a git log of it?

It doesn't need to be after tarball function now. It was needed just because confirmations, and the confirmations are not needed for the new answers format.

@ilyakurdyukov
Copy link
Contributor Author

I can make < work with the new format if you insist. By simply adding a header to the answers file. So if mkioccccentry sees this header in the first prompt(), then interpret it as an answers file from the "-i" option.

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

You (@ilyakurdyukov and @xexyl) are having a good discussion.

Based on some of your replies, we seem to have been mistaken when we wrote some of our previous comments.

May we suggest that you try to arrive at some common recommendation if possible? For example does the pull request meet your common ideas or does it need to be further updated?

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

I can make < work with the new format if you insist. By simply adding a header to the answers file. So if mkioccccentry sees this header in the first prompt(), then interpret it as an answers file from the "-i" option.

That seems like an interest possibility. What are the downsides to doing that, if any?

@ilyakurdyukov
Copy link
Contributor Author

That seems like an interest possibility. What are the downsides to doing that, if any?

I want to include the version in this header, this might be a nice feature if something changes later in the tool. So the version in that header will also change and the newer tool will say that the answer file is in an older format and should be re-entered.

But change the version in the header only if there are incompatible changes, keep the same if changes in the tool do not change the field order or introduce a new fields/questions.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

I think that when the file is opened with the -i option, yes_no() can be called at the end, reading from stdin, to confirm if there are any warnings.

That seems like a good thing to do.

This would however also mean that you have to interact with the program. Yes it would be mostly automatic but it wouldn't be entirely. Is there a way to restore stdin after using freopen()? If there is I'm not sure. If there isn't then that would not be feasible since stdin becomes the answers file.

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

We have to go to a meeting on a different topic. Good discussion.

Please do consider updating the patch and let us know if you are able to reach some sort of consensus.

@lcn2
Copy link
Contributor

lcn2 commented Jan 29, 2022

ret = printf("\nYou've ignored one or more warnings. If you update your files so that these warnings\n" "aren't triggered or if different warnings are triggered, it is very likely that the\n" "answers file will cause invalid results and we STRONGLY recommend that you re-enter\n" "your answers!\n");

And also

printf("\nAlthough you've not ignored any warnings be aware that if you add or change a file that\n" "triggers a warning the next time, then this can result in improper answers being provided.\n");

We liked those warnings, BTW.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

We have to go to a meeting on a different topic. Good discussion.

Please do consider updating the patch and let us know if you are able to reach some sort of consensus.

I personally think it's better to work on the things that still haven't been done. Ilya seems to be experienced in JSON so he could go for that part. He could also change the warnings to go to stderr if he doesn't like them so he could redirect it to /dev/null (as I suggested several times). That sounds like a good compromise to me.

What seems very important to me is to make sure to have those warnings though and also let the user decide whether or not they want to proceed. Ilya makes a point about how a different warning might be ignored because of the 'y' in the file but his patch doesn't let you decide at all - it just assumes yes for all warnings. But what can be done with the y ignoring a different warning? There IS a certain risk with ignoring warnings and there's no way past that. But it's better to give the user the chance to abort and tell warn them about this.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

ret = printf("\nYou've ignored one or more warnings. If you update your files so that these warnings\n" "aren't triggered or if different warnings are triggered, it is very likely that the\n" "answers file will cause invalid results and we STRONGLY recommend that you re-enter\n" "your answers!\n");
And also
printf("\nAlthough you've not ignored any warnings be aware that if you add or change a file that\n" "triggers a warning the next time, then this can result in improper answers being provided.\n");

We liked those warnings, BTW.

I have a lot of experience with users. If you don't have warnings like this there will be people who complain! It's true that warnings might annoy some users but those users can simply ignore them; warnings like these are for the people who are actually doing the risky things.

@ilyakurdyukov
Copy link
Contributor Author

This would however also mean that you have to interact with the program. Yes it would be mostly automatic but it wouldn't be entirely. Is there a way to restore stdin after using freopen()? If there is I'm not sure. If there isn't then that would not be feasible since stdin becomes the answers file.

I'll try to do this (so you have the feature you want and I have the feature I want), deal?

But it's in the morning, because it's already very late in my time zone.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

This would however also mean that you have to interact with the program. Yes it would be mostly automatic but it wouldn't be entirely. Is there a way to restore stdin after using freopen()? If there is I'm not sure. If there isn't then that would not be feasible since stdin becomes the answers file.

I'll try to do this (so you have the feature you want and I have the feature I want), deal?

Well... as the judges liked my warnings I think they should be put back. I still also think it's imperative that the user gets to decide whether to ignore the warnings or not.

I also think using shell redirection should have the same behaviour. Maybe we should have been a bit clearer with each other. I'll start:

What exactly do you want? I can then reply to that though it won't be until my tomorrow as I go to bed early. Maybe we can come to some consensus.

But it's in the morning, because it's already very late in my time zone.

Yeah I was thinking that. Sleep well!

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

A possible way to restore stdin occurred to me. I've not tested this but doing something else entirely the dup(2) syscall popped into my head. I have no idea why but this happens with me. It does seem like it would complicate it unnecessarily though (though see below). Also why have change stdin to be a file only for it to go back to input at the keyboard?

Is the purpose to make the user confirm everything is okay after the tarball has been formed? I can maybe see that as an idea - since they are relying on automation. But at the same time they can look at the output and see if it's correct. I don't know. I'm kind of mixed here. As I'm thinking on it this might actually be a fair idea. I don't know if it's necessary though and it would complicate things quite a bit.

But Ilya it seems you're after certain things. I want to reiterate my question of what are those things you're after. I think that's the fair approach.

As for what I want it's basically what I did. I will not ever ignore the warnings but I think having the warnings there is a good idea (as do the judges as they have said). If you want a header/version tag I think that that might be an idea as long as it behaves the same as < answers. Even if it doesn't though I suppose it's not a huge problem (I would use the option in the tool anyway). Having an EOF marker might also be an idea. I'm not sure.

And you're right that if the y is there it might inadvertently say yes to a different warning but as I noted ignoring warnings has a certain risk to begin with and there's no perfect solution (but it's better to not assume yes for all the warnings).

What I am against is taking the choice of whether to ignore the warnings or not away from the user and I think that in addition to keeping that the user should be alerted to the fact that if they change the files (in a way that triggers - or no longer triggers - a warning) it might result in invalid input.

My original idea was that I could simply input the answers once and then not have to repeatedly input the same thing. I would never ignore the warnings about e.g. empty prog.c (though interestingly I did have a different take on an empty prog.c in 2018 and I thought it was fun and funny but I knew it was highly unlikely that it would win ... I knew also that if any of my entries that year would win it would be the Weasel entry which of course it did) but I added this to the code though because I felt it should be complete - without it the answers file would not work (and you saw what happens if you change it from valid to not valid in your patch).

So what are your wishes? I again stress that if you're not liking the extra warnings just make them go to stderr so you can redirect it to /dev/null. That would solve that part of the problem for you but it would still be there for people who are actually going to ignore warnings. And as for me (besides above) the more I think on it the more I wonder if it's a good idea to have the user have to actually type 'y' that confirms that the tarball is correct. It might be a bit annoying for me but it might be the better way to go about it for the contest as a whole. The dup() syscall is the only way I can think of doing this but again I've not tested this (maybe there's another way too).

I think that's all I have for the day. Hope you're having a good sleep and a good day when you wake up!

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

Perhaps the safer thing to do is to abort on any problem when using -i answers and to issue a message that the user fix the issue or re-run without the answers file?

Would you mind defining 'problem'? Because it might be something that's implicitly there. If the input is invalid then the process will fail. But define invalid input. If it's an invalid sequence it will fail but how to tell if it works but is actually not correct. Ilya pointed this out with 'y' being there could make it ignore a different warning though they already are ignoring warnings which is risky but is there another thing you can think of?

I think the idea of abort on any problems and issue a message that the user fix or re-run without the answers file is a sound idea but the question is (as above) how to define problem.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

WARNING: prog.c has character(s) with high bit set

The above was a result of using mkiocccentry.c as our prog.c.

However when we run iocccsize on it directly:

./iocccsize mkiocccentry.c

The iocccsize only reports:

140507
Warning: character(s) with high bit set found! Be careful you don't violate rule 13!
Warning: your source under Rule 2a: 201955 exceeds Rule 2a limit: 4096: Rule 2a violation!

We searched mkiocccentry.c and didn't find a character with the high bit set. Did we miss something or is this also a bug?

FWIW I added in a copy of iocccsize.c in read_ch() an fprintf() call to print the character and this is what I got running it on mkiocccentry.c:

high bit: 226
high bit: 226
high bit: 128
high bit: 128
high bit: 147
high bit: 147
high bit: 226
high bit: 226
high bit: 128
high bit: 128
high bit: 147
high bit: 147
high bit: 226
high bit: 226
high bit: 128
high bit: 128
high bit: 147
high bit: 147

Running the 2020 iocccsize like:

./iocccsize -i < ../../mkiocccentry/mkiocccentry.c >/dev/null

Gave this:

iocccsize: NUL or non-ASCII characters

Which I guess might be the diacritics in some of the countries? I did not do any debugging but maybe that will be something of interest to you or make you think of something in particular.

@xexyl
Copy link
Contributor

xexyl commented Jan 29, 2022

I just tried removing the diacritics and I got the same warnings. I guess the obvious answer is to have the code print the adjacent characters so you can find out which ones are giving it trouble.

I'm going for the night but maybe it'll give you some ideas. If nothing else it doesn't seem to be the diacritics (I assume those characters have diacritics) in the country names.

@ilyakurdyukov
Copy link
Contributor Author

ilyakurdyukov commented Jan 30, 2022

Yes you did. I had:

ret = printf("\nYou've ignored one or more warnings. If you update your files so that these warnings\n" "aren't triggered or if different warnings are triggered, it is very likely that the\n" "answers file will cause invalid results and we STRONGLY recommend that you re-enter\n" "your answers!\n");

And also

printf("\nAlthough you've not ignored any warnings be aware that if you add or change a file that\n" "triggers a warning the next time, then this can result in improper answers being provided.\n");

And there might have been others.

So you're angry because I'm removing your warnings. But that warning is completely deprecated with the new method.

Because: "answers file will cause invalid results"

The answers will NEVER give wrong results with my method, either any warning are triggered or not triggered.

I explained it, but you keep insisting that these warnings be returned.

And why I strongly dislike the warnings you made, and are strongly against them:

These warnings do not solve the problem, instead of solving it, you leave the problem as it is and think that this is a good solution?

I think warning the user is not a solution. Is this something that can't be fixed? No, it can be! And I don't see your intent to make a real fix other than these warnings. You're happy not fixing the problem, but I'm not happy with that solution.

So I made a fix, and you are angry at me for changing your code - is this the real problem, what are you against my patch? Not because anything else? I removed that warning because it's obsolete now, because the problem solved.

I personally think it's better to work on the things that still haven't been done. Ilya seems to be experienced in JSON so he could go for that part.

So, you want me to go do the other part and give up to fix this just because you don't want someone to edit your code, even if your code doesn't solve the problem and someone has a solution? Not fair at all.

I think it's impossible to develop the code together when one of the participants is trying to keep their code untouched, even when it is outdated and there is a better solution. And they attack those who try to change their code, coming up with reasons why the new code is worse.

The user is prompted for final confirmation if there were warnings when using the -i option.
Answers file can be read from standard input.

Warnings and messages could be improved.
@ilyakurdyukov
Copy link
Contributor Author

The answers file can now be read from stdin.

And the user is asked for final confirmation if there are any warnings and the -i option is used.

But it's clear to me that Cody refuses anyone to edit his code. That's the problem, because I offered a solution to all his complaints about this patch. This is very unconstructive behavior, because if we avoid changing other people's code, we won't be able to improve anything.

His warnings should no longer be here because the answer file is now consistent and cannot be broken by the different warnings layout.

@ilyakurdyukov
Copy link
Contributor Author

The new code should be edited with additional comments, improved warnings and error messages, and fixed error codes.

But I'm not in the mood to do it. Right now I'm very stressed and tired of this pointless conflict over the outdated warnings.

@xexyl
Copy link
Contributor

xexyl commented Jan 30, 2022

I will try looking at the rest later but I wanted to say I'm not angry with you. I know you're sick right now and you should take it easy until you're feeling better. I know all too well how hard that can be to do but it's important! I don't want to contribute to you not feeling well. If this discussion makes you think I'm angry it's time to take a step back - which like I said in email might be good anyway.

I hope you're feeling all better soon.

@xexyl
Copy link
Contributor

xexyl commented Jan 30, 2022

Will try now to reply because it seems to be important. I want to reiterate with you I'm not angry at all.

Yes you did. I had:
ret = printf("\nYou've ignored one or more warnings. If you update your files so that these warnings\n" "aren't triggered or if different warnings are triggered, it is very likely that the\n" "answers file will cause invalid results and we STRONGLY recommend that you re-enter\n" "your answers!\n");
And also
printf("\nAlthough you've not ignored any warnings be aware that if you add or change a file that\n" "triggers a warning the next time, then this can result in improper answers being provided.\n");
And there might have been others.

So you're angry because I'm removing your warnings. But that warning is completely deprecated with the new method.

Please don't make it all about me. This is one of the reasons I asked you what it is you want. Remember the judges also liked these warnings. I'm not saying they can't be improved but I think having warnings is important - yes even with your changes.

Because: "answers file will cause invalid results"

The answers will NEVER give wrong results with my method, either any warning are triggered or not triggered.

But that's the problem: the user should have the choice of deciding to confirm that they want to ignore the warnings before the tarball is formed. Those final warnings you have are good but they're not enough for all users, I can assure you that!

I explained it, but you keep insisting that these warnings be returned.

What's more important is that the user has the choice of confirming that they want to ignore the warnings - and in so doing it's why the warnings should be there. You have too much faith in users if you think the final warnings are enough!

And why I strongly dislike the warnings you made, and are strongly against them:

These warnings do not solve the problem, instead of solving it, you leave the problem as it is and think that this is a good solution?

Neither is a perfect solution: your way doesn't solve the problem either because it removes the choice from the user whereas mine it can cause invalid input which means the user must revisit the answers (because a change was made that warrants this).

I think warning the user is not a solution. Is this something that can't be fixed? No, it can be! And I don't see your intent to make a real fix other than these warnings. You're happy not fixing the problem, but I'm not happy with that solution.

It's not a solution. There is no solution to the user ignoring warnings. But warnings are there for a reason and if the user cannot confirm this then there's a problem.

So I made a fix, and you are angry at me for changing your code - is this the real problem, what are you against my patch? Not because anything else? I removed that warning because it's obsolete now, because the problem solved.

I'm not angry and if you think I am you should take a step back. I know you're recovering from a cold and it's not good to be working yourself up when you're unwell (it's never a good idea but especially when you're sick). I've even suggested that some of your ideas are great and I gave a possible solution of how to do it (e.g. since I used freopen() on stdin).

You say the warnings are obsolete now but that's because you've completely removed the possibility to confirm that the user wants to ignore the warning which is not a solution at all. Once the tarball is formed if the user did not get a prompt about it some are likely to ignore the final warnings. Again I think the final warnings are a good idea but I don't think not letting the user decide is a bad idea too.

I personally think it's better to work on the things that still haven't been done. Ilya seems to be experienced in JSON so he could go for that part.

So, you want me to go do the other part and give up to fix this just because you don't want someone to edit your code, even if your code doesn't solve the problem and someone has a solution? Not fair at all.

I'm not against all of your patch, no. What I was trying to say though is as the judges pointed out they could use more help on other parts - as the answers file is fine. Oh sure there are places it can be improved upon but removing the choice from the user is not one of those places. The judges have given us other things to do. As for bringing up JSON I did that because it seems your'e experienced with it - it was nothing but encouragement! Again if you're thinking like this you should take a step back (see above - I have agreed that some of your ideas are great even one that might be annoying to me but is a better idea than what I have nonetheless).

I think it's impossible to develop the code together when one of the participants is trying to keep their code untouched, even when it is outdated and there is a better solution. And they attack those who try to change their code, coming up with reasons why the new code is worse.

I'm not attacking you. I'm having a discussion with you. I also don't think your patch is entirely useless. We're disagreeing on one point in particular (and this point also leads to your removal of the warnings): that you think the user doesn't have to have the choice of confirming that they want to ignore the warning. That's the thing I'm against. The rest I'm not against. But as for the warnings I gave a possible solution to you (since it seems they annoy you).

Please take good care of yourself and if you're stressed do take a break. I cannot stress that enough! It's so important. As I also said I realised yesterday I've been irritable (though not at any specific person - just a general thing) and that's a reason I wanted to step back too. It's also why I asked you what you exactly wanted.

I hope this helps you out. I'm not against all of your changes. I was encouraging you on the JSON because you're experienced in it (and I'm not) and I know you'll do something great. I'm definitely not attacking you but if you think I am you should take a step back ... and I'll do the same. A clear head from both of us will help the matter.

Feel better soon. The most important thing right now is that you take good care of yourself whilst you're recovering from the cold. Not programming. Not anything else. You have to take care of yourself first. You can address my concerns later (again though I'm not attacking you nor am I against all your patch or ideas - I'm against one part of it).

@xexyl
Copy link
Contributor

xexyl commented Jan 30, 2022

The answers file can now be read from stdin.

That's good.

And the user is asked for final confirmation if there are any warnings and the -i option is used.

Great. I agree with this.

But it's clear to me that Cody refuses anyone to edit his code. That's the problem, because I offered a solution to all his complaints about this patch. This is very unconstructive behavior, because if we avoid changing other people's code, we won't be able to improve anything.

This is not true. I'm not against anyone editing my code. I have told you things I like about your ideas and patch. I'm only against one thing in your patch.

His warnings should no longer be here because the answer file is now consistent and cannot be broken by the different warnings layout.

If you've removed the ability for the user to decide whether to ignore the warnings though this is not a better way. Yes it means that the warnings might not be relevant but it's riskier if the user is not PROMPTED. That's the problem. They should be prompted. Having a warning at the end is great (and I had one too) but if they're not prompted they're much less likely to think about it and that's not good. Well maybe it's good in that others are more likely to win :) but I'm trying to be fair to everyone.

@xexyl
Copy link
Contributor

xexyl commented Jan 30, 2022

The new code should be edited with additional comments, improved warnings and error messages, and fixed error codes.

But I'm not in the mood to do it. Right now I'm very stressed and tired of this pointless conflict over the outdated warnings.

Please take good care of yourself. You're recovering from a cold. Doing that is more important. I'll give it a break too. Let me put it this way though:

My main complaint is NOT about removing the warnings; it's the reason you removed them: not prompting the user if they want to ignore the warning. Humans have this tendency to ignore warnings but they're MORE likely to ignore warnings if they're NOT prompted about it: if they're not asked if they want to continue anyway. In your code they don't even get a chance to confirm that (in the checking of the files). It's that that I am against.

This is not a pointless discussion (yes - discussion).

@xexyl
Copy link
Contributor

xexyl commented Jan 30, 2022

Okay here's a thought. I might just have a good compromise (or even just fully concede).

I just took a break - had a shower, had some food (well actually liquid - I don't eat until late in the day) - and I was thinking. I'm sorry I'm adding stress to your situation; that's not what I mean to do at all. I want you to feel well.

Last night I slept about 11 hours and I'm still exhausted. Part of the problem is I had a lot of vivid dreams and dreams always exhaust me. Anyway I will not consider any of this today. Instead I'll take it easy. Tomorrow I have something going on but I'll make an effort to look at this Tuesday.

It's true that I think it unwise to remove the prompting of the user about warnings (that's my problem with this patch) but since I won't be ignoring the warnings if it means that much to you I'm seriously considering just letting it go. I mean it's not the end of the world and it doesn't truly affect me or my entries.

I do have a suggestion though with your warnings that might just solve the problem: maybe instead of including say prog.c is 0 size maybe have the full warning message that the code shows earlier on (in the check functions). That way the user has a better idea of the seriousness of it. That could be a good compromise actually as although it would still not have the prompt it would remove your problems with the confirmation too (which means the answer file will always work - which seems good to me I might add ... again I'm not totally against your ideas!). This way you have your way but it still expresses more warnings to the user.

I'll probably look at the code before Tuesday but I will try not reacting to anything until then. How does that sound to you? I don't want to add to your stress and I'm sorry (it's very clear to me that I have) that I've upset you. I'm so serious about that that I'm almost tempted to just say: add the full warnings and then go for it. That might just be enough to make me happy (it's not as good, maybe, in some ways, as having the prompt, but it at least explains to the user why there's a problem rather than just the one line message).

Hope you have a good night and hope you sleep well and again I'm very sorry that I've upset you. Btw I still think you should go for the JSON code irrespective of this code; I know you'll deliver a great tool! I know I wouldn't as I've never played with parsing JSON nor have I even played with JSON full stop. But it seems like you would do well. I'll take a look at the other requests later on - probably not today.

Cheers and I hope you feel better soon mate! I hope this message helps you out. I really am trying to be reasonable and that's why I'm trying to come up with a solution (and why I've given it thought even when not at the computer).

@lcn2
Copy link
Contributor

lcn2 commented Jan 30, 2022

We will continue to watch your discussion @xexyl and @ilyakurdyukov. Let us know when you reach a consensus and update the pull request if/as needed.

@xexyl
Copy link
Contributor

xexyl commented Jan 31, 2022

A short bit ago I had a thought that might help here. After that I looked at the code and saw that it's already there. But looking at the code I see a couple ways to improve it. I'd say go for accepting these and I'll add in my thoughts below.

Here's what I like about the patch that's different from my code:

  • It does ask for confirmation if warnings are ignored (after the more recent changes from Ilya). The difference is it's asked right before the tarball is formed. The better thing here is that it doesn't need the 'y' in the answers file so if the user triggers a different warning it still works.
  • It has a versions tag and an EOF marker. I think those are nice ideas.

I did notice though that if you ignore a warning you can have the result of:

Are you sure you want to create a tarball with having these warnings unresolved? [yn]: FATAL[74]: prompt: EOF while reading prompt input

So reading from stdin is incomplete. Here's where I think there could be some improvements (besides making it so this is complete).

  • Minor detail: show how many warnings are ignored rather than just 'one or more warnings'. This is easy enough to do.
  • Next to the warnings like WARNING: prog.c is empty show the FULL warning (which is in the check functions).
  • It might also be good to prompt for each warning individually before continuing because this way it's really drilled into the user that these can be a problem. I believe that a prompt for each warning GROUP is good; that is to say: all the warnings (if any) of the iocccsize tool should have a single prompt as should the prog.c being empty as well as the Makefile warning. This would be better than what I had and I think it improves Ilya's code too.
  • I also think that the answers file should not be recorded until after confirmations are verified (clarified: Ilya's confirmations are verified). On the other hand this might not be necessary since the answers are not added to the answer file which means that the other information can be there by itself (which means that the answers file can in fact be used again).

Since Ilya is stressed and also these are my summarised thoughts I'll add these. Thus I would say you should go ahead and accept these changes and I'll work on the additions. This I think will make us both happy and I think the changes together will make the tool all the better.

How does that sound to you @ilyakurdyukov ? I hope this will make you happy and again I'm sorry if I caused you any stress. With a clearer head it's a lot easier to see your ideas as an improvement (I was against not prompting the user to ignore warnings and since you've added that - I did not see that yesterday as I was too tired - I think it's good but I still think I can update it a bit to make it a bit more rounded).

I'm going to work on these changes now on Ilya's code and once this is accepted into the repo I will just copy the mkiocccentry.c in that directory to my fork and then I will do a PR.

@xexyl
Copy link
Contributor

xexyl commented Jan 31, 2022

Okay I just did the following against Ilya's changes and I think this will work out; it'll be a good compromise between us and I hope it'll work for him.

  • Warnings

He had it so that there's a summary of warnings that are displayed after processing the files. However the warnings that were in the check functions were also printed. When reading from the answers file he had it so that it did not prompt you: it just went right ahead and proceeded but still showed the warnings.

What I did is make it so the full warnings are not displayed until the end (after processing) and prompt individually for each warning (as if it wasn't automated except that everything other than the warnings are automated much like how he had it only I show the full warnings to show the importance of it).

If there aren't any warnings there's no problem: the creation of the tarball is done; else it's automated but at the end the user can decide whether or not to ignore the warnings. This means that those who don't have any warnings in their files can automate it without any prompting but if they do change it they will be prompted. This satisfies my disquiet about not having the prompts but it also means the answers file will always work (which satisfies Ilya's concern).

I also modularised the warnings: each warning is in its own function which prints the warning and prompts if the user wishes to proceed. This way there's no need to duplicate the code in the two places.

  • The creation of the tarball

I made it so even if it's automated (answers file used) the user is prompted if the directory is correct (correct files and so on). I think this is a good idea but this is certainly a matter of opinion: it could go either way and I'd be happy; whatever the general consensus is. I'm okay with this either way.

  • stdin versus answers file

I think that given that the answers file has the tag and EOF marker that maybe it's not necessary that if there are warnings that doing < answers needs to work; if they want that they can use the option to read in the answers file which makes it easier and built-in. I have a possible idea of how it might be done where it would work but I'm not sure if it's worth it.

  • Summary

Once Ilya's PR is accepted I will commit and do another PR against his and I think we can both be satisfied.

  • Other unrelated information that might mean I can't be so easily working on the tool(s)

I seem to be having a problem with my charger on my laptop; my power bank works but this could be a serious drain so I'm not sure how much I can do until this can be worked out. It was working strangely before but after a power outage it no longer charges at all so I need to get a replacement (and that might not be the problem because it seems also that there's a possible building wiring fault on the line). I hope to get to the other stuff sooner than later.

@lcn2
Copy link
Contributor

lcn2 commented Feb 1, 2022

This is great progress @xexyl and @ilyakurdyukov! Thanks!

Let us know when the pull request has been updated / ready for us to merge.

@xexyl
Copy link
Contributor

xexyl commented Feb 1, 2022

@lcn2 Please merge it. Once that's done I'll fetch upstream on my fork and then commit my changes and make a pull request.

@lcn2 lcn2 merged commit c9b31d4 into ioccc-src:master Feb 2, 2022
@lcn2
Copy link
Contributor

lcn2 commented Feb 2, 2022

@lcn2 Please merge it. Once that's done I'll fetch upstream on my fork and then commit my changes and make a pull request.

done, @xexyl .. thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants