DL usage

S

Stephan Kämper

Hi all,

when using DL to generate some code to access dynamic library functions,
I noticed that it doesn't find a symbol, if the given prototype has a
space character just before the right parenthesis (or right after the
left parenthesis).

int DocumentGetErrorNumber(extHandle )
C:/ruby/lib/ruby/1.8/dl/import.rb:125:in `symbol': can't find the symbol
`DocumentGetErrorNumber' (RuntimeError)
from C:/ruby/lib/ruby/1.8/dl/import.rb:144:in `import'
from C:/ruby/lib/ruby/1.8/dl/import.rb:61:in `extern'

After changing the prototype to

int DocumentGetErrorNumber(extHandle)

everything's fine.

Although is just a little bit inconvenient (I just applied 'strip' to
the argument list of the prototype), I wonder if it's possible to make
DL even more helpful, by changing this behaviour?

For example changing line 41 of 'dl/import.rb' to

args = $2.strip

would that. Is that an ugly hack? I don't know. Perhaps tweaking the
regular expression would be more elegant.
Of course, I don't dare to make a prediction about breaking other code
by doing this. But then, if the white space isn't stripped, the
prototype isn't going to work anyway. On the other hand, the way it is
may be intended behaviour...

Happy rubying

Stephan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top