-
Notifications
You must be signed in to change notification settings - Fork 20
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
Only remove the last extension from a source file name. #79
base: master
Are you sure you want to change the base?
Conversation
I don’t understand, neither from this nor from #78, what the actual problem is. Can you please describe a bit more explicitly, ideally if a sample bkl file demonstrating the problem (and really ideally, including the difference in generated output)? Without knowing more, this doesn’t seem right, and if I’m reading this correctly, will uglify names of object files — I’d very much like to avoid that. If there’s some edge case that isn’t handled correctly, it would be better to fix that instead of changing the output this drastically. Again, if I’m understanding this patch correctly. P.S. If you could use standard git commit message formatting, it would be greatly appreciated. |
Sorry, I should have lead with an example. This commit only changes the output in a specific edge-case:
which currently outputs:
while this is the desired output:
The issue is in the way the object name is derived from the source file name. First, get_basename() removes the path and extension. Second, change_extension() removes the extension, if possible, and adds the object extension. However, in the common case it isn't possible to remove the extension in the second step because it was already removed in the first step. In effect, change_extension() is never used to change the extension as intended. In short, only get_basename() or change_extension() should remove the extension, not both. I decided to modify change_extension() because it seemed to have the least impact. If you prefer to leave change_extension() alone, then get_basename() must not remove the extension. |
I’m terribly sorry, I was leaving for a trip right when you replied and by the time I came back, I completely forgot about it and GitHub’s notification mail felt under the fold :(
Are you sure, i.e. did you see if there are any changes in bkl’s test/example files?
I still don’t understand any of this. It also seems that you’re saying there’s a noop step somewhere and that there’s something removing too much, but I don’t see anything of the sorts in the commit’s diff — so again, what’s the relation to the changes? Isn’t the actual problem something else, namely that both these functions consider too much to be an extension — i.e. that they treat “.x.c” as the extension in your example, not “.c”, or possibly only one of them (which?) does? If yes, then that is what needs fixing, the correct behavior obviously should be that get_basename("hello.x.c”) = “hello.x” and change_extension() replaces the “.c” part, not “.x.c”. |
Since get_basename() already removes the extension from a path expression, changing the extension removes a second extension, causing *hello.x.c* and *hello.y.c* to both generate *hello.o*. Adding an extension instead generates *hello.x.o* and *hello.y.o* as expected.
9962a9e
to
68c7c08
Compare
Fixes #78 by replacing change_extension() with add_extension(). Since get_basename() already removes the extension from a path expression, it isn't appropriate to change the extension of the base name.
All calls to change_extension() were made to an object returned by get_basename(), so there is no reason to keep both change_extension() and add_extension(), unless it is used by an external plugin.