Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Skylark functions/links
Re: Skylark functions/links [message #42926 is a reply to message #42925] |
Mon, 14 April 2014 20:16 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
mingodad wrote on Mon, 14 April 2014 16:49Thanks for the link !
I've created this function:
Value WitzUrlEncode(const Vector<Value>& arg, const Renderer *) {
if(arg.GetCount() != 1 || !IsString(arg[0]))
return String();
StringBuffer buf;
UrlEncode(buf, String(arg[0]));
return Value(buf.Begin());
}
INITBLOCK {
Compiler::Register("url_encode", WitzUrlEncode);
}
But I get two kind of errors ($rec.name has valid content) :
------
$url_encode($rec.name) >>> Internal server error (206,12): missing number
------
or
------
$url_encode(rec.name) >>> *************PANIC: Invalid memory access! Segmentation fault (core dumped)
------
Probably a bug in U++ !!!
Attached sample to test!
Well, this is nice one...
What happened here is that you have probably seen
UrlEncode(StringBuffer& b, const char *s) signature in Skylark - but that is local function (my fault, should have made it static).
What got called instead was
UrlEncode(const char *begin, const char *end);
(from Core/Inet.h)
which, having begin and end pointing to unrelated things, obviously crashed.
This works:
Value WitzUrlEncode(const Vector<Value>& arg, const Renderer *) {
return arg.GetCount() == 1 && IsString(arg[0]) ? UrlEncode(arg[0]) : String();
}
INITBLOCK {
Compiler::Register("url_encode", WitzUrlEncode);
}
|
|
|
Goto Forum:
Current Time: Sun May 05 12:30:15 CEST 2024
Total time taken to generate the page: 0.02325 seconds
|