Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on Lua.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/lua.e>
#           or at <http://angg.twu.net/e/lua.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





My latest and greatest version of Lua for Debian:
# «.lua_4.0-0.3»	(to "lua_4.0-0.3")
# «.lua_4.0-0.3_old»	(to "lua_4.0-0.3_old")
# «.edrx-regexp-funs»	(to "edrx-regexp-funs")

Migrating to Lua-5.0:
# «.lua5.0-alpha»	(to "lua5.0-alpha")
# «.lua5.0-beta»	(to "lua5.0-beta")

About packaging Lua for Debian (older stuff):
# «.fetching_the_debs»	(to "fetching_the_debs")
# «.fetch_debs_by_hand»	(to "fetch_debs_by_hand")
# «.any_distro»		(to "any_distro")
# «.re-yada-ing»	(to "re-yada-ing")
# «.lua_yada»		(to "lua_yada")
# «.lua-packagesfile»	(to "lua-packagesfile")
# «.lua-3.2_yada»	(to "lua-3.2_yada")

Standard demos and docs:
# «.lua_docs»		(to "lua_docs")
# «.lua.info»		(to "lua.info")
# «.lua_demos»		(to "lua_demos")
# «.lua_demos_C»	(to "lua_demos_C")
# «.lua-list»		(to "lua-list")

Patches:
# «.bitops_and_regexps»	(to "bitops_and_regexps")

Details of the language:
# «.tags_of_tables»	(to "tags_of_tables")
# «.tags»		(to "tags")
# «.weirdnesses»	(to "weirdnesses")
# «.scope»		(to "scope")
# «.argv»		(to "argv")

Other Debian packages of Lua:
# «.dsilver_lua_deb»	(to "dsilver_lua_deb")
# «.jaycarlson_lua_deb»	(to "jaycarlson_lua_deb")


# «.first_progs»	(to "first_progs")
# «.toposort»		(to "toposort")
# «.apt-move.lua»	(to "apt-move.lua")
# «.apt-move.lua_prep»	(to "apt-move.lua_prep")
# «.apt-move.lua_P_apply»  (to "apt-move.lua_P_apply")
# «.apt-move.lua_old»	(to "apt-move.lua_old")
# «.debversions_lua»	(to "debversions_lua")

# «.lua_before_deb»	(to "lua_before_deb")
# «.lua.el»		(to "lua.el")
# «.lua-mode.el»	(to "lua-mode.el")
# «.ldb»		(to "ldb")
# «.lux»		(to "lux")
# «.yield»		(to "yield")
# «.untabify»		(to "untabify")
# «.dednat»		(to "dednat")
# «.flua»		(to "flua")
# «.cgilua»		(to "cgilua")
# «.luasql»		(to "luasql")
# «.pio_fontx»		(to "pio_fontx")
# «.gllua»		(to "gllua")
# «.tolua»		(to "tolua")
# «.tklua»		(to "tklua")
# «.tolua_tklua_.so»	(to "tolua_tklua_.so")
# «.loadtklua»		(to "loadtklua")
# «.tklua_first_progs»	(to "tklua_first_progs")
# «.luasocket»		(to "luasocket")
# «.dostring»		(to "dostring")
# «.for»		(to "for")
# «.inheriting»		(to "inheriting")
# «._ERRORMESSAGE»	(to "_ERRORMESSAGE")








#####
#
# How to fetch the .debs for Lua 4.0
# 2001feb
#
#####

# «fetching_the_debs»  (to ".fetching_the_debs")

# Warning: the block below is obsolete.
# The way to get the latest Debian version is to follow the
# instructions in the following file:
# (find-fline "~/lua-4.0/README.yada")

# (find-shttpw3 "angg.twu.net/debian/dists/potato/local/binary-i386/Packages")

# The "standard way" to fetch the debs using apt: add some lines to
# /etc/apt/sources.list, as explained in:
#  (find-shttpw3 "angg.twu.net/debian/dists/potato/local/README.txt")
#  (find-fline "/etc/apt/sources.list")
# then:

# the "binary way":
apt-get update
apt-get install lua

# or the "source way":
cd /tmp/
apt-get update
apt-get source lua
cd lua-4.0/
#patch -p0 < loadlib.patch

debian/rules binary	2>&1 | tee odrb
dpkg -i ../lua_4.0-0_i386.deb

# If the "debian/rules binary" above gives yada errors then try this instead:
# (to "re-yada-ing")





# «fetch_debs_by_hand»  (to ".fetch_debs_by_hand")
# If you just want to fetch the .debs and .dscs & friends by hand...
cd ~/tmp/
wget http://angg.twu.net/debian/dists/potato/local/binary-i386/lua_4.0-0_i386.deb

cd ~/tmp/
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0-0.diff.gz
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0-0.dsc
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0.orig.tar.gz



# «any_distro»  (to ".any_distro")
# And here's how to recompile lua4.0 from the sources without using
# any specific Debian tool; this should work on non-Debian systems
# (but I haven't tested it yet), and the nice point is that you'll get
# a lua compiled with Reuben Thomas' regexps+bitops patch, and
# optionally also with my useful but still very dirty "loadllib"
# patch.

# (Ignore this; this is just what I use for tests).
#cd /tmp/; rm -Rv lua*; cp -v /usr/src/lua_4.0* .
# (end of the "ignore this" block).
#*
cd ~/tmp/
rm -Rv lua-4.0.orig/ lua-4.0/
tar -xvzf lua_4.0.orig.tar.gz
mv lua-4.0.orig/ lua-4.0/
cd lua-4.0/
zcat ../lua_4.0-0.diff.gz | patch -p1

#*
# If you want to include my hackish "loadlib" in the standard Lua
# library then run the commented-out "patch" command below.
#  (find-angg "LUA/loadlib/README.loadlib")
#  (find-angg "LUA/loadlib/lloadlib.c")
#  (find-fline "~/LUA/loadlib/loadlib.patch")
#patch -p0 < loadlib.patch

#*
# debian/rules is a "#!/usr/bin/make -f" script, i.e., an executable
# makefile, so this should work almost anywhere (will break only when
# the debian-specific commands start to be invoked, near the end of
# the build process).
#
make -f debian/rules binary	2>&1 | tee odrb
# (find-es "bash" "pipe_stdout_stderr")

# UPDATE: there's a check that the user is root (or is running
# "fakeroot") just at the beginning of debin/rules, which is something
# that makes sense when you're building a .deb, but that spoils
# everything in the case of a normal user trying to install Lua in his
# own account (like me at the university). I'll post the fix as soon
# as I can ssh into my university account again, it is blocked now.






#####
#
# Re-"yada"ing my Lua Debian package for Woody or Sid
# 2001jun26
#
#####

# «re-yada-ing»  (to ".re-yada-ing")
apt-get install yada grep-dctrl
#*
mkdir ~/tmp/
cd ~/tmp/
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0-0.1.diff.gz
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0-0.1.dsc
wget http://angg.twu.net/debian/dists/potato/local/source/lua_4.0.orig.tar.gz

#*
rm -Rv ~/tmp/lua-4.0/
rm -v  ~/tmp/lua_4.0-*.deb
cd ~/tmp/
dpkg-source -sn -x lua_4.0-0.1.dsc
cd ~/tmp/lua-4.0/

# Optional (and non-standard!):
#patch -p0 < loadlib.patch
# (No longer makes sense now that I have dllua)

# If the "debian/rules binary" below gives errors you may want to try this:
rm -fv debian/control debian/rules debian/yada
rm -fv debian/files debian/substvars
yada yada
yada rebuild rules
yada rebuild control

fakeroot debian/rules binary	2>&1 | tee odrb

#*





#####
#
# lua-4.0 as debian package (blitzkrieg version), using yada
# 2000dec15
#
#####

# «lua_yada»  (to ".lua_yada")
# For the "serious way" to pack lua4.0 follow these links:
#	(to "lua_4.0-0.3")
# My notes for version 3.2 are at:
#	(to "lua-3.2_yada")
# (find-angg ".zshrc" "makepage_deb")
# (find-angg "bin/edrxpage" "package")
# (find-fline "~/EDRXPAGE/")
# (find-fline "~/EDRXPAGE/README")
# (find-fline "~/EDRXPAGE/packages")
# (find-es "xxx-server" "edrxpage_yada")

# (find-status "edrxpage")
# (find-vldifile "edrxpage.list")
# (find-fline "/usr/doc/edrxpage/")

# (code-c-d "lua" "/usr/src/lua-4.0/")
# (find-luafile "")
# (find-luafile "Makefile")
# (find-luafile "config")
# (find-luafile "doc/")
# (find-luafile "etc/")
# (find-luaw3 "doc/")

#*
rm -Rv /usr/src/lua-4.0/
mkdir  /usr/src/lua-4.0/
cd     /usr/src/lua-4.0/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
mv -v lua/* .
rmdir lua/

# Optional: install Reuben Thomas' bitops/regexp libs.
# (to "bitops_and_regexps")
mkdir rttpatch
cd rttpatch
unzip $S/http/www.cl.cam.ac.uk/users/rrt1001/lualibs.zip
mv README README.rttpatch
for i in $(find * -type f); do mv -v $i ../$i; done
cd /usr/src/lua-4.0/
rmdir rttpatch

cd     /usr/src/lua-4.0/
#find * | sort > .files

mkdir debian

# «lua-packagesfile»  (to ".lua-packagesfile")
# (find-fline "~/lua-4.0/debian/packages")
# Changes to the "packages" file should be made here, not in the file (?)
# itself.

cat > debian/packages <<'---'
Source: lua
Section: devel
Priority: optional
Maintainer: Eduardo Ochs <edrx@mat.puc-rio.br>
Standards-Version: 3.0.1
Home-Page: <URL:http://www.tecgraf.puc-rio.br/lua/>
Description: Lua is an extensible extension language.
 Lua is an extensible extension language.
Copyright: .
Major-Changes:
Build: sh
 # (find-luafile "Makefile")
 # (find-luafile "config" "INSTALL_ROOT")
 find * | sort > .files
 make all so sobin
 mkdir inst
 make INSTALL_ROOT=$PWD/inst install
 rm                  inst/lib/liblua.so
 ln -s liblua.so.4.0 inst/lib/liblua.so
 rm                     inst/lib/liblualib.so
 ln -s liblualib.so.4.0 inst/lib/liblualib.so
Clean: sh
 #make distclean || true

Package: lua
Architecture: any
Depends: [/usr/bin/*]
Description: Lua is an extensible extension language.
 This Debian package is in alpha stage.
 Follow this link for more info: (find-es "lua" "lua_yada")
Install: sh
 # (find-fline "/usr/src/lua/.instfiles")
 # (find-fline "/usr/doc/yada/yada.txt.gz" "yada install")
 #
 yada install -bin  inst/bin/*
 yada install -dir  usr/include
 yada install -into usr/include inst/include/*
 yada install -lib  inst/lib/*.a inst/lib/*.so.*
 cp -dv inst/lib/*.so debian/tmp-lua/usr/lib/
 yada install -man  inst/man/man1/*
 yada install -doc  HISTORY README doc/*.html doc/*.gif
 yada install -doc -as copyright COPYRIGHT
 yada install -doc -subdir examples     test/README test/*.lua
 yada install -doc -subdir examples/ps  test/examples/ps/*
 yada install -doc -subdir examples/www test/examples/www/*
 yada install -doc -subdir etc etc/*
 #
 if [ -e README.rttpatch ]; then yada install -doc README.rttpatch; fi
 if [ -e README.loadlib ];  then yada install -doc README.loadlib; fi
---

cp -v debian/packages ~/lua-4.0/debian/
#cp -v debian/changelog ~/lua-4.0/debian/
# (find-fline "~/lua-4.0/debian/")
# (find-fline "/usr/bin/yada" "Wile E. Coyote")
# (find-es "debiandev" "yada")

yada yada
debian/yada rebuild rules
cd /usr/src/lua-4.0/
debian/rules binary		|& tee oy
# ar p /usr/src/lua_4.0-1_i386.deb data.tar.gz | tar -tvzf -

#*
# (find-es "debiandev" "yada")

dpkg -i /usr/src/lua_4.0-1_i386.deb

# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/")




#####
#
# lua-3.2 as debian package, using yada
# 2000dec25
#
#####

# «lua-3.2_yada»  (to ".lua-3.2_yada")
# Warning! This is just a slight and careless modification of the
# quick script that debianizes lua-4.0: (to "lua_yada")

# (code-c-d "lua3" "/usr/src/lua3.2-3.2/")
# (find-lua3file "")
# (find-lua3file "INSTALL")
# (find-lua3w3 "doc/")

#*
rm -Rv /usr/src/lua3.2-3.2.orig/
mkdir  /usr/src/lua3.2-3.2.orig/
cd     /usr/src/lua3.2-3.2.orig/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-3.2.tar.gz
mv -v lua/* .
rmdir lua/

rm -Rv /usr/src/lua3.2-3.2/
mkdir  /usr/src/lua3.2-3.2/
cd     /usr/src/lua3.2-3.2/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-3.2.tar.gz
mv -v lua/* .
rmdir lua/
cd     /usr/src/lua3.2-3.2/

mkdir debian

cat > debian/packages <<'---'
Source: lua3.2
Section: devel
Priority: optional
Maintainer: Eduardo Ochs <edrx@mat.puc-rio.br>
Standards-Version: 3.0.1
Home-Page: <URL:http://www.tecgraf.puc-rio.br/lua/>
Description: Lua is an extensible extension language.
 This Debian package is in pre-alpha stage (this is for version 3.2)!
 Follow this link for more info: (find-es "lua" "lua-3.2_yada")
Copyright: .
Major-Changes:
Build: sh
 make
 # (find-lua3file "INSTALL" "* Shared Libraries")
 # Make the shared libs:
 ld -o lib/liblua.so.3.2 -shared src/*.o
 ld -o lib/liblualib.so.3.2 -shared src/lib/*.o
 ln -s liblua.so.3.2 lib/liblua.so
 ln -s liblualib.so.3.2 lib/liblualib.so
 #
 # Recompile lua and luac using the shared libs:
 rm bin/lua
 rm bin/luac
 (cd src/lua; make)
 (cd src/luac; make)
Clean: sh
 #make distclean || true

Package: lua3.2
Architecture: any
Depends: [/usr/bin/*]
Provides: lua
Conflicts: lua
Description: Lua is an extensible extension language.
 This Debian package is in pre-alpha stage (this is for version 3.2)!
 Follow this link for more info: (find-es "lua" "lua-3.2_yada")
Install: sh
 # (find-fline "/usr/doc/yada/yada.txt.gz" "yada install")
 #
 yada install -bin  bin/*
 yada install -dir  usr/include
 yada install -into usr/include include/*.h
 yada install -lib  lib/*.a lib/*.so.*
 cp -dv lib/*.so debian/tmp-lua3.2/usr/lib/
 yada install -doc  HISTORY README doc/*.html
 yada install -doc -as copyright COPYRIGHT
 yada install -doc -subdir examples     test/README test/*.lua
 yada install -doc -subdir examples/ps  test/examples/ps/*
 yada install -doc -subdir examples/www test/examples/www/*
 yada install -doc -subdir etc etc/*
---

yada yada
debian/yada rebuild rules
# debian/rules binary		|& tee oy

cat > $EEG <<'---'
TestPasswd
TestPasswd
---
eeg dpkg-buildpackage		|& tee /tmp/odbp

# ar p /usr/src/lua_3.2-1_i386.deb data.tar.gz | tar -tvzf -
ar p /usr/src/lua3.2_3.2-1_i386.deb data.tar.gz | tar -tzf -

#*
cd /usr/src/
mv -v lua3.2*.deb .debs/
mv -v lua3.2*.dsc .dscs/
mv -v lua3.2*.gz  .dscs/
mv -v lua3.2*.changes .dscs/
aptu-local-i386

#*

# (find-fline "/usr/src/lua-3.2/")
# (find-fline "/usr/src/lua-3.2/oy")
# (find-es "debiandev" "yada")

dpkg -i /usr/src/lua_3.2-1_i386.deb

# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/")





#####
#
# lua docs
# 2000dec26
#
#####

# «lua_docs»  (to ".lua_docs")
# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/")

lynx -dump /usr/doc/lua/manual.html > ~/tmp/lua-manual.txt
# (find-fline "~/tmp/lua-manual.txt")
# (find-fline "~/tmp/lua-manual.txt" "\n  4.4.4 - For Statement")
# (find-fline "~/tmp/lua-manual.txt" "v:f")
# (find-fline "~/tmp/lua-manual.txt" "getargs")
# (find-fline "~/tmp/lua-manual.txt" "strfind")
# (find-fline "~/tmp/lua-manual.txt" "strsub")
# (find-fline "~/tmp/lua-manual.txt" "tinsert")
# (find-fline "~/tmp/lua-manual.txt" "\n6.4 - I/O Facilities")
# (find-fline "~/tmp/lua-manual.txt" "\n  read ")
# (find-fline "~/tmp/lua-manual.txt" "\n  4.4.2 - Assignment")
# (find-fline "~/tmp/lua-manual.txt" "g(x, f())")
# (find-fline "~/tmp/lua-manual.txt" "function g(a, b, ...)")

# (find-shttpw3 "www.tecgraf.puc-rio.br/lua/spe.html")
# (find-shttpw3 "www.tecgraf.puc-rio.br/lua/faq.html")
# (find-shttpw3 "www.tecgraf.puc-rio.br/lua/ddj.html")

# (find-fline "$S/http/www.tecgraf.puc-rio.br/lua/spe.html")
# (find-fline "$S/http/www.tecgraf.puc-rio.br/lua/faq.html")
# (find-fline "$S/http/www.tecgraf.puc-rio.br/lua/ddj.html")





#####
#
# the lua manual in texinfo format
# 2001mar11
#
#####

# «lua.info»  (to ".lua.info")
# (find-fline "~/lua-4.0/doc/")
# (find-fline "~/lua-4.0/doc/lua.texi")
#*
cd ~/lua-4.0/doc/
rm -v lua.info*
makeinfo lua.texi
# (code-c-d "lua" "/usr/src/lua-4.0/" "~/lua-4.0/doc/lua")
# (find-luanode "Top")
#*
cd ~/lua-4.0/doc/
rm -v lua.info*
rm -v /usr/share/info/lua.info*
makeinfo lua.texi && (
  gzip -9v lua.info*
  mv -iv   lua.info* /usr/share/info/
)
# (code-c-d "lua" "/usr/src/lua-4.0/" "lua")
# (find-luanode "Top")

#*
# (find-es "dpkg" "install-info")
# (eeman "8 install-info")
# (eeman "8 install-info" "--infodir=infodir")
# (eeman "8 install-info" "--description=xxx")
install-info							\
  --section Development Development				\
  --description='Lua is an extensible extension language.'	\
  /usr/share/info/lua.info.gz
echo $?
#*
install-info --remove lua
echo $?
#*
# Uploading to twu:
cd /usr/src/lua-4.0/debian/tmp-lua/usr/share/info/
anonftp angg.twu.net 'cd ~/info/' 'mput lua.info*.gz' 'quit'

#*
# (progn (catch '(kill-buffer "*info*")) (find-node "(dir)Top" "lua"))

# install-info --quiet --section Emacs Emacs /usr/share/info/${file}.gz || true
# install-info --remove emacs > /dev/null 2>&1






#####
#
# lua demos
# 2000dec14
#
#####

# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/")

# «lua_demos»  (to ".lua_demos")
#*
rm -Rv /tmp/lua-ex/
mkdir  /tmp/lua-ex/
cd     /usr/doc/lua/examples/
cp -diPpvR * /tmp/lua-ex/
cd     /tmp/lua-ex/
for i in $(find * | grep '.gz$'); do gzip -dv $i; done
#*

# (find-fline "/usr/doc/lua/examples/")
# (find-fline "/tmp/lua-ex/")

cd     /tmp/lua-ex/
read; lua bisect.lua
read; lua cf-for.lua
read; lua cf.lua
read; lua factorial.lua
read; lua fib.lua
read; lua hello.lua
read; lua lisp.lua
read; lua save.lua
read; lua sort.lua
read; lua trace-globals.lua
read; lua undefined.lua

read; lua life.lua

read; lua trace-calls.lua hello.lua
read; lua trace-calls.lua bisect.lua

# read; lua globals.lua
# read; lua old.lua
# read; lua qp.lua
# read; lua table.lua
# read; lua webform.lua

# (find-fline "/tmp/lua-ex/globals.lua")
# (find-fline "/tmp/lua-ex/old.lua")
# (find-fline "/tmp/lua-ex/qp.lua")
# (find-fline "/tmp/lua-ex/table.lua")
# (find-fline "/tmp/lua-ex/trace-calls.lua")
# (find-fline "/tmp/lua-ex/webform.lua")

cd /tmp/lua-ex/ps/
lua hilbert.lua > out.ps
gv out.ps

#*





#####
#
# Lua demos using C
# 2001feb08
#
#####

# «lua_demos_C»  (to ".lua_demos_C")
# (find-fline "~/tmp/lua-manual.txt" "API")
# (find-fline "/usr/doc/lua/")
# (find-fline "/usr/doc/lua/etc/")
#*
rm -Rv /tmp/lua/
mkdir  /tmp/lua/
cd /usr/doc/lua/etc/
cp -iv min.c trace.c /tmp/lua/

cd /tmp/lua/
gcc -llua -o min min.c
echo 'print(322)' | ./min

gcc -g -llua -llualib -lm -o trace trace.c
#*
cd /usr/doc/lua/examples/
cat /usr/doc/lua/examples/hello.lua | /tmp/lua/trace
cat /usr/doc/lua/examples/factorial.lua | /tmp/lua/trace

# Tracing fib takes some time and generates a dump with 29MB.
#cat /usr/doc/lua/examples/fib.lua | /tmp/lua/trace >& /tmp/ofib

#*
set env LD_LIBRARY_PATH /usr/src/lua-4.0/lib:
set args /usr/doc/lua/examples/fib.lua
br main
run
# (gdbk-gdb t "/tmp/lua/trace")

#*





#####
#
# the lua mailing list
# 2000dec14
#
#####

# «lua-list»  (to ".lua-list")
# Oops, better to use this: (find-es "lua5" "mailing-list-archive")
lynx http://www.lua.org/ftp/
#*
psne http://www.tecgraf.puc-rio.br/lua/ftp/lua-l-archive.gz
#*
zcat $S/http/www.tecgraf.puc-rio.br/lua/ftp/lua-l-archive.gz \
  > /tmp/lua-l-archive
# (find-fline "/tmp/lua-l-archive")
#*
cd /tmp/
mutt -R -f lua-l-archive
#*

# (find-shttpw3 "www.tecgraf.puc-rio.br/lua/lua-l.html")
echo | sendemail -s 'subscribe' lua-l-request@tecgraf.puc-rio.br





#####
#
# bitops and regexps library
# 2001jan03
#
#####

# «bitops_and_regexps»  (to ".bitops_and_regexps")
# (find-fline "/tmp/lua-l-archive" "DYADIC(intXor")
# (find-fline "/tmp/lua-l-archive" "merge of his and my efforts")
# (find-fline "/tmp/lua-l-archive" "first cut of a POSIX regexp library")

# I wrote this block while I was just examining the patch; after I
# learned how to use it I applied the patch to my deb of lua-4.0.

#*
rm -Rv /tmp/lualibs/
mkdir  /tmp/lualibs/
cd     /tmp/lualibs/
unzip $S/http/www.cl.cam.ac.uk/users/rrt1001/lualibs.zip
mv README README.rtt
#*
cd     /tmp/lualibs/
for i in $(find * -type f); do
  laf /usr/src/lua-4.0/$i $i
  diff -u /usr/src/lua-4.0/$i $i
done
#*





#####
#
# About setting tags for tables
# 2001feb02
#
#####

# «tags_of_tables»  (to ".tags_of_tables")
# From a message by Jean-Claude Wippler in lua-l, 2001feb02:
# http://lua-users.org/lists/lua-l/2001-02/msg00034.html
#*
lua -e '
  local vtable = {
    _tag_ = newtag(),
    times = function (self,i) return self.v * i end,
    hello = function () return "hi!" end,
  }

  settagmethod(vtable._tag_, "index",
    function (x,i) return %vtable[i] end)

  t = {}
  settag(t, vtable._tag_)

  t.v = 111

  assert(t.v == 111)
  assert(t.none == nil)
  assert(t:times(222) == 24642)
  assert(t.hello() == "hi!")
'
#*




#####
#
# tag methods
# 2001sep29
#
#####

# «tags»  (to ".tags")
# (find-luanode "Tag Methods")
# (find-luanode "settag")
# (find-luanode "settagmethod")
# (find-luanode "Types and Tags")
# (find-luafile "")
# (find-luafile "src/lib/lbaselib.c" "\"tag\"")
# (find-luatag "LUA_TNIL")
# (find-luatag "luaT_tag")
#*
mylua -e '
  p(tag({1, 2}))
  p(tag("asd"))
  p(tag(123))
  p(tag(nil))
'
#*
mylua -e '
  LUA_TTABLE_EDRX = newtag();       p(LUA_TTABLE_EDRX)
  mytable = {1, 2, 3, 4};           p(tag(mytable))
  settag(mytable, LUA_TTABLE_EDRX); p(tag(mytable))
  function edrx_gettable(table, index)
    print("!!", index); -- p(table); px(index); return 99
  end
  oldmethod = settagmethod(LUA_TTABLE_EDRX,"gettable",edrx_gettable)
  p(oldmethod)
  p(mytable[23])
'
#*
mylua -e '
  TTABLE = tag({})
  TVECTOR = newtag()
  mytable = {1, 2, 3, 4}
  settag(mytable, TVECTOR)
  settagmethod(TVECTOR, "gettable", function(t, i)
      settag(t, TTABLE)
      local result
      if i<=0 and i>=getn(t) then
        result = t[i-getn(t)]
      else
        result = t[i]
      end
      settag(t, TVECTOR)
      return result
    end)
  p(mytable[4])
  p(mytable[0])
  p(mytable[-1])
'
#*

# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/examples/")
# (find-fline "/usr/doc/lua/examples/trace-globals.lua" "settagmethod")

# (find-luanode "Tag Method gettable")



#####
#
# Some weirdnesses
# 2001feb09
#
#####

# «weirdnesses»  (to ".weirdnesses")
# (find-fline "~/tmp/lua-manual.txt")
# Explanation: a statement cannot begin with a parentheses.
# (This is for "\n"->";" reasons).
#*
luae '
  action = {}
  action["*"] = function () print("Hello") end
  action["*"]()
  (action["*"])()
'

#*
cat > /tmp/weird.lua <<'---'
  action = {}
  action["*"] = function () print("Hello") end
  action["*"]()
  (action["*"])()
  action["*"]()()
---
luac -o - -l /tmp/weird.lua |& tee ~/o
# (find-fline "~/o")

#*
set env LD_LIBRARY_PATH /usr/src/lua-4.0/lib:
set args -o - -l /tmp/weird.lua
# br main
br luaY_parser
run
# (gdbk-gdb t "/usr/src/lua-4.0/bin/luac")

#*

# (find-luafile "")
# (find-luafile "src/lparser.c")





#####
#
# Do locals shadows globals during calls?
# 2001feb14
#
#####

# «scope»  (to ".scope")
#*
# (find-elnode "Scope" "will be seen in `user'")
luae '
  function printa() print(a) end
  a = 22; printa()
  do local a = 33; print(a); printa() end
  printa()
'	      ;# -> 22  33  22  22
# No: the answer is 22, 33, 22, 22; with indefinite scoping it
# would have been   22, 33, 33, 22.
#*




#####
#
# argv
# 2001mar31
#
#####

# «argv»  (to ".argv")
# (find-luafile "src/lua/lua.c" "static void print_message (void) {")
# (find-luafile "src/lua/lua.c" "static void getargs")
# (find-luafile "src/lua/lua.c" "\"arg\"")
# (find-luafile "src/lua/README")
#*
# These don't work:
#luae 'p(arg)' -- foo bar 99
#luae 'px(arg)' -f /dev/null foo bar 99
echo 'px(arg)' | luae '' -f - foo bar 99

# These do:
echo 'px(arg)' | mylua -f /dev/stdin foo bar 99
echo 'px(arg[0], arg)' > /tmp/m.lua
mylua -f /tmp/m.lua foo bar 99

#*
# Problem: the (z)shell function "luaef" below
# drops the null parameters...
# (find-luanode "getinfo")

print -l foo '' bar ''
function luaef () {
  echo $1 > /tmp/tmp.lua
  print -l $*[2,-1]
  mylua -f /tmp/tmp.lua $*[2,-1]
}
luaef 'p(arg)' '' foo '' bar -- a
luaef 'p(getinfo(0))'
luaef 'p(getinfo(1))'

#*
echo 'p(arg)' > /tmp/tmp.lua
mylua -f /tmp/tmp.lua '' foo '' bar 99

#*




#####
#
# First programs
# 2000dec19
#
#####

# «first_progs»  (to ".first_progs")
# (find-fline "~/LUA/inc.lua")
#*
function luae () { lua -e 'dofile(getenv("HOME").."/LUA/inc.lua"); '$* }
function luae () { lua ~/LUA/inc.lua -e $* }
luae 'p(22)'
#*
function luai () { lua ~/LUA/inc.lua -i $* }
#*
# (find-w3 "/usr/doc/lua/manual.html#tableconstructor")
# (find-w3 "/usr/doc/lua/manual.html#predefined")

cat > $EEG <<'%%%'
p(22)
p()
p(5,6)
--
p({5, 6})
p{5, 6}
--
p{}
p{foo=2, bar=4}
p{["foo"]=2, bar=4}
a={}; a["foo"]=2; a["bar"]=4; p(a);
p{foo=2, bar=4; 3, 22}
p{3, 22; foo=2, bar=4}
p{[2]=22, [1]=3, foo=2, bar=4}
p{[2]=22, [1]=3, foo=2, bar=4}
exit()
%%%
eeg lua ~/LUA/inc.lua -i
#*

lua -e '
function fe(t)  foreach(t, function(i, v) print(i, v); end);  print(); end
function fei(t) foreachi(t, function(i, v) print(i, v); end); print(); end
a={[4]=44, [1]=11, [1.5]=15, foo="bar", [3]=33, [2]=22}
fe(a)
print(a.n, a.gaa, a[33], getn(a))
print()
fei(a)
'
#*

lua -e ' function foo(); print("hi"); end'
lua -e ' function foo() print("hi"); end'
lua -e ' function foo() print("hi") end'
lua -e ' function foo(); print("hi") end'

# (find-luafile "src/lib/lstrlib.c" "str_find")

lua ~/LUA/inc.lua -e '
  yn, _, first, rest, e, f =
    strfind("binary-arch:  kernel_image  kernel_headers",
            "^[%s]*([^%s]+)[%s]*(.*)")
  print(yn, _, first, rest, e, f)
'

#*
lua ~/LUA/inc.lua -e '
function split(s)
  local a={}; local found, first
  while 1 do
    found, _, first, s = strfind(s, "^[%s]*([^%s]+)[%s]*(.*)")
    if not found then return a; end
    tinsert(a, first)
  end
end
p(split("foo bar plic"))
'
#*
lua ~/LUA/inc.lua -e '
  A = {"a1", "a2", "a3"}
  B = {"b1", "b2", "b3"}
  C = {"c1", "c2", "c3"}
  for _, a in A do
    for _, b in B do
      for _, c in C do
        print(a, b, c)
      end
    end
  end
'

#*
luae 'px(split1("indio bororo", "o"))'
luae 'px(split1("indio bororo"))'
(echo foo; echo bar) | luae 'px(read(), read(), read())'
#*
# (find-node "(lua)For Statement")
luae 'for i=0,5 do print(i) end'
luae 'for i=0,5,2 do print(i) end'
luae 'for i=0,6,2 do print(i) end'
#*
# (find-node "(lua)strsub")
luae 'print(strsub("abcdef", 2, 4))	-- ->"bcd"'
luae 'print(strbyte("012"))		-- ->48'
luae 'print(strbyte("012", 1))		-- ->48'
luae 'print(strbyte("012", 2))		-- ->49'
#*






#####
#
# topological sort
# 2000dec26
#
#####

# «toposort»  (to ".toposort")
# (find-es "kernel" "make-kpkg_rules")
# (find-fline "~/LUA/")
# (find-fline "~/LUA/toposort.lua")

#*
(cat <<'---'
all build: configure stamp-build
buildpackage: stamp-buildpackage
stamp-buildpackage: configure
debian: stamp-debian
configure: debian stamp-configure
stamp-configure: debian .config
binary: binary-indep binary-arch
binary-indep: kernel_source kernel_doc
binary-arch:  kernel_image  kernel_headers
kernel-source kernel_source: stamp-source
stamp-source: debian
libc-kheaders libc_kheaders: stamp-libc-kheaders
stamp-libc-kheaders: configure
kernel-headers kernel_headers: stamp-headers
stamp-headers: configure
kernel-doc kernel_doc: stamp-doc
stamp-doc: debian
kernel-image kernel_image: stamp-image
stamp-image: configure build kernel-image-deb
modules-image modules_image: configure
modules: configure
modules-config modules_config: configure
modules-clean modules_clean: configure
.PHONY: binary binary-arch binary-indep clean modules modules_image
---
) | \
  lua ~/LUA/toposort.lua
#*




#####
#
# apt-move.lua
# 2000dec26
#
#####

# «apt-move.lua»  (to ".apt-move.lua")
# (find-fline "~/tmp/lua-manual.txt" "\n6.4 - I/O Facilities")
# (find-angg ".zshrc" "debbasename")
#*
# «apt-move.lua_prep»  (to ".apt-move.lua_prep")
# (find-angg ".zshrc" "installeddebs")
installeddebs | sort \
  > /tmp/idebs

cat $SDEBIAN/dists/potato/main/binary-i386/Packages     | pfilenames \
  > /tmp/pdebs-main
cat $SDEBIAN/dists/potato/contrib/binary-i386/Packages  | pfilenames \
  > /tmp/pdebs-contrib
cat $SDEBIAN/dists/potato/non-free/binary-i386/Packages | pfilenames \
  > /tmp/pdebs-non-free

cat /tmp/pdebs-{main,contrib,non-free} > /tmp/pdebs

find /hdd6/debian/		-name '*.deb' | sort > /tmp/fdebs-CB
find $SDEBIAN/dists/potato	-name '*.deb' | sort > /tmp/fdebs-S
find /var/cache/apt/archives/	-name '*.deb' | sort > /tmp/fdebs-c

cat /tmp/fdebs-{CB,S,c} > /tmp/fdebs

# (find-fline "/tmp/")
# (find-fline "/tmp/idebs")
# (find-fline "/tmp/pdebs")
# (find-fline "/tmp/fdebs")
# (find-fline "$SDEBIAN/")
# (find-fline "/var/state/apt/lists/")

#*
# «apt-move.lua_P_apply»  (to ".apt-move.lua_P_apply")
# (find-angg "LUA/apt-move.lua" "P_apply")
# The preparation stage that produces the /tmp/?debs files is above.
lua ~/LUA/apt-move.lua -e '
  Installed ("/tmp/idebs")
  Pfilenames("/tmp/pdebs")
  Found     ("/tmp/fdebs")

  P_apply("RV&OP", "s,p,op", function (s, p, op)
      write(format("mv -iv %s %s\n", p, op))
    end)
  print()
  P_apply("RV&~OP", "s,p", function (s, p)
      write(format("# No official path: %s %s\n", s, p))
    end)
  print()
  P_apply("WV", "s,v", function (s, v)
      write(format("# No deb of the right version: %s_%s\n", s, v))
    end)
  print()
  P_apply("ND", "s,v", function (s, v)
      write(format("# No deb at all: %s_%s\n", s, v))
    end)

' |& tee ~/o
# (find-fline "~/o")
# (progn (find-fline "~/o") (wrap 0))
#*





#####
#
# An obsolete way of using apt-move.lua
# 2001jan10
#
#####

# «apt-move.lua_old»  (to ".apt-move.lua_old")
# (find-fline "~/LUA/apt-move.lua")
#*
lua ~/LUA/apt-move.lua -e '
  Installed ("/tmp/idebs")
  Pfilenames("/tmp/pdebs")
  Found     ("/tmp/fdebs")
  --
  function for_each_status_stem(status, f)
    for_each_stem(function (stem, istem)
        if istem.methods[1] == %status then
          %f(stem, istem)
        end
      end)
  end
function for_each_nodeb_stem(f) for_each_status_stem("NODEB", f) end
function for_each_wvdeb_stem(f) for_each_status_stem("WRONGVERSIONDEB", f) end
function for_each_rvdeb_stem(f) for_each_status_stem("RIGHTVERSIONDEB", f) end
  --
  for_each_rvdeb_stem(function (stem, istem) px("rvdeb:", stem) end)
  print("---")
  for_each_wvdeb_stem(function (stem, istem) px("wvdeb:", stem) end)
  print("---")
  for_each_nodeb_stem(function (stem, istem) px("nodeb:", stem) end)
  print("---")
  p(installed)
' |& tee ~/o
#*
# (find-fline "~/o")
# (find-fline "~/tmp/lua-manual.txt" "\n6.2 - String Manipulation")
# (find-fline "~/LUA/inc.lua")
# (find-fline "~/LUA/apt-move.lua")





#####
#
# Using Lua to compare versions of .debs
# 2001feb10
#
#####

# «debversions_lua»  (to ".debversions_lua")
# (find-es "dpkg" "dpkg:debversions")

(defun find-pmt (pos-spec)
  (find-fline "/usr/doc/packaging-manual/packaging.text.gz" pos-spec))

# (find-pmt "5. Version numbering")
# (find-pmt "<debian-revision>\n")
# (find-pmt "compared lexically")
# (find-pmt "--compare-versions")
# (eeman "dpkg" "--compare-versions")

#*
# (find-angg "LUA/inc.lua" "split1")
# (find-fline "~/tmp/lua-manual.txt" "strsub")
# (find-fline "~/tmp/lua-manual.txt" "strfind")
luae '
  while 1 do
    li = read()
    if not li then break end
    li = before_first_delim(li, " -> ")
    li = after_last_delim(li, " ")
    px(li)
  end
'
#*
luae '
  px(2,3,4)
  px(split_at_first("foo->bar->quux", "->"))
  px(split_at_first("foo_bar_quux", ":", 1, 2, 3))
  px(split_at_last("foo->bar->quux", "->"))
  px(split_at_last("foo:bar:::quux", ":"))
  px(split_at_last("foo_bar_quux", ":"))
'
#*
luae '
  function glue_ab(a, b, c) return a..b, c end
  function glue_bc(a, b, c) return a, b..c end

  function size_path_stem_ver_arch_deb_link(str)
    local size, path, stem, ul1, ver, ul2, arch, deb, link
    str, link = glue_bc(split_at_first(str, " -> ", str, "", ""))
    str,  deb = glue_bc(split_at_last(str, ".deb", str, "", ""))
    size, str = glue_ab(split_at_last(str, " ", "", "", str))
    path, str = glue_ab(split_at_last(str, "/", "", "", str))
    stem, ul1, str = split_at_first(str, "_", str, "", "")
    ver, ul2, arch = split_at_last(str, "_", str, "", "")
    px(size, path, stem, ul1, ver, ul2, arch, deb, link)
  end

  f = size_path_stem_ver_arch_deb_link
  f("  999  /var/cache/apt/archives/gcc_1%3a2.95.2-12_i386.deb -> foo")
  f("/var/cache/apt/archives/ddd_1.0.deb")
'
#*

# (find-fline "~/TH/unclassified2.th" "2001feb05 Lua:")
# (find-shttpfile "www.tecgraf.puc-rio.br/")





#####
#
# lua (before I debianized it)
# 2000dec14
#
#####

# «lua_before_deb»  (to ".lua_before_deb")
#*
rm -Rv /usr/src/lua/
cd /usr/src/
tar -xvzf $S/http/www.tecgraf.puc-rio.br/lua/ftp/lua.tar.gz
cd /usr/src/lua/
# make	|& tee om
make all so sobin	|& tee om
mkdir inst
# make so		|& tee omso
# make sobin	|& tee omsobin
make install INSTALL_ROOT=/usr/src/lua/inst	|& tee omi
(cd inst; find * > ../.instfiles)
#*

# (code-c-d "lua" "/usr/src/lua/")
# (find-luafile "")
# (find-luafile "om")
# (find-luafile "test/")
# (find-luafile "test/examples/ps/")
# (find-luafile "test/examples/www/")
# (find-luafile "doc/")
# (find-luafile "etc/")
# (find-luaw3 "doc/")





#####
#
# lua-mode for emacs
# 2001feb15
#
#####

# «lua.el»  (to ".lua.el")
# (find-fline "~/LUA/lua.el")

# (find-elnode "Index")
# (find-elnode "Derived Modes")
# (find-elnode "Font Lock Mode")
# (find-efile "font-lock.el")

# (find-elnode "Merging Faces")
# (find-elnode "Glyphs")
# (find-etag "eval-last-sexp")
# (find-elnode "Overlay Properties" "overlay-get")

# (find-angg "eev-extras.el" "glyphs_du_jour")
# (find-angg ".emacs" "faces")

# «lua-mode.el»  (to ".lua-mode.el")
# 2007feb05
# (find-fline "~/elisp/lua-mode.el")




#####
#
# ldb (Not working! Seems that I can't find the right Lua version)
# 2001feb10
#
#####

# «ldb»  (to ".ldb")
# (find-shttpw3 "www.tecgraf.puc-rio.br/~tomas/ldb/")
# (find-shttpw3 "www.tecgraf.puc-rio.br/~tomas/ldb/index.html#installation")
#*
rm -Rv /usr/src/ldb/
mkdir  /usr/src/ldb/
cd     /usr/src/ldb/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-3.2.tar.gz
#tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-3.0.tar.gz
mv -v lua/* .
rmdir lua/

lynx -dump $S/http/www.tecgraf.puc-rio.br/~tomas/ldb/index.html > index.txt
# (find-fline "/usr/src/ldb/index.txt" "Installation")
#
# 1. copy the debugger files (ldblib.c and ldblib.h) to ./lua/src/lua
#    (where lua.c remains)
# 2. edit Makefile to add ldblib.o and ldblib.c at lines beggining with
#    OBJS= and SRCS= respectively
# 3. edit lua.c adding:
#       + #include "ldblib.h"
#         just after the last include line (#include "lualib.h")
#       + ldblib_open();
#         just after the last open library function invocation
#         (lua_mathlibopen();)

tar -xvzf $S/http/www.tecgraf.puc-rio.br/~tomas/ldb/ldb.tar.gz
for i in ldblib.c ldblib.h; do
  mv -v $i $i.orig
  grep -v ldb.nw < $i.orig > $i
done

# (find-fline "/usr/src/ldb/src/lib/")
# (find-fline "/usr/src/ldb/src/lib/linit.c")
# (find-fline "/usr/src/ldb/src/lib/Makefile")
# (find-fline "/usr/src/ldb/src/lib/ldblib.c")
# (find-fline "/usr/src/ldb/src/lua/")

#*
cp -v ldblib.c ldblib.h src/lib/
patch -p0 src/lib/Makefile <<'%%%'
10,11c10,11
< OBJS= linit.o ldblib.o liolib.o lmathlib.o lstrlib.o
< SRCS= linit.c ldblib.c liolib.c lmathlib.c lstrlib.c
---
> OBJS= linit.o ldblib.o liolib.o lmathlib.o lstrlib.o   ldblib.o
> SRCS= linit.c ldblib.c liolib.c lmathlib.c lstrlib.c   lbdlib.c
%%%
patch -p0 src/lib/linit.c <<'%%%'
8a9
> #include "ldblib.h"		/* ldb */
15a17
>   ldblib_open();		/* ldb */
%%%

#*
#cp -v ldblib.c ldblib.h src/lua/
#patch -p0 src/lua/Makefile <<'%%%'
#9,10c9,10
#< OBJS= lua.o
#< SRCS= lua.c
#---
#> OBJS= lua.o ldblib.o
#> SRCS= lua.c ldblib.c
#%%%
#patch -p0 src/lua/lua.c <<'%%%'
#15a16
#> #include "ldblib.h"		/* ldb */
#128a130
#>   ldblib_open();		/* ldb */
#%%%

make |& tee om

# (find-fline "/usr/src/ldb/src/lua/")
# (find-fline "/usr/src/ldb/src/lua/Makefile")
# (find-fline "/usr/src/ldb/src/lua/lua.c")

# (find-fline "/usr/src/ldb/")
# (find-fline "/usr/src/ldb/om")
# (find-fline "~/tmp/lua-manual.txt" "7.3 - Hooks")

#*







#####
#
# jcw's lux
# 2001feb25
#
#####

# «lux»  (to ".lux")
# (code-c-d "lux" "/usr/src/lux-0.1/")
#*
rm -Rv /usr/src/lux-0.1/
cd /usr/src/
tar -xvzf $S/http/www.equi4.com/lux/lux-0.1.tar.gz
cd /usr/src/lux-0.1/

gcc -c -o luxsys.o luxsys.c
gcc -c -o lux.o    lux.c
gcc -o lux -ldl -lm -lz lux.o luxsys.o
#*

cd /usr/src/lux-0.1/examples/
../lux bin2c.lua
../lux cols.lua
# Slow:
#../lux md5calc.lua
../lux phf.lua

../lux base64.lua
../lux lsd.lua
../lux preload.lua
../lux run.lua
../lux tea.lua
../lux tester.lua
../lux util.lua
../lux vt.lua
../lux wiki.lua

../lux dhl.lua
../lux zip.lua

# pydemo.py
# tkdemo.tcl

#*

# (find-luxfile "")
# (find-luxfile "luxsys.c" "dynlib[] =")
# (find-luxfile "examples/")

# (find-efile "progmodes/hideif.el")




#####
#
# yield
# 2001feb25
#
#####

# «yield»  (to ".yield")
# (find-shttpw3 "www.tecgraf.puc-rio.br/~tomas/yield/")
# (find-fline "/tmp/yield.lua")
# (find-fline "/tmp/yield.lua" "Y.cmd_line")
# (find-fline "/tmp/yield.lua" "predefined_shortcuts")
#*
cd /tmp/
#cp -iv $S/http/www.tecgraf.puc-rio.br/~tomas/yield/yield.lua ~/LUA/
cat > test.lua <<'---'
Y.open()
Y.cmd_line()
print ("hello")
print ("hello")
print ("bye")
---
cat > $EEG <<'---'
'n
'n
'n
---
eeg lua ~/LUA/yield.lua test.lua

#*
# (find-fline "/tmp/yield.lua")





#####
#
# dednat.lua
# 2001mar12
#
#####

# «dednat»  (to ".dednat")
# (find-angg "LATEX/dednat.icn")
# (find-angg "LUA/dednat.lua")
#*
cd ~/LUA/
dednat.lua |& tee o
#gnuclient o
#*




#####
#
# cgilua
# 2001may29
#
#####

# «cgilua»  (to ".cgilua")
# (to "lua_4.0-0.2")
#*
rm -Rv /usr/src/cgilua/
cd /usr/src/
tar -xvzf $S/http/www.inf.puc-rio.br/~ana/cgilua-4.0.1b.tgz
cd /usr/src/cgilua/

make	|& tee om
#*
# (code-c-d "cgilua" "/usr/src/cgilua/")
# (find-cgiluafile "")
# (find-cgiluafile "loadlib/")
# (find-cgiluafile "loadlib/loadlib.c")




#####
#
# luasql
# 2001jun12
#
#####

# «luasql»  (to ".luasql")
#*
rm -Rv /usr/src/luasql/
cd /usr/src/
tar -xvzf $S/http/www.tecgraf.puc-rio.br/luasql/luasql.tar.gz
cd /usr/src/luasql/
#*
# (find-w3 "/usr/src/luasql/manual.html")
#*
cd /usr/src/luasql/
gcc -g -Wall -shared -I/usr/include/postgresql -lpq -o ls_pg.so ls_pg.c
#*
# (to "loadlib-gdb")
cd /usr/src/luasql/
cat > pgtest.lua <<'---'
  loadlib("/usr/src/luasql/ls_pg.so", "lua_sqllibopen")
  ENV, err = SQLOpen();			assert(ENV, err)
  CON, err = ENV:Connect("foo");	assert(CON, err)
  res, err = CON:Execute"DROP TABLE friends"
  res, err = CON:Execute[[
    CREATE TABLE friends(
      friendid int,
      friendname  varchar(64),
      friendage int);
  ]];					assert(res, err)
  -- add a few elements
  friends = {
    {ID = 1, Name = "John", Age = 24},
    {ID = 2, Name = "Mary", Age = 21},
    {ID = 5, Name = "Anaconda", Age = 70},
    {ID = 3, Name = "Rita", Age = 28},
    {ID = 4, Name = "Stephan", Age = 23}
  }
  for i, f in friends do
    res, err = CON:Execute(format([[
      INSERT INTO friends(friendid, friendname, friendage)
      VALUES(%d, '%s', %d)]], f.ID, f.Name, f.Age)
    )
    assert(res, err)
  end
  -- retrieve a cursor for all friends, sorted by age
  CUR, err = CON:Execute[[
          SELECT friendname, friendage FROM friends ORDER BY friendage
  ]]
  assert(CUR, err)
  -- rows will be indexed by column name
  res, err = CUR:SetOptions{name_columns = "true"}
  assert(res, err)
  -- print all rows of the result
  while 1 do
          row = CUR:Fetch()
          if not row then break end
          print(format("Name: %s, Age: %d", row.friendname, row.friendage))
  end
  -- close everything
  CUR:Close()
  CON:Close()
  ENV:Close()
---
LD_LIBRARY_PATH=/usr/src/lua-4.0/lib \
  /usr/src/lua-4.0/bin/lua pgtest.lua
#*
# (gdbk-gdb t "/usr/src/lua-4.0/bin/lua")
set args /usr/src/luasql/pgtest.lua
set env LD_LIBRARY_PATH /usr/src/lua-4.0/lib
br main
run
info share
br loadlib
#*

# (find-status "postgresql-dev")
# (find-vldifile "postgresql-dev.list")
# (find-fline "/usr/doc/postgresql-dev/")





#####
#
# pio_fontx as a lua library (in a .so)
# 2001jul29
#
#####

# «pio_fontx»  (to ".pio_fontx")
# (find-angg "LUA/pio_fontx.c")
# (find-angg "LUA/vtutil.lua")
#*
cd /usr/src/lua-4.0/
find * | grep '\.[ch]$' | grep -v debian/tmp-lua > .files.ch
etags $(<.files.ch)

#*
-- (hexl-find-file "~/MTA/math1.8.psf")
-- (find-fline "/usr/doc/console-tools/file-formats/psf" "psf_header =")
-- (find-k22file "drivers/char/vt.c" "PIO_FONTX")
-- (eeman "4 console_ioctl" "PIO_FONTX")
-- (eeman "2 ioctl")
-- (find-fline "~/MTA/pio_fontx.c")

-- (find-es "lua" "lua_4.0-0.2:dltest2")
-- (find-luafile "src/lib/lbitlib.c")
-- (find-luafile "include/lauxlib.h")
-- (find-luafile "src/lib/")
-- (find-luafile "src/lib/lstrlib.c")

#*
# (find-node "(lua)Defining C Functions" "if (!lua_isnumber(L, i))")
cd /tmp/
cat > lua_pio_fontx.c <<'---'
#include <dllua.h>
#include <sys/ioctl.h>
#include <linux/kd.h>

#include <unistd.h>
/* #include <errno.h> */
/* #include <fcntl.h> */
/* #include <stdio.h> */

static int lua_pio_fontx(lua_State* L) {
  struct consolefontdesc cfd;
  int len, rslt;
  cfd.charcount = luaL_check_int(L, 1);
  cfd.charheight = luaL_check_int(L, 2);
  cfd.chardata = luaL_check_lstr(L, 3, &len);
  rslt = ioctl(STDIN_FILENO, PIO_FONTX, &cfd);
  lua_pushnumber(L, rslt);
  return 1;
}

void pio_fontx_init(lua_State *L) {
  lua_register(L, "pio_fontx", lua_pio_fontx);
}
---
gcc -g -Wall -shared -o lua_pio_fontx.so lua_pio_fontx.c

#*
luae '
  psf = readfile(getenv("HOME").."/MTA/math1.8.psf")
  magic1   = strbyte(psf, 1)		-- 0x36
  magic2   = strbyte(psf, 2)		-- 0x04
  filemode = strbyte(psf, 3)		-- 0 means 256 chars, no unicode
  height   = strbyte(psf, 4)		-- in scanlines; typically 8, 14 or 16
  print("0x36 0x04 filemode height", magic1, magic2, filemode, height)
  bigstr = strsub(psf, 5)
  font = {nchars = 256}
  for nchar=0,255 do
    font[nchar] = strsub(bigstr, nchar*height+1, (nchar+1)*height)
  end
  print(strlen(font[0]))
  print(strlen(font[255]))
  --
  bigstr = ""
  zeroes = strrep("\000", 32)
  for nchar=0,255 do
    bigstr = bigstr .. strsub(font[nchar]..zeroes, 1, 32)
  end
  print(strlen(bigstr))
  --
  libhandle, err = loadlib("/tmp/lua_pio_fontx.so")
  print(libhandle, err)
  callfromlib(libhandle, "pio_fontx_init")
  pio_fontx(256, height, bigstr)
'

#*




#####
#
# lua_4.0-0.3
# 2001sep07
#
#####

# «lua_4.0-0.3»  (to ".lua_4.0-0.3")
# (find-fline "$S/http/www.cl.cam.ac.uk/users/rrt1001/lualibs.zip")
# (code-c-d "lua" "~/usrc/lua-4.0/")
# (find-luafile "debian/packages")
# (find-fline "~/lua-4.0/debian/rules")
# ftp://ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
#*
rm -Rv ~/usrc/lua_4.0*

rm -Rv ~/usrc/lua-4.0.orig/
mkdir  ~/usrc/lua-4.0.orig/
cd     ~/usrc/lua-4.0.orig/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
mv -v lua/* .
rmdir lua/

rm -Rv ~/usrc/lua-4.0/
mkdir  ~/usrc/lua-4.0/
cd     ~/usrc/lua-4.0/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
mv -v lua/* .
rmdir lua/

# (find-fline "~/lua-4.0/")
mkdir debian/ src/libdllua/

(cd ~/lua-4.0/; for i in $(<_NEWFILES); do
  cp --parents -iav $i ~/usrc/lua-4.0/; done)
(cd ~/lua-4.0/; for i in $(<_PATCHES); do patch -p0 ~/usrc/lua-4.0/$i < $i.patch; done)

# Use my version of lrexlib instead of plain rtt's:
# (find-angg "lua-4.0/src/libdllua/lrexlib-new.c")
(cd src/libdllua/; mv -v lrexlib.c lrexlib-orig.c; mv -v lrexlib-new.c lrexlib.c)

#*
cd ~/usrc/
rm -fv lua_4.0{-0.3{.diff.gz,.dsc,{_i386,_source}.changes,_i386.deb},.orig.tar.gz}

cd ~/lua-4.0/debian/
cp -v control dirs docs rules ~/usrc/lua-4.0/debian/

# (find-fline "/usr/bin/dpkg-buildpackage")
cd ~/usrc/lua-4.0/
# dpkg-buildpackage -us -uc
dpkg-buildpackage -us -uc -S

#*
cd ~/tmp/ && rm -fv lua_4.0.orig.tar.gz lua_4.0-0.3.diff.gz lua_4.0-0.3.dsc
cd ~/usrc/
cp -iv lua_4.0.orig.tar.gz lua_4.0-0.3.diff.gz lua_4.0-0.3.dsc ~/tmp/
cd
./run-prep lua

#*
rm -Rv /tmp/zedrx
mkdir /tmp/zedrx
cd /tmp/zedrx
tar -xvzf ~/TH/L/edrx.tgz
mkdir tmp
cd ~/usrc/
cp -iv lua_4.0.orig.tar.gz lua_4.0-0.3.diff.gz lua_4.0-0.3.dsc /tmp/zedrx/tmp/
cd /tmp/zedrx

#*
rm -Rv ~/usrc/lua-4.0/
rm -Rv ~/usrc/lua-4.0.orig/
cd ~/usrc/

cd ~/usrc/lua-4.0/
debian/rules binary	|& tee odrb

#*
cd ~/usrc/lua-4.0/
mv -v debian/ debian-yada/
dh_make

cd ~/usrc/lua-4.0/debian/
rm -v cron.d.ex emacsen-install.ex emacsen-remove.ex emacsen-startup.ex
rm -v init.d.ex manpage.1.ex manpage.sgml.ex menu.ex postinst.ex postrm.ex
rm -v preinst.ex prerm.ex watch.ex   conffiles.ex ex.package.doc-base

#*
cd ~/usrc/lua-4.0/debian/
cp -v control dirs docs rules ~/lua-4.0/debian/

#*
cd ~/lua-4.0/debian/
cp -v control dirs docs rules ~/usrc/lua-4.0/debian/

#*
# (find-luafile "debian/")
# (find-luafile "debian-yada/packages")

# (find-status "lua")
# (find-vldifile "lua.list")
# (find-fline "/usr/doc/lua/")

#*
cd     ~/usrc/lua-4.0/
yada yada
yada rebuild rules

# (find-fline "~/lua-4.0/debian/changelog")
#debian/rules binary	|& tee odrb
#cd ~/usrc/lua-4.0/	&& etags $(grep '\.[ch]' .files)

#:*
cat > $EEG <<'---'
TestPasswd
TestPasswd
---
cd ~/usrc/lua-4.0/
sh -x /usr/bin/dpkg-buildpackage
# (find-fline "/usr/bin/dpkg-buildpackage")
# (find-fline "/usr/bin/dpkg-checkbuilddeps")
# eeg dpkg-buildpackage		|& tee /tmp/odbp

#*
# find * | grep '\.[ch]$' | grep -v debian/tmp-lua > .files.ch
# etags $(<.files.ch)

cd ~/usrc/lua-4.0/	&& etags $(grep '\.[ch]' .files)

cd ~/usrc/
laf lua_*

#*
dpkg -i ~/usrc/lua_4.0-0.3_i386.deb

#*
# (find-fline "~/lua-4.0/")




#####
#
# lua_4.0-0.3 - old way of building it
# 2001sep07
#
#####

# «lua_4.0-0.3_old»  (to ".lua_4.0-0.3_old")
# (find-fline "$S/http/www.cl.cam.ac.uk/users/rrt1001/lualibs.zip")
#*
rm -Rv /usr/src/lua_4.0*

rm -Rv /usr/src/lua-4.0.orig/
mkdir  /usr/src/lua-4.0.orig/
cd     /usr/src/lua-4.0.orig/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
mv -v lua/* .
rmdir lua/

rm -Rv /usr/src/lua-4.0/
mkdir  /usr/src/lua-4.0/
cd     /usr/src/lua-4.0/
tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/lua/lua-4.0.tar.gz
mv -v lua/* .
rmdir lua/

# (find-fline "~/lua-4.0/")
mkdir debian/ src/libdllua/

(cd ~/lua-4.0/; for i in $(<_NEWFILES); do cp -Piav $i /usr/src/lua-4.0/; done)
(cd ~/lua-4.0/; for i in $(<_PATCHES); do patch -p0 /usr/src/lua-4.0/$i < $i.patch; done)

# Use my version of lrexlib instead of plain rtt's:
# (find-angg "lua-4.0/src/libdllua/lrexlib-new.c")
(cd src/libdllua/; mv -v lrexlib.c lrexlib-orig.c; mv -v lrexlib-new.c lrexlib.c)

yada yada
yada rebuild rules

# (find-fline "~/lua-4.0/debian/changelog")
#debian/rules binary	|& tee odrb
#cd /usr/src/lua-4.0/	&& etags $(grep '\.[ch]' .files)

#:*
cat > $EEG <<'---'
TestPasswd
TestPasswd
---
eeg dpkg-buildpackage		|& tee /tmp/odbp
cd /usr/src/lua-4.0/	&& etags $(grep '\.[ch]' .files)

cd /usr/src/
laf lua_*

#*
dpkg -i /usr/src/lua_4.0-0.3_i386.deb

#*
# (find-fline "~/lua-4.0/")




#####
#
# Making changes to the regexp libs
# 2001oct02
#
#####

# «edrx-regexp-funs»  (to ".edrx-regexp-funs")
# (find-fline "~/lua-4.0/")
# (find-fline "~/lua-4.0/src/libdllua/lrexlib.c")
#*
cd /usr/src/lua-4.0/src/libdllua/
cp -v ~/lua-4.0/src/libdllua/lrexlib-new.c lrexlib.c
touch lrexlib.c
gcc -E lrexlib.c > lrexlib.E

# Use special compilation options, as "alloca(...)" can't be used with "-ansi":
# (find-node "(gcc)C Dialect Options" "`-fno-builtin'" "`-ansi'")
# (find-luafile "src/libdllua/Makefile")
# (find-luafile "config" "-ansi")
# Update: I changed lrexlib-new.c to use malloc instead, so "-ansi" now works.
make WARN="-pedantic -Wall" |& tee om

#*
# (find-fline "~/lua-4.0/README.other")
cd /usr/src/lua-4.0/ && rm -v lib/*
make all so sobin

#*
# LD_LIBRARY_PATH=/usr/src/lua-4.0/lib \
mylua -e '
  re = regex("ba(na)+")
  px(regmatch(re, "fruta banana mosca"))
  px(regmatch(re, "fruta banana mosca", 3))
  px(regmatch(re, "fruto bonono mosco"))
'
#*
# (find-fline "~/lua-4.0/src/libdllua/lrexlib-new.c")
# (find-fline "/usr/src/lua-4.0/src/libdllua/om")
# (find-fline "/usr/src/lua-4.0/src/libdllua/lrexlib.E")
# (find-fline "/usr/include/stdlib.h")
# (find-fline "/usr/include/alloca.h")





#####
#
# uploading lua_4.0-0.3
# 2001sep11
#
#####

#*
cd /usr/src/
anonftp ftp://angg.twu.net/home2/edrx/slow_html/tmp/ \
  'put lua_4.0-0.3.diff.gz' \
  'put lua_4.0-0.3.dsc' \
  'put lua_4.0.orig.tar.gz' \
  quit
#*

# (find-es "page" "apt_repository")
# (find-angg ".zshrc" "apt")
#*
# (eevt-bounded 'once)
cd ~/slow_html/debian/dists/potato/local/source/ && rm -v lua*
cp -v ~/slow_html/tmp/lua* ~/slow_html/debian/dists/potato/local/source/
cd ~/slow_html/debian/
dpkg-scan_p+s dists/potato/local
(rm -Rv ~/public_html/debian/; cd ~/slow_html/; cp -dPpvRl * ~/public_html/)

#*
# (eevt-bounded)
cd ~/slow_html/debian/dists/potato/local/
l binary-i386/Packages source/Sources

#*





#####
#
# dsilver's Debian package of lua-4.1-alpha (too dry)
# 2001?????
#
#####

# «dsilver_lua_deb»  (to ".dsilver_lua_deb")
# (code-c-d "lua41" "/usr/src/lua-4.1-alpha/")
# (find-lua41file "")
# (find-lua41file "HISTORY")
# (find-fline "~/tmp/lua-manual.txt")
#*
pdsc $S/http/ftp.debian.org/debian/pool/main/l/lua/lua_4.1-alpha-1.dsc
cd /usr/src/lua-4.1-alpha/
lynx -dump /usr/doc/lua/manual.html > ~/tmp/lua-manual.txt

#*

# (find-fline "$S/http/ftp.debian.org/debian/pool/main/l/lua/lua_4.1-alpha-1.diff.gz")

# (find-fline "/debian/hdb5/hdb8/MAIL/01oct04.inxmail" "Eduardo Ochs wrote:")
# (find-fline "/debian/hdb5/hdb8/MAIL/01oct04.inxmail" "'lua-dl'")
# (find-fline "/debian/hdb5/hdb8/MAIL/01sep16.inxmail" "http://people.debian.org/~dsilvers/")
# (find-fline "/debian/hdb5/hdb8/MAIL/01sep16.inxmail" "http://apt.digital-scurf.org/")
# (find-fline "/debian/hdb5/hdb8/MAIL/01dec10.popmail" "http://www.place.org/~nop/lua/")




#####
#
# Jay Carlson's Debian package of Lua4.0, with many nice features
# 2002apr16
#
#####

# «jaycarlson_lua_deb»  (to ".jaycarlson_lua_deb")
# (find-shttpw3 "www.place.org/~nop/lua/")
lynx http://www.place.org/~nop/lua/
lynx http://www.place.org/~nop/lua/debian/source/
psne http://www.place.org/~nop/lua/debian/source/lua4.0_4.0.0-1.diff.gz
psne http://www.place.org/~nop/lua/debian/source/lua4.0_4.0.0-1.dsc
psne http://www.place.org/~nop/lua/debian/source/lua4.0_4.0.0.orig.tar.gz

# (find-shttpfile "www.place.org/~nop/lua/debian/source/")

# To do: get a link to the original announcement that Jay ("nop")
# posted on the Lua mailing list - it describes all the features
# nicely and briefly. And it mentions me :-)

# From: "Jay Carlson" <nop@nop.com>
# Subject: Yet another Debian package of Lua and friends
# Date: Mon, 10 Dec 2001 02:08:31 -0500
# (find-fline "/debian/hdb5/hdb8/MAIL/01dec10.popmail" "http://www.place.org/~nop/lua/")





#####
#
# gllua for lua 4.0 (not working)
# 2001sep17
#
#####

# «gllua»  (to ".gllua")
# There were some messages about gllua for lua4.0 around april 6, on
# the mailing list:
# (find-fline "~/01apr16.popmail")
# (find-shttpw3 "www.cis.upenn.edu/~cvogler/lua/tklua.html")

#*
rm -Rv /usr/src/gllua/
cd     /usr/src/
# tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/celes/gllua/gllua.tar.gz
tar -xvzf $S/ftp/ftp.cis.upenn.edu/pub/cvogler/software/gllua.tar.gz
cd     /usr/src/gllua/

make TOLUA=/usr/src/tolua |& tee om

#*
# (code-c-d "gllua" "/usr/src/gllua/")
# (find-glluafile "")
# (find-glluafile "config")





#####
#
# tolua and tklua
# 2001sep17
#
#####

# (code-c-d "tolua" "/usr/src/tolua/")
# (code-c-d "tklua" "/usr/src/tklua/")
#*
# «tolua»  (to ".tolua")
rm -Rv /usr/src/tolua/
cd     /usr/src/
#tar -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/celes/tolua/tolua.tar.gz
tar  -xvzf $S/ftp/ftp.tecgraf.puc-rio.br/pub/celes/tolua/tolua-4.0a.tar.gz
cd     /usr/src/tolua/

patch -b -p0 < /usr/src/tklua/patches/tolua-4.0a-patch

make CC="gcc -g" |& tee om

#:*
# «tklua»  (to ".tklua")
rm -Rv /usr/src/tklua/
cd     /usr/src/
tar -xvzf $S/ftp/ftp.cis.upenn.edu/pub/cvogler/software/tklua.tar.gz
cd     /usr/src/tklua/
mkdir bin

find * -name '*.[ch]' | sort > .files.ch
etags $(<.files.ch)

patch -b -p0 src/bin/Makefile <<'%%%'
13c13,14
< COMMON_LIBS= -ltk8.0 -ltcl8.0 ldl -ltklua -ltolua  -llua -llualib
---
> # COMMON_LIBS= -ltk8.0 -ltcl8.0 ldl -ltklua -ltolua  -llua -llualib
> COMMON_LIBS= -ltk8.3 -ltcl8.3 -ldl -ltklua -ltolua  -llua -llualib
%%%

make CC="gcc -g" TCLINC=/usr/include/tcl8.3 TOLUA=/usr/src/tolua |& tee om

# (find-tkluafile "config")
# (find-tkluafile "om" "libtklua.a")

#:*
# «tolua_tklua_.so»  (to ".tolua_tklua_.so")
# (find-toluafile "om" "libtolua.a")
# (find-tkluafile "om" "libtklua.a")
cd /usr/src/tolua/
gcc -g -Wall -shared -o lib/libtolua.so src/lib/tolua_{lb,rg,tt,tm,gp,eh,bd}.o
cd /usr/src/tklua/
gcc -g -Wall -shared -o lib/libtklua.so src/lib/{tkbnd,tklua}.o

#*
cd /usr/src/tklua/test/
echo '\n\n'; cat test1.lua; ../bin/tklua test1.lua
echo '\n\n'; cat test2.lua; ../bin/tklua test2.lua
echo '\n\n'; cat test3.lua; ../bin/tklua test3.lua
echo '\n\n'; cat test4.lua; ../bin/tklua test4.lua
echo '\n\n'; cat test5.lua; ../bin/tklua test5.lua
echo '\n\n'; cat test6.lua; ../bin/tklua test6.lua
echo '\n\n'; cat test7.lua; ../bin/tklua test7.lua

#*
# «loadtklua»  (to ".loadtklua")
# (find-angg "LUA/inc.lua" "loadtklua")
# (find-angg ".zshrc" "lua")

cd /usr/src/tklua/test/
echo '\n\n'; cat test1.lua; mytklua test1.lua -e "tkmainloop()"
echo '\n\n'; cat test2.lua; mytklua test2.lua -e "tkmainloop()"
echo '\n\n'; cat test3.lua; mytklua test3.lua -e "tkmainloop()"
echo '\n\n'; cat test4.lua; mytklua test4.lua -e "tkmainloop()"
echo '\n\n'; cat test5.lua; mytklua test5.lua -e "tkmainloop()"
echo '\n\n'; cat test6.lua; mytklua test6.lua -e "tkmainloop()"
echo '\n\n'; cat test7.lua; mytklua test7.lua -e "tkmainloop()"

#*




#####
#
# Programming in tklua
# 2001sep17
#
#####

# «tklua_first_progs»  (to ".tklua_first_progs")
# (find-es "tcl" "freehand")
# (find-tkluafile "src/lib/")
# (find-angg "LATEX/diaglib.014" "drag")
# (find-angg "LATEX/diaglib.014" "basic_window")
# (find-angg "LATEX/diaglib.014" "text_objects")
#*
mytklua -e '
  c = tkcanvas{width=500, height=350, relief="sunken", borderwidth=2}
  c:create{"text", 100, 100; text="ha!", fill="brown4"}
  px(c:find{"all"})
  beD = tkbutton{"eval $OnDump"}
  bD  = tkbutton{"$OnDump"}
  bC  = tkbutton{"$OnCreate"}
  bU  = tkbutton{"$OnUpdate"}
  bo  = tkbutton{">stdout"}
  buttons1 = tkframe{side="left"; beD, bD, bC, bU, bo}
  bb = tkbutton{"blackify"}
  ca = tkbutton{"clear auxiliaries"}
  bp = tkbutton{">.eps"}
  bq = tkbutton{"quit"; command=tkexit}
  buttons2 = tkframe{side="left"; bb, ca, bp, bq}
  fr = tkmain{objects={c, buttons1, buttons2}}
  fr:show()
  tkmainloop()
'
#*
# (find-tkluafile "doc/")
# (find-tkluaw3 "doc/index.html")
# (find-tkluaw3 "doc/basic.html")
# (find-tkluaw3 "doc/tkwidgets.html")
# (find-tkluaw3 "doc/using.html")

# (find-tkluaw3 "doc/behind.html")
# (find-tkluaw3 "doc/opengl.html")
# (find-tkluaw3 "doc/tklua.html")




#####
#
# tklua - understanding how it calls Tk (and fixing a "canvas create text")
# 2001sep28
#
#####

#*
cat > /tmp/tktest.lua <<'---'
  loadtklua()
  c = tkcanvas{width=500, height=350, relief="sunken", borderwidth=2}
  local dummy = sin(0)
  c:create{"text", 100, 100; text="ha!", fill="brown4"}
  px(c:find{"all"})
  fr = tkmain{objects={c}}
  fr:show()
  tkmainloop()
---

# LD_LIBRARY_PATH=/usr/src/lua-4.0/lib: ldd /usr/src/lua-4.0/bin/dllua

#*
set env LD_LIBRARY_PATH /usr/src/lua-4.0/lib:
set args /home/root/LUA/inc.lua /tmp/tktest.lua
tbr main
run
tbr math_sin
cont
br tklua_tkEval
cont

br tklua.c:425
cont
p tklua->cmd

# (gdbk-gdb t "/usr/src/lua-4.0/bin/dllua")
#*

# (find-luafile "src/lib/lmathlib.c" "sin")
# (find-luafile "src/libdllua/loadlib.c")
# (find-tkluafile "src/lib/tklua.c")
# (find-tkluafile "src/lib/tklua.c" "lua_register(tklua_S,")





#####
#
# luasocket
# 2001sep27
#
#####

# «luasocket»  (to ".luasocket")
#*
rm -Rv /usr/src/luasocket-1.3b/
cd /usr/src/
tar -xvzf $S/http/www.tecgraf.puc-rio.br/luasocket/luasocket-1.3b.tar.gz
cd /usr/src/luasocket-1.3b/

# (find-luasockfile "makefile")
gcc -g -Wall -shared -D_DEBUG -o luasocket.so luasocket.c

#*
# (find-luasockfile "lua/")
# (find-luasockfile "lua/http.lua" "function http_get(")
# (find-angg ".zshrc" "lua")

cd /usr/src/luasocket-1.3b/lua/
myluasock http.lua -e '
  body, hdrs, line, err = http_get("http://127.0.0.1/")
  px(strlen(body), hdrs, line, err)
'

#*
# (find-node "(screen)Split" "`C-a S'")
# (find-node "(screen)Focus" "`C-a <Tab>'")
# (find-node "(screen)Only" "`C-a Q'")
# (find-luasockfile "test/")
# (find-luasockfile "test/README")

cd /usr/src/luasocket-1.3b/test/
cat > $EEG <<'---'
loadeeglibs k
k C-a S  C-a tab  C-a c  C-a tab
l "myluasock testsrvr.lua"
k C-a tab
l "myluasock testclnt.lua"
k C-d  C-a tab  C-a Q  C-d
---
eeg4 screen zsh
screen -ls

#*




#####
#
# strfind and strsub
# 2001oct11
#
#####

#*
# (find-luanode "strfind")
mylua -e '
  px(strfind("abcde", "bc"))      --> 2   3
  px(strfind("abcde", "bc", 1))   --> 2   3
  px(strfind("abcde", "bc", 2))   --> 2   3
  px(strfind("abcde", "bc", 3))   --> ?nil
  px(strsub("abcde", 2, 3))       --> "bc"
'
#*



#####
#
# error, dostring, protected calls
# 2001oct13
#
#####

# «dostring»  (to ".dostring")
# (find-angg "LUA/inc.lua" "dostring")
#*
# (find-luatag "lua_dostring")
# (find-luafile "src/lib/lbaselib.c" "{\"dostring\", luaB_dostring}")
# (find-luatag "luaB_dostring")
# (find-luatag "lua_pushusertag")
# (find-luanode "dostring")
mylua -e '
  px = print
  px(dostring("return 1, 2"))	--> 1   2
  -- When the code returns nothing dostring returns a userdata with tag 0 and
  -- a null pointer...
  px(dostring("return"))	--> ?userdata
  px(dostring("return nil"))	--> ?nil
  px(dostring("foo()"))		--> [an error, then:]   ?nil   "run-time error"
  px(dostring("return nil, \"run-time error\""))    --> ?nil   "run-time error"
  print("Note that dostring errors don\039t stop the execution...")
'
#*
# (find-luanode "dofile")
# (find-luatag "dofile")
# (find-luatag "exit")
src/lib/liolib.c:   {"exit"

cat > /tmp/mydostring.c <<'---'
#include <dllua.h>

static int passresults (lua_State *L, int status, int oldtop) {
  if (status == 0) {
    int nresults = lua_gettop(L) - oldtop;
    return nresults;  /* results are already on the stack */
  } else {  /* error */
    lua_pushnil(L);
    lua_pushstring(L, errornames[status]);  /* error code */
    return 2;
  }
}

static int luaB_dostring (lua_State *L) {
  int oldtop = lua_gettop(L);
  size_t l;
  const char *s = luaL_check_lstr(L, 1, &l);
  if (*s == '\27')  /* binary files start with ESC... */
    lua_error(L, "`dostring' cannot run pre-compiled code");
  return passresults(L, lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)), oldtop);
}






#####
#
# for
# 2001oct14
#
#####

# «for»  (to ".for")
# (find-luanode "For Statement")
#*
lua -e 'for i=1,4 do write(" ", i) end; print()'
lua -e 'for i=2,2 do write(" ", i) end; print()'
lua -e 'for i=5,3 do write(" ", i) end; print()'
lua -e 'for i=1,4,2 do write(" ", i) end; print()'
#*



#####
#
# inheriting
# 2001nov30
#
#####

# «inheriting»  (to ".inheriting")
# (find-node "(lua)Tag Methods")
# (find-node "(lua)Tag Method gettable")
# (find-node "(lua)Types and Tags" "userdata and table can have variable tags")
# (find-node "(lua)Basic Functions")
# (find-node "(lua)settag")
# (find-node "(lua)settagmethod")
# (find-node "(lua)Logical Operators")
#*
mylua -e '
  heritabletag = newtag()
  settagmethod(heritabletag, "gettable", function( table, index )
      local a = rawget(table, index); if a then return a end
      local up = rawget(table, "UP"); if up then return up[index] end
    end)
  a = {foo=1, bar=2}
  b = {baz=3, qux=4, UP=a}
  settag(b, heritabletag)
  pa(b.baz, b.bar, b.gax)
  c = {quux=5, quuux=6}
  settag(c, heritabletag)
  pa(c.quux, c.bar)
'

#*
mylua -e '
  heritabletag = newtag()
  H = function(table) settag(table, heritabletag); return table end
  settagmethod(heritabletag, "gettable", function( table, index )
      local a = rawget(table, index); if a then return a end
      local up = rawget(table, "UP"); if up then return up[index] end
    end)
  a =  {foo=1, bar=2}
  b = H{baz=3, qux=4, UP=a}
  c = H{quux=5, quuux=6}
  pa(b.baz, b.bar, b.gax)
  pa(c.quux, c.bar)
  settagmethod(heritabletag, "function", pa)
  b(22, 33)
  settagmethod(heritabletag, "function", function( self, ... )
      pa(self)
      pa(arg)
    end)
  b(44, 55)
'
#*




#####
#
# _ERRORMESSAGE
# 2001dec04
#
#####

# (find-node "(lua)Error Handling")
# (find-node "(lua)_ALERT")
# «_ERRORMESSAGE»  (to "._ERRORMESSAGE")

# (find-luafile "")
# (find-luafile "include/lua.h")
# (find-luafile "src/lib/liolib.c" "LUA_ERRORMESSAGE")
#*
mylua -e 'function e() dostring("foo()") end; e(); e()'

#*
mylua -e '
  e = function( ) dostring("foo()") end
  _ERRORMESSAGE = function( msg )
    print("Err:", msg)
    exit()
  end
  e()
  e()
'
#*




#####
#
# lua5.0-alpha: making an e-script version of the manual
# 2002sep08
#
#####

# «lua5.0-alpha»  (to ".lua5.0-alpha")
#*
lynx http://www.lua.org/ftp/
#*
gv $S/http/www.lua.org/ftp/refman-5.0-alpha.ps.gz &
#*
tar -tvzf $S/http/www.lua.org/ftp/lua-5.0-alpha.tar.gz
#*
zcat $S/http/www.lua.org/ftp/refman-5.0-alpha.ps.gz \
  | pstotext > ~/tmp/luaref.txt
#*
# (find-fline "~/tmp/luaref.txt")
# (progn (find-fline "~/tmp/luaref.txt") (ee-isearch "­"))
# (progn (find-fline "~/tmp/luaref.txt") (ee-isearch "­\n"))
# (code-ps "lua50" "$S/http/www.lua.org/ftp/refman-5.0-alpha.ps.gz")
# (find-lua50page 1)

# (find-fline "~/LUA/lua50ref.e")
# (find-fline "~/LUA/lua50betaref.e")

(code-ps "lua50" "$S/http/www.lua.org/ftp/refman-5.0-alpha.ps.gz")
(progn
(fooi "Di#erent" "Different" "di#erent" "different" "o#cial" "official"
      "e#ects" "effects" "e#ectively" "effectively" "a#ecting" "affecting"
      " # " " -> " "a#ect" "affect" "e#cient" "efficient" "o#ers" "offers"
      "o#set" "offset" "di#erence" "difference" "turns o# " "turns off "
      "su#x" "suffix")
(fooi "+ ­\n" "+ -\n" "MERCHANTABIL­\nITY" "MERCHANTABILITY"
      "proce­\ndural" "procedural" "auto­\nmatically" "automatically"
      "con­\ncatenation" "concatenation" "discus­\nsion" "discussion"
      "con­\nventional" "conventional" "assign­\nments" "assignments"
      "state­\nment" "statement" "arith­\nmetic" "arithmetic"
      "oper­\nadors" "operadors" "multipli­\ncation" "multiplication"
      "appro­\npriate" "appropriate" "garbage­\ncollection"
      "garbage-collection" "pseudo­\nindices" "pseudo-indices"
      "ready­\nto­use" "ready-to-use" "termi­\nnating" "terminating"
      "stan­\ndard" "standard" "imple­\nmented" "implemented"
      "mod­\nules" "modules" "ap­\nplication" "application"
      "char­\nacters" "characters" "repre­\nsents" "represents"
      "cap­\ntured" "captured" "nec­\nessary" "necessary"
      "genera­\ntor" "generator" "compil­\ners" "compilers"
      "de­\nscribing" "describing" "comple­\ntion" "completion"
      "unpro­\ntected" "unprotected")
(fooi-re "\n\\([0-9]+\\)\n" "\n# «p\\1» (find-lua50page \\1)\n")
(fooi-re "§\\([0-9]+\\(\\.[0-9]+\\)*\\)" "(to \"sec\\1\")")
(fooi-re "\n\\([0-9]+\\(\\.[0-9]+\\)*\\) \\([A-Z][-­A-Za-z ]*\\)"
         "\n# «sec\\1»\n# «\\3»\n\n\\1 \\3")

)

(fooi "’e" "é" "›c" "ç" "”a" "ã" "”o" "õ" "’o" "ó"
      "‘a" "à" "“a" "â" "’" "í" "’a" "á")

(fooi "­\n" "")
(fooi "­\n" "-")
(fooi "­" "-")








#####
#
# lua5.0-beta: making an e-script version of the manual
# 2002sep08
#
#####

# «lua5.0-beta»  (to ".lua5.0-beta")
#*
lynx http://www.lua.org/ftp/
#*
gv $S/http/www.lua.org/ftp/refman-5.0-alpha.ps.gz &
#*
tar -tvzf $S/http/www.lua.org/ftp/lua-5.0-alpha.tar.gz
#*
cd $S/http/www.lua.org/ftp/
zcat refman-5.0-beta.ps.gz | pstotext | tee refman-5.0-beta.txt
# (find-fline "$S/http/www.lua.org/ftp/refman-5.0-beta.txt")
#*
# (find-fline "~/LUA/lua50betaref.e")
cp -iv $S/http/www.lua.org/ftp/refman-5.0-beta.txt ~/LUA/lua50betaref.e
#*

(find-shttpfile "www.lua.org/ftp/")
(find-es "lua" "lua5.0-beta")

(code-ps "lua50" "$S/http/www.lua.org/ftp/refman-5.0-beta.ps.gz")
(find-lua50page 1)
emacs ~/LUA/lua50betaref.e &

(progn
(fooi "_e" "é" "_c" "ç" "_a" "ã" "_o" "õ" "_o" "ó"
      "_a" "à" "_a" "â" "__" "í" "_a" "á")
(fooi "Di#erent" "Different" "di#erent" "different" "o#cial" "official"
      "e#ects" "effects" "e#ectively" "effectively" "a#ecting" "affecting"
      " # " " -> " "a#ect" "affect" "e#cient" "efficient" "o#ers" "offers"
      "o#set" "offset" "di#erence" "difference" "turns o# " "turns off "
      "su#x" "suffix")
(fooi "+ ­\n" "+ -\n" "MERCHANTABIL­\nITY" "MERCHANTABILITY"
      "proce­\ndural" "procedural" "auto­\nmatically" "automatically"
      "con­\ncatenation" "concatenation" "discus­\nsion" "discussion"
      "con­\nventional" "conventional" "assign­\nments" "assignments"
      "state­\nment" "statement" "arith­\nmetic" "arithmetic"
      "oper­\nadors" "operadors" "multipli­\ncation" "multiplication"
      "appro­\npriate" "appropriate" "garbage­\ncollection"
      "garbage-collection" "pseudo­\nindices" "pseudo-indices"
      "ready­\nto­use" "ready-to-use" "termi­\nnating" "terminating"
      "stan­\ndard" "standard" "imple­\nmented" "implemented"
      "mod­\nules" "modules" "ap­\nplication" "application"
      "char­\nacters" "characters" "repre­\nsents" "represents"
      "cap­\ntured" "captured" "nec­\nessary" "necessary"
      "genera­\ntor" "generator" "compil­\ners" "compilers"
      "de­\nscribing" "describing" "comple­\ntion" "completion"
      "unpro­\ntected" "unprotected" "pre­compile" "pre-compile"
      "re­\nturning" "returning" "oth­\nerwise" "otherwise"
      "mes­\nsage" "message")
)

(progn
(fooi-re "\n\\([0-9]+\\)\n" "\n\n# «p\\1» (find-lua50page \\1)\n")
(fooi-re "§\\([0-9]+\\(\\.[0-9]+\\)*\\)" "(to \"sec\\1\")")
(save-excursion
  (ee-goto-position "\nIncompatibilities with")
  (fooi-re "\n\\([0-9]+\\(\\.[0-9]+\\)*\\) \\([A-Z][-­A-Za-z ]*\\)"
           "\n\n# «sec\\1»\n# «\\3»\n\n\\1 \\3\n")
  )
(save-excursion
  (ee-goto-position "\nStandard Libraries")
  (fooi-re "\n\\(\\. \\([a-z.:]+\\) (\\)"
           "\n# «\\2»\n\\1")
  )
(fooi-re "\n\\(``\\([a-z]*\\)'':\\)" "\n# «__\\2»\n\\1")
)

(ee-isearch "­\n")
(ee-isearch "­")
(fooi "­\n" "")
(fooi "­\n" "-")

(fooi "­" "-")






(progn (jump-to-register ?a) (ee-isearch "-\n"))

egrep '^[0-9]+$' ~/tmp/luaref.txt | l -S


# (find-tkluafile "config")
# (find-tkluafile "src/bin/Makefile")

# (find-toluafile "")

# (find-tkluafile "patches/tolua-4.0a-patch")
# (find-toluafile "src/lib/tolua_gp.c" "tolua_getvalue")

# (find-fline "/usr/src/tklua/")
# (find-tkluaw3 "doc/")
# (find-tkluafile "test/")
# (find-tkluafile "")
# (find-tkluafile "src/bin/")
# (find-tkluafile "src/lib/")

# (find-status "tk8.3-dev")
# (find-vldifile "tk8.3-dev.list")
# (find-fline "/usr/doc/tk8.3-dev/")

# (load-library "~/LUA/lua.el")
# (find-fline "/usr/doc/lua/examples/")








#  Local Variables:
#  coding:               utf-8-unix
#  End: