Opened 9 years ago
Closed 9 years ago
#378 closed defect (fixed)
Atom spec parsing stops at non-whitespace
| Reported by: | Tom Goddard | Owned by: | Conrad Huang |
|---|---|---|---|
| Priority: | major | Milestone: | Alpha Release |
| Component: | Command Line | Version: | |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Notify when closed: | Platform: | all | |
| Project: | ChimeraX |
Description
Atom spec parsing is terminating at a non-whitespace character. For example
save #1 /tmp/test.mrc
parses "#1 /tmp/test" as an atom spec (chains tmp and test) leaving the ".mrc" as the next argument.
As atom spec parsing tries to consume additional whitespace delimited tokens it should reject tokens that are not complete valid atoms specs.
I fixed a different case of this same bug
save ~/Desktop/test.png
which was being parsed as model "~/Desktop/test" and filename ".png". I fixed it in a bad way where I simply made AtomSpecArg check if the rest of the unparsed line does not begin with white space then the atom spec parsing fails. Here the rest of the text is ".png". But this does not help in the "save #1 /tmp/test.mrc" example where the atomspec parser needs to know not to include partial tokens.
Change History (2)
comment:1 by , 9 years ago
| Milestone: | → Alpha Release |
|---|
comment:2 by , 9 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
The "save" command usage was already changed to put the filename before the atomspec so the issue is worked around.
86f9a64 makes atomspec parsing terminate at the preceding whitespace if an error occurs in the middle of a string. This does not help the case where a filename consists only of alphanumeric and / (e.g., old_save #1 /tmp/xyz) since #1 /tmp/xyz is a legal atomspec for chains tmp and xyz in model 1. But it does help for old_save #1 /tmp/test.mrc since .mrc causes a parsing error in the middle of a string. The atomspec parser will only use the input up to the preceding whitespace, or #1, leaving /tmp/test.mrc for the next argument.