Skip to content

Conversation

zielmicha
Copy link
Contributor

Fixes #726, possibly #274, and fixes regression introduced by #702. And I hope it doesn't break new things.

Sorry for "Normalize whitespace in os.nim", but I'd rather spend time fixing Nimrod, than doing nasty tricks in bash or reconfiguring my editor. (and we all don't like trailing whitespace?)

New code in parseopt.nim adheres to the following "specification":

## 1. short options - ``-abcd``, where a, b, c, d are names
## 2. long option - ``--foo:bar``, ``--foo=bar``, ``--foo`` or ``-f:bar``
## 3. argument - everything else

There is also a new test - tests/system/params.nim. I'm not sure if it works on Windows.

I can't edit it - trick with asking git to ignore whitespace doesn't
work if I need to change indention level.
commandLineParams returns seq of arguments given to program on command line.
@gradha
Copy link
Contributor

gradha commented Dec 10, 2013

Maybe it's getting there, but there still are problems running koch web:

...
/Users/gradha/project/nimrod/root/tools/nimweb web/nimrod --putenv:nimrodversion=0.9.3 --path:/Users/gradha/project/nimrod/root
[Warning] Skipping unknown section: quotations
nimrod rst2html --compileonly --hint[Conf]:off --putenv:nimrodversion=0.9.3 --path:/Users/gradha/project/nimrod/root -o:web/index.temp web/index.txt
command line(1, 1) Error: invalid command line option: '--putenv:nimrodversion'
external program failed
Error: execution of an external program failed

It seems that the putenv is being cut, but it conforms to the new specification, or doesn't?

@zielmicha
Copy link
Contributor Author

It doesn't. Option is split on = before :. I guess I need to change priority.

@zielmicha
Copy link
Contributor Author

It should work now. Btw ./koch web still fails (lib/pure/actors.nim(30, 21) Error: undeclared identifier: 'TChannel').
This PR hasn't much to do with #732 - I will take care of quoteIfContainsWhite in next one.
(And also update web page there, as now there would be a conflict with gradha's revert and I don't want to merge master into this now).

Araq added a commit that referenced this pull request Dec 10, 2013
Make parseopt correct (and based on seq[string] as parameters, not string)
@Araq Araq merged commit a532eb2 into nim-lang:master Dec 10, 2013
reactormonk pushed a commit to reactormonk/nim that referenced this pull request Apr 7, 2014
This reverts commit a54ba4c to avoid
tool breakage. A different approach is being worked on nim-lang#730.
reactormonk pushed a commit to reactormonk/nim that referenced this pull request Apr 7, 2014
Make parseopt correct (and based on seq[string] as parameters, not string)
Clyybber pushed a commit to Clyybber/Nim that referenced this pull request Sep 16, 2023
## Summary

Create a copy of the token before calling `parsePragma` in
`identWithPragma`, which fixes a subtle issue where the `Token.literal`
string pointed to already-freed heap memory.

## Details

For a call such as `p(a, p2(a))` where `proc p(x: ObjType)` and
`proc p2(x: var ObjType)`, the *C code-generator* introduces a shallow
temporary that captures the state of `a` prior to the evaluating
`p2(a)`, with the temporary then being passed to `p` in the place of
`a`.

This is done in order to uphold the left-to-right evaluation guarantees.
However, if the `ObjType` stores indirections such as `seq` or `string`,
updates of their contents are still observable through the shallow
temporary, and should `p2` resize the `seq` or `string`, the pointer in
the shallow temporary becomes dangling.
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.

3 participants