some lua in C

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

some lua in C

Max Ischenko
I'm implementing C wrapper around pidof command.

pidof returns a string of pids for given process.
For example, pidof xterm -> 34 56 546

Currently my C impl. returns just a string '34 56 546' but I want it
to return a table {[1]=34,[2]=56,[3]=546,[n]=3}.

In lua i wrote
t = {}
s = pidof('rxvt')
gsub(s, '(%S+)', function (str) tinsert(%t, str) end)

How can rewrote it in C?

-- 
How much do Windows cost, and do you have to buy each one separately?

rje
Reply | Threaded
Open this post in threaded view
|

Re: some lua in C

rje
On Wed, Jan 10, 2001 at 04:08:55PM +0200, Max Ischenko wrote:
> 
> I'm implementing C wrapper around pidof command.

<snip>

> In lua i wrote
> t = {}
> s = pidof('rxvt')
> gsub(s, '(%S+)', function (str) tinsert(%t, str) end)
> 
> How can rewrote it in C?

Which version of Lua are you using?  The method can change somewhat
between versions.

-- 
Rob Kendrick - http://www.digital-scurf.org/
Good news from afar can bring you a welcome visitor.

Reply | Threaded
Open this post in threaded view
|

Re: some lua in C

Max Ischenko
	Hi there, [hidden email]!
	On Wednesday, 10 of January you wrote:

> 
> > In lua i wrote
> > t = {}
> > s = pidof('rxvt')
> > gsub(s, '(%S+)', function (str) tinsert(%t, str) end)
> > 
> > How can rewrote it in C?
> 
> Which version of Lua are you using?  The method can change somewhat
> between versions.

Lua 4.0 

-- 
Best regards, Maxim F. Ischenko.