From ff003bc446adeea1fc3f7848a0cd7e23357cef0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 19 Mar 2012 10:19:24 +0100 Subject: [PATCH 01/48] Fixed build issue on Linux when building luac --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf521cac..7806059d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,8 +157,8 @@ set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua CLEAN_DIRECT_OUTPUT 1 add_executable ( lua ${SRC_LUA} src/lua.rc ) target_link_libraries ( lua liblua ) -add_executable ( luac ${SRC_LUAC} src/luac.rc ) -target_link_libraries ( luac liblua ) +add_executable ( luac ${SRC_CORE} ${SRC_LIB} ${SRC_LUAC} src/luac.rc ) +target_link_libraries ( luac ${LIBS} ) install_executable ( lua luac ) install_library ( liblua ) From 3544f0d82899f37d5d0be590f8ce9176f44bccb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Sun, 1 Apr 2012 19:00:15 +0200 Subject: [PATCH 02/48] Travis-CI hook. --- .travis.yml | 10 ++++++++++ CMakeLists.txt | 2 +- README => README.md | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .travis.yml rename README => README.md (53%) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..8568a8ee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: erlang # Not really ... + +install: + - sudo apt-get install cmake + +script: + - mkdir _build && cd _build + - cmake .. -DCMAKE_INSTALL_PREFIX=../install + - cmake --build . --target install + - ctest . diff --git a/CMakeLists.txt b/CMakeLists.txt index 7806059d..10d81129 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,7 @@ target_link_libraries ( luac ${LIBS} ) install_executable ( lua luac ) install_library ( liblua ) -install_data ( README ) +install_data ( README.md ) #install_lua_module ( strict etc/strict.lua ) install_header (src/lua.h src/lualib.h src/lauxlib.h ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) install_doc ( doc/ ) diff --git a/README b/README.md similarity index 53% rename from README rename to README.md index 9c384675..596c35e1 100644 --- a/README +++ b/README.md @@ -1,5 +1,8 @@ This is Lua 5.2, released on 12 Dec 2011. +================ + +[![Build Status](https://secure.travis-ci.org/LuaDist/lua.png?branch=master)](http://travis-ci.org/LuaDist/lua) For installation instructions, license details, and further information about Lua, see doc/readme.html. From 99673da66d3279594e62317436d164d2012568de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Sun, 1 Apr 2012 19:23:51 +0200 Subject: [PATCH 03/48] Minor adjustment in install destination --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8568a8ee..b91301dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,6 @@ install: script: - mkdir _build && cd _build - - cmake .. -DCMAKE_INSTALL_PREFIX=../install + - cmake .. -DCMAKE_INSTALL_PREFIX=../_install - cmake --build . --target install - ctest . From 2aa2174d3afd0d6b8fe26fae9e58670ebdb1352f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Mon, 2 Apr 2012 23:43:21 +0200 Subject: [PATCH 04/48] Added Imporved Travis Build --- .travis.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b91301dd..c7582788 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,50 @@ -language: erlang # Not really ... +# +# LuaDist Travis-CI Hook +# +# Since CMake is not directly supported we use erlang VMs +language: erlang + +# Try using multiple Lua Implementations +env: + - LUA="" # Use automatic dependencies + - LUA="luajit" # Try with LuaJIT +# - CMAKE="-DCMAKE_VARIABLE=value" +# - LUA="lua-5.1.5" + +# Allow luajit to fail +matrix: + allow_failures: + - env: LUA="luajit" + +# We need CMake and LuaDist install: - - sudo apt-get install cmake + - export MODULE='basename $PWD' + - sudo apt-get install cmake + - git clone git://github.com/LuaDist/bootstrap.git _luadist + - cd _luadist + - git submodule update --init + - ./bootstrap + - export LUADIST=$PWD/_install/bin/luadist + - cd $HOME +# Use LuaDist to deploy the module script: - - mkdir _build && cd _build - - cmake .. -DCMAKE_INSTALL_PREFIX=../_install - - cmake --build . --target install - - ctest . + - $LUADIST _test install $LUA $MODULE-scm $CMAKE -verbose=true -debug=true -test=true + +# Execute additional tests or commands +#after_script: +# - [run additional test commans] + +# Only watch the master branch +branches: + only: + - master + +# Notify the LuaDist Dev group if needed +notifications: + recipients: + - luadist-dev@googlegroups.com + email: + on_success: change + on_failure: always \ No newline at end of file From e3741804f47d3abe59392ee4a8ff8f1cf625db7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Mon, 2 Apr 2012 23:48:27 +0200 Subject: [PATCH 05/48] Minotr fix Travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c7582788..9b638361 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ matrix: # We need CMake and LuaDist install: - - export MODULE='basename $PWD' + - export MODULE=`basename $PWD` - sudo apt-get install cmake - git clone git://github.com/LuaDist/bootstrap.git _luadist - cd _luadist From 4ce3e3802e56e59aad1efb857a7693fb4648b7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Tue, 3 Apr 2012 01:41:58 +0200 Subject: [PATCH 06/48] Updated travis build --- .travis.yml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b638361..74b4f337 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,36 +5,24 @@ # Since CMake is not directly supported we use erlang VMs language: erlang -# Try using multiple Lua Implementations -env: - - LUA="" # Use automatic dependencies - - LUA="luajit" # Try with LuaJIT -# - CMAKE="-DCMAKE_VARIABLE=value" -# - LUA="lua-5.1.5" - -# Allow luajit to fail -matrix: - allow_failures: - - env: LUA="luajit" - # We need CMake and LuaDist install: - export MODULE=`basename $PWD` - - sudo apt-get install cmake - - git clone git://github.com/LuaDist/bootstrap.git _luadist + - sudo apt-get install cmake >/dev/null 2>&1 + - git clone git://github.com/LuaDist/bootstrap.git _luadist >/dev/null 2>&1 - cd _luadist - - git submodule update --init - - ./bootstrap + - git submodule update --init >/dev/null 2>&1 + - ./bootstrap >/dev/null 2>&1 - export LUADIST=$PWD/_install/bin/luadist - cd $HOME # Use LuaDist to deploy the module script: - - $LUADIST _test install $LUA $MODULE-scm $CMAKE -verbose=true -debug=true -test=true + - $LUADIST _test install $LUA $MODULE-scm -verbose=true -test=true # Execute additional tests or commands -#after_script: -# - [run additional test commans] +after_script: + - ./_test/bin/lua -e "print '_VERSION'" # Only watch the master branch branches: From 597b68854a53bb537ee74363f7a26327d4b62cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Tue, 3 Apr 2012 01:48:30 +0200 Subject: [PATCH 07/48] Minor fix in after-script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 74b4f337..4bab3f7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ script: # Execute additional tests or commands after_script: - - ./_test/bin/lua -e "print '_VERSION'" + - ./_test/bin/lua -e "print ('_VERSION')" # Only watch the master branch branches: From f4555b8b6441ab486fef1941e76532ba59e5a246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Tue, 3 Apr 2012 01:53:57 +0200 Subject: [PATCH 08/48] Version report fix in Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4bab3f7f..b7fd0f0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ script: # Execute additional tests or commands after_script: - - ./_test/bin/lua -e "print ('_VERSION')" + - ./_test/bin/lua -e "print (_VERSION)" # Only watch the master branch branches: From ee82f7b1da6ea0c9563558f2e1cbed8af8025377 Mon Sep 17 00:00:00 2001 From: David Manura Date: Sat, 7 Apr 2012 22:47:09 -0400 Subject: [PATCH 09/48] cmake: fixed path style in .rc for mingw cross compile from linux --- src/lua.rc | 2 +- src/luac.rc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua.rc b/src/lua.rc index 76541865..9829ab27 100644 --- a/src/lua.rc +++ b/src/lua.rc @@ -1,4 +1,4 @@ -0 ICON "..\\etc\\lua.ico" +0 ICON "../etc/lua.ico" 1 VERSIONINFO FILEVERSION 5,2,0,0 diff --git a/src/luac.rc b/src/luac.rc index 60eca7a3..82cc2527 100644 --- a/src/luac.rc +++ b/src/luac.rc @@ -1,4 +1,4 @@ -0 ICON "..\\etc\\lua.ico" +0 ICON "../etc/lua.ico" 1 VERSIONINFO FILEVERSION 5,2,0,0 From 7c6b93fc5d90f729ad40737655a4d936883102a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 11 May 2012 11:17:54 +0200 Subject: [PATCH 10/48] Added new LuaDist macros --- CMakeLists.txt | 5 +- cmake/FindLua.cmake | 118 +++++ .../FindReadline.cmake | 0 cmake/dist.cmake | 321 +++++++++++++ cmake/lua.cmake | 390 +++++++++++++++ dist.cmake | 450 ------------------ 6 files changed, 830 insertions(+), 454 deletions(-) create mode 100644 cmake/FindLua.cmake rename FindReadline.cmake => cmake/FindReadline.cmake (100%) create mode 100644 cmake/dist.cmake create mode 100644 cmake/lua.cmake delete mode 100644 dist.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 10d81129..3b953a3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ project ( lua C ) cmake_minimum_required ( VERSION 2.6 ) -include ( dist.cmake ) +include ( cmake/dist.cmake ) ## CONFIGURATION # Default configuration (we assume POSIX by default) @@ -18,9 +18,6 @@ option ( LUA_ANSI "Use only ansi features." OFF ) option ( LUA_USE_RELATIVE_LOADLIB "Use modified loadlib.c with support for relative paths on posix systems." ON ) option ( LUA_COMPAT_ALL "Enable backwards compatibility options." ON ) set ( LUA_IDSIZE 60 CACHE NUMBER "gives the maximum size for the description of the source." ) -#set ( LUA_PROMPT "> " CACHE STRING "Is the default prompt used by stand-alone Lua." ) -#set ( LUA_PROMPT2 ">> " CACHE STRING "Is the default continuation prompt used by stand-alone Lua." ) -#set ( LUA_MAXINPUT 512 CACHE NUMBER "Is the maximum length for an input line in the stand-alone interpreter.") #2DO: LUAI_* and LUAL_* settings, for now defaults are used. diff --git a/cmake/FindLua.cmake b/cmake/FindLua.cmake new file mode 100644 index 00000000..7fb7ca3f --- /dev/null +++ b/cmake/FindLua.cmake @@ -0,0 +1,118 @@ +# Locate Lua library +# This module defines +# LUA_EXECUTABLE, if found +# LUA_FOUND, if false, do not try to link to Lua +# LUA_LIBRARIES +# LUA_INCLUDE_DIR, where to find lua.h +# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) +# +# Note that the expected include convention is +# #include "lua.h" +# and not +# #include +# This is because, the lua location is not standardized and may exist +# in locations other than lua/ + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# Modified to support Lua 5.2 by LuaDist 2012 +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +# +# The required version of Lua can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Lua 5.1) +# Otherwise the module will search for any available Lua implementation + +# Always search for non-versioned lua first (recommended) +SET(_POSSIBLE_LUA_INCLUDE include include/lua) +SET(_POSSIBLE_LUA_EXECUTABLE lua) +SET(_POSSIBLE_LUA_LIBRARY lua) + +# Determine possible naming suffixes (there is no standard for this) +IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}") +ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1") +ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR) + +# Set up possible search names and locations +FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES}) + LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}") + LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}") + LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}") +ENDFOREACH(_SUFFIX) + +# Find the lua executable +FIND_PROGRAM(LUA_EXECUTABLE + NAMES ${_POSSIBLE_LUA_EXECUTABLE} +) + +# Find the lua header +FIND_PATH(LUA_INCLUDE_DIR lua.h + HINTS + $ENV{LUA_DIR} + PATH_SUFFIXES ${_POSSIBLE_LUA_INCLUDE} + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +# Find the lua library +FIND_LIBRARY(LUA_LIBRARY + NAMES ${_POSSIBLE_LUA_LIBRARY} + HINTS + $ENV{LUA_DIR} + PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +IF(LUA_LIBRARY) + # include the math library for Unix + IF(UNIX AND NOT APPLE) + FIND_LIBRARY(LUA_MATH_LIBRARY m) + SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries") + # For Windows and Mac, don't need to explicitly include the math library + ELSE(UNIX AND NOT APPLE) + SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries") + ENDIF(UNIX AND NOT APPLE) +ENDIF(LUA_LIBRARY) + +# Determine Lua version +IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") + FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"") + + STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}") + UNSET(lua_version_str) +ENDIF() + +INCLUDE(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if +# all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua + REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR + VERSION_VAR LUA_VERSION_STRING) + +MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE) + diff --git a/FindReadline.cmake b/cmake/FindReadline.cmake similarity index 100% rename from FindReadline.cmake rename to cmake/FindReadline.cmake diff --git a/cmake/dist.cmake b/cmake/dist.cmake new file mode 100644 index 00000000..310ef94c --- /dev/null +++ b/cmake/dist.cmake @@ -0,0 +1,321 @@ +# LuaDist CMake utility library. +# Provides sane project defaults and macros common to LuaDist CMake builds. +# +# Copyright (C) 2007-2012 LuaDist. +# by David Manura, Peter DrahoÅ¡ +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Please note that the package source code is licensed under its own license. + +## Extract information from dist.info +if ( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dist.info ) + message ( FATAL_ERROR + "Missing dist.info file (${CMAKE_CURRENT_SOURCE_DIR}/dist.info)." ) +endif () +file ( READ ${CMAKE_CURRENT_SOURCE_DIR}/dist.info DIST_INFO ) +if ( "${DIST_INFO}" STREQUAL "" ) + message ( FATAL_ERROR "Failed to load dist.info." ) +endif () +# Reads field `name` from dist.info string `DIST_INFO` into variable `var`. +macro ( _parse_dist_field name var ) + string ( REGEX REPLACE ".*${name}[ \t]?=[ \t]?[\"']([^\"']+)[\"'].*" "\\1" + ${var} "${DIST_INFO}" ) + if ( ${var} STREQUAL DIST_INFO ) + message ( FATAL_ERROR "Failed to extract \"${var}\" from dist.info" ) + endif () +endmacro () +# +_parse_dist_field ( name DIST_NAME ) +_parse_dist_field ( version DIST_VERSION ) +_parse_dist_field ( license DIST_LICENSE ) +_parse_dist_field ( author DIST_AUTHOR ) +_parse_dist_field ( maintainer DIST_MAINTAINER ) +_parse_dist_field ( url DIST_URL ) +_parse_dist_field ( desc DIST_DESC ) +message ( "DIST_NAME: ${DIST_NAME}") +message ( "DIST_VERSION: ${DIST_VERSION}") +message ( "DIST_LICENSE: ${DIST_LICENSE}") +message ( "DIST_AUTHOR: ${DIST_AUTHOR}") +message ( "DIST_MAINTAINER: ${DIST_MAINTAINER}") +message ( "DIST_URL: ${DIST_URL}") +message ( "DIST_DESC: ${DIST_DESC}") +string ( REGEX REPLACE ".*depends[ \t]?=[ \t]?[\"']([^\"']+)[\"'].*" "\\1" + DIST_DEPENDS ${DIST_INFO} ) +if ( DIST_DEPENDS STREQUAL DIST_INFO ) + set ( DIST_DEPENDS "" ) +endif () +message ( "DIST_DEPENDS: ${DIST_DEPENDS}") +## 2DO: Parse DIST_DEPENDS and try to install Dependencies with automatically using externalproject_add + + +## INSTALL DEFAULTS (Relative to CMAKE_INSTALL_PREFIX) +# Primary paths +set ( INSTALL_BIN bin CACHE PATH "Where to install binaries to." ) +set ( INSTALL_LIB lib CACHE PATH "Where to install libraries to." ) +set ( INSTALL_INC include CACHE PATH "Where to install headers to." ) +set ( INSTALL_ETC etc CACHE PATH "Where to store configuration files" ) +set ( INSTALL_SHARE share CACHE PATH "Directory for shared data." ) + +# Secondary paths +option ( INSTALL_VERSION + "Install runtime libraries and executables with version information." OFF) +set ( INSTALL_DATA ${INSTALL_SHARE}/${DIST_NAME} CACHE PATH + "Directory the package can store documentation, tests or other data in.") +set ( INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH + "Recommended directory to install documentation into.") +set ( INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH + "Recommended directory to install examples into.") +set ( INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH + "Recommended directory to install tests into.") +set ( INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH + "Where to install additional files") + +# Tweaks and other defaults +# Setting CMAKE to use loose block and search for find modules in source directory +set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) +set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} ) +option ( BUILD_SHARED_LIBS "Build shared libraries" ON ) + +# In MSVC, prevent warnings that can occur when using standard libraries. +if ( MSVC ) + add_definitions ( -D_CRT_SECURE_NO_WARNINGS ) +endif () + +# RPath and relative linking +option ( USE_RPATH "Use relative linking." ON) +if ( USE_RPATH ) + string ( REGEX REPLACE "[^!/]+" ".." UP_DIR ${INSTALL_BIN} ) + set ( CMAKE_SKIP_BUILD_RPATH FALSE CACHE STRING "" FORCE ) + set ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_RPATH $ORIGIN/${UP_DIR}/${INSTALL_LIB} + CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE STRING "" FORCE ) + set ( CMAKE_INSTALL_NAME_DIR @executable_path/${UP_DIR}/${INSTALL_LIB} + CACHE STRING "" FORCE ) +endif () + +## MACROS +# Parser macro +macro ( parse_arguments prefix arg_names option_names) + set ( DEFAULT_ARGS ) + foreach ( arg_name ${arg_names} ) + set ( ${prefix}_${arg_name} ) + endforeach () + foreach ( option ${option_names} ) + set ( ${prefix}_${option} FALSE ) + endforeach () + + set ( current_arg_name DEFAULT_ARGS ) + set ( current_arg_list ) + foreach ( arg ${ARGN} ) + set ( larg_names ${arg_names} ) + list ( FIND larg_names "${arg}" is_arg_name ) + if ( is_arg_name GREATER -1 ) + set ( ${prefix}_${current_arg_name} ${current_arg_list} ) + set ( current_arg_name ${arg} ) + set ( current_arg_list ) + else () + set ( loption_names ${option_names} ) + list ( FIND loption_names "${arg}" is_option ) + if ( is_option GREATER -1 ) + set ( ${prefix}_${arg} TRUE ) + else () + set ( current_arg_list ${current_arg_list} ${arg} ) + endif () + endif () + endforeach () + set ( ${prefix}_${current_arg_name} ${current_arg_list} ) +endmacro () + + +# install_executable ( executable_targets ) +# Installs any executables generated using "add_executable". +# USE: install_executable ( lua ) +# NOTE: subdirectories are NOT supported +set ( CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "${DIST_NAME} Runtime" ) +set ( CPACK_COMPONENT_RUNTIME_DESCRIPTION + "Executables and runtime libraries. Installed into ${INSTALL_BIN}." ) +macro ( install_executable ) + foreach ( _file ${ARGN} ) + if ( INSTALL_VERSION ) + set_target_properties ( ${_file} PROPERTIES VERSION ${DIST_VERSION} + SOVERSION ${DIST_VERSION} ) + endif () + install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} + COMPONENT Runtime ) + endforeach() +endmacro () + +# install_library ( library_targets ) +# Installs any libraries generated using "add_library" into apropriate places. +# USE: install_library ( libexpat ) +# NOTE: subdirectories are NOT supported +set ( CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "${DIST_NAME} Development Libraries" ) +set ( CPACK_COMPONENT_LIBRARY_DESCRIPTION + "Static and import libraries needed for development. Installed into ${INSTALL_LIB} or ${INSTALL_BIN}." ) +macro ( install_library ) + foreach ( _file ${ARGN} ) + if ( INSTALL_VERSION ) + set_target_properties ( ${_file} PROPERTIES VERSION ${DIST_VERSION} + SOVERSION ${DIST_VERSION} ) + endif () + install ( TARGETS ${_file} + RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT Runtime + LIBRARY DESTINATION ${INSTALL_LIB} COMPONENT Runtime + ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT Library ) + endforeach() +endmacro () + +# helper function for various install_* functions, for PATTERN/REGEX args. +macro ( _complete_install_args ) + if ( NOT("${_ARG_PATTERN}" STREQUAL "") ) + set ( _ARG_PATTERN PATTERN ${_ARG_PATTERN} ) + endif () + if ( NOT("${_ARG_REGEX}" STREQUAL "") ) + set ( _ARG_REGEX REGEX ${_ARG_REGEX} ) + endif () +endmacro () + +# install_header ( files/directories [INTO destination] ) +# Install a directories or files into header destination. +# USE: install_header ( lua.h luaconf.h ) or install_header ( GL ) +# USE: install_header ( mylib.h INTO mylib ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_HEADER_DISPLAY_NAME "${DIST_NAME} Development Headers" ) +set ( CPACK_COMPONENT_HEADER_DESCRIPTION + "Headers needed for development. Installed into ${INSTALL_INC}." ) +macro ( install_header ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} + COMPONENT Header ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} + COMPONENT Header ) + endif () + endforeach() +endmacro () + +# install_data ( files/directories [INTO destination] ) +# This installs additional data files or directories. +# USE: install_data ( extra data.dat ) +# USE: install_data ( image1.png image2.png INTO images ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_DATA_DISPLAY_NAME "${DIST_NAME} Data" ) +set ( CPACK_COMPONENT_DATA_DESCRIPTION + "Application data. Installed into ${INSTALL_DATA}." ) +macro ( install_data ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} + DESTINATION ${INSTALL_DATA}/${_ARG_INTO} + COMPONENT Data ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} + COMPONENT Data ) + endif () + endforeach() +endmacro () + +# INSTALL_DOC ( files/directories [INTO destination] ) +# This installs documentation content +# USE: install_doc ( doc/ doc.pdf ) +# USE: install_doc ( index.html INTO html ) +# For directories, supports optional PATTERN/REGEX arguments like install(). +set ( CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "${DIST_NAME} Documentation" ) +set ( CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION + "Application documentation. Installed into ${INSTALL_DOC}." ) +macro ( install_doc ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} + COMPONENT Documentation ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} + COMPONENT Documentation ) + endif () + endforeach() +endmacro () + +# install_example ( files/directories [INTO destination] ) +# This installs additional examples +# USE: install_example ( examples/ exampleA ) +# USE: install_example ( super_example super_data INTO super) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_EXAMPLE_DISPLAY_NAME "${DIST_NAME} Examples" ) +set ( CPACK_COMPONENT_EXAMPLE_DESCRIPTION + "Examples and their associated data. Installed into ${INSTALL_EXAMPLE}." ) +macro ( install_example ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} + COMPONENT Example ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} + COMPONENT Example ) + endif () + endforeach() +endmacro () + +# install_test ( files/directories [INTO destination] ) +# This installs tests and test files, DOES NOT EXECUTE TESTS +# USE: install_test ( my_test data.sql ) +# USE: install_test ( feature_x_test INTO x ) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_TEST_DISPLAY_NAME "${DIST_NAME} Tests" ) +set ( CPACK_COMPONENT_TEST_DESCRIPTION + "Tests and associated data. Installed into ${INSTALL_TEST}." ) +macro ( install_test ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} + COMPONENT Test ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} + COMPONENT Test ) + endif () + endforeach() +endmacro () + +# install_foo ( files/directories [INTO destination] ) +# This installs optional or otherwise unneeded content +# USE: install_foo ( etc/ example.doc ) +# USE: install_foo ( icon.png logo.png INTO icons) +# For directories, supports optional PATTERN/REGEX argument like install(). +set ( CPACK_COMPONENT_OTHER_DISPLAY_NAME "${DIST_NAME} Unspecified Content" ) +set ( CPACK_COMPONENT_OTHER_DESCRIPTION + "Other unspecified content. Installed into ${INSTALL_FOO}." ) +macro ( install_foo ) + parse_arguments ( _ARG "INTO;PATTERN;REGEX" "" ${ARGN} ) + _complete_install_args() + foreach ( _file ${_ARG_DEFAULT_ARGS} ) + if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) + install ( DIRECTORY ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} + COMPONENT Other ${_ARG_PATTERN} ${_ARG_REGEX} ) + else () + install ( FILES ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} + COMPONENT Other ) + endif () + endforeach() +endmacro () + +## CTest defaults + +## CPack defaults +set ( CPACK_GENERATOR "ZIP" ) +set ( CPACK_STRIP_FILES TRUE ) +set ( CPACK_PACKAGE_NAME "${DIST_NAME}" ) +set ( CPACK_PACKAGE_VERSION "${DIST_VERSION}") +set ( CPACK_PACKAGE_VENDOR "LuaDist" ) +set ( CPACK_COMPONENTS_ALL Runtime Library Header Data Documentation Example Other ) +include ( CPack ) diff --git a/cmake/lua.cmake b/cmake/lua.cmake new file mode 100644 index 00000000..a0f3e67d --- /dev/null +++ b/cmake/lua.cmake @@ -0,0 +1,390 @@ +# LuaDist CMake utility library for Lua. +# +# Copyright (C) 2007-2012 LuaDist. +# by David Manura, Peter Drahos +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Please note that the package source code is licensed under its own license. + +set ( INSTALL_LMOD ${INSTALL_LIB}/lua + CACHE PATH "Directory to install Lua modules." ) +set ( INSTALL_CMOD ${INSTALL_LIB}/lua + CACHE PATH "Directory to install Lua binary modules." ) + +option ( SKIP_LUA_WRAPPER + "Do not build and install Lua executable wrappers." OFF) + +# List of (Lua module name, file path) pairs. +# Used internally by add_lua_test. Built by add_lua_module. +set ( _lua_modules ) + +# utility function: appends path `path` to path `basepath`, properly +# handling cases when `path` may be relative or absolute. +macro ( _append_path basepath path result ) + if ( IS_ABSOLUTE "${path}" ) + set ( ${result} "${path}" ) + else () + set ( ${result} "${basepath}/${path}" ) + endif () +endmacro () + +# install_lua_executable ( target source ) +# Automatically generate a binary wrapper for lua application and install it +# The wrapper and the source of the application will be placed into /bin +# If the application source did not have .lua suffix then it will be added +# USE: lua_executable ( sputnik src/sputnik.lua ) +macro ( install_lua_executable _name _source ) + get_filename_component ( _source_name ${_source} NAME_WE ) + if ( NOT SKIP_LUA_WRAPPER ) + enable_language ( C ) + + find_package ( Lua REQUIRED ) + include_directories ( ${LUA_INCLUDE_DIR} ) + + set ( _wrapper ${CMAKE_CURRENT_BINARY_DIR}/${_name}.c ) + set ( _code +"// Not so simple executable wrapper for Lua apps +#include +#include +#include +#include +#include + +lua_State *L\; + +static int getargs (lua_State *L, char **argv, int n) { +int narg\; +int i\; +int argc = 0\; +while (argv[argc]) argc++\; +narg = argc - (n + 1)\; +luaL_checkstack(L, narg + 3, \"too many arguments to script\")\; +for (i=n+1\; i < argc\; i++) + lua_pushstring(L, argv[i])\; +lua_createtable(L, narg, n + 1)\; +for (i=0\; i < argc\; i++) { + lua_pushstring(L, argv[i])\; + lua_rawseti(L, -2, i - n)\; +} +return narg\; +} + +static void lstop (lua_State *L, lua_Debug *ar) { +(void)ar\; +lua_sethook(L, NULL, 0, 0)\; +luaL_error(L, \"interrupted!\")\; +} + +static void laction (int i) { +signal(i, SIG_DFL)\; +lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1)\; +} + +static void l_message (const char *pname, const char *msg) { +if (pname) fprintf(stderr, \"%s: \", pname)\; +fprintf(stderr, \"%s\\n\", msg)\; +fflush(stderr)\; +} + +static int report (lua_State *L, int status) { +if (status && !lua_isnil(L, -1)) { + const char *msg = lua_tostring(L, -1)\; + if (msg == NULL) msg = \"(error object is not a string)\"\; + l_message(\"${_source_name}\", msg)\; + lua_pop(L, 1)\; +} +return status\; +} + +static int traceback (lua_State *L) { +if (!lua_isstring(L, 1)) + return 1\; +lua_getfield(L, LUA_GLOBALSINDEX, \"debug\")\; +if (!lua_istable(L, -1)) { + lua_pop(L, 1)\; + return 1\; +} +lua_getfield(L, -1, \"traceback\")\; +if (!lua_isfunction(L, -1)) { + lua_pop(L, 2)\; + return 1\; +} +lua_pushvalue(L, 1)\; +lua_pushinteger(L, 2)\; +lua_call(L, 2, 1)\; +return 1\; +} + +static int docall (lua_State *L, int narg, int clear) { +int status\; +int base = lua_gettop(L) - narg\; +lua_pushcfunction(L, traceback)\; +lua_insert(L, base)\; +signal(SIGINT, laction)\; +status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base)\; +signal(SIGINT, SIG_DFL)\; +lua_remove(L, base)\; +if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0)\; +return status\; +} + +int main (int argc, char **argv) { +L=lua_open()\; +lua_gc(L, LUA_GCSTOP, 0)\; +luaL_openlibs(L)\; +lua_gc(L, LUA_GCRESTART, 0)\; +int narg = getargs(L, argv, 0)\; +lua_setglobal(L, \"arg\")\; + +// Script +char script[500] = \"./${_source_name}.lua\"\; +lua_getglobal(L, \"_PROGDIR\")\; +if (lua_isstring(L, -1)) { + sprintf( script, \"%s/${_source_name}.lua\", lua_tostring(L, -1))\; +} +lua_pop(L, 1)\; + +// Run +int status = luaL_loadfile(L, script)\; +lua_insert(L, -(narg+1))\; +if (status == 0) + status = docall(L, narg, 0)\; +else + lua_pop(L, narg)\; + +report(L, status)\; +lua_close(L)\; +return status\; +}; +") + file ( WRITE ${_wrapper} ${_code} ) + add_executable ( ${_name} ${_wrapper} ) + target_link_libraries ( ${_name} ${LUA_LIBRARY} ) + install ( TARGETS ${_name} DESTINATION ${INSTALL_BIN} ) + endif() + install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN} + RENAME ${_source_name}.lua ) +endmacro () + +macro ( _lua_module_helper is_install _name ) + parse_arguments ( _MODULE "LINK;ALL_IN_ONE" "" ${ARGN} ) + # _target is CMake-compatible target name for module (e.g. socket_core). + # _module is relative path of target (e.g. socket/core), + # without extension (e.g. .lua/.so/.dll). + # _MODULE_SRC is list of module source files (e.g. .lua and .c files). + # _MODULE_NAMES is list of module names (e.g. socket.core). + if ( _MODULE_ALL_IN_ONE ) + string ( REGEX REPLACE "\\..*" "" _target "${_name}" ) + string ( REGEX REPLACE "\\..*" "" _module "${_name}" ) + set ( _target "${_target}_all_in_one") + set ( _MODULE_SRC ${_MODULE_ALL_IN_ONE} ) + set ( _MODULE_NAMES ${_name} ${_MODULE_DEFAULT_ARGS} ) + else () + string ( REPLACE "." "_" _target "${_name}" ) + string ( REPLACE "." "/" _module "${_name}" ) + set ( _MODULE_SRC ${_MODULE_DEFAULT_ARGS} ) + set ( _MODULE_NAMES ${_name} ) + endif () + if ( NOT _MODULE_SRC ) + message ( FATAL_ERROR "no module sources specified" ) + endif () + list ( GET _MODULE_SRC 0 _first_source ) + + get_filename_component ( _ext ${_first_source} EXT ) + if ( _ext STREQUAL ".lua" ) # Lua source module + list ( LENGTH _MODULE_SRC _len ) + if ( _len GREATER 1 ) + message ( FATAL_ERROR "more than one source file specified" ) + endif () + + set ( _module "${_module}.lua" ) + + get_filename_component ( _module_dir ${_module} PATH ) + get_filename_component ( _module_filename ${_module} NAME ) + _append_path ( "${CMAKE_CURRENT_SOURCE_DIR}" "${_first_source}" _module_path ) + list ( APPEND _lua_modules "${_name}" "${_module_path}" ) + + if ( ${is_install} ) + install ( FILES ${_first_source} DESTINATION ${INSTALL_LMOD}/${_module_dir} + RENAME ${_module_filename} ) + endif () + else () # Lua C binary module + enable_language ( C ) + find_package ( Lua REQUIRED ) + include_directories ( ${LUA_INCLUDE_DIR} ) + + set ( _module "${_module}${CMAKE_SHARED_MODULE_SUFFIX}" ) + + get_filename_component ( _module_dir ${_module} PATH ) + get_filename_component ( _module_filenamebase ${_module} NAME_WE ) + foreach ( _thisname ${_MODULE_NAMES} ) + list ( APPEND _lua_modules "${_thisname}" + "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_CFG_INTDIR}/${_module}" ) + endforeach () + + add_library( ${_target} MODULE ${_MODULE_SRC}) + target_link_libraries ( ${_target} ${LUA_LIBRARY} ${_MODULE_LINK} ) + set_target_properties ( ${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY + "${_module_dir}" PREFIX "" OUTPUT_NAME "${_module_filenamebase}" ) + if ( ${is_install} ) + install ( TARGETS ${_target} DESTINATION ${INSTALL_CMOD}/${_module_dir}) + endif () + endif () +endmacro () + +# add_lua_module +# Builds a Lua source module into a destination locatable by Lua +# require syntax. +# Binary modules are also supported where this function takes sources and +# libraries to compile separated by LINK keyword. +# USE: add_lua_module ( socket.http src/http.lua ) +# USE2: add_lua_module ( mime.core src/mime.c ) +# USE3: add_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} ) +# USE4: add_lua_module ( ssl.context ssl.core ALL_IN_ONE src/context.c src/ssl.c ) +# This form builds an "all-in-one" module (e.g. ssl.so or ssl.dll containing +# both modules ssl.context and ssl.core). The CMake target name will be +# ssl_all_in_one. +# Also sets variable _module_path (relative path where module typically +# would be installed). +macro ( add_lua_module ) + _lua_module_helper ( 0 ${ARGN} ) +endmacro () + + +# install_lua_module +# This is the same as `add_lua_module` but also installs the module. +# USE: install_lua_module ( socket.http src/http.lua ) +# USE2: install_lua_module ( mime.core src/mime.c ) +# USE3: install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} ) +macro ( install_lua_module ) + _lua_module_helper ( 1 ${ARGN} ) +endmacro () + +# Builds string representing Lua table mapping Lua modules names to file +# paths. Used internally. +macro ( _make_module_table _outvar ) + set ( ${_outvar} ) + list ( LENGTH _lua_modules _n ) + if ( ${_n} GREATER 0 ) # avoids cmake complaint + foreach ( _i RANGE 1 ${_n} 2 ) + list ( GET _lua_modules ${_i} _path ) + math ( EXPR _ii ${_i}-1 ) + list ( GET _lua_modules ${_ii} _name ) + set ( ${_outvar} "${_table} ['${_name}'] = '${_path}'\;\n") + endforeach () + endif () + set ( ${_outvar} +"local modules = { +${_table}}" ) +endmacro () + +# add_lua_test ( _testfile [ WORKING_DIRECTORY _working_dir ] ) +# Runs Lua script `_testfile` under CTest tester. +# Optional named argument `WORKING_DIRECTORY` is current working directory to +# run test under (defaults to ${CMAKE_CURRENT_BINARY_DIR}). +# Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}. +# Any modules previously defined with install_lua_module are automatically +# preloaded (via package.preload) prior to running the test script. +# Under LuaDist, set test=true in config.lua to enable testing. +# USE: add_lua_test ( test/test1.lua [args...] [WORKING_DIRECTORY dir]) +macro ( add_lua_test _testfile ) + if ( NOT SKIP_TESTING ) + parse_arguments ( _ARG "WORKING_DIRECTORY" "" ${ARGN} ) + include ( CTest ) + find_program ( LUA NAMES lua lua.bat ) + get_filename_component ( TESTFILEABS ${_testfile} ABSOLUTE ) + get_filename_component ( TESTFILENAME ${_testfile} NAME ) + get_filename_component ( TESTFILEBASE ${_testfile} NAME_WE ) + + # Write wrapper script. + # Note: One simple way to allow the script to find modules is + # to just put them in package.preload. + set ( TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME} ) + _make_module_table ( _table ) + set ( TESTWRAPPERSOURCE +"local CMAKE_CFG_INTDIR = ... or '.' +${_table} +local function preload_modules(modules) + for name, path in pairs(modules) do + if path:match'%.lua' then + package.preload[name] = assert(loadfile(path)) + else + local name = name:gsub('.*%-', '') -- remove any hyphen prefix + local symbol = 'luaopen_' .. name:gsub('%.', '_') + --improve: generalize to support all-in-one loader? + local path = path:gsub('%$%{CMAKE_CFG_INTDIR%}', CMAKE_CFG_INTDIR) + package.preload[name] = assert(package.loadlib(path, symbol)) + end + end +end +preload_modules(modules) +arg[0] = '${TESTFILEABS}' +table.remove(arg, 1) +return assert(loadfile '${TESTFILEABS}')(unpack(arg)) +" ) + if ( _ARG_WORKING_DIRECTORY ) + get_filename_component ( + TESTCURRENTDIRABS ${_ARG_WORKING_DIRECTORY} ABSOLUTE ) + # note: CMake 2.6 (unlike 2.8) lacks WORKING_DIRECTORY parameter. + set ( _pre ${CMAKE_COMMAND} -E chdir "${TESTCURRENTDIRABS}" ) + endif () + file ( WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE}) + add_test ( NAME ${TESTFILEBASE} COMMAND ${_pre} ${LUA} + ${TESTWRAPPER} "${CMAKE_CFG_INTDIR}" + ${_ARG_DEFAULT_ARGS} ) + endif () + # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake + # Note: ${CMAKE_CFG_INTDIR} is a command-line argument to allow proper + # expansion by the native build tool. +endmacro () + + +# Converts Lua source file `_source` to binary string embedded in C source +# file `_target`. Optionally compiles Lua source to byte code (not available +# under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua +# versions of bin2c [1] and luac [2] may be passed respectively as additional +# arguments. +# +# [1] http://lua-users.org/wiki/BinToCee +# [2] http://lua-users.org/wiki/LuaCompilerInLua +function ( add_lua_bin2c _target _source ) + find_program ( LUA NAMES lua lua.bat ) + execute_process ( COMMAND ${LUA} -e "string.dump(function()end)" + RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET ) + if ( NOT ${_LUA_DUMP_RESULT} ) + SET ( HAVE_LUA_DUMP true ) + endif () + message ( "-- string.dump=${HAVE_LUA_DUMP}" ) + + if ( ARGV2 ) + get_filename_component ( BIN2C ${ARGV2} ABSOLUTE ) + set ( BIN2C ${LUA} ${BIN2C} ) + else () + find_program ( BIN2C NAMES bin2c bin2c.bat ) + endif () + if ( HAVE_LUA_DUMP ) + if ( ARGV3 ) + get_filename_component ( LUAC ${ARGV3} ABSOLUTE ) + set ( LUAC ${LUA} ${LUAC} ) + else () + find_program ( LUAC NAMES luac luac.bat ) + endif () + endif ( HAVE_LUA_DUMP ) + message ( "-- bin2c=${BIN2C}" ) + message ( "-- luac=${LUAC}" ) + + get_filename_component ( SOURCEABS ${_source} ABSOLUTE ) + if ( HAVE_LUA_DUMP ) + get_filename_component ( SOURCEBASE ${_source} NAME_WE ) + add_custom_command ( + OUTPUT ${_target} DEPENDS ${_source} + COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo + ${SOURCEABS} + COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo + ">${_target}" ) + else () + add_custom_command ( + OUTPUT ${_target} DEPENDS ${SOURCEABS} + COMMAND ${BIN2C} ${_source} ">${_target}" ) + endif () +endfunction() diff --git a/dist.cmake b/dist.cmake deleted file mode 100644 index 10c6a68c..00000000 --- a/dist.cmake +++ /dev/null @@ -1,450 +0,0 @@ -# LuaDist CMake utility library. -# Provides variables and utility functions common to LuaDist CMake builds. -# -# Copyright (C) 2007-2011 LuaDist. -# by David Manura, Peter Drahos -# Redistribution and use of this file is allowed according to the terms of the MIT license. -# For details see the COPYRIGHT file distributed with LuaDist. -# Please note that the package source code is licensed under its own license. - -## INSTALL DEFAULTS (Relative to CMAKE_INSTALL_PREFIX) -# Primary paths -set ( INSTALL_BIN bin CACHE PATH "Where to install binaries to." ) -set ( INSTALL_LIB lib CACHE PATH "Where to install libraries to." ) -set ( INSTALL_INC include CACHE PATH "Where to install headers to." ) -set ( INSTALL_ETC etc CACHE PATH "Where to store configuration files" ) -set ( INSTALL_LMOD ${INSTALL_LIB}/lua CACHE PATH "Directory to install Lua modules." ) -set ( INSTALL_CMOD ${INSTALL_LIB}/lua CACHE PATH "Directory to install Lua binary modules." ) -set ( INSTALL_SHARE share CACHE PATH "Directory for shared data." ) - -# Secondary paths -set ( INSTALL_DATA ${INSTALL_SHARE}/${PROJECT_NAME} CACHE PATH "Directory the package can store documentation, tests or other data in.") -set ( INSTALL_DOC ${INSTALL_DATA}/doc CACHE PATH "Recommended directory to install documentation into.") -set ( INSTALL_EXAMPLE ${INSTALL_DATA}/example CACHE PATH "Recommended directory to install examples into.") -set ( INSTALL_TEST ${INSTALL_DATA}/test CACHE PATH "Recommended directory to install tests into.") -set ( INSTALL_FOO ${INSTALL_DATA}/etc CACHE PATH "Where to install additional files") - -# Skipable content, headers, binaries and libraries are always required -option ( SKIP_TESTING "Do not add tests." OFF) -option ( SKIP_LUA_WRAPPER "Do not build and install Lua executable wrappers." OFF) -option ( SKIP_INSTALL_DATA "Skip installing all data." OFF ) -if ( NOT SKIP_INSTALL_DATA ) - option ( SKIP_INSTALL_DOC "Skip installation of documentation." OFF ) - option ( SKIP_INSTALL_EXAMPLE "Skip installation of documentation." OFF ) - option ( SKIP_INSTALL_TEST "Skip installation of tests." OFF) - option ( SKIP_INSTALL_FOO "Skip installation of optional package content." OFF) -endif () - -# TWEAKS -# Setting CMAKE to use loose block and search for find modules in source directory -set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) -set ( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) - -# In MSVC, prevent warnings that can occur when using standard libraries. -if ( MSVC ) - add_definitions ( -D_CRT_SECURE_NO_WARNINGS ) -endif () - -## MACROS -# Parser macro -macro ( parse_arguments prefix arg_names option_names) - set ( DEFAULT_ARGS ) - foreach ( arg_name ${arg_names} ) - set ( ${prefix}_${arg_name} ) - endforeach () - foreach ( option ${option_names} ) - set ( ${prefix}_${option} FALSE ) - endforeach () - - set ( current_arg_name DEFAULT_ARGS ) - set ( current_arg_list ) - foreach ( arg ${ARGN} ) - set ( larg_names ${arg_names} ) - list ( FIND larg_names "${arg}" is_arg_name ) - if ( is_arg_name GREATER -1 ) - set ( ${prefix}_${current_arg_name} ${current_arg_list} ) - set ( current_arg_name ${arg} ) - set ( current_arg_list ) - else () - set ( loption_names ${option_names} ) - list ( FIND loption_names "${arg}" is_option ) - if ( is_option GREATER -1 ) - set ( ${prefix}_${arg} TRUE ) - else () - set ( current_arg_list ${current_arg_list} ${arg} ) - endif () - endif () - endforeach () - set ( ${prefix}_${current_arg_name} ${current_arg_list} ) -endmacro () - -# INSTALL_LUA_EXECUTABLE ( target source ) -# Automatically generate a binary wrapper for lua application and install it -# The wrapper and the source of the application will be placed into /bin -# If the application source did not have .lua suffix then it will be added -# USE: lua_executable ( sputnik src/sputnik.lua ) -macro ( install_lua_executable _name _source ) - get_filename_component ( _source_name ${_source} NAME_WE ) - if ( NOT SKIP_LUA_WRAPPER ) - enable_language ( C ) - - find_package ( Lua51 REQUIRED ) - include_directories ( ${LUA_INCLUDE_DIR} ) - - set ( _wrapper ${CMAKE_CURRENT_BINARY_DIR}/${_name}.c ) - set ( _code -"// Not so simple executable wrapper for Lua apps -#include -#include -#include -#include -#include - -lua_State *L\; - -static int getargs (lua_State *L, char **argv, int n) { -int narg\; -int i\; -int argc = 0\; -while (argv[argc]) argc++\; -narg = argc - (n + 1)\; -luaL_checkstack(L, narg + 3, \"too many arguments to script\")\; -for (i=n+1\; i < argc\; i++) - lua_pushstring(L, argv[i])\; -lua_createtable(L, narg, n + 1)\; -for (i=0\; i < argc\; i++) { - lua_pushstring(L, argv[i])\; - lua_rawseti(L, -2, i - n)\; -} -return narg\; -} - -static void lstop (lua_State *L, lua_Debug *ar) { -(void)ar\; -lua_sethook(L, NULL, 0, 0)\; -luaL_error(L, \"interrupted!\")\; -} - -static void laction (int i) { -signal(i, SIG_DFL)\; -lua_sethook(L, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1)\; -} - -static void l_message (const char *pname, const char *msg) { -if (pname) fprintf(stderr, \"%s: \", pname)\; -fprintf(stderr, \"%s\\n\", msg)\; -fflush(stderr)\; -} - -static int report (lua_State *L, int status) { -if (status && !lua_isnil(L, -1)) { - const char *msg = lua_tostring(L, -1)\; - if (msg == NULL) msg = \"(error object is not a string)\"\; - l_message(\"${_source_name}\", msg)\; - lua_pop(L, 1)\; -} -return status\; -} - -static int traceback (lua_State *L) { -if (!lua_isstring(L, 1)) - return 1\; -lua_getfield(L, LUA_GLOBALSINDEX, \"debug\")\; -if (!lua_istable(L, -1)) { - lua_pop(L, 1)\; - return 1\; -} -lua_getfield(L, -1, \"traceback\")\; -if (!lua_isfunction(L, -1)) { - lua_pop(L, 2)\; - return 1\; -} -lua_pushvalue(L, 1)\; -lua_pushinteger(L, 2)\; -lua_call(L, 2, 1)\; -return 1\; -} - -static int docall (lua_State *L, int narg, int clear) { -int status\; -int base = lua_gettop(L) - narg\; -lua_pushcfunction(L, traceback)\; -lua_insert(L, base)\; -signal(SIGINT, laction)\; -status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base)\; -signal(SIGINT, SIG_DFL)\; -lua_remove(L, base)\; -if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0)\; -return status\; -} - -int main (int argc, char **argv) { -L=lua_open()\; -lua_gc(L, LUA_GCSTOP, 0)\; -luaL_openlibs(L)\; -lua_gc(L, LUA_GCRESTART, 0)\; -int narg = getargs(L, argv, 0)\; -lua_setglobal(L, \"arg\")\; - -// Script -char script[500] = \"./${_source_name}.lua\"\; -lua_getglobal(L, \"_PROGDIR\")\; -if (lua_isstring(L, -1)) { - sprintf( script, \"%s/${_source_name}.lua\", lua_tostring(L, -1))\; -} -lua_pop(L, 1)\; - -// Run -int status = luaL_loadfile(L, script)\; -lua_insert(L, -(narg+1))\; -if (status == 0) - status = docall(L, narg, 0)\; -else - lua_pop(L, narg)\; - -report(L, status)\; -lua_close(L)\; -return status\; -}; -") - file ( WRITE ${_wrapper} ${_code} ) - add_executable ( ${_name} ${_wrapper} ) - target_link_libraries ( ${_name} ${LUA_LIBRARY} ) - install ( TARGETS ${_name} DESTINATION ${INSTALL_BIN} ) - endif() - install ( PROGRAMS ${_source} DESTINATION ${INSTALL_BIN} RENAME ${_source_name}.lua ) -endmacro () - -# INSTALL_LIBRARY -# Installs any libraries generated using "add_library" into apropriate places. -# USE: install_library ( libexpat ) -macro ( install_library ) - foreach ( _file ${ARGN} ) - install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB} ) - endforeach() -endmacro () - -# INSTALL_EXECUTABLE -# Installs any executables generated using "add_executable". -# USE: install_executable ( lua ) -macro ( install_executable ) - foreach ( _file ${ARGN} ) - install ( TARGETS ${_file} RUNTIME DESTINATION ${INSTALL_BIN} ) - endforeach() -endmacro () - -# INSTALL_HEADER -# Install a directories or files into header destination. -# USE: install_header ( lua.h luaconf.h ) or install_header ( GL ) -# NOTE: If headers need to be installed into subdirectories use the INSTALL command directly -macro ( install_header ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_INC}/${_ARG_INTO} ) - endif () - endforeach() -endmacro () - -# INSTALL_DATA ( files/directories ) -# This installs additional data files or directories. -# USE: install_data ( extra data.dat ) -macro ( install_data ) - if ( NOT SKIP_INSTALL_DATA ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_DATA}/${_ARG_INTO} ) - endif () - endforeach() - endif() -endmacro () - -# INSTALL_DOC ( files/directories ) -# This installs documentation content -# USE: install_doc ( doc/ ) -macro ( install_doc ) - if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_DOC ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_DOC}/${_ARG_INTO} ) - endif () - endforeach() - endif() -endmacro () - -# INSTALL_EXAMPLE ( files/directories ) -# This installs additional data -# USE: install_example ( examples/ exampleA.lua ) -macro ( install_example ) - if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_EXAMPLE ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_EXAMPLE}/${_ARG_INTO} ) - endif () - endforeach() - endif() -endmacro () - -# INSTALL_TEST ( files/directories ) -# This installs tests -# USE: install_example ( examples/ exampleA.lua ) -macro ( install_test ) - if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_TEST ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_TEST}/${_ARG_INTO} ) - endif () - endforeach() - endif() -endmacro () - -# INSTALL_FOO ( files/directories ) -# This installs optional content -# USE: install_foo ( examples/ exampleA.lua ) -macro ( install_foo ) - if ( NOT SKIP_INSTALL_DATA AND NOT SKIP_INSTALL_FOO ) - parse_arguments ( _ARG "INTO" "" ${ARGN} ) - foreach ( _file ${_ARG_DEFAULT_ARGS} ) - if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_file}" ) - install ( DIRECTORY ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} ) - else () - install ( FILES ${_file} DESTINATION ${INSTALL_FOO}/${_ARG_INTO} ) - endif () - endforeach() - endif() -endmacro () - -# INSTALL_LUA_MODULE -# This macro installs a lua source module into destination given by lua require syntax. -# Binary modules are also supported where this funcion takes sources and libraries to compile separated by LINK keyword -# USE: install_lua_module ( socket.http src/http.lua ) -# USE2: install_lua_module ( mime.core src/mime.c ) -# USE3: install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} ) -macro (install_lua_module _name ) - string ( REPLACE "." "/" _module "${_name}" ) - string ( REPLACE "." "_" _target "${_name}" ) - - set ( _lua_module "${_module}.lua" ) - set ( _bin_module "${_module}${CMAKE_SHARED_MODULE_SUFFIX}" ) - - parse_arguments ( _MODULE "LINK" "" ${ARGN} ) - get_filename_component ( _ext ${ARGV1} EXT ) - if ( _ext STREQUAL ".lua" ) - get_filename_component ( _path ${_lua_module} PATH ) - get_filename_component ( _filename ${_lua_module} NAME ) - install ( FILES ${ARGV1} DESTINATION ${INSTALL_LMOD}/${_path} RENAME ${_filename} ) - else () - enable_language ( C ) - get_filename_component ( _module_name ${_bin_module} NAME_WE ) - get_filename_component ( _module_path ${_bin_module} PATH ) - - find_package ( Lua51 REQUIRED ) - include_directories ( ${LUA_INCLUDE_DIR} ) - - add_library( ${_target} MODULE ${_MODULE_DEFAULT_ARGS}) - target_link_libraries ( ${_target} ${LUA_LIBRARY} ${_MODULE_LINK} ) - set_target_properties ( ${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${_module_path}" PREFIX "" OUTPUT_NAME "${_module_name}" ) - - install ( TARGETS ${_target} DESTINATION ${INSTALL_CMOD}/${_module_path}) - endif () -endmacro () - -# ADD_LUA_TEST -# Runs Lua script `_testfile` under CTest tester. -# Optional named argument `WORKING_DIRECTORY` is current working directory to run test under -# (defaults to ${CMAKE_CURRENT_BINARY_DIR}). -# Both paths, if relative, are relative to ${CMAKE_CURRENT_SOURCE_DIR}. -# Under LuaDist, set test=true in config.lua to enable testing. -# USE: add_lua_test ( test/test1.lua [args...] [WORKING_DIRECTORY dir]) -macro ( add_lua_test _testfile ) - if ( NOT SKIP_TESTING ) - parse_arguments ( _ARG "WORKING_DIRECTORY" "" ${ARGN} ) - include ( CTest ) - find_program ( LUA NAMES lua lua.bat ) - get_filename_component ( TESTFILEABS ${_testfile} ABSOLUTE ) - get_filename_component ( TESTFILENAME ${_testfile} NAME ) - get_filename_component ( TESTFILEBASE ${_testfile} NAME_WE ) - - # Write wrapper script. - set ( TESTWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/${TESTFILENAME} ) - set ( TESTWRAPPERSOURCE -"local configuration = ... -local sodir = '${CMAKE_CURRENT_BINARY_DIR}' .. (configuration == '' and '' or '/' .. configuration) -package.path = sodir .. '/?.lua\;' .. sodir .. '/?.lua\;' .. package.path -package.cpath = sodir .. '/?.so\;' .. sodir .. '/?.dll\;' .. package.cpath -arg[0] = '${TESTFILEABS}' -table.remove(arg, 1) -return assert(loadfile '${TESTFILEABS}')(unpack(arg)) -" ) - if ( _ARG_WORKING_DIRECTORY ) - get_filename_component ( TESTCURRENTDIRABS ${_ARG_WORKING_DIRECTORY} ABSOLUTE ) - # note: CMake 2.6 (unlike 2.8) lacks WORKING_DIRECTORY parameter. -#old: set ( TESTWRAPPERSOURCE "require 'lfs'; lfs.chdir('${TESTCURRENTDIRABS}' ) ${TESTWRAPPERSOURCE}" ) - set ( _pre ${CMAKE_COMMAND} -E chdir "${TESTCURRENTDIRABS}" ) - endif () - file ( WRITE ${TESTWRAPPER} ${TESTWRAPPERSOURCE}) - add_test ( NAME ${TESTFILEBASE} COMMAND ${_pre} ${LUA} ${TESTWRAPPER} $ ${_ARG_DEFAULT_ARGS} ) - endif () - # see also http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake -endmacro () - -# Converts Lua source file `_source` to binary string embedded in C source -# file `_target`. Optionally compiles Lua source to byte code (not available -# under LuaJIT2, which doesn't have a bytecode loader). Additionally, Lua -# versions of bin2c [1] and luac [2] may be passed respectively as additional -# arguments. -# -# [1] http://lua-users.org/wiki/BinToCee -# [2] http://lua-users.org/wiki/LuaCompilerInLua -function ( add_lua_bin2c _target _source ) - find_program ( LUA NAMES lua lua.bat ) - execute_process ( COMMAND ${LUA} -e "string.dump(function()end)" RESULT_VARIABLE _LUA_DUMP_RESULT ERROR_QUIET ) - if ( NOT ${_LUA_DUMP_RESULT} ) - SET ( HAVE_LUA_DUMP true ) - endif () - message ( "-- string.dump=${HAVE_LUA_DUMP}" ) - - if ( ARGV2 ) - get_filename_component ( BIN2C ${ARGV2} ABSOLUTE ) - set ( BIN2C ${LUA} ${BIN2C} ) - else () - find_program ( BIN2C NAMES bin2c bin2c.bat ) - endif () - if ( HAVE_LUA_DUMP ) - if ( ARGV3 ) - get_filename_component ( LUAC ${ARGV3} ABSOLUTE ) - set ( LUAC ${LUA} ${LUAC} ) - else () - find_program ( LUAC NAMES luac luac.bat ) - endif () - endif ( HAVE_LUA_DUMP ) - message ( "-- bin2c=${BIN2C}" ) - message ( "-- luac=${LUAC}" ) - - get_filename_component ( SOURCEABS ${_source} ABSOLUTE ) - if ( HAVE_LUA_DUMP ) - get_filename_component ( SOURCEBASE ${_source} NAME_WE ) - add_custom_command ( - OUTPUT ${_target} DEPENDS ${_source} - COMMAND ${LUAC} -o ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ${SOURCEABS} - COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCEBASE}.lo ">${_target}" ) - else () - add_custom_command ( - OUTPUT ${_target} DEPENDS ${SOURCEABS} - COMMAND ${BIN2C} ${_source} ">${_target}" ) - endif () -endfunction() From 5a3a2ebc16c55a34aa8b79b78988d8ca826de259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 11 May 2012 12:41:22 +0200 Subject: [PATCH 11/48] Updated icons --- etc/lua.ico | Bin 1078 -> 116114 bytes etc/lua_lang.ico | Bin 0 -> 119793 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 etc/lua_lang.ico diff --git a/etc/lua.ico b/etc/lua.ico index ccbabc4e2004683f29598a991006d7caff6d837d..1dd0d0d5775e1c50598dbab3e8740102886eb925 100644 GIT binary patch literal 116114 zcmeEP1z1$g*S||6Dk36cfgRZ0V2hn#q1YlV7>JaOg^HN3iuD@Ut*BsviQS5U9iWIb z^Zm}Uci&~%g%nBgg66bKDe!!w6>();Vxod&-MEItcob;denIs zxYwh4@vMf6j!v9=>C$YnK}qJOtIMX8G-OU18qBL=CFWL4kGW`TucLCvFRV{=EyM@) z1^;Vn%QgvSl4Ru^o<1ENtZ}o+eMKm++<-yw!8&I3qjIELna|{RV7` zehD_MbQ$)Kr4?Il(UmX1nlC59-w-_4M*S(iRjYztO+KG6-aK*?dvNj;TW2+pPoFI+ zFQl9216Rd z1}A5yGIWn;b&+Q?!V84Y2$v9?oH$Ms@lyn%Ed@NwgaeNU=rNRpOV=c8N=LcdqVn;i z=hFEk@){vO1w906e?nOUw+bllfw-xxvdX4O+XH3q$V7D zXj9FhW0eqB0`J?~+uN(+z8|$U+&4z3o!>Y*I5?1wSUEa6Y9nN8Z=p}>z@;4WTjU2G zpv{cn@HR;qn69p_dMMvfnKFD{(5XtafQ|}$8Xu#*m4luSLhyvn`%z5yl+NejW0WTx ziYSXe$_zmnZ5|HAXqVkkAN4zFWK$7~gXo@Y)EVH?O|l%|=mMU?@*rKxR37#KF!xH< zm(w-!?*~6J*%9DSMG~&8Ys!OApMM6L%b~7^In^iU`9t6#mI>h2g*-Ch#MeVH$q2NI z^&5Sc4&dID16$1d9G>3eG)+EL@cNHEAaF69|q(9ppEO`OBwE$KZPv z)SY54P+`w+++a5j9AuZaZWD%W6CBv45hK~7v**}8PcQZY&-c4~u%#V3v1gYqv46+e zvWTt!viDD(Fz?D$2`}oCs_}Jz&te|)X=GP`S6lubI4=_NRaCzSj+p16@HtlY?kl|C z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4yw|O4ZVd>-x2&K4v}wz4@R(u9@}h2_kVT z4Kk4$c|UH49NP7iDsk%9_N$Ia-1ZVha}p5wpI_AWRMbRFC}#*~rijJL+-Ha4r7j~| zbUEs@B=1WL2y>OW>t5D*$FOi3wW@2J1a9+l71^6bk%9kHUtCq^`BW`{UtnIy{j}~> zJNFx2re$U&na42vfEEP2y5G5t!sm9s;$IoWqnW;ia%8+G)hu7xl4E|D3VJbX9VX7GW1~6FSw!BIQq_T0tNo32b^bxZ4H5fZGR7xh?&v!Y3 zDh3=J`#b+#Yy%W{!g4u>(a#g`Mme7+yefc~5wPOflDr`o81qe{?|t$BfABsDzNw;V z8cH*0{6W<;G9Np#7ik(qoR4aR5-A@{5)}DJ9&}FRBA#X_5+im4-kQSzMF^)-t2(Vi ztw-^|Sn8@O_lM9`oos+0wMZGt&`Bq(aK&XCv1Gfr&Jtd6%lKPdD{s=unqGWyb3%y{X9SS{jB~HMh0oKMISQrDC zJ;K?)>ElnpmN^UNE-rXxtyk{c#rCe~`P=qnFT7 bCxwx*w%~s~=?o*z_6Fk4@7l(poWF`cPpA(! diff --git a/etc/lua_lang.ico b/etc/lua_lang.ico new file mode 100644 index 0000000000000000000000000000000000000000..b189462da2499e4e077d5c1a05aa5cb106beceaf GIT binary patch literal 119793 zcmeEP30#a@8=p3*BwZ4+6hh(>vXdln$)31&3GEV+q_WE;*+K|O5|`{`UoP3V>^s>L zk|a6b|9P8t?ljHROpE1y&F}ZjS>Cfe+j-9Vo>w4H5|j{>DIX6O5R4QE1cruL z;f;vDfVhSYg<)fXV1k}N(5_upxK4Y4plU0DARs^(E~zBw=!XLEqw=P86A0XAC<*Ey zjG_>e6%R+y4&_Sz7-LG(z|+%HAD}CQvT${zrIU<9x{3r+;*B966e8_8P~Itq5adG&C9NsXun?SY3B_cNJk-6%nTfeA6iZ_}|KM zxNjOej?MhN0b6L@kwv?Eup^<%c$)k?JUj?zZ61d)0zpL=&@7&RrdcEAUA7#XRLOv? z>}$^!cm9LV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zn7X8xI^%aa1r8#USG4lQh>;dUk%b!E{indd`=^qDV#0g(xwT=I_#FMX^%&*JK~cY` zd>~El?t{`D*gK3vC{gu0Q8Cm3jSmBAqN3x6v2= zyoa0QgDf}yY`*9BOO#1(MNiQJd`~h9as~U;5~re{>&xRc$7YYKPGsp3aD}XdD{5$w zm}IlQkqv45OPbI@EQxf!mmcwKWgU7cRS@mZtd0_OV~jsSi@~ww4AfNU{qD2#B?%);`ttSUgaXW^8b-ys)4gN_1G%$k25=@lPu6}D4@_!`UniT*5 literal 0 HcmV?d00001 From 0c085822a7055ec20aefe7582abe875a7af59f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 11 May 2012 12:41:46 +0200 Subject: [PATCH 12/48] Updated rc files --- src/lua.rc | 10 +++++----- src/luac.rc | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lua.rc b/src/lua.rc index 9829ab27..38b72d45 100644 --- a/src/lua.rc +++ b/src/lua.rc @@ -1,4 +1,4 @@ -0 ICON "../etc/lua.ico" +0 ICON "../etc/lua_lang.ico" 1 VERSIONINFO FILEVERSION 5,2,0,0 @@ -10,12 +10,12 @@ BEGIN BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" - VALUE "FileDescription", "Lua Console Standalone Interpreter\0" - VALUE "FileVersion", "5.2.0-beta\0" - VALUE "LegalCopyright", "Copyright © 1994-2011 Lua.org, PUC-Rio.\0" + VALUE "FileDescription", "Lua Standalone Interpreter\0" + VALUE "FileVersion", "5.2.0\0" + VALUE "LegalCopyright", "Copyright © 1994-2012 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "lua.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.0-beta\0" + VALUE "ProductVersion", "5.2.0\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END diff --git a/src/luac.rc b/src/luac.rc index 82cc2527..ce2346ab 100644 --- a/src/luac.rc +++ b/src/luac.rc @@ -10,12 +10,12 @@ BEGIN BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" - VALUE "FileDescription", "Lua Console Compiler\0" - VALUE "FileVersion", "5.2.0-beta\0" - VALUE "LegalCopyright", "Copyright © 1994-2011 Lua.org, PUC-Rio.\0" + VALUE "FileDescription", "Lua Compiler\0" + VALUE "FileVersion", "5.2.0\0" + VALUE "LegalCopyright", "Copyright © 1994-2012 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "luac.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.0-beta\0" + VALUE "ProductVersion", "5.2.0\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END From 47bda2e9009c8d290dba0943d437768bddd533d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 15 Jun 2012 12:17:15 +0200 Subject: [PATCH 13/48] Updated to Lua 5.2.1 --- CMakeLists.txt | 78 +++----- Makefile | 2 +- README.md | 4 +- dist.info | 2 +- doc/contents.html | 8 +- doc/lua.css | 10 +- doc/manual.css | 4 +- doc/manual.html | 266 +++++++++++++++------------ doc/readme.html | 17 +- src/Makefile | 2 +- src/lapi.c | 20 +- src/lauxlib.c | 19 +- src/lbaselib.c | 3 +- src/lcorolib.c | 5 +- src/ldblib.c | 21 ++- src/ldebug.c | 13 +- src/ldo.c | 32 ++-- src/ldump.c | 7 +- src/lfunc.c | 20 +- src/lfunc.h | 5 +- src/lgc.c | 456 ++++++++++++++++++++++++++++------------------ src/lgc.h | 10 +- src/llex.c | 27 ++- src/llimits.h | 17 +- src/lmathlib.c | 12 +- src/lmem.c | 18 +- src/loadlib.c | 97 +++++----- src/lobject.h | 75 ++++---- src/lopcodes.c | 3 +- src/loslib.c | 17 +- src/lparser.c | 153 +++++++++------- src/lparser.h | 6 +- src/lstate.c | 42 ++++- src/lstate.h | 20 +- src/lstring.c | 115 +++++++++--- src/lstring.h | 17 +- src/lstrlib.c | 35 ++-- src/ltable.c | 27 ++- src/lua.c | 31 ++-- src/lua.h | 8 +- src/luaconf.h.in | 74 +++++++- src/lundump.c | 38 ++-- src/lundump.h | 4 +- src/lvm.c | 50 ++--- src/lzio.c | 4 +- 45 files changed, 1121 insertions(+), 773 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b953a3d..e445082b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -# Copyright (C) 2007-2011 LuaDist. +# Copyright (C) 2007-2012 LuaDist. # Created by Peter DrahoÅ¡, Peter Kapec # Redistribution and use of this file is allowed according to the terms of the MIT license. # For details see the COPYRIGHT file distributed with LuaDist. # Please note that the package source code is licensed under its own license. project ( lua C ) -cmake_minimum_required ( VERSION 2.6 ) +cmake_minimum_required ( VERSION 2.8 ) include ( cmake/dist.cmake ) ## CONFIGURATION @@ -20,7 +20,6 @@ option ( LUA_COMPAT_ALL "Enable backwards compatibility options." ON ) set ( LUA_IDSIZE 60 CACHE NUMBER "gives the maximum size for the description of the source." ) #2DO: LUAI_* and LUAL_* settings, for now defaults are used. - set ( LUA_DIRSEP "/" ) set ( LUA_MODULE_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX} ) set ( LUA_LDIR ${INSTALL_LMOD} ) @@ -29,10 +28,10 @@ set ( LUA_CDIR ${INSTALL_CMOD} ) if ( LUA_USE_RELATIVE_LOADLIB ) # This will set up relative paths to lib string ( REGEX REPLACE "[^!/]+" ".." LUA_DIR "!/${INSTALL_BIN}/" ) -else () +else ( ) # Direct path to installation - set ( LUA_DIR ${CMAKE_INSTALL_PREFIX} CACHE STRING "Destination from which modules will be resolved. See INSTALL_LMOD and INSTALL_CMOD.") -endif () + set ( LUA_DIR ${CMAKE_INSTALL_PREFIX} CACHE STRING "Destination from which modules will be resolved. See INSTALL_LMOD and INSTALL_CMOD." ) +endif ( ) set ( LUA_PATH_DEFAULT "./?.lua;${LUA_DIR}${LUA_LDIR}/?.lua;${LUA_DIR}${LUA_LDIR}/?/init.lua" ) set ( LUA_CPATH_DEFAULT "./?${LUA_MODULE_SUFFIX};${LUA_DIR}${LUA_CDIR}/?${LUA_MODULE_SUFFIX};${LUA_DIR}${LUA_CDIR}/loadall${LUA_MODULE_SUFFIX}" ) @@ -42,59 +41,58 @@ if ( WIN32 AND NOT CYGWIN ) option ( LUA_WIN "Windows specific build." ON ) option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON ) # Paths (Double escapes needed) - set ( LUA_DIRSEP "\\\\" ) - string ( REPLACE "/" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) + set ( LUA_DIRSEP "\\\\" ) string ( REPLACE " /" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_LDIR "${LUA_LDIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_CDIR "${LUA_CDIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_PATH_DEFAULT "${LUA_PATH_DEFAULT}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_CPATH_DEFAULT "${LUA_CPATH_DEFAULT}" ) -else () +else ( ) # Posix systems (incl. Cygwin) option ( LUA_USE_POSIX "Use POSIX functionality." ON ) option ( LUA_USE_DLOPEN "Use dynamic linker to load modules." ON ) option ( LUA_USE_MKSTEMP "Use mkstep." ON ) option ( LUA_USE_ISATTY "Use tty." ON ) option ( LUA_USE_POPEN "Use popen." ON ) - option ( LUA_USE_ULONGJMP "Use ulongjmp" ON) + option ( LUA_USE_ULONGJMP "Use ulongjmp" ON ) option ( LUA_USE_STRTODHEX "assume 'strtod' handles hexa formats" ON ) option ( LUA_USE_AFORMAT "assume 'printf' handles 'aA' specifiers" ON ) - option ( LUA_USE_LONGLONG "assume support for long long" ON) -endif () + option ( LUA_USE_LONGLONG "assume support for long long" ON ) +endif ( ) ## SETUP # Optional libraries find_package ( Readline ) if ( READLINE_FOUND ) option ( LUA_USE_READLINE "Use readline in the Lua CLI." ON ) -endif () +endif ( ) find_package ( Curses ) if ( CURSES_FOUND ) option ( LUA_USE_CURSES "Use curses in the Lua CLI." ON ) -endif () +endif ( ) # Setup needed variables and libraries if ( LUA_USE_POSIX ) # On POSIX Lua links to standard math library "m" list ( APPEND LIBS m ) -endif () +endif ( ) if ( LUA_USE_DLOPEN ) # Link to dynamic linker library "dl" list ( APPEND LIBS dl ) -endif () +endif ( ) if ( LUA_USE_READLINE ) # Add readline include_directories ( ${READLINE_INCLUDE_DIR} ) list ( APPEND LIBS ${READLINE_LIBRARY} ) -endif () +endif ( ) if ( LUA_USE_CURSES ) # Add curses include_directories ( ${CURSES_INCLUDE_DIR} ) list ( APPEND LIBS ${CURSES_LIBRARY} ) -endif () +endif ( ) ## SOURCES # Generate luaconf.h @@ -102,48 +100,20 @@ configure_file ( src/luaconf.h.in ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) # Sources and headers include_directories ( src ${CMAKE_CURRENT_BINARY_DIR} ) -set ( SRC_CORE - src/lapi.c - src/lcode.c - src/lctype.c - src/ldebug.c - src/ldo.c - src/ldump.c - src/lfunc.c - src/lgc.c - src/llex.c - src/lmem.c - src/lobject.c - src/lopcodes.c - src/lparser.c - src/lstate.c - src/lstring.c - src/ltable.c - src/ltm.c - src/lundump.c - src/lvm.c - src/lzio.c) -set ( SRC_LIB - src/lauxlib.c - src/lbaselib.c - src/lbitlib.c - src/lcorolib.c - src/ldblib.c - src/liolib.c - src/lmathlib.c - src/loslib.c - src/lstrlib.c - src/ltablib.c - src/linit.c) +set ( SRC_CORE src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c + src/lfunc.c src/lgc.c src/llex.c src/lmem.c src/lobject.c src/lopcodes.c src/lparser.c + src/lstate.c src/lstring.c src/ltable.c src/ltm.c src/lundump.c src/lvm.c src/lzio.c ) +set ( SRC_LIB src/lauxlib.c src/lbaselib.c src/lbitlib.c src/lcorolib.c src/ldblib.c + src/liolib.c src/lmathlib.c src/loslib.c src/lstrlib.c src/ltablib.c src/linit.c ) set ( SRC_LUA src/lua.c ) set ( SRC_LUAC src/luac.c ) if ( LUA_USE_RELATIVE_LOADLIB ) # Use modified loadlib list ( APPEND SRC_LIB src/loadlib_rel.c ) -else () +else ( ) list ( APPEND SRC_LIB src/loadlib.c ) -endif () +endif ( ) ## BUILD # Create lua library @@ -161,7 +131,7 @@ install_executable ( lua luac ) install_library ( liblua ) install_data ( README.md ) #install_lua_module ( strict etc/strict.lua ) -install_header (src/lua.h src/lualib.h src/lauxlib.h ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) +install_header ( src/lua.h src/lualib.h src/lauxlib.h ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) install_doc ( doc/ ) install_foo ( etc/ ) #install_test ( test/ ) diff --git a/Makefile b/Makefile index ec53e1a2..bd9515fd 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ TO_MAN= lua.1 luac.1 # Lua version and release. V= 5.2 -R= $V.0 +R= $V.1 # Targets start here. all: $(PLAT) diff --git a/README.md b/README.md index 596c35e1..e07e097e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -This is Lua 5.2, released on 12 Dec 2011. +This is Lua 5.2.1, released on 08 Jun 2012. ================ -[![Build Status](https://secure.travis-ci.org/LuaDist/lua.png?branch=master)](http://travis-ci.org/LuaDist/lua) - For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/dist.info b/dist.info index 95e41d4e..c239db34 100644 --- a/dist.info +++ b/dist.info @@ -1,7 +1,7 @@ --- This file is part of LuaDist project name = "lua" -version = "5.2" +version = "5.2.1" desc = "Lua is a powerful, fast, light-weight, embeddable scripting language." author = "Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo" diff --git a/doc/contents.html b/doc/contents.html index 5342723f..9f506051 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -33,9 +33,9 @@

    index
    -Copyright © 2011 Lua.org, PUC-Rio. +Copyright © 2011–2012 Lua.org, PUC-Rio. Freely available under the terms of the -Lua license. +Lua license.

    Contents

    @@ -521,10 +521,10 @@

    auxiliary library


    Last update: -Tue Nov 29 22:30:23 BRST 2011 +Sat May 26 08:52:25 BRT 2012 diff --git a/doc/lua.css b/doc/lua.css index 54708f82..7fafbb1b 100644 --- a/doc/lua.css +++ b/doc/lua.css @@ -3,8 +3,8 @@ body { background-color: #FFFFFF ; font-family: Helvetica, Arial, sans-serif ; text-align: justify ; - margin-right: 20px ; - margin-left: 20px ; + margin-right: 30px ; + margin-left: 30px ; } h1, h2, h3, h4 { @@ -16,9 +16,9 @@ h1, h2, h3, h4 { h2 { padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 20px ; - padding-right: 20px ; - margin-left: -20px ; + padding-left: 30px ; + padding-right: 30px ; + margin-left: -30px ; background-color: #E0E0FF ; } diff --git a/doc/manual.css b/doc/manual.css index ac357a89..b49b3629 100644 --- a/doc/manual.css +++ b/doc/manual.css @@ -18,7 +18,7 @@ span.apii { p+h1, ul+h1 { padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 20px ; - margin-left: -20px ; + padding-left: 30px ; + margin-left: -30px ; background-color: #E0E0FF ; } diff --git a/doc/manual.html b/doc/manual.html index 360d3168..4ba084df 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,9 +19,9 @@

    by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes

    -Copyright © 2011 Lua.org, PUC-Rio. +Copyright © 2011–2012 Lua.org, PUC-Rio. Freely available under the terms of the -Lua license. +Lua license.


    @@ -33,7 +33,7 @@

    - + @@ -913,6 +913,14 @@

    2.5.1 – Garbage-Collection Metamethods

    its finalizer will never be called twice. +

    +When you close a state (see lua_close), +Lua calls the finalizers of all objects marked for collection, +following the reverse order that they were marked. +If any finalizer marks new objects for collection during that phase, +these new objects will not be finalized. + + @@ -1206,7 +1214,7 @@

    3.1 – Lexical Conventions

    The escape sequence '\z' skips the following span of white-space characters, including line breaks; -it is particularly useful to break and indent a long string +it is particularly useful to break and indent a long literal string into multiple lines without adding the newlines and spaces into the string contents. @@ -1234,7 +1242,7 @@

    3.1 – Lexical Conventions

    and so on. A closing long bracket is defined similarly; for instance, a closing long bracket of level 4 is written as ]====]. -A long string starts with an opening long bracket of any level and +A long literal starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. It can contain any text except a closing bracket of the proper level. Literals in this bracketed form can run for several lines, @@ -2820,8 +2828,7 @@

    4.8 – Functions and Types

    The third field, x, tells whether the function may throw errors: '-' means the function never throws any error; -'m' means the function may throw only memory allocation errors; -'e' means the function may throw other kinds of errors; +'e' means the function may throw errors; 'v' means the function may throw an error on purpose. @@ -2922,7 +2929,7 @@

    4.8 – Functions and Types


    lua_arith

    [-(2|1), +1, e] -

    int lua_arith (lua_State *L, int op);
    +
    void lua_arith (lua_State *L, int op);

    Performs an arithmetic operation over the two values @@ -3183,7 +3190,7 @@

    4.8 – Functions and Types


    lua_createtable

    -[-0, +1, m] +[-0, +1, e]

    void lua_createtable (lua_State *L, int narr, int nrec);

    @@ -3202,7 +3209,7 @@

    4.8 – Functions and Types


    lua_dump

    -[-0, +0, m] +[-0, +0, e]

    int lua_dump (lua_State *L, lua_Writer writer, void *data);

    @@ -3343,7 +3350,7 @@

    4.8 – Functions and Types


    lua_getctx

    [-0, +0, –] -

    int lua_getctx  (lua_State *L, int *ctx);
    +
    int lua_getctx (lua_State *L, int *ctx);

    This function is called by a continuation function (see §4.7) @@ -3740,7 +3747,7 @@

    4.8 – Functions and Types


    lua_newtable

    -[-0, +1, m] +[-0, +1, e]

    void lua_newtable (lua_State *L);

    @@ -3752,7 +3759,7 @@

    4.8 – Functions and Types


    lua_newthread

    -[-0, +1, m] +[-0, +1, e]

    lua_State *lua_newthread (lua_State *L);

    @@ -3773,7 +3780,7 @@

    4.8 – Functions and Types


    lua_newuserdata

    -[-0, +1, m] +[-0, +1, e]

    void *lua_newuserdata (lua_State *L, size_t size);

    @@ -3959,7 +3966,7 @@

    4.8 – Functions and Types


    lua_pushcclosure

    -[-n, +1, m] +[-n, +1, e]

    void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);

    @@ -4025,7 +4032,7 @@

    4.8 – Functions and Types


    lua_pushfstring

    -[-0, +1, m] +[-0, +1, e]

    const char *lua_pushfstring (lua_State *L, const char *fmt, ...);

    @@ -4092,7 +4099,7 @@

    4.8 – Functions and Types


    lua_pushliteral

    -[-0, +1, m] +[-0, +1, e]

    const char *lua_pushliteral (lua_State *L, const char *s);

    @@ -4105,7 +4112,7 @@

    4.8 – Functions and Types


    lua_pushlstring

    -[-0, +1, m] +[-0, +1, e]

    const char *lua_pushlstring (lua_State *L, const char *s, size_t len);

    @@ -4148,7 +4155,7 @@

    4.8 – Functions and Types


    lua_pushstring

    -[-0, +1, m] +[-0, +1, e]

    const char *lua_pushstring (lua_State *L, const char *s);

    @@ -4195,7 +4202,7 @@

    4.8 – Functions and Types


    lua_pushvfstring

    -[-0, +1, m] +[-0, +1, e]

    const char *lua_pushvfstring (lua_State *L,
                                   const char *fmt,
                                   va_list argp);
    @@ -4282,7 +4289,7 @@

    4.8 – Functions and Types


    lua_rawset

    -[-2, +0, m] +[-2, +0, e]

    void lua_rawset (lua_State *L, int index);

    @@ -4294,7 +4301,7 @@

    4.8 – Functions and Types


    lua_rawseti

    -[-1, +0, m] +[-1, +0, e]

    void lua_rawseti (lua_State *L, int index, int n);

    @@ -4313,7 +4320,7 @@

    4.8 – Functions and Types


    lua_rawsetp

    -[-1, +0, m] +[-1, +0, e]

    void lua_rawsetp (lua_State *L, int index, const void *p);

    @@ -4400,7 +4407,7 @@

    4.8 – Functions and Types


    lua_resume

    [-?, +?, –] -

    int lua_resume (lua_State *L, lua_State *from, int narg);
    +
    int lua_resume (lua_State *L, lua_State *from, int nargs);

    Starts and resumes a coroutine in a given thread. @@ -4410,7 +4417,7 @@

    4.8 – Functions and Types

    To start a coroutine, you push onto the thread stack the main function plus any arguments; then you call lua_resume, -with narg being the number of arguments. +with nargs being the number of arguments. This call returns when the coroutine suspends or finishes its execution. When it returns, the stack contains all values passed to lua_yield, or all values returned by the body function. @@ -4550,14 +4557,15 @@

    4.8 – Functions and Types

    typedef struct lua_State lua_State;

    -An opaque structure that keeps the whole state of a Lua interpreter. +An opaque structure that points to a thread and indirectly +(through the thread) to the whole state of a Lua interpreter. The Lua library is fully reentrant: it has no global variables. -All information about a state is kept in this structure. +All information about a state is accessible through this structure.

    -A pointer to this state must be passed as the first argument to +A pointer to this structure must be passed as the first argument to every function in the library, except to lua_newstate, which creates a Lua state from scratch. @@ -4660,7 +4668,7 @@

    4.8 – Functions and Types


    lua_tolstring

    -[-0, +0, m] +[-0, +0, e]

    const char *lua_tolstring (lua_State *L, int index, size_t *len);

    @@ -4743,7 +4751,7 @@

    4.8 – Functions and Types


    lua_tostring

    -[-0, +0, m] +[-0, +0, e]

    const char *lua_tostring (lua_State *L, int index);

    @@ -4848,7 +4856,7 @@

    4.8 – Functions and Types


    lua_typename

    [-0, +0, –] -

    const char *lua_typename  (lua_State *L, int tp);
    +
    const char *lua_typename (lua_State *L, int tp);

    Returns the name of the type encoded by the value tp, @@ -4932,7 +4940,7 @@

    4.8 – Functions and Types


    lua_yield

    [-?, +?, –] -

    int lua_yield  (lua_State *L, int nresults);
    +
    int lua_yield (lua_State *L, int nresults);

    This function is equivalent to lua_yieldk, @@ -4947,7 +4955,7 @@

    4.8 – Functions and Types


    lua_yieldk

    [-?, +?, –] -

    int lua_yieldk  (lua_State *L, int nresults, int ctx, lua_CFunction k);
    +
    int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k);

    Yields a coroutine. @@ -5145,11 +5153,11 @@

    4.9 – The Debug Interface


    lua_getinfo

    -[-(0|1), +(0|1|2), m] +[-(0|1), +(0|1|2), e]

    int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);

    -Returns information about a specific function or function invocation. +Gets information about a specific function or function invocation.

    @@ -5268,7 +5276,7 @@

    4.9 – The Debug Interface

    int lua_getstack (lua_State *L, int level, lua_Debug *ar);

    -Get information about the interpreter runtime stack. +Gets information about the interpreter runtime stack.

    @@ -5345,6 +5353,20 @@

    4.9 – The Debug Interface

    this execution occurs without any calls to hooks. +

    +Hook functions cannot have continuations, +that is, they cannot call lua_yieldk, +lua_pcallk, or lua_callk with a non-null k. + + +

    +Hook functions can yield under the following conditions: +Only count and line events can yield +and they cannot yield any value; +to yield a hook function must finish its execution +calling lua_yield with nresults equal to zero. + + @@ -5450,7 +5472,7 @@

    4.9 – The Debug Interface

    Returns an unique identifier for the upvalue numbered n -from the closure at index fidx. +from the closure at index funcindex. Parameters funcindex and n are as in the lua_getupvalue (see lua_getupvalue) (but n cannot be greater than the number of upvalues). @@ -5467,13 +5489,14 @@

    4.9 – The Debug Interface

    -

    lua_upvaluejoin

    -
    void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
    -                                    int fidx2, int n2);
    +

    lua_upvaluejoin

    +[-0, +0, –] +

    void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
    +                                    int funcindex2, int n2);

    -Make the n1-th upvalue of the Lua closure at index fidx1 -refer to the n2-th upvalue of the Lua closure at index fidx2. +Make the n1-th upvalue of the Lua closure at index funcindex1 +refer to the n2-th upvalue of the Lua closure at index funcindex2. @@ -5538,7 +5561,7 @@

    5.1 – Functions and Types


    luaL_addchar

    -[-?, +?, m] +[-?, +?, e]

    void luaL_addchar (luaL_Buffer *B, char c);

    @@ -5550,7 +5573,7 @@

    5.1 – Functions and Types


    luaL_addlstring

    -[-?, +?, m] +[-?, +?, e]

    void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);

    @@ -5564,7 +5587,7 @@

    5.1 – Functions and Types


    luaL_addsize

    -[-?, +?, m] +[-?, +?, e]

    void luaL_addsize (luaL_Buffer *B, size_t n);

    @@ -5577,7 +5600,7 @@

    5.1 – Functions and Types


    luaL_addstring

    -[-?, +?, m] +[-?, +?, e]

    void luaL_addstring (luaL_Buffer *B, const char *s);

    @@ -5591,7 +5614,7 @@

    5.1 – Functions and Types


    luaL_addvalue

    -[-1, +?, m] +[-1, +?, e]

    void luaL_addvalue (luaL_Buffer *B);

    @@ -5614,7 +5637,7 @@

    5.1 – Functions and Types

    [-0, +0, v]
    void luaL_argcheck (lua_State *L,
                         int cond,
    -                    int narg,
    +                    int arg,
                         const char *extramsg);

    @@ -5627,7 +5650,7 @@

    5.1 – Functions and Types


    luaL_argerror

    [-0, +0, v] -

    int luaL_argerror (lua_State *L, int narg, const char *extramsg);
    +
    int luaL_argerror (lua_State *L, int arg, const char *extramsg);

    Raises an error with a standard message @@ -5686,7 +5709,7 @@

    5.1 – Functions and Types

  • Then copy the string into that space.
  • -Finish by calling luaL_pushresult(&b, sz), +Finish by calling luaL_pushresultsize(&b, sz), where sz is the total size of the resulting string copied into that space.
  • @@ -5728,7 +5751,7 @@

    5.1 – Functions and Types


    luaL_buffinitsize

    -[-?, +?, m] +[-?, +?, e]

    char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);

    @@ -5762,11 +5785,11 @@

    5.1 – Functions and Types


    luaL_checkany

    [-0, +0, v] -

    void luaL_checkany (lua_State *L, int narg);
    +
    void luaL_checkany (lua_State *L, int arg);

    Checks whether the function has an argument -of any type (including nil) at position narg. +of any type (including nil) at position arg. @@ -5774,10 +5797,10 @@

    5.1 – Functions and Types


    luaL_checkint

    [-0, +0, v] -

    int luaL_checkint (lua_State *L, int narg);
    +
    int luaL_checkint (lua_State *L, int arg);

    -Checks whether the function argument narg is a number +Checks whether the function argument arg is a number and returns this number cast to an int. @@ -5786,10 +5809,10 @@

    5.1 – Functions and Types


    luaL_checkinteger

    [-0, +0, v] -

    lua_Integer luaL_checkinteger (lua_State *L, int narg);
    +
    lua_Integer luaL_checkinteger (lua_State *L, int arg);

    -Checks whether the function argument narg is a number +Checks whether the function argument arg is a number and returns this number cast to a lua_Integer. @@ -5798,10 +5821,10 @@

    5.1 – Functions and Types


    luaL_checklong

    [-0, +0, v] -

    long luaL_checklong (lua_State *L, int narg);
    +
    long luaL_checklong (lua_State *L, int arg);

    -Checks whether the function argument narg is a number +Checks whether the function argument arg is a number and returns this number cast to a long. @@ -5810,10 +5833,10 @@

    5.1 – Functions and Types


    luaL_checklstring

    [-0, +0, v] -

    const char *luaL_checklstring (lua_State *L, int narg, size_t *l);
    +
    const char *luaL_checklstring (lua_State *L, int arg, size_t *l);

    -Checks whether the function argument narg is a string +Checks whether the function argument arg is a string and returns this string; if l is not NULL fills *l with the string's length. @@ -5829,10 +5852,10 @@

    5.1 – Functions and Types


    luaL_checknumber

    [-0, +0, v] -

    lua_Number luaL_checknumber (lua_State *L, int narg);
    +
    lua_Number luaL_checknumber (lua_State *L, int arg);

    -Checks whether the function argument narg is a number +Checks whether the function argument arg is a number and returns this number. @@ -5842,12 +5865,12 @@

    5.1 – Functions and Types


    luaL_checkoption

    [-0, +0, v]

    int luaL_checkoption (lua_State *L,
    -                      int narg,
    +                      int arg,
                           const char *def,
                           const char *const lst[]);

    -Checks whether the function argument narg is a string and +Checks whether the function argument arg is a string and searches for this string in the array lst (which must be NULL-terminated). Returns the index in the array where the string was found. @@ -5858,7 +5881,7 @@

    5.1 – Functions and Types

    If def is not NULL, the function uses def as a default value when -there is no argument narg or when this argument is nil. +there is no argument arg or when this argument is nil.

    @@ -5886,10 +5909,10 @@

    5.1 – Functions and Types


    luaL_checkstring

    [-0, +0, v] -

    const char *luaL_checkstring (lua_State *L, int narg);
    +
    const char *luaL_checkstring (lua_State *L, int arg);

    -Checks whether the function argument narg is a string +Checks whether the function argument arg is a string and returns this string. @@ -5903,10 +5926,10 @@

    5.1 – Functions and Types


    luaL_checktype

    [-0, +0, v] -

    void luaL_checktype (lua_State *L, int narg, int t);
    +
    void luaL_checktype (lua_State *L, int arg, int t);

    -Checks whether the function argument narg has type t. +Checks whether the function argument arg has type t. See lua_type for the encoding of types for t. @@ -5915,10 +5938,10 @@

    5.1 – Functions and Types


    luaL_checkudata

    [-0, +0, v] -

    void *luaL_checkudata (lua_State *L, int narg, const char *tname);
    +
    void *luaL_checkudata (lua_State *L, int arg, const char *tname);

    -Checks whether the function argument narg is a userdata +Checks whether the function argument arg is a userdata of the type tname (see luaL_newmetatable) and returns the userdata address (see lua_touserdata). @@ -5928,10 +5951,10 @@

    5.1 – Functions and Types


    luaL_checkunsigned

    [-0, +0, v] -

    lua_Unsigned luaL_checkunsigned (lua_State *L, int narg);
    +
    lua_Unsigned luaL_checkunsigned (lua_State *L, int arg);

    -Checks whether the function argument narg is a number +Checks whether the function argument arg is a number and returns this number cast to a lua_Unsigned. @@ -5955,7 +5978,7 @@

    5.1 – Functions and Types


    luaL_dofile

    -[-0, +?, m] +[-0, +?, e]

    int luaL_dofile (lua_State *L, const char *filename);

    @@ -6014,7 +6037,7 @@

    5.1 – Functions and Types


    luaL_execresult

    -[-0, +3, m] +[-0, +3, e]

    int luaL_execresult (lua_State *L, int stat);

    @@ -6027,7 +6050,7 @@

    5.1 – Functions and Types


    luaL_fileresult

    -[-0, +(1|3), m] +[-0, +(1|3), e]

    int luaL_fileresult (lua_State *L, int stat, const char *fname);

    @@ -6040,7 +6063,7 @@

    5.1 – Functions and Types


    luaL_getmetafield

    -[-0, +(0|1), m] +[-0, +(0|1), e]

    int luaL_getmetafield (lua_State *L, int obj, const char *e);

    @@ -6067,7 +6090,7 @@

    5.1 – Functions and Types


    luaL_getsubtable

    -[-0, +1, m] +[-0, +1, e]

    int luaL_getsubtable (lua_State *L, int idx, const char *fname);

    @@ -6083,7 +6106,7 @@

    5.1 – Functions and Types


    luaL_gsub

    -[-0, +1, m] +[-0, +1, e]

    const char *luaL_gsub (lua_State *L,
                            const char *s,
                            const char *p,
    @@ -6100,7 +6123,7 @@ 

    5.1 – Functions and Types


    luaL_len

    -[-0, +1, e] +[-0, +0, e]

    int luaL_len (lua_State *L, int index);

    @@ -6108,7 +6131,7 @@

    5.1 – Functions and Types

    as a number; it is equivalent to the '#' operator in Lua (see §3.4.6). Raises an error if the result of the operation is not a number. -(This only can happen through metamethods.) +(This case only can happen through metamethods.) @@ -6153,7 +6176,7 @@

    5.1 – Functions and Types


    luaL_loadfile

    -[-0, +1, m] +[-0, +1, e]

    int luaL_loadfile (lua_State *L, const char *filename);

    @@ -6164,7 +6187,7 @@

    5.1 – Functions and Types


    luaL_loadfilex

    -[-0, +1, m] +[-0, +1, e]

    int luaL_loadfilex (lua_State *L, const char *filename,
                                                 const char *mode);
    @@ -6218,7 +6241,7 @@

    5.1 – Functions and Types


    luaL_newlib

    -[-0, +1, m] +[-0, +1, e]

    int luaL_newlib (lua_State *L, const luaL_Reg *l);

    @@ -6234,7 +6257,7 @@

    5.1 – Functions and Types


    luaL_newlibtable

    -[-0, +1, m] +[-0, +1, e]

    int luaL_newlibtable (lua_State *L, const luaL_Reg l[]);

    @@ -6255,7 +6278,7 @@

    5.1 – Functions and Types


    luaL_newmetatable

    -[-0, +1, m] +[-0, +1, e]

    int luaL_newmetatable (lua_State *L, const char *tname);

    @@ -6309,10 +6332,10 @@

    5.1 – Functions and Types


    luaL_optint

    [-0, +0, v] -

    int luaL_optint (lua_State *L, int narg, int d);
    +
    int luaL_optint (lua_State *L, int arg, int d);

    -If the function argument narg is a number, +If the function argument arg is a number, returns this number cast to an int. If this argument is absent or is nil, returns d. @@ -6325,11 +6348,11 @@

    5.1 – Functions and Types


    luaL_optinteger

    [-0, +0, v]

    lua_Integer luaL_optinteger (lua_State *L,
    -                             int narg,
    +                             int arg,
                                  lua_Integer d);

    -If the function argument narg is a number, +If the function argument arg is a number, returns this number cast to a lua_Integer. If this argument is absent or is nil, returns d. @@ -6341,10 +6364,10 @@

    5.1 – Functions and Types


    luaL_optlong

    [-0, +0, v] -

    long luaL_optlong (lua_State *L, int narg, long d);
    +
    long luaL_optlong (lua_State *L, int arg, long d);

    -If the function argument narg is a number, +If the function argument arg is a number, returns this number cast to a long. If this argument is absent or is nil, returns d. @@ -6357,12 +6380,12 @@

    5.1 – Functions and Types


    luaL_optlstring

    [-0, +0, v]

    const char *luaL_optlstring (lua_State *L,
    -                             int narg,
    +                             int arg,
                                  const char *d,
                                  size_t *l);

    -If the function argument narg is a string, +If the function argument arg is a string, returns this string. If this argument is absent or is nil, returns d. @@ -6379,10 +6402,10 @@

    5.1 – Functions and Types


    luaL_optnumber

    [-0, +0, v] -

    lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
    +
    lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);

    -If the function argument narg is a number, +If the function argument arg is a number, returns this number. If this argument is absent or is nil, returns d. @@ -6395,11 +6418,11 @@

    5.1 – Functions and Types


    luaL_optstring

    [-0, +0, v]

    const char *luaL_optstring (lua_State *L,
    -                            int narg,
    +                            int arg,
                                 const char *d);

    -If the function argument narg is a string, +If the function argument arg is a string, returns this string. If this argument is absent or is nil, returns d. @@ -6412,11 +6435,11 @@

    5.1 – Functions and Types


    luaL_optunsigned

    [-0, +0, v]

    lua_Unsigned luaL_optunsigned (lua_State *L,
    -                               int narg,
    +                               int arg,
                                    lua_Unsigned u);

    -If the function argument narg is a number, +If the function argument arg is a number, returns this number cast to a lua_Unsigned. If this argument is absent or is nil, returns u. @@ -6427,7 +6450,7 @@

    5.1 – Functions and Types


    luaL_prepbuffer

    -[-?, +?, m] +[-?, +?, e]

    char *luaL_prepbuffer (luaL_Buffer *B);

    @@ -6439,7 +6462,7 @@

    5.1 – Functions and Types


    luaL_prepbuffsize

    -[-?, +?, m] +[-?, +?, e]

    char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);

    @@ -6455,7 +6478,7 @@

    5.1 – Functions and Types


    luaL_pushresult

    -[-?, +1, m] +[-?, +1, e]

    void luaL_pushresult (luaL_Buffer *B);

    @@ -6467,7 +6490,7 @@

    5.1 – Functions and Types


    luaL_pushresultsize

    -[-?, +1, m] +[-?, +1, e]

    void luaL_pushresultsize (luaL_Buffer *B, size_t sz);

    @@ -6478,7 +6501,7 @@

    5.1 – Functions and Types


    luaL_ref

    -[-1, +0, m] +[-1, +0, e]

    int luaL_ref (lua_State *L, int t);

    @@ -6582,8 +6605,8 @@

    5.1 – Functions and Types


    luaL_testudata

    -[-0, +0, m] -

    void *luaL_testudata (lua_State *L, int narg, const char *tname);
    +[-0, +0, e] +
    void *luaL_testudata (lua_State *L, int arg, const char *tname);

    This function works like luaL_checkudata, @@ -6618,7 +6641,7 @@

    5.1 – Functions and Types


    luaL_traceback

    -[-0, +1, m] +[-0, +1, e]

    void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
                          int level);
    @@ -6665,7 +6688,7 @@

    5.1 – Functions and Types


    luaL_where

    -[-0, +1, m] +[-0, +1, e]

    void luaL_where (lua_State *L, int lvl);

    @@ -6749,7 +6772,7 @@

    6 – Standard Libraries

    luaopen_string (for the string library), luaopen_table (for the table library), luaopen_math (for the mathematical library), -luaopen_bitlib (for the bit library), +luaopen_bit32 (for the bit library), luaopen_io (for the I/O library), luaopen_os (for the Operating System library), and luaopen_debug (for the debug library). @@ -7914,24 +7937,26 @@

    6.4 – String Manipulation

    The character % works as an escape character: any sequence in repl of the form %d, with d between 1 and 9, -stands for the value of the d-th captured substring (see below). +stands for the value of the d-th captured substring. The sequence %0 stands for the whole match. The sequence %% stands for a single %.

    If repl is a table, then the table is queried for every match, -using the first capture as the key; -if the pattern specifies no captures, -then the whole match is used as the key. +using the first capture as the key.

    If repl is a function, then this function is called every time a match occurs, with all captured substrings passed as arguments, -in order; +in order. + + +

    +In any case, if the pattern specifies no captures, -then the whole match is passed as a sole argument. +then it behaves as if the whole pattern was inside a capture.

    @@ -10091,6 +10116,9 @@

    8 – Incompatibilities with the Previous Version

    appropriate options (see file luaconf.h). However, all these compatibility options will be removed in the next version of Lua. +Similarly, +all features marked as deprecated in Lua 5.1 +have been removed in Lua 5.2. @@ -10387,10 +10415,10 @@

    9 – The Complete Syntax of Lua


    Last update: -Mon Dec 12 15:21:08 BRST 2011 +Fri Jun 8 16:13:40 BRT 2012 diff --git a/doc/readme.html b/doc/readme.html index f0c77a16..2ff294ec 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -43,7 +43,6 @@

    license · reference manual -

    About Lua

    @@ -101,14 +100,6 @@

    Installing Lua

    Lua for Windows, an easy-to-use distribution of Lua that includes many useful libraries. - -

    Building Lua

    @@ -118,7 +109,7 @@

    Building Lua

    1. Open a terminal window and move to -the top-level directory, which is named lua-5.2.0. +the top-level directory, which is named lua-5.2.1. The Makefile there controls both the build process and the installation process.

    2. @@ -381,7 +372,7 @@

      License

      this.
      -Copyright © 1994–2011 Lua.org, PUC-Rio. +Copyright © 1994–2012 Lua.org, PUC-Rio.

      Permission is hereby granted, free of charge, to any person obtaining a copy @@ -409,10 +400,10 @@

      License


      Last update: -Wed Nov 23 16:17:22 BRST 2011 +Tue May 29 21:57:51 BRT 2012 diff --git a/src/Makefile b/src/Makefile index bba1693f..8c9ee677 100644 --- a/src/Makefile +++ b/src/Makefile @@ -56,7 +56,7 @@ o: $(ALL_O) a: $(ALL_A) $(LUA_A): $(BASE_O) - $(AR) $@ $? + $(AR) $@ $(BASE_O) $(RANLIB) $@ $(LUA_T): $(LUA_O) $(LUA_A) diff --git a/src/lapi.c b/src/lapi.c index e96ceb9e..1854fe61 100644 --- a/src/lapi.c +++ b/src/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.159 2011/11/30 12:32:05 roberto Exp $ +** $Id: lapi.c,v 2.164 2012/06/08 15:14:04 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -950,7 +950,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, ci->u.c.k = k; /* save continuation */ ci->u.c.ctx = ctx; /* save context */ /* save information for error recovery */ - ci->u.c.extra = savestack(L, c.func); + ci->extra = savestack(L, c.func); ci->u.c.old_allowhook = L->allowhook; ci->u.c.old_errfunc = L->errfunc; L->errfunc = func; @@ -1045,17 +1045,17 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { } case LUA_GCSTEP: { if (g->gckind == KGC_GEN) { /* generational mode? */ - res = (g->lastmajormem == 0); /* 1 if will do major collection */ + res = (g->GCestimate == 0); /* true if it will do major collection */ luaC_forcestep(L); /* do a single step */ } else { - while (data-- >= 0) { - luaC_forcestep(L); - if (g->gcstate == GCSpause) { /* end of cycle? */ - res = 1; /* signal it */ - break; - } - } + lu_mem debt = cast(lu_mem, data) * 1024 - GCSTEPSIZE; + if (g->gcrunning) + debt += g->GCdebt; /* include current debt */ + luaE_setdebt(g, debt); + luaC_forcestep(L); + if (g->gcstate == GCSpause) /* end of cycle? */ + res = 1; /* signal it */ } break; } diff --git a/src/lauxlib.c b/src/lauxlib.c index 0aa80fd9..36ae7e62 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.240 2011/12/06 16:33:55 roberto Exp $ +** $Id: lauxlib.c,v 1.244 2012/05/31 20:28:45 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -520,11 +520,11 @@ LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { LUALIB_API int luaL_ref (lua_State *L, int t) { int ref; - t = lua_absindex(L, t); if (lua_isnil(L, -1)) { lua_pop(L, 1); /* remove from stack */ return LUA_REFNIL; /* `nil' has a unique fixed reference */ } + t = lua_absindex(L, t); lua_rawgeti(L, t, freelist); /* get first free element */ ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ lua_pop(L, 1); /* remove it from stack */ @@ -616,8 +616,10 @@ static int skipBOM (LoadF *lf) { static int skipcomment (LoadF *lf, int *cp) { int c = *cp = skipBOM(lf); if (c == '#') { /* first line is a comment (Unix exec. file)? */ - while ((c = getc(lf->f)) != EOF && c != '\n') ; /* skip first line */ - *cp = getc(lf->f); /* skip end-of-line */ + do { /* skip first line */ + c = getc(lf->f); + } while (c != EOF && c != '\n') ; + *cp = getc(lf->f); /* skip end-of-line, if present */ return 1; /* there was a comment */ } else return 0; /* no comment */ @@ -843,6 +845,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, ** Returns with only the table at the stack. */ LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { + luaL_checkversion(L); luaL_checkstack(L, nup, "too many upvalues"); for (; l->name != NULL; l++) { /* fill the table with given functions */ int i; @@ -863,8 +866,8 @@ LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { lua_getfield(L, idx, fname); if (lua_istable(L, -1)) return 1; /* table already there */ else { - idx = lua_absindex(L, idx); lua_pop(L, 1); /* remove previous result */ + idx = lua_absindex(L, idx); lua_newtable(L); lua_pushvalue(L, -1); /* copy to be left at top */ lua_setfield(L, idx, fname); /* assign new table to field */ @@ -889,10 +892,8 @@ LUALIB_API void luaL_requiref (lua_State *L, const char *modname, lua_setfield(L, -2, modname); /* _LOADED[modname] = module */ lua_pop(L, 1); /* remove _LOADED table */ if (glb) { - lua_pushglobaltable(L); - lua_pushvalue(L, -2); /* copy of 'mod' */ - lua_setfield(L, -2, modname); /* _G[modname] = module */ - lua_pop(L, 1); /* remove _G table */ + lua_pushvalue(L, -1); /* copy of 'mod' */ + lua_setglobal(L, modname); /* _G[modname] = module */ } } diff --git a/src/lbaselib.c b/src/lbaselib.c index 1dfae301..dbfcb02c 100644 --- a/src/lbaselib.c +++ b/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.273 2011/11/30 13:03:24 roberto Exp $ +** $Id: lbaselib.c,v 1.274 2012/04/27 14:13:19 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -293,6 +293,7 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { lua_pushvalue(L, 1); /* get function */ lua_call(L, 0, 1); /* call it */ if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* pop result */ *size = 0; return NULL; } diff --git a/src/lcorolib.c b/src/lcorolib.c index 0edde26d..c7932d90 100644 --- a/src/lcorolib.c +++ b/src/lcorolib.c @@ -1,5 +1,5 @@ /* -** $Id: lcorolib.c,v 1.3 2011/08/23 17:24:34 roberto Exp $ +** $Id: lcorolib.c,v 1.4 2012/04/27 18:59:04 roberto Exp $ ** Coroutine Library ** See Copyright Notice in lua.h */ @@ -80,8 +80,9 @@ static int luaB_auxwrap (lua_State *L) { static int luaB_cocreate (lua_State *L) { - lua_State *NL = lua_newthread(L); + lua_State *NL; luaL_checktype(L, 1, LUA_TFUNCTION); + NL = lua_newthread(L); lua_pushvalue(L, 1); /* move function to top */ lua_xmove(L, NL, 1); /* move function from L to NL */ return 1; diff --git a/src/ldblib.c b/src/ldblib.c index 3c2f1595..c0226945 100644 --- a/src/ldblib.c +++ b/src/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.131 2011/10/24 14:54:05 roberto Exp $ +** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -253,14 +253,15 @@ static int db_upvaluejoin (lua_State *L) { } -#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY); +#define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY) static void hookf (lua_State *L, lua_Debug *ar) { static const char *const hooknames[] = {"call", "return", "line", "count", "tail call"}; gethooktable(L); - lua_rawgetp(L, -1, L); + lua_pushthread(L); + lua_rawget(L, -2); if (lua_isfunction(L, -1)) { lua_pushstring(L, hooknames[(int)ar->event]); if (ar->currentline >= 0) @@ -306,10 +307,15 @@ static int db_sethook (lua_State *L) { count = luaL_optint(L, arg+3, 0); func = hookf; mask = makemask(smask, count); } - gethooktable(L); + if (gethooktable(L) == 0) { /* creating hook table? */ + lua_pushstring(L, "k"); + lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ + lua_pushvalue(L, -1); + lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ + } + lua_pushthread(L1); lua_xmove(L1, L, 1); lua_pushvalue(L, arg+1); - lua_rawsetp(L, -2, L1); /* set new hook */ - lua_pop(L, 1); /* remove hook table */ + lua_rawset(L, -3); /* set new hook */ lua_sethook(L1, func, mask, count); /* set hooks */ return 0; } @@ -325,7 +331,8 @@ static int db_gethook (lua_State *L) { lua_pushliteral(L, "external hook"); else { gethooktable(L); - lua_rawgetp(L, -1, L1); /* get hook */ + lua_pushthread(L1); lua_xmove(L1, L, 1); + lua_rawget(L, -2); /* get hook */ lua_remove(L, -2); /* remove hook table */ } lua_pushstring(L, unmakemask(mask, buff)); diff --git a/src/ldebug.c b/src/ldebug.c index 31b7ae40..43f8f046 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.88 2011/11/30 12:43:51 roberto Exp $ +** $Id: ldebug.c,v 2.89 2012/01/20 22:05:50 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -30,6 +30,9 @@ +#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) + + static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); @@ -173,7 +176,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { static void funcinfo (lua_Debug *ar, Closure *cl) { - if (cl == NULL || cl->c.isC) { + if (noLuaClosure(cl)) { ar->source = "=[C]"; ar->linedefined = -1; ar->lastlinedefined = -1; @@ -191,7 +194,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) { static void collectvalidlines (lua_State *L, Closure *f) { - if (f == NULL || f->c.isC) { + if (noLuaClosure(f)) { setnilvalue(L->top); incr_top(L); } @@ -210,7 +213,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, - Closure *f, CallInfo *ci) { + Closure *f, CallInfo *ci) { int status = 1; for (; *what; what++) { switch (*what) { @@ -224,7 +227,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, } case 'u': { ar->nups = (f == NULL) ? 0 : f->c.nupvalues; - if (f == NULL || f->c.isC) { + if (noLuaClosure(f)) { ar->isvararg = 1; ar->nparams = 0; } diff --git a/src/ldo.c b/src/ldo.c index 26f9a674..d18e33cd 100644 --- a/src/ldo.c +++ b/src/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.102 2011/11/29 15:55:08 roberto Exp $ +** $Id: ldo.c,v 2.105 2012/06/08 15:14:04 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -402,8 +402,6 @@ static void finishCcall (lua_State *L) { int n; lua_assert(ci->u.c.k != NULL); /* must have a continuation */ lua_assert(L->nny == 0); - /* finish 'luaD_call' */ - L->nCcalls--; /* finish 'lua_callk' */ adjustresults(L, ci->nresults); /* call continuation function */ @@ -453,7 +451,7 @@ static int recover (lua_State *L, int status) { CallInfo *ci = findpcall(L); if (ci == NULL) return 0; /* no recovery point */ /* "finish" luaD_pcall */ - oldtop = restorestack(L, ci->u.c.extra); + oldtop = restorestack(L, ci->extra); luaF_close(L, oldtop); seterrorobj(L, status, oldtop); L->ci = ci; @@ -484,9 +482,10 @@ static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { ** do the work for 'lua_resume' in protected mode */ static void resume (lua_State *L, void *ud) { + int nCcalls = L->nCcalls; StkId firstArg = cast(StkId, ud); CallInfo *ci = L->ci; - if (L->nCcalls >= LUAI_MAXCCALLS) + if (nCcalls >= LUAI_MAXCCALLS) resume_error(L, "C stack overflow", firstArg); if (L->status == LUA_OK) { /* may be starting a coroutine */ if (ci != &L->base_ci) /* not in base level? */ @@ -499,10 +498,10 @@ static void resume (lua_State *L, void *ud) { resume_error(L, "cannot resume dead coroutine", firstArg); else { /* resuming from previous yield */ L->status = LUA_OK; + ci->func = restorestack(L, ci->extra); if (isLua(ci)) /* yielded inside a hook? */ luaV_execute(L); /* just continue running Lua code */ else { /* 'common' yield */ - ci->func = restorestack(L, ci->u.c.extra); if (ci->u.c.k != NULL) { /* does it have a continuation? */ int n; ci->u.c.status = LUA_YIELD; /* 'default' status */ @@ -513,11 +512,11 @@ static void resume (lua_State *L, void *ud) { api_checknelems(L, n); firstArg = L->top - n; /* yield results come from continuation */ } - L->nCcalls--; /* finish 'luaD_call' */ luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ } unroll(L, NULL); } + lua_assert(nCcalls == L->nCcalls); } @@ -564,13 +563,13 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { luaG_runerror(L, "attempt to yield from outside a coroutine"); } L->status = LUA_YIELD; + ci->extra = savestack(L, ci->func); /* save current 'func' */ if (isLua(ci)) { /* inside a hook? */ api_check(L, k == NULL, "hooks cannot continue after yielding"); } else { if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ ci->u.c.ctx = ctx; /* save context */ - ci->u.c.extra = savestack(L, ci->func); /* save current 'func' */ ci->func = L->top - nresults - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } @@ -627,24 +626,23 @@ static void checkmode (lua_State *L, const char *mode, const char *x) { static void f_parser (lua_State *L, void *ud) { int i; - Proto *tf; Closure *cl; struct SParser *p = cast(struct SParser *, ud); int c = zgetc(p->z); /* read first character */ if (c == LUA_SIGNATURE[0]) { checkmode(L, p->mode, "binary"); - tf = luaU_undump(L, p->z, &p->buff, p->name); + cl = luaU_undump(L, p->z, &p->buff, p->name); } else { checkmode(L, p->mode, "text"); - tf = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); + cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); + } + lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); + for (i = 0; i < cl->l.nupvalues; i++) { /* initialize upvalues */ + UpVal *up = luaF_newupval(L); + cl->l.upvals[i] = up; + luaC_objbarrier(L, cl, up); } - setptvalue2s(L, L->top, tf); - incr_top(L); - cl = luaF_newLclosure(L, tf); - setclLvalue(L, L->top - 1, cl); - for (i = 0; i < tf->sizeupvalues; i++) /* initialize upvalues */ - cl->l.upvals[i] = luaF_newupval(L); } diff --git a/src/ldump.c b/src/ldump.c index 699e1dc4..d5e6a47c 100644 --- a/src/ldump.c +++ b/src/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 1.19 2011/11/23 17:48:18 lhf Exp $ +** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -84,8 +84,8 @@ static void DumpConstants(const Proto* f, DumpState* D) for (i=0; ik[i]; - DumpChar(ttype(o),D); - switch (ttype(o)) + DumpChar(ttypenv(o),D); + switch (ttypenv(o)) { case LUA_TNIL: break; @@ -98,6 +98,7 @@ static void DumpConstants(const Proto* f, DumpState* D) case LUA_TSTRING: DumpString(rawtsvalue(o),D); break; + default: lua_assert(0); } } n=f->sizep; diff --git a/src/lfunc.c b/src/lfunc.c index 1a1a8bb8..4fd27fe5 100644 --- a/src/lfunc.c +++ b/src/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.27 2010/06/30 14:11:17 roberto Exp $ +** $Id: lfunc.c,v 2.29 2012/05/08 13:53:33 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -21,18 +21,15 @@ Closure *luaF_newCclosure (lua_State *L, int n) { - Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeCclosure(n), NULL, 0)->cl; - c->c.isC = 1; + Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl; c->c.nupvalues = cast_byte(n); return c; } -Closure *luaF_newLclosure (lua_State *L, Proto *p) { - int n = p->sizeupvalues; - Closure *c = &luaC_newobj(L, LUA_TFUNCTION, sizeLclosure(n), NULL, 0)->cl; - c->l.isC = 0; - c->l.p = p; +Closure *luaF_newLclosure (lua_State *L, int n) { + Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl; + c->l.p = NULL; c->l.nupvalues = cast_byte(n); while (n--) c->l.upvals[n] = NULL; return c; @@ -146,13 +143,6 @@ void luaF_freeproto (lua_State *L, Proto *f) { } -void luaF_freeclosure (lua_State *L, Closure *c) { - int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : - sizeLclosure(c->l.nupvalues); - luaM_freemem(L, c, size); -} - - /* ** Look for n-th local variable at line `line' in function `func'. ** Returns NULL if not found. diff --git a/src/lfunc.h b/src/lfunc.h index da189231..e236a717 100644 --- a/src/lfunc.h +++ b/src/lfunc.h @@ -1,5 +1,5 @@ /* -** $Id: lfunc.h,v 2.6 2010/06/04 13:06:15 roberto Exp $ +** $Id: lfunc.h,v 2.8 2012/05/08 13:53:33 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -20,12 +20,11 @@ LUAI_FUNC Proto *luaF_newproto (lua_State *L); LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); -LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, Proto *p); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); LUAI_FUNC UpVal *luaF_newupval (lua_State *L); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC void luaF_close (lua_State *L, StkId level); LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); -LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, int pc); diff --git a/src/lgc.c b/src/lgc.c index cdd92e52..06f972a7 100644 --- a/src/lgc.c +++ b/src/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.116 2011/12/02 13:18:41 roberto Exp $ +** $Id: lgc.c,v 2.133 2012/05/31 21:28:59 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -24,34 +24,40 @@ -/* how much to allocate before next GC step */ -#define GCSTEPSIZE 1024 +/* +** cost of sweeping one element (the size of a small object divided +** by some adjust for the sweep speed) +*/ +#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) /* maximum number of elements to sweep in each single step */ -#define GCSWEEPMAX 40 - -/* cost of sweeping one element */ -#define GCSWEEPCOST 1 +#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) /* maximum number of finalizers to call in each GC step */ #define GCFINALIZENUM 4 -/* cost of marking the root set */ -#define GCROOTCOST 10 -/* cost of atomic step */ -#define GCATOMICCOST 1000 +/* +** macro to adjust 'stepmul': 'stepmul' is actually used like +** 'stepmul / STEPMULADJ' (value chosen by tests) +*/ +#define STEPMULADJ 200 + +/* +** macro to adjust 'pause': 'pause' is actually used like +** 'pause / PAUSEADJ' (value chosen by tests) +*/ +#define PAUSEADJ 200 + -/* basic cost to traverse one object (to be added to the links the - object may have) */ -#define TRAVCOST 5 /* ** standard negative debt for GC; a reasonable "time" to wait before ** starting a new cycle */ -#define stddebt(g) (-cast(l_mem, gettotalbytes(g)/100) * g->gcpause) +#define stddebtest(g,e) (-cast(l_mem, (e)/PAUSEADJ) * g->gcpause) +#define stddebt(g) stddebtest(g, gettotalbytes(g)) /* @@ -65,8 +71,6 @@ #define white2gray(x) resetbits(gch(x)->marked, WHITEBITS) #define black2gray(x) resetbit(gch(x)->marked, BLACKBIT) -#define stringmark(s) ((void)((s) && resetbits((s)->tsv.marked, WHITEBITS))) - #define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT) @@ -123,10 +127,10 @@ static void removeentry (Node *n) { ** other objects: if really collected, cannot keep them; for objects ** being finalized, keep them in keys, but not in values */ -static int iscleared (const TValue *o) { +static int iscleared (global_State *g, const TValue *o) { if (!iscollectable(o)) return 0; else if (ttisstring(o)) { - stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */ return 0; } else return iswhite(gcvalue(o)); @@ -217,7 +221,8 @@ void luaC_checkupvalcolor (global_State *g, UpVal *uv) { GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, int offset) { global_State *g = G(L); - GCObject *o = obj2gco(cast(char *, luaM_newobject(L, tt, sz)) + offset); + char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); + GCObject *o = obj2gco(raw + offset); if (list == NULL) list = &g->allgc; /* standard list for collectable objects */ gch(o)->marked = luaC_white(g); @@ -239,54 +244,63 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, /* -** mark an object. Userdata and closed upvalues are visited and turned -** black here. Strings remain gray (it is the same as making them -** black). Other objects are marked gray and added to appropriate list -** to be visited (and turned black) later. (Open upvalues are already -** linked in 'headuv' list.) +** mark an object. Userdata, strings, and closed upvalues are visited +** and turned black here. Other objects are marked gray and added +** to appropriate list to be visited (and turned black) later. (Open +** upvalues are already linked in 'headuv' list.) */ static void reallymarkobject (global_State *g, GCObject *o) { - lua_assert(iswhite(o) && !isdead(g, o)); + lu_mem size; white2gray(o); switch (gch(o)->tt) { - case LUA_TSTRING: { - return; /* for strings, gray is as good as black */ + case LUA_TSHRSTR: + case LUA_TLNGSTR: { + size = sizestring(gco2ts(o)); + break; /* nothing else to mark; make it black */ } case LUA_TUSERDATA: { Table *mt = gco2u(o)->metatable; markobject(g, mt); markobject(g, gco2u(o)->env); - gray2black(o); /* all pointers marked */ - return; + size = sizeudata(gco2u(o)); + break; } case LUA_TUPVAL: { UpVal *uv = gco2uv(o); markvalue(g, uv->v); - if (uv->v == &uv->u.value) /* closed? (open upvalues remain gray) */ - gray2black(o); /* make it black */ + if (uv->v != &uv->u.value) /* open? */ + return; /* open upvalues remain gray */ + size = sizeof(UpVal); + break; + } + case LUA_TLCL: { + gco2lcl(o)->gclist = g->gray; + g->gray = o; return; } - case LUA_TFUNCTION: { - gco2cl(o)->c.gclist = g->gray; + case LUA_TCCL: { + gco2ccl(o)->gclist = g->gray; g->gray = o; - break; + return; } case LUA_TTABLE: { linktable(gco2t(o), &g->gray); - break; + return; } case LUA_TTHREAD: { gco2th(o)->gclist = g->gray; g->gray = o; - break; + return; } case LUA_TPROTO: { gco2p(o)->gclist = g->gray; g->gray = o; - break; + return; } - default: lua_assert(0); + default: lua_assert(0); return; } + gray2black(o); + g->GCmemtrav += size; } @@ -359,7 +373,7 @@ static void traverseweakvalue (global_State *g, Table *h) { else { lua_assert(!ttisnil(gkey(n))); markvalue(g, gkey(n)); /* mark key */ - if (!hasclears && iscleared(gval(n))) /* is there a white value? */ + if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ hasclears = 1; /* table will have to be cleared */ } } @@ -388,7 +402,7 @@ static int traverseephemeron (global_State *g, Table *h) { checkdeadkey(n); if (ttisnil(gval(n))) /* entry is empty? */ removeentry(n); /* remove it */ - else if (iscleared(gkey(n))) { /* key is not marked (yet)? */ + else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ hasclears = 1; /* table must be cleared */ if (valiswhite(gval(n))) /* value not marked yet? */ prop = 1; /* must propagate again */ @@ -426,30 +440,26 @@ static void traversestrongtable (global_State *g, Table *h) { } -static int traversetable (global_State *g, Table *h) { +static lu_mem traversetable (global_State *g, Table *h) { + const char *weakkey, *weakvalue; const TValue *mode = gfasttm(g, h->metatable, TM_MODE); markobject(g, h->metatable); - if (mode && ttisstring(mode)) { /* is there a weak mode? */ - int weakkey = (strchr(svalue(mode), 'k') != NULL); - int weakvalue = (strchr(svalue(mode), 'v') != NULL); - if (weakkey || weakvalue) { /* is really weak? */ - black2gray(obj2gco(h)); /* keep table gray */ - if (!weakkey) { /* strong keys? */ - traverseweakvalue(g, h); - return TRAVCOST + sizenode(h); - } - else if (!weakvalue) { /* strong values? */ - traverseephemeron(g, h); - return TRAVCOST + h->sizearray + sizenode(h); - } - else { - linktable(h, &g->allweak); /* nothing to traverse now */ - return TRAVCOST; - } - } /* else go through */ + if (mode && ttisstring(mode) && /* is there a weak mode? */ + ((weakkey = strchr(svalue(mode), 'k')), + (weakvalue = strchr(svalue(mode), 'v')), + (weakkey || weakvalue))) { /* is really weak? */ + black2gray(obj2gco(h)); /* keep table gray */ + if (!weakkey) /* strong keys? */ + traverseweakvalue(g, h); + else if (!weakvalue) /* strong values? */ + traverseephemeron(g, h); + else /* all weak */ + linktable(h, &g->allweak); /* nothing to traverse now */ } - traversestrongtable(g, h); - return TRAVCOST + h->sizearray + (2 * sizenode(h)); + else /* not weak */ + traversestrongtable(g, h); + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); } @@ -457,86 +467,101 @@ static int traverseproto (global_State *g, Proto *f) { int i; if (f->cache && iswhite(obj2gco(f->cache))) f->cache = NULL; /* allow cache to be collected */ - stringmark(f->source); + markobject(g, f->source); for (i = 0; i < f->sizek; i++) /* mark literals */ markvalue(g, &f->k[i]); for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ - stringmark(f->upvalues[i].name); + markobject(g, f->upvalues[i].name); for (i = 0; i < f->sizep; i++) /* mark nested protos */ markobject(g, f->p[i]); for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ - stringmark(f->locvars[i].varname); - return TRAVCOST + f->sizek + f->sizeupvalues + f->sizep + f->sizelocvars; + markobject(g, f->locvars[i].varname); + return sizeof(Proto) + sizeof(Instruction) * f->sizecode + + sizeof(Proto *) * f->sizep + + sizeof(TValue) * f->sizek + + sizeof(int) * f->sizelineinfo + + sizeof(LocVar) * f->sizelocvars + + sizeof(Upvaldesc) * f->sizeupvalues; } -static int traverseclosure (global_State *g, Closure *cl) { - if (cl->c.isC) { - int i; - for (i=0; ic.nupvalues; i++) /* mark its upvalues */ - markvalue(g, &cl->c.upvalue[i]); - } - else { - int i; - lua_assert(cl->l.nupvalues == cl->l.p->sizeupvalues); - markobject(g, cl->l.p); /* mark its prototype */ - for (i=0; il.nupvalues; i++) /* mark its upvalues */ - markobject(g, cl->l.upvals[i]); - } - return TRAVCOST + cl->c.nupvalues; +static lu_mem traverseCclosure (global_State *g, CClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->upvalue[i]); + return sizeCclosure(cl->nupvalues); +} + +static lu_mem traverseLclosure (global_State *g, LClosure *cl) { + int i; + markobject(g, cl->p); /* mark its prototype */ + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->upvals[i]); + return sizeLclosure(cl->nupvalues); } -static int traversestack (global_State *g, lua_State *L) { - StkId o = L->stack; +static lu_mem traversestack (global_State *g, lua_State *th) { + StkId o = th->stack; if (o == NULL) return 1; /* stack not completely built yet */ - for (; o < L->top; o++) + for (; o < th->top; o++) markvalue(g, o); if (g->gcstate == GCSatomic) { /* final traversal? */ - StkId lim = L->stack + L->stacksize; /* real end of stack */ + StkId lim = th->stack + th->stacksize; /* real end of stack */ for (; o < lim; o++) /* clear not-marked stack slice */ setnilvalue(o); } - return TRAVCOST + cast_int(o - L->stack); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize; } /* ** traverse one gray object, turning it to black (except for threads, ** which are always gray). -** Returns number of values traversed. */ -static int propagatemark (global_State *g) { +static void propagatemark (global_State *g) { + lu_mem size; GCObject *o = g->gray; lua_assert(isgray(o)); gray2black(o); switch (gch(o)->tt) { case LUA_TTABLE: { Table *h = gco2t(o); - g->gray = h->gclist; - return traversetable(g, h); + g->gray = h->gclist; /* remove from 'gray' list */ + size = traversetable(g, h); + break; + } + case LUA_TLCL: { + LClosure *cl = gco2lcl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseLclosure(g, cl); + break; } - case LUA_TFUNCTION: { - Closure *cl = gco2cl(o); - g->gray = cl->c.gclist; - return traverseclosure(g, cl); + case LUA_TCCL: { + CClosure *cl = gco2ccl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseCclosure(g, cl); + break; } case LUA_TTHREAD: { lua_State *th = gco2th(o); - g->gray = th->gclist; + g->gray = th->gclist; /* remove from 'gray' list */ th->gclist = g->grayagain; - g->grayagain = o; + g->grayagain = o; /* insert into 'grayagain' list */ black2gray(o); - return traversestack(g, th); + size = traversestack(g, th); + break; } case LUA_TPROTO: { Proto *p = gco2p(o); - g->gray = p->gclist; - return traverseproto(g, p); + g->gray = p->gclist; /* remove from 'gray' list */ + size = traverseproto(g, p); + break; } - default: lua_assert(0); return 0; + default: lua_assert(0); return; } + g->GCmemtrav += size; } @@ -599,12 +624,12 @@ static void convergeephemerons (global_State *g) { ** clear entries with unmarked keys from all weaktables in list 'l' up ** to element 'f' */ -static void clearkeys (GCObject *l, GCObject *f) { +static void clearkeys (global_State *g, GCObject *l, GCObject *f) { for (; l != f; l = gco2t(l)->gclist) { Table *h = gco2t(l); Node *n, *limit = gnodelast(h); for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && (iscleared(gkey(n)))) { + if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { setnilvalue(gval(n)); /* remove value ... */ removeentry(n); /* and remove entry from table */ } @@ -617,18 +642,18 @@ static void clearkeys (GCObject *l, GCObject *f) { ** clear entries with unmarked values from all weaktables in list 'l' up ** to element 'f' */ -static void clearvalues (GCObject *l, GCObject *f) { +static void clearvalues (global_State *g, GCObject *l, GCObject *f) { for (; l != f; l = gco2t(l)->gclist) { Table *h = gco2t(l); Node *n, *limit = gnodelast(h); int i; for (i = 0; i < h->sizearray; i++) { TValue *o = &h->array[i]; - if (iscleared(o)) /* value was collected? */ + if (iscleared(g, o)) /* value was collected? */ setnilvalue(o); /* remove value */ } for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && iscleared(gval(n))) { + if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { setnilvalue(gval(n)); /* remove value ... */ removeentry(n); /* and remove entry from table */ } @@ -640,13 +665,22 @@ static void clearvalues (GCObject *l, GCObject *f) { static void freeobj (lua_State *L, GCObject *o) { switch (gch(o)->tt) { case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; - case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TLCL: { + luaM_freemem(L, o, sizeLclosure(gco2lcl(o)->nupvalues)); + break; + } + case LUA_TCCL: { + luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); + break; + } case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; case LUA_TTABLE: luaH_free(L, gco2t(o)); break; case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; - case LUA_TSTRING: { + case LUA_TSHRSTR: G(L)->strt.nuse--; + /* go through */ + case LUA_TLNGSTR: { luaM_freemem(L, o, sizestring(gco2ts(o))); break; } @@ -689,7 +723,6 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { int ow = otherwhite(g); int toclear, toset; /* bits to clear and to set in all live objects */ int tostop; /* stop sweep when this is true */ - l_mem debt = g->GCdebt; /* current debt */ if (isgenerational(g)) { /* generational mode? */ toclear = ~0; /* clear nothing */ toset = bitmask(OLDBIT); /* set the old bit of all surviving objects */ @@ -708,19 +741,30 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { freeobj(L, curr); /* erase 'curr' */ } else { + if (testbits(marked, tostop)) + return NULL; /* stop sweeping this list */ if (gch(curr)->tt == LUA_TTHREAD) sweepthread(L, gco2th(curr)); /* sweep thread's upvalues */ - if (testbits(marked, tostop)) { - static GCObject *nullp = NULL; - p = &nullp; /* stop sweeping this list */ - break; - } /* update marks */ gch(curr)->marked = cast_byte((marked & toclear) | toset); p = &gch(curr)->next; /* go to next element */ } } - luaE_setdebt(g, debt); /* sweeping should not change debt */ + return (*p == NULL) ? NULL : p; +} + + +/* +** sweep a list until a live object (or end of list) +*/ +static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { + GCObject ** old = p; + int i = 0; + do { + i++; + p = sweeplist(L, p, 1); + } while (p == old); + if (n) *n += i; return p; } @@ -783,12 +827,14 @@ static void GCTM (lua_State *L, int propagateerrors) { L->allowhook = oldah; /* restore hooks */ g->gcrunning = running; /* restore state */ if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ - if (status == LUA_ERRRUN) { /* is there an error msg.? */ - luaO_pushfstring(L, "error in __gc metamethod (%s)", - lua_tostring(L, -1)); + if (status == LUA_ERRRUN) { /* is there an error object? */ + const char *msg = (ttisstring(L->top - 1)) + ? svalue(L->top - 1) + : "no message"; + luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); status = LUA_ERRGCMM; /* error in __gc metamethod */ } - luaD_throw(L, status); /* re-send error */ + luaD_throw(L, status); /* re-throw error */ } } } @@ -834,12 +880,21 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { return; /* nothing to be done */ else { /* move 'o' to 'finobj' list */ GCObject **p; - for (p = &g->allgc; *p != o; p = &gch(*p)->next) ; - *p = gch(o)->next; /* remove 'o' from root list */ - gch(o)->next = g->finobj; /* link it in list 'finobj' */ + GCheader *ho = gch(o); + if (g->sweepgc == &ho->next) { /* avoid removing current sweep object */ + lua_assert(issweepphase(g)); + g->sweepgc = sweeptolive(L, g->sweepgc, NULL); + } + /* search for pointer pointing to 'o' */ + for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } + *p = ho->next; /* remove 'o' from root list */ + ho->next = g->finobj; /* link it in list 'finobj' */ g->finobj = o; - l_setbit(gch(o)->marked, SEPARATED); /* mark it as such */ - resetoldbit(o); /* see MOVE OLD rule */ + l_setbit(ho->marked, SEPARATED); /* mark it as such */ + if (!keepinvariant(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + else + resetoldbit(o); /* see MOVE OLD rule */ } } @@ -856,6 +911,28 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { #define sweepphases \ (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep)) + +/* +** enter first sweep phase (strings) and prepare pointers for other +** sweep phases. The calls to 'sweeptolive' make pointers point to an +** object inside the list (instead of to the header), so that the real +** sweep do not need to skip objects created between "now" and the start +** of the real sweep. +** Returns how many objects it sweeped. +*/ +static int entersweep (lua_State *L) { + global_State *g = G(L); + int n = 0; + g->gcstate = GCSsweepstring; + lua_assert(g->sweepgc == NULL && g->sweepfin == NULL); + /* prepare to sweep strings, finalizable objects, and regular objects */ + g->sweepstrgc = 0; + g->sweepfin = sweeptolive(L, &g->finobj, &n); + g->sweepgc = sweeptolive(L, &g->allgc, &n); + return n; +} + + /* ** change GC mode */ @@ -865,15 +942,14 @@ void luaC_changemode (lua_State *L, int mode) { if (mode == KGC_GEN) { /* change to generational mode */ /* make sure gray lists are consistent */ luaC_runtilstate(L, bitmask(GCSpropagate)); - g->lastmajormem = gettotalbytes(g); + g->GCestimate = gettotalbytes(g); g->gckind = KGC_GEN; } else { /* change to incremental mode */ /* sweep all objects to turn them back to white (as white has not changed, nothing extra will be collected) */ - g->sweepstrgc = 0; - g->gcstate = GCSsweepstring; g->gckind = KGC_NORMAL; + entersweep(L); luaC_runtilstate(L, ~sweepphases); } } @@ -907,8 +983,9 @@ void luaC_freeallobjects (lua_State *L) { } -static void atomic (lua_State *L) { +static l_mem atomic (lua_State *L) { global_State *g = G(L); + l_mem work = -g->GCmemtrav; /* start counting work */ GCObject *origweak, *origall; lua_assert(!iswhite(obj2gco(g->mainthread))); markobject(g, L); /* mark running thread */ @@ -917,77 +994,87 @@ static void atomic (lua_State *L) { markmt(g); /* mark basic metatables */ /* remark occasional upvalues of (maybe) dead threads */ remarkupvals(g); + propagateall(g); /* propagate changes */ + work += g->GCmemtrav; /* stop counting (do not (re)count grays) */ /* traverse objects caught by write barrier and by 'remarkupvals' */ retraversegrays(g); + work -= g->GCmemtrav; /* restart counting */ convergeephemerons(g); /* at this point, all strongly accessible objects are marked. */ /* clear values from weak tables, before checking finalizers */ - clearvalues(g->weak, NULL); - clearvalues(g->allweak, NULL); + clearvalues(g, g->weak, NULL); + clearvalues(g, g->allweak, NULL); origweak = g->weak; origall = g->allweak; + work += g->GCmemtrav; /* stop counting (objects being finalized) */ separatetobefnz(L, 0); /* separate objects to be finalized */ - markbeingfnz(g); /* mark userdata that will be finalized */ + markbeingfnz(g); /* mark objects that will be finalized */ propagateall(g); /* remark, to propagate `preserveness' */ + work -= g->GCmemtrav; /* restart counting */ convergeephemerons(g); /* at this point, all resurrected objects are marked. */ /* remove dead objects from weak tables */ - clearkeys(g->ephemeron, NULL); /* clear keys from all ephemeron tables */ - clearkeys(g->allweak, NULL); /* clear keys from all allweak tables */ + clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ + clearkeys(g, g->allweak, NULL); /* clear keys from all allweak tables */ /* clear values from resurrected weak tables */ - clearvalues(g->weak, origweak); - clearvalues(g->allweak, origall); - g->sweepstrgc = 0; /* prepare to sweep strings */ - g->gcstate = GCSsweepstring; + clearvalues(g, g->weak, origweak); + clearvalues(g, g->allweak, origall); g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ - /*lua_checkmemory(L);*/ + work += g->GCmemtrav; /* complete counting */ + return work; /* estimate of memory marked by 'atomic' */ } -static l_mem singlestep (lua_State *L) { +static lu_mem singlestep (lua_State *L) { global_State *g = G(L); switch (g->gcstate) { case GCSpause: { + g->GCmemtrav = 0; /* start to count memory traversed */ if (!isgenerational(g)) markroot(g); /* start a new collection */ - /* in any case, root must be marked */ + /* in any case, root must be marked at this point */ lua_assert(!iswhite(obj2gco(g->mainthread)) && !iswhite(gcvalue(&g->l_registry))); g->gcstate = GCSpropagate; - return GCROOTCOST; + return g->GCmemtrav; } case GCSpropagate: { - if (g->gray) - return propagatemark(g); + if (g->gray) { + lu_mem oldtrav = g->GCmemtrav; + propagatemark(g); + return g->GCmemtrav - oldtrav; /* memory traversed in this step */ + } else { /* no more `gray' objects */ + lu_mem work; + int sw; g->gcstate = GCSatomic; /* finish mark phase */ - atomic(L); - return GCATOMICCOST; + g->GCestimate = g->GCmemtrav; /* save what was counted */; + work = atomic(L); /* add what was traversed by 'atomic' */ + g->GCestimate += work; /* estimate of total memory traversed */ + sw = entersweep(L); + return work + sw * GCSWEEPCOST; } } case GCSsweepstring: { - if (g->sweepstrgc < g->strt.size) { - sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); - return GCSWEEPCOST; - } - else { /* no more strings to sweep */ - g->sweepgc = &g->finobj; /* prepare to sweep finalizable objects */ + int i; + for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++) + sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]); + g->sweepstrgc += i; + if (g->sweepstrgc >= g->strt.size) /* no more strings to sweep? */ g->gcstate = GCSsweepudata; - return 0; - } + return i * GCSWEEPCOST; } case GCSsweepudata: { - if (*g->sweepgc) { - g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (g->sweepfin) { + g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX); return GCSWEEPMAX*GCSWEEPCOST; } else { - g->sweepgc = &g->allgc; /* go to next phase */ g->gcstate = GCSsweep; - return GCSWEEPCOST; + return 0; } } case GCSsweep: { - if (*g->sweepgc) { + if (g->sweepgc) { g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); return GCSWEEPMAX*GCSWEEPCOST; } @@ -1018,43 +1105,52 @@ void luaC_runtilstate (lua_State *L, int statesmask) { static void generationalcollection (lua_State *L) { global_State *g = G(L); - if (g->lastmajormem == 0) { /* signal for another major collection? */ + if (g->GCestimate == 0) { /* signal for another major collection? */ luaC_fullgc(L, 0); /* perform a full regular collection */ - g->lastmajormem = gettotalbytes(g); /* update control */ + g->GCestimate = gettotalbytes(g); /* update control */ } else { + lu_mem estimate = g->GCestimate; luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ luaC_runtilstate(L, bitmask(GCSpause)); - if (gettotalbytes(g) > g->lastmajormem/100 * g->gcmajorinc) - g->lastmajormem = 0; /* signal for a major collection */ + if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) + g->GCestimate = 0; /* signal for a major collection */ } luaE_setdebt(g, stddebt(g)); } -static void step (lua_State *L) { +static void incstep (lua_State *L) { global_State *g = G(L); - l_mem lim = g->gcstepmul; /* how much to work */ + l_mem debt = g->GCdebt; + int stepmul = g->gcstepmul; + if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values */ + /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */ + debt = (debt / STEPMULADJ) + 1; + debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; do { /* always perform at least one single step */ - lim -= singlestep(L); - } while (lim > 0 && g->gcstate != GCSpause); - if (g->gcstate != GCSpause) - luaE_setdebt(g, g->GCdebt - GCSTEPSIZE); + lu_mem work = singlestep(L); /* do some work */ + debt -= work; + } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); + if (g->gcstate == GCSpause) + debt = stddebtest(g, g->GCestimate); /* pause until next cycle */ else - luaE_setdebt(g, stddebt(g)); + debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */ + luaE_setdebt(g, debt); } /* -** performs a basic GC step even if the collector is stopped +** performs a basic GC step */ void luaC_forcestep (lua_State *L) { global_State *g = G(L); int i; if (isgenerational(g)) generationalcollection(L); - else step(L); - for (i = 0; i < GCFINALIZENUM && g->tobefnz; i++) - GCTM(L, 1); /* Call a few pending finalizers */ + else incstep(L); + /* run a few finalizers (or all of them at the end of a collect cycle) */ + for (i = 0; g->tobefnz && (i < GCFINALIZENUM || g->gcstate == GCSpause); i++) + GCTM(L, 1); /* call one finalizer */ } @@ -1062,10 +1158,13 @@ void luaC_forcestep (lua_State *L) { ** performs a basic GC step only if collector is running */ void luaC_step (lua_State *L) { - if (G(L)->gcrunning) luaC_forcestep(L); + global_State *g = G(L); + if (g->gcrunning) luaC_forcestep(L); + else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */ } + /* ** performs a full GC cycle; if "isemergency", does not call ** finalizers (which could change stack positions) @@ -1073,16 +1172,19 @@ void luaC_step (lua_State *L) { void luaC_fullgc (lua_State *L, int isemergency) { global_State *g = G(L); int origkind = g->gckind; + int someblack = keepinvariant(g); lua_assert(origkind != KGC_EMERGENCY); - if (!isemergency) /* do not run finalizers during emergency GC */ + if (isemergency) /* do not run finalizers during emergency GC */ + g->gckind = KGC_EMERGENCY; + else { + g->gckind = KGC_NORMAL; callallpendingfinalizers(L, 1); - if (keepinvariant(g)) { /* marking phase? */ + } + if (someblack) { /* may there be some black objects? */ /* must sweep all objects to turn them back to white (as white has not changed, nothing will be collected) */ - g->sweepstrgc = 0; - g->gcstate = GCSsweepstring; + entersweep(L); } - g->gckind = isemergency ? KGC_EMERGENCY : KGC_NORMAL; /* finish any pending sweep phase to start a new cycle */ luaC_runtilstate(L, bitmask(GCSpause)); /* run entire collector */ diff --git a/src/lgc.h b/src/lgc.h index aa5dfce2..bdd5cce6 100644 --- a/src/lgc.h +++ b/src/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.52 2011/10/03 17:54:25 roberto Exp $ +** $Id: lgc.h,v 2.56 2012/05/23 15:43:14 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -25,6 +25,14 @@ */ + +/* how much to allocate before next GC step */ +#if !defined(GCSTEPSIZE) +/* ~100 small strings */ +#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) +#endif + + /* ** Possible states of the Garbage Collector */ diff --git a/src/llex.c b/src/llex.c index 74deebb9..c4d8c65b 100644 --- a/src/llex.c +++ b/src/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.59 2011/11/30 12:43:51 roberto Exp $ +** $Id: llex.c,v 2.61 2012/01/23 23:05:51 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -67,7 +67,7 @@ void luaX_init (lua_State *L) { for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + ts->tsv.extra = cast_byte(i+1); /* reserved word */ } } @@ -222,13 +222,24 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) { /* LUA_NUMBER */ +/* +** this function is quite liberal in what it accepts, as 'luaO_str2d' +** will reject ill-formed numerals. +*/ static void read_numeral (LexState *ls, SemInfo *seminfo) { + const char *expo = "Ee"; + int first = ls->current; lua_assert(lisdigit(ls->current)); - do { - save_and_next(ls); - if (check_next(ls, "EePp")) /* exponent part? */ + save_and_next(ls); + if (first == '0' && check_next(ls, "Xx")) /* hexadecimal? */ + expo = "Pp"; + for (;;) { + if (check_next(ls, expo)) /* exponent part? */ check_next(ls, "+-"); /* optional exponent sign */ - } while (lislalnum(ls->current) || ls->current == '.'); + if (lisxdigit(ls->current) || ls->current == '.') + save_and_next(ls); + else break; + } save(ls, '\0'); buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ if (!buff2d(ls->buff, &seminfo->r)) /* format error? */ @@ -480,8 +491,8 @@ static int llex (LexState *ls, SemInfo *seminfo) { ts = luaX_newstring(ls, luaZ_buffer(ls->buff), luaZ_bufflen(ls->buff)); seminfo->ts = ts; - if (ts->tsv.reserved > 0) /* reserved word? */ - return ts->tsv.reserved - 1 + FIRST_RESERVED; + if (isreserved(ts)) /* reserved word? */ + return ts->tsv.extra - 1 + FIRST_RESERVED; else { return TK_NAME; } diff --git a/src/llimits.h b/src/llimits.h index 48dc81f7..fc9de1a1 100644 --- a/src/llimits.h +++ b/src/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.95 2011/12/06 16:58:36 roberto Exp $ +** $Id: llimits.h,v 1.99 2012/05/28 20:32:28 roberto Exp $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -31,6 +31,8 @@ typedef unsigned char lu_byte; #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) +#define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2)) + #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ @@ -209,31 +211,36 @@ typedef lu_int32 Instruction; #elif defined(LUA_IEEE754TRICK) /* }{ */ /* the next trick should work on any machine using IEEE754 with - a 32-bit integer type */ + a 32-bit int type */ union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; #if !defined(LUA_IEEEENDIAN) /* { */ #define LUAI_EXTRAIEEE \ static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)}; -#define LUA_IEEEENDIAN (ieeeendian.l_p[1] == 33) +#define LUA_IEEEENDIANLOC (ieeeendian.l_p[1] == 33) #else +#define LUA_IEEEENDIANLOC LUA_IEEEENDIAN #define LUAI_EXTRAIEEE /* empty */ #endif /* } */ #define lua_number2int32(i,n,t) \ { LUAI_EXTRAIEEE \ volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \ - (i) = (t)u.l_p[LUA_IEEEENDIAN]; } + (i) = (t)u.l_p[LUA_IEEEENDIANLOC]; } #define luai_hashnum(i,n) \ { volatile union luai_Cast u; u.l_d = (n) + 1.0; /* avoid -0 */ \ (i) = u.l_p[0]; (i) += u.l_p[1]; } /* add double bits for his hash */ #define lua_number2int(i,n) lua_number2int32(i, n, int) -#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer) #define lua_number2unsigned(i,n) lua_number2int32(i, n, lua_Unsigned) +/* the trick can be expanded to lua_Integer when it is a 32-bit value */ +#if defined(LUA_IEEELL) +#define lua_number2integer(i,n) lua_number2int32(i, n, lua_Integer) +#endif + #endif /* } */ diff --git a/src/lmathlib.c b/src/lmathlib.c index b17237f0..c3c605e8 100644 --- a/src/lmathlib.c +++ b/src/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.80 2011/07/05 12:49:35 roberto Exp $ +** $Id: lmathlib.c,v 1.81 2012/05/18 17:47:53 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -17,17 +17,17 @@ #include "lualib.h" -#undef PI -#define PI (3.14159265358979323846) -#define RADIANS_PER_DEGREE (PI/180.0) - - /* macro 'l_tg' allows the addition of an 'l' or 'f' to all math operations */ #if !defined(l_tg) #define l_tg(x) (x) #endif +#undef PI +#define PI (l_tg(3.1415926535897932384626433832795)) +#define RADIANS_PER_DEGREE (PI/180.0) + + static int math_abs (lua_State *L) { lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1))); diff --git a/src/lmem.c b/src/lmem.c index 792deb3c..3f88496e 100644 --- a/src/lmem.c +++ b/src/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.83 2011/11/30 12:42:49 roberto Exp $ +** $Id: lmem.c,v 1.84 2012/05/23 15:41:53 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -94,22 +94,6 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { } lua_assert((nsize == 0) == (newblock == NULL)); g->GCdebt = (g->GCdebt + nsize) - realosize; -#if defined(TRACEMEM) - { /* auxiliary patch to monitor garbage collection. - ** To plot, gnuplot with following command: - ** plot TRACEMEM using 1:2 with lines, TRACEMEM using 1:3 with lines - */ - static unsigned long total = 0; /* our "time" */ - static FILE *f = NULL; /* output file */ - total++; /* "time" always grows */ - if ((total % 200) == 0) { - if (f == NULL) f = fopen(TRACEMEM, "w"); - fprintf(f, "%lu %u %d %d\n", total, - gettotalbytes(g), g->GCdebt, g->gcstate * 10000); - } - } -#endif - return newblock; } diff --git a/src/loadlib.c b/src/loadlib.c index 783bc12b..a9959277 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.108 2011/12/12 16:34:03 roberto Exp $ +** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -92,9 +92,9 @@ #define LUA_OFSEP "_" -#define LIBPREFIX "LOADLIB: " +/* table (in the registry) that keeps handles for all loaded C libraries */ +#define CLIBS "_CLIBS" -#define POF LUA_POF #define LIB_FAIL "open" @@ -248,48 +248,54 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { #endif - -static void **ll_register (lua_State *L, const char *path) { - void **plib; - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ - if (!lua_isnil(L, -1)) /* is there an entry? */ - plib = (void **)lua_touserdata(L, -1); - else { /* no entry yet; create one */ - lua_pop(L, 1); /* remove result from gettable */ - plib = (void **)lua_newuserdata(L, sizeof(const void *)); - *plib = NULL; - luaL_setmetatable(L, "_LOADLIB"); - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_pushvalue(L, -2); - lua_settable(L, LUA_REGISTRYINDEX); - } +static void *ll_checkclib (lua_State *L, const char *path) { + void *plib; + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_getfield(L, -1, path); + plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ + lua_pop(L, 2); /* pop CLIBS table and 'plib' */ return plib; } +static void ll_addtoclib (lua_State *L, const char *path, void *plib) { + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_pushlightuserdata(L, plib); + lua_pushvalue(L, -1); + lua_setfield(L, -3, path); /* CLIBS[path] = plib */ + lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ + lua_pop(L, 1); /* pop CLIBS table */ +} + + /* -** __gc tag method: calls library's `ll_unloadlib' function with the lib -** handle +** __gc tag method for CLIBS table: calls 'll_unloadlib' for all lib +** handles in list CLIBS */ static int gctm (lua_State *L) { - void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); - if (*lib) ll_unloadlib(*lib); - *lib = NULL; /* mark library as closed */ + int n = luaL_len(L, 1); + for (; n >= 1; n--) { /* for each handle, in reverse order */ + lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ + ll_unloadlib(lua_touserdata(L, -1)); + lua_pop(L, 1); /* pop handle */ + } return 0; } static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { - void **reg = ll_register(L, path); - if (*reg == NULL) *reg = ll_load(L, path, *sym == '*'); - if (*reg == NULL) return ERRLIB; /* unable to load library */ + void *reg = ll_checkclib(L, path); /* check loaded C libraries */ + if (reg == NULL) { /* must load library? */ + reg = ll_load(L, path, *sym == '*'); + if (reg == NULL) return ERRLIB; /* unable to load library */ + ll_addtoclib(L, path, reg); + } if (*sym == '*') { /* loading only library (no function)? */ lua_pushboolean(L, 1); /* return 'true' */ return 0; /* no errors */ } else { - lua_CFunction f = ll_sym(L, *reg, sym); + lua_CFunction f = ll_sym(L, reg, sym); if (f == NULL) return ERRFUNC; /* unable to find function */ lua_pushcfunction(L, f); /* else create new function */ @@ -418,12 +424,12 @@ static int loadfunc (lua_State *L, const char *filename, const char *modname) { if (mark) { int stat; funcname = lua_pushlstring(L, modname, mark - modname); - funcname = lua_pushfstring(L, POF"%s", funcname); + funcname = lua_pushfstring(L, LUA_POF"%s", funcname); stat = ll_loadfunc(L, filename, funcname); if (stat != ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - funcname = lua_pushfstring(L, POF"%s", modname); + funcname = lua_pushfstring(L, LUA_POF"%s", modname); return ll_loadfunc(L, filename, funcname); } @@ -476,9 +482,9 @@ static void findloader (lua_State *L, const char *name) { lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ if (!lua_istable(L, 3)) luaL_error(L, LUA_QL("package.searchers") " must be a table"); - /* iterate over available seachers to find a loader */ + /* iterate over available searchers to find a loader */ for (i = 1; ; i++) { - lua_rawgeti(L, 3, i); /* get a seacher */ + lua_rawgeti(L, 3, i); /* get a searcher */ if (lua_isnil(L, -1)) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ luaL_pushresult(&msg); /* create error message */ @@ -666,18 +672,10 @@ static const luaL_Reg ll_funcs[] = { }; -static const lua_CFunction searchers[] = - {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; - - -LUAMOD_API int luaopen_package (lua_State *L) { +static void createsearcherstable (lua_State *L) { + static const lua_CFunction searchers[] = + {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; int i; - /* create new type _LOADLIB */ - luaL_newmetatable(L, "_LOADLIB"); - lua_pushcfunction(L, gctm); - lua_setfield(L, -2, "__gc"); - /* create `package' table */ - luaL_newlib(L, pk_funcs); /* create 'searchers' table */ lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); /* fill it with pre-defined searchers */ @@ -686,6 +684,19 @@ LUAMOD_API int luaopen_package (lua_State *L) { lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i+1); } +} + + +LUAMOD_API int luaopen_package (lua_State *L) { + /* create table CLIBS to keep track of loaded C libraries */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); + lua_createtable(L, 0, 1); /* metatable for CLIBS */ + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ + lua_setmetatable(L, -2); + /* create `package' table */ + luaL_newlib(L, pk_funcs); + createsearcherstable(L); #if defined(LUA_COMPAT_LOADERS) lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */ diff --git a/src/lobject.h b/src/lobject.h index 06246bfa..ca75a028 100644 --- a/src/lobject.h +++ b/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.64 2011/10/31 17:48:22 roberto Exp $ +** $Id: lobject.h,v 2.70 2012/05/11 14:10:50 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -36,6 +36,9 @@ ** bit 6: whether value is collectable */ +#define VARBITS (3 << 4) + + /* ** LUA_TFUNCTION variants: ** 0 - Lua function @@ -49,6 +52,12 @@ #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ +/* +** LUA_TSTRING variants */ +#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ +#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ + + /* Bit mark for collectable types */ #define BIT_ISCOLLECTABLE (1 << 6) @@ -109,23 +118,28 @@ typedef struct lua_TValue TValue; /* raw type tag of a TValue */ #define rttype(o) ((o)->tt_) +/* tag with no variants (bits 0-3) */ +#define novariant(x) ((x) & 0x0F) + /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ #define ttype(o) (rttype(o) & 0x3F) - /* type tag of a TValue with no variants (bits 0-3) */ -#define ttypenv(o) (rttype(o) & 0x0F) +#define ttypenv(o) (novariant(rttype(o))) /* Macros to test type */ #define checktag(o,t) (rttype(o) == (t)) +#define checktype(o,t) (ttypenv(o) == (t)) #define ttisnumber(o) checktag((o), LUA_TNUMBER) #define ttisnil(o) checktag((o), LUA_TNIL) #define ttisboolean(o) checktag((o), LUA_TBOOLEAN) #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) -#define ttisstring(o) checktag((o), ctb(LUA_TSTRING)) +#define ttisstring(o) checktype((o), LUA_TSTRING) +#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) +#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) #define ttistable(o) checktag((o), ctb(LUA_TTABLE)) -#define ttisfunction(o) (ttypenv(o) == LUA_TFUNCTION) +#define ttisfunction(o) checktype(o, LUA_TFUNCTION) #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) @@ -161,7 +175,7 @@ typedef struct lua_TValue TValue; /* Macros for internal tests */ -#define righttt(obj) (ttypenv(obj) == gcvalue(obj)->gch.tt) +#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) #define checkliveness(g,obj) \ lua_longassert(!iscollectable(obj) || \ @@ -193,7 +207,8 @@ typedef struct lua_TValue TValue; #define setsvalue(L,obj,x) \ { TValue *io=(obj); \ - val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TSTRING)); \ + TString *x_ = (x); \ + val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \ checkliveness(G(L),io); } #define setuvalue(L,obj,x) \ @@ -221,11 +236,6 @@ typedef struct lua_TValue TValue; val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \ checkliveness(G(L),io); } -#define setptvalue(L,obj,x) \ - { TValue *io=(obj); \ - val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TPROTO)); \ - checkliveness(G(L),io); } - #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) @@ -256,6 +266,8 @@ typedef struct lua_TValue TValue; #define setsvalue2n setsvalue +/* check whether a number is valid (useful only for NaN trick) */ +#define luai_checknum(L,o,c) { /* empty */ } /* @@ -263,10 +275,7 @@ typedef struct lua_TValue TValue; ** NaN Trick ** ======================================================= */ - -#if defined(LUA_NANTRICK) \ - || defined(LUA_NANTRICK_LE) \ - || defined(LUA_NANTRICK_BE) +#if defined(LUA_NANTRICK) /* ** numbers are represented in the 'd_' field. All other values have the @@ -274,15 +283,23 @@ typedef struct lua_TValue TValue; ** a "signaled NaN", which is never generated by regular operations by ** the CPU (nor by 'strtod') */ -#if !defined(NNMARK) + +/* allows for external implementation for part of the trick */ +#if !defined(NNMARK) /* { */ + + +#if !defined(LUA_IEEEENDIAN) +#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN' +#endif + + #define NNMARK 0x7FF7A500 #define NNMASK 0x7FFFFF00 -#endif #undef TValuefields #undef NILCONSTANT -#if defined(LUA_NANTRICK_LE) +#if (LUA_IEEEENDIAN == 0) /* { */ /* little endian */ #define TValuefields \ @@ -293,7 +310,7 @@ typedef struct lua_TValue TValue; #define d_(o) ((o)->u.d__) #define tt_(o) ((o)->u.i.tt__) -#elif defined(LUA_NANTRICK_BE) +#else /* }{ */ /* big endian */ #define TValuefields \ @@ -304,10 +321,9 @@ typedef struct lua_TValue TValue; #define d_(o) ((o)->u.d__) #define tt_(o) ((o)->u.i.tt__) -#elif !defined(TValuefields) -#error option 'LUA_NANTRICK' needs declaration for 'TValuefields' +#endif /* } */ -#endif +#endif /* } */ /* correspondence with standard representation */ @@ -348,21 +364,18 @@ typedef struct lua_TValue TValue; */ #undef checktag +#undef checktype #define checktag(o,t) (tt_(o) == tag2tt(t)) +#define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS)) #undef ttisequal #define ttisequal(o1,o2) \ (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2))) - +#undef luai_checknum #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } - -#else - -#define luai_checknum(L,o,c) { /* empty */ } - #endif /* }====================================================== */ @@ -401,7 +414,7 @@ typedef union TString { L_Umaxalign dummy; /* ensures maximum alignment for strings */ struct { CommonHeader; - lu_byte reserved; + lu_byte extra; /* reserved words for short strings; "has hash" for longs */ unsigned int hash; size_t len; /* number of characters in string */ } tsv; @@ -501,7 +514,7 @@ typedef struct UpVal { */ #define ClosureHeader \ - CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist + CommonHeader; lu_byte nupvalues; GCObject *gclist typedef struct CClosure { ClosureHeader; diff --git a/src/lopcodes.c b/src/lopcodes.c index 2e346766..ef736927 100644 --- a/src/lopcodes.c +++ b/src/lopcodes.c @@ -1,5 +1,6 @@ /* -** $Id: lopcodes.c,v 1.48 2011/04/19 16:22:13 roberto Exp $ +** $Id: lopcodes.c,v 1.49 2012/05/14 13:34:18 roberto Exp $ +** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/src/loslib.c b/src/loslib.c index 881667da..489755b6 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.38 2011/11/30 12:35:05 roberto Exp $ +** $Id: loslib.c,v 1.39 2012/05/23 15:37:09 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -26,11 +26,12 @@ #if !defined(LUA_STRFTIMEOPTIONS) #if !defined(LUA_USE_POSIX) -#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" } +#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" } #else -#define LUA_STRFTIMEOPTIONS { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "", \ - "E", "cCxXyY", \ - "O", "deHImMSuUVwWy" } +#define LUA_STRFTIMEOPTIONS \ + { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \ + "", "E", "cCxXyY", \ + "O", "deHImMSuUVwWy" } #endif #endif @@ -43,7 +44,7 @@ */ #if defined(LUA_USE_MKSTEMP) #include -#define LUA_TMPNAMBUFSIZE 32 +#define LUA_TMPNAMBUFSIZE 32 #define lua_tmpnam(b,e) { \ strcpy(b, "/tmp/lua_XXXXXX"); \ e = mkstemp(b); \ @@ -52,8 +53,8 @@ #elif !defined(lua_tmpnam) -#define LUA_TMPNAMBUFSIZE L_tmpnam -#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } #endif diff --git a/src/lparser.c b/src/lparser.c index 4d689365..b3eb3ca9 100644 --- a/src/lparser.c +++ b/src/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.124 2011/12/02 13:23:56 roberto Exp $ +** $Id: lparser.c,v 2.128 2012/05/20 14:51:23 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -222,7 +222,7 @@ static int searchupvalue (FuncState *fs, TString *name) { int i; Upvaldesc *up = fs->f->upvalues; for (i = 0; i < fs->nups; i++) { - if (eqstr(up[i].name, name)) return i; + if (luaS_eqstr(up[i].name, name)) return i; } return -1; /* not found */ } @@ -246,7 +246,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { static int searchvar (FuncState *fs, TString *n) { int i; for (i=fs->nactvar-1; i >= 0; i--) { - if (eqstr(n, getlocvar(fs, i)->varname)) + if (luaS_eqstr(n, getlocvar(fs, i)->varname)) return i; } return -1; /* not found */ @@ -342,7 +342,7 @@ static void closegoto (LexState *ls, int g, Labeldesc *label) { FuncState *fs = ls->fs; Labellist *gl = &ls->dyd->gt; Labeldesc *gt = &gl->arr[g]; - lua_assert(eqstr(gt->name, label->name)); + lua_assert(luaS_eqstr(gt->name, label->name)); if (gt->nactvar < label->nactvar) { TString *vname = getlocvar(fs, gt->nactvar)->varname; const char *msg = luaO_pushfstring(ls->L, @@ -369,7 +369,7 @@ static int findlabel (LexState *ls, int g) { /* check labels in current block for a match */ for (i = bl->firstlabel; i < dyd->label.n; i++) { Labeldesc *lb = &dyd->label.arr[i]; - if (eqstr(lb->name, gt->name)) { /* correct label? */ + if (luaS_eqstr(lb->name, gt->name)) { /* correct label? */ if (gt->nactvar > lb->nactvar && (bl->upval || dyd->label.n > bl->firstlabel)) luaK_patchclose(ls->fs, gt->pc, lb->nactvar); @@ -403,7 +403,7 @@ static void findgotos (LexState *ls, Labeldesc *lb) { Labellist *gl = &ls->dyd->gt; int i = ls->fs->bl->firstgoto; while (i < gl->n) { - if (eqstr(gl->arr[i].name, lb->name)) + if (luaS_eqstr(gl->arr[i].name, lb->name)) closegoto(ls, i, lb); else i++; @@ -461,7 +461,7 @@ static void breaklabel (LexState *ls) { ** message when label name is a reserved word (which can only be 'break') */ static l_noret undefgoto (LexState *ls, Labeldesc *gt) { - const char *msg = (gt->name->tsv.reserved > 0) + const char *msg = isreserved(gt->name) ? "<%s> at line %d not inside a loop" : "no visible label " LUA_QS " for at line %d"; msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); @@ -493,21 +493,30 @@ static void leaveblock (FuncState *fs) { /* -** adds prototype being created into its parent list of prototypes -** and codes instruction to create new closure +** adds a new prototype into list of prototypes */ -static void codeclosure (LexState *ls, Proto *clp, expdesc *v) { - FuncState *fs = ls->fs->prev; - Proto *f = fs->f; /* prototype of function creating new closure */ +static Proto *addprototype (LexState *ls) { + Proto *clp; + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; /* prototype of current function */ if (fs->np >= f->sizep) { int oldsize = f->sizep; - luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, - MAXARG_Bx, "functions"); + luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); while (oldsize < f->sizep) f->p[oldsize++] = NULL; } - f->p[fs->np++] = clp; - luaC_objbarrier(ls->L, f, clp); - init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + f->p[fs->np++] = clp = luaF_newproto(L); + luaC_objbarrier(L, f, clp); + return clp; +} + + +/* +** codes instruction to create new closure in parent function +*/ +static void codeclosure (LexState *ls, expdesc *v) { + FuncState *fs = ls->fs->prev; + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); luaK_exp2nextreg(fs, v); /* fix it at stack top (for GC) */ } @@ -529,13 +538,9 @@ static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { fs->nactvar = 0; fs->firstlocal = ls->dyd->actvar.n; fs->bl = NULL; - f = luaF_newproto(L); - fs->f = f; + f = fs->f; f->source = ls->source; f->maxstacksize = 2; /* registers 0/1 are always valid */ - /* anchor prototype (to avoid being collected) */ - setptvalue2s(L, L->top, f); - incr_top(L); fs->h = luaH_new(L); /* anchor table of constants (to avoid being collected) */ sethvalue2s(L, L->top, fs->h); @@ -568,20 +573,6 @@ static void close_func (LexState *ls) { anchor_token(ls); L->top--; /* pop table of constants */ luaC_checkGC(L); - L->top--; /* pop prototype (after possible collection) */ -} - - -/* -** opens the main function, which is a regular vararg function with an -** upvalue named LUA_ENV -*/ -static void open_mainfunc (LexState *ls, FuncState *fs, BlockCnt *bl) { - expdesc v; - open_func(ls, fs, bl); - fs->f->is_vararg = 1; /* main function is always vararg */ - init_exp(&v, VLOCAL, 0); - newupvalue(fs, ls->envn, &v); /* create environment upvalue */ } @@ -795,8 +786,9 @@ static void body (LexState *ls, expdesc *e, int ismethod, int line) { /* body -> `(' parlist `)' block END */ FuncState new_fs; BlockCnt bl; - open_func(ls, &new_fs, &bl); + new_fs.f = addprototype(ls); new_fs.f->linedefined = line; + open_func(ls, &new_fs, &bl); checknext(ls, '('); if (ismethod) { new_localvarliteral(ls, "self"); /* create 'self' parameter */ @@ -807,7 +799,7 @@ static void body (LexState *ls, expdesc *e, int ismethod, int line) { statlist(ls); new_fs.f->lastlinedefined = ls->linenumber; check_match(ls, TK_END, TK_FUNCTION, line); - codeclosure(ls, new_fs.f, e); + codeclosure(ls, e); close_func(ls); } @@ -879,8 +871,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) { */ -static void prefixexp (LexState *ls, expdesc *v) { - /* prefixexp -> NAME | '(' expr ')' */ +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> NAME | '(' expr ')' */ switch (ls->t.token) { case '(': { int line = ls->linenumber; @@ -901,12 +893,12 @@ static void prefixexp (LexState *ls, expdesc *v) { } -static void primaryexp (LexState *ls, expdesc *v) { - /* primaryexp -> - prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ +static void suffixedexp (LexState *ls, expdesc *v) { + /* suffixedexp -> + primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ FuncState *fs = ls->fs; int line = ls->linenumber; - prefixexp(ls, v); + primaryexp(ls, v); for (;;) { switch (ls->t.token) { case '.': { /* fieldsel */ @@ -941,7 +933,7 @@ static void primaryexp (LexState *ls, expdesc *v) { static void simpleexp (LexState *ls, expdesc *v) { /* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... | - constructor | FUNCTION body | primaryexp */ + constructor | FUNCTION body | suffixedexp */ switch (ls->t.token) { case TK_NUMBER: { init_exp(v, VKNUM, 0); @@ -981,7 +973,7 @@ static void simpleexp (LexState *ls, expdesc *v) { return; } default: { - primaryexp(ls, v); + suffixedexp(ls, v); return; } } @@ -1141,10 +1133,10 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { expdesc e; check_condition(ls, vkisvar(lh->v.k), "syntax error"); - if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ struct LHS_assign nv; nv.prev = lh; - primaryexp(ls, &nv.v); + suffixedexp(ls, &nv.v); if (nv.v.k != VINDEXED) check_conflict(ls, lh, &nv.v); checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, @@ -1200,7 +1192,7 @@ static void gotostat (LexState *ls, int pc) { static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { int i; for (i = fs->bl->firstlabel; i < ll->n; i++) { - if (eqstr(label, ll->arr[i].name)) { + if (luaS_eqstr(label, ll->arr[i].name)) { const char *msg = luaO_pushfstring(fs->ls->L, "label " LUA_QS " already defined on line %d", getstr(label), ll->arr[i].line); @@ -1210,6 +1202,13 @@ static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { } +/* skip no-op statements */ +static void skipnoopstat (LexState *ls) { + while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) + statement(ls); +} + + static void labelstat (LexState *ls, TString *label, int line) { /* label -> '::' NAME '::' */ FuncState *fs = ls->fs; @@ -1219,9 +1218,7 @@ static void labelstat (LexState *ls, TString *label, int line) { checknext(ls, TK_DBCOLON); /* skip double colon */ /* create new entry for this label */ l = newlabelentry(ls, ll, label, line, fs->pc); - /* skip other no-op statements */ - while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) - statement(ls); + skipnoopstat(ls); /* skip other no-op statements */ if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ /* assume that locals are already out of scope */ ll->arr[l].nactvar = fs->bl->nactvar; @@ -1384,6 +1381,7 @@ static void test_then_block (LexState *ls, int *escapelist) { luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ enterblock(fs, &bl, 0); /* must enter block before 'goto' */ gotostat(ls, v.t); /* handle goto/break */ + skipnoopstat(ls); /* skip other no-op statements */ if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ leaveblock(fs); return; /* and that is it */ @@ -1480,13 +1478,15 @@ static void exprstat (LexState *ls) { /* stat -> func | assignment */ FuncState *fs = ls->fs; struct LHS_assign v; - primaryexp(ls, &v.v); - if (v.v.k == VCALL) /* stat -> func */ - SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ - else { /* stat -> assignment */ + suffixedexp(ls, &v.v); + if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ v.prev = NULL; assignment(ls, &v, 1); } + else { /* stat -> func */ + check_condition(ls, v.v.k == VCALL, "syntax error"); + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + } } @@ -1594,27 +1594,42 @@ static void statement (LexState *ls) { /* }====================================================================== */ -Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - Dyndata *dyd, const char *name, int firstchar) { +/* +** compiles the main function, which is a regular vararg function with an +** upvalue named LUA_ENV +*/ +static void mainfunc (LexState *ls, FuncState *fs) { + BlockCnt bl; + expdesc v; + open_func(ls, fs, &bl); + fs->f->is_vararg = 1; /* main function is always vararg */ + init_exp(&v, VLOCAL, 0); /* create and... */ + newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ + luaX_next(ls); /* read first token */ + statlist(ls); /* parse main body */ + check(ls, TK_EOS); + close_func(ls); +} + + +Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar) { LexState lexstate; FuncState funcstate; - BlockCnt bl; - TString *tname = luaS_new(L, name); - setsvalue2s(L, L->top, tname); /* push name to protect it */ + Closure *cl = luaF_newLclosure(L, 1); /* create main closure */ + /* anchor closure (to avoid being collected) */ + setclLvalue(L, L->top, cl); incr_top(L); + funcstate.f = cl->l.p = luaF_newproto(L); + funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ lexstate.buff = buff; lexstate.dyd = dyd; dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; - luaX_setinput(L, &lexstate, z, tname, firstchar); - open_mainfunc(&lexstate, &funcstate, &bl); - luaX_next(&lexstate); /* read first token */ - statlist(&lexstate); /* main body */ - check(&lexstate, TK_EOS); - close_func(&lexstate); - L->top--; /* pop name */ + luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); + mainfunc(&lexstate, &funcstate); lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); /* all scopes should be correctly finished */ lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); - return funcstate.f; + return cl; /* it's on the stack too */ } diff --git a/src/lparser.h b/src/lparser.h index caabf46c..301167d4 100644 --- a/src/lparser.h +++ b/src/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.69 2011/07/27 18:09:01 roberto Exp $ +** $Id: lparser.h,v 1.70 2012/05/08 13:53:33 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -112,8 +112,8 @@ typedef struct FuncState { } FuncState; -LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - Dyndata *dyd, const char *name, int firstchar); +LUAI_FUNC Closure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar); #endif diff --git a/src/lstate.c b/src/lstate.c index 6e2801c4..3c00c285 100644 --- a/src/lstate.c +++ b/src/lstate.c @@ -1,11 +1,12 @@ /* -** $Id: lstate.c,v 2.92 2011/10/03 17:54:25 roberto Exp $ +** $Id: lstate.c,v 2.98 2012/05/30 12:33:44 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ #include +#include #define lstate_c #define LUA_CORE @@ -38,7 +39,18 @@ #endif -#define MEMERRMSG "not enough memory" +#define MEMERRMSG "not enough memory" + + +/* +** a macro to help the creation of a unique random seed when a state is +** created; the seed is used to randomize hashes. +*/ +#if !defined(luai_makeseed) +#include +#define luai_makeseed() cast(size_t, time(NULL)) +#endif + /* @@ -65,6 +77,28 @@ typedef struct LG { #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) +/* +** Compute an initial seed as random as possible. In ANSI, rely on +** Address Space Layout Randomization (if present) to increase +** randomness.. +*/ +#define addbuff(b,p,e) \ + { size_t t = cast(size_t, e); \ + memcpy(buff + p, &t, sizeof(t)); p += sizeof(t); } + +static unsigned int makeseed (lua_State *L) { + char buff[4 * sizeof(size_t)]; + unsigned int h = luai_makeseed(); + int p = 0; + addbuff(buff, p, L); /* heap variable */ + addbuff(buff, p, &h); /* local variable */ + addbuff(buff, p, luaO_nilobject); /* global variable */ + addbuff(buff, p, &lua_newstate); /* public function */ + lua_assert(p == sizeof(buff)); + return luaS_hash(buff, p, h); +} + + /* ** set GCdebt to a new value keeping the value (totalbytes + GCdebt) ** invariant @@ -242,10 +276,11 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { g->frealloc = f; g->ud = ud; g->mainthread = L; + g->seed = makeseed(L); g->uvhead.u.l.prev = &g->uvhead; g->uvhead.u.l.next = &g->uvhead; g->gcrunning = 0; /* no GC while building state */ - g->lastmajormem = 0; + g->GCestimate = 0; g->strt.size = 0; g->strt.nuse = 0; g->strt.hash = NULL; @@ -257,6 +292,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { g->allgc = NULL; g->finobj = NULL; g->tobefnz = NULL; + g->sweepgc = g->sweepfin = NULL; g->gray = g->grayagain = NULL; g->weak = g->ephemeron = g->allweak = NULL; g->totalbytes = sizeof(LG); diff --git a/src/lstate.h b/src/lstate.h index 4743d741..29f810ba 100644 --- a/src/lstate.h +++ b/src/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.74 2011/09/30 12:45:07 roberto Exp $ +** $Id: lstate.h,v 2.81 2012/06/08 15:14:04 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -72,6 +72,7 @@ typedef struct CallInfo { struct CallInfo *previous, *next; /* dynamic call link */ short nresults; /* expected number of results from this function */ lu_byte callstatus; + ptrdiff_t extra; union { struct { /* only for Lua functions */ StkId base; /* base for this function */ @@ -81,7 +82,6 @@ typedef struct CallInfo { int ctx; /* context info. in case of yields */ lua_CFunction k; /* continuation in case of yields */ ptrdiff_t old_errfunc; - ptrdiff_t extra; lu_byte old_allowhook; lu_byte status; } c; @@ -100,6 +100,7 @@ typedef struct CallInfo { #define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ #define CIST_STAT (1<<5) /* call has an error status (pcall) */ #define CIST_TAIL (1<<6) /* call was tail called */ +#define CIST_HOOKYIELD (1<<7) /* last hook called yielded */ #define isLua(ci) ((ci)->callstatus & CIST_LUA) @@ -113,9 +114,11 @@ typedef struct global_State { void *ud; /* auxiliary data to `frealloc' */ lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */ l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ - lu_mem lastmajormem; /* memory in use after last major collection */ + lu_mem GCmemtrav; /* memory traversed by the GC */ + lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ stringtable strt; /* hash table for strings */ TValue l_registry; + unsigned int seed; /* randomized seed for hashes */ lu_byte currentwhite; lu_byte gcstate; /* state of garbage collector */ lu_byte gckind; /* kind of GC running */ @@ -123,7 +126,8 @@ typedef struct global_State { int sweepstrgc; /* position of sweep in `strt' */ GCObject *allgc; /* list of all collectable objects */ GCObject *finobj; /* list of collectable objects with finalizers */ - GCObject **sweepgc; /* current position of sweep */ + GCObject **sweepgc; /* current position of sweep in list 'allgc' */ + GCObject **sweepfin; /* current position of sweep in list 'finobj' */ GCObject *gray; /* list of gray objects */ GCObject *grayagain; /* list of objects to be traversed atomically */ GCObject *weak; /* list of tables with weak values */ @@ -193,11 +197,15 @@ union GCObject { #define gch(o) (&(o)->gch) /* macros to convert a GCObject into a specific value */ -#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define rawgco2ts(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((o)->ts)) #define gco2ts(o) (&rawgco2ts(o)->tsv) #define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) #define gco2u(o) (&rawgco2u(o)->uv) -#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2lcl(o) check_exp((o)->gch.tt == LUA_TLCL, &((o)->cl.l)) +#define gco2ccl(o) check_exp((o)->gch.tt == LUA_TCCL, &((o)->cl.c)) +#define gco2cl(o) \ + check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((o)->cl)) #define gco2t(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) #define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) #define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) diff --git a/src/lstring.c b/src/lstring.c index adec415e..8b959f19 100644 --- a/src/lstring.c +++ b/src/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.19 2011/05/03 16:01:57 roberto Exp $ +** $Id: lstring.c,v 2.24 2012/05/11 14:14:42 roberto Exp $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -18,7 +18,49 @@ #include "lstring.h" +/* +** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to +** compute its hash +*/ +#if !defined(LUAI_HASHLIMIT) +#define LUAI_HASHLIMIT 5 +#endif + + +/* +** equality for long strings +*/ +int luaS_eqlngstr (TString *a, TString *b) { + size_t len = a->tsv.len; + lua_assert(a->tsv.tt == LUA_TLNGSTR && b->tsv.tt == LUA_TLNGSTR); + return (a == b) || /* same instance or... */ + ((len == b->tsv.len) && /* equal length and ... */ + (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ +} + + +/* +** equality for strings +*/ +int luaS_eqstr (TString *a, TString *b) { + return (a->tsv.tt == b->tsv.tt) && + (a->tsv.tt == LUA_TSHRSTR ? eqshrstr(a, b) : luaS_eqlngstr(a, b)); +} + + +unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { + unsigned int h = seed ^ l; + size_t l1; + size_t step = (l >> LUAI_HASHLIMIT) + 1; + for (l1 = l; l1 >= step; l1 -= step) + h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1])); + return h; +} + +/* +** resizes the string table +*/ void luaS_resize (lua_State *L, int newsize) { int i; stringtable *tb = &G(L)->strt; @@ -50,37 +92,49 @@ void luaS_resize (lua_State *L, int newsize) { } -static TString *newlstr (lua_State *L, const char *str, size_t l, - unsigned int h) { - size_t totalsize; /* total size of TString object */ - GCObject **list; /* (pointer to) list where it will be inserted */ +/* +** creates a new string object +*/ +static TString *createstrobj (lua_State *L, const char *str, size_t l, + int tag, unsigned int h, GCObject **list) { TString *ts; - stringtable *tb = &G(L)->strt; - if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) - luaM_toobig(L); - if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) - luaS_resize(L, tb->size*2); /* too crowded */ + size_t totalsize; /* total size of TString object */ totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); - list = &tb->hash[lmod(h, tb->size)]; - ts = &luaC_newobj(L, LUA_TSTRING, totalsize, list, 0)->ts; + ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts; ts->tsv.len = l; ts->tsv.hash = h; - ts->tsv.reserved = 0; + ts->tsv.extra = 0; memcpy(ts+1, str, l*sizeof(char)); ((char *)(ts+1))[l] = '\0'; /* ending 0 */ - tb->nuse++; return ts; } -TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { +/* +** creates a new short string, inserting it into string table +*/ +static TString *newshrstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + GCObject **list; /* (pointer to) list where it will be inserted */ + stringtable *tb = &G(L)->strt; + TString *s; + if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + list = &tb->hash[lmod(h, tb->size)]; + s = createstrobj(L, str, l, LUA_TSHRSTR, h, list); + tb->nuse++; + return s; +} + + +/* +** checks whether short string exists and reuses it or creates a new one +*/ +static TString *internshrstr (lua_State *L, const char *str, size_t l) { GCObject *o; - unsigned int h = cast(unsigned int, l); /* seed */ - size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ - size_t l1; - for (l1=l; l1>=step; l1-=step) /* compute hash */ - h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); - for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + global_State *g = G(L); + unsigned int h = luaS_hash(str, l, g->seed); + for (o = g->strt.hash[lmod(h, g->strt.size)]; o != NULL; o = gch(o)->next) { TString *ts = rawgco2ts(o); @@ -92,10 +146,27 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { return ts; } } - return newlstr(L, str, l, h); /* not found; create a new string */ + return newshrstr(L, str, l, h); /* not found; create a new string */ +} + + +/* +** new string (with explicit length) +*/ +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + if (l <= LUAI_MAXSHORTLEN) /* short string? */ + return internshrstr(L, str, l); + else { + if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL); + } } +/* +** new zero-terminated string +*/ TString *luaS_new (lua_State *L, const char *str) { return luaS_newlstr(L, str, strlen(str)); } diff --git a/src/lstring.h b/src/lstring.h index d708a1b0..d312ff3d 100644 --- a/src/lstring.h +++ b/src/lstring.h @@ -1,5 +1,5 @@ /* -** $Id: lstring.h,v 1.46 2010/04/05 16:26:37 roberto Exp $ +** $Id: lstring.h,v 1.49 2012/02/01 21:57:15 roberto Exp $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -23,11 +23,20 @@ /* -** as all string are internalized, string equality becomes -** pointer equality +** test whether a string is a reserved word */ -#define eqstr(a,b) ((a) == (b)) +#define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) + +/* +** equality for short strings, which are always internalized +*/ +#define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) + + +LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); +LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); +LUAI_FUNC int luaS_eqstr (TString *a, TString *b); LUAI_FUNC void luaS_resize (lua_State *L, int newsize); LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); diff --git a/src/lstrlib.c b/src/lstrlib.c index f5d61fd8..e13098bb 100644 --- a/src/lstrlib.c +++ b/src/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.173 2011/11/30 18:24:56 roberto Exp $ +** $Id: lstrlib.c,v 1.176 2012/05/23 15:37:09 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -30,7 +30,7 @@ /* macro to `unsign' a character */ -#define uchar(c) ((unsigned char)(c)) +#define uchar(c) ((unsigned char)(c)) @@ -119,7 +119,9 @@ static int str_rep (lua_State *L) { char *p = luaL_buffinitsize(L, &b, totallen); while (n-- > 1) { /* first n-1 copies (followed by separator) */ memcpy(p, s, l * sizeof(char)); p += l; - memcpy(p, sep, lsep * sizeof(char)); p += lsep; + if (lsep > 0) { /* avoid empty 'memcpy' (may be expensive) */ + memcpy(p, sep, lsep * sizeof(char)); p += lsep; + } } memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */ luaL_pushresultsize(&b, totallen); @@ -745,20 +747,17 @@ static int str_gsub (lua_State *L) { #if !defined(LUA_INTFRMLEN) /* { */ #if defined(LUA_USE_LONGLONG) -#define LUA_INTFRMLEN "ll" -#define LUA_INTFRM_T long long +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long #else -#define LUA_INTFRMLEN "l" -#define LUA_INTFRM_T long +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long #endif #endif /* } */ -#define MAX_UINTFRM ((lua_Number)(~(unsigned LUA_INTFRM_T)0)) -#define MAX_INTFRM ((lua_Number)((~(unsigned LUA_INTFRM_T)0)/2)) -#define MIN_INTFRM (-(lua_Number)((~(unsigned LUA_INTFRM_T)0)/2) - 1) /* ** LUA_FLTFRMLEN is the length modifier for float conversions in @@ -767,8 +766,8 @@ static int str_gsub (lua_State *L) { */ #if !defined(LUA_FLTFRMLEN) -#define LUA_FLTFRMLEN "" -#define LUA_FLTFRM_T double +#define LUA_FLTFRMLEN "" +#define LUA_FLTFRM_T double #endif @@ -870,18 +869,22 @@ static int str_format (lua_State *L) { } case 'd': case 'i': { lua_Number n = luaL_checknumber(L, arg); - luaL_argcheck(L, (MIN_INTFRM - 1) < n && n < (MAX_INTFRM + 1), arg, + LUA_INTFRM_T ni = (LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, "not a number in proper range"); addlenmod(form, LUA_INTFRMLEN); - nb = sprintf(buff, form, (LUA_INTFRM_T)n); + nb = sprintf(buff, form, ni); break; } case 'o': case 'u': case 'x': case 'X': { lua_Number n = luaL_checknumber(L, arg); - luaL_argcheck(L, 0 <= n && n < (MAX_UINTFRM + 1), arg, + unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n; + lua_Number diff = n - (lua_Number)ni; + luaL_argcheck(L, -1 < diff && diff < 1, arg, "not a non-negative number in proper range"); addlenmod(form, LUA_INTFRMLEN); - nb = sprintf(buff, form, (unsigned LUA_INTFRM_T)n); + nb = sprintf(buff, form, ni); break; } case 'e': case 'E': case 'f': diff --git a/src/ltable.c b/src/ltable.c index 9581add9..ffa5ecb3 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.67 2011/11/30 12:41:45 roberto Exp $ +** $Id: ltable.c,v 2.71 2012/05/23 15:37:09 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -48,10 +48,10 @@ #define MAXASIZE (1 << MAXBITS) -#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) -#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) -#define hashboolean(t,p) hashpow2(t, p) +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) /* @@ -98,7 +98,15 @@ static Node *mainposition (const Table *t, const TValue *key) { switch (ttype(key)) { case LUA_TNUMBER: return hashnum(t, nvalue(key)); - case LUA_TSTRING: + case LUA_TLNGSTR: { + TString *s = rawtsvalue(key); + if (s->tsv.extra == 0) { /* no hash? */ + s->tsv.hash = luaS_hash(getstr(s), s->tsv.len, s->tsv.hash); + s->tsv.extra = 1; /* now it has its hash */ + } + return hashstr(t, rawtsvalue(key)); + } + case LUA_TSHRSTR: return hashstr(t, rawtsvalue(key)); case LUA_TBOOLEAN: return hashboolean(t, bvalue(key)); @@ -453,12 +461,13 @@ const TValue *luaH_getint (Table *t, int key) { /* -** search function for strings +** search function for short strings */ const TValue *luaH_getstr (Table *t, TString *key) { Node *n = hashstr(t, key); + lua_assert(key->tsv.tt == LUA_TSHRSTR); do { /* check whether `key' is somewhere in the chain */ - if (ttisstring(gkey(n)) && eqstr(rawtsvalue(gkey(n)), key)) + if (ttisshrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)), key)) return gval(n); /* that's it */ else n = gnext(n); } while (n); @@ -470,9 +479,9 @@ const TValue *luaH_getstr (Table *t, TString *key) { ** main search function */ const TValue *luaH_get (Table *t, const TValue *key) { - switch (ttypenv(key)) { + switch (ttype(key)) { case LUA_TNIL: return luaO_nilobject; - case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); case LUA_TNUMBER: { int k; lua_Number n = nvalue(key); diff --git a/src/lua.c b/src/lua.c index e20ab86d..7614c703 100644 --- a/src/lua.c +++ b/src/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.203 2011/12/12 16:34:03 roberto Exp $ +** $Id: lua.c,v 1.205 2012/05/23 15:37:09 roberto Exp $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -45,13 +45,13 @@ */ #if defined(LUA_USE_ISATTY) #include -#define lua_stdin_is_tty() isatty(0) +#define lua_stdin_is_tty() isatty(0) #elif defined(LUA_WIN) #include #include -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) #else -#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ #endif @@ -66,19 +66,19 @@ #include #include #include -#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) #define lua_saveline(L,idx) \ if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \ add_history(lua_tostring(L, idx)); /* add it to history */ -#define lua_freeline(L,b) ((void)L, free(b)) +#define lua_freeline(L,b) ((void)L, free(b)) #elif !defined(lua_readline) -#define lua_readline(L,b,p) \ +#define lua_readline(L,b,p) \ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ -#define lua_saveline(L,idx) { (void)L; (void)idx; } -#define lua_freeline(L,b) { (void)L; (void)b; } +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } #endif @@ -223,16 +223,11 @@ static int dostring (lua_State *L, const char *s, const char *name) { static int dolibrary (lua_State *L, const char *name) { int status; - lua_pushglobaltable(L); - lua_getfield(L, -1, "require"); + lua_getglobal(L, "require"); lua_pushstring(L, name); - status = docall(L, 1, 1); - if (status == LUA_OK) { - lua_setfield(L, -2, name); /* global[name] = require return */ - lua_pop(L, 1); /* remove global table */ - } - else - lua_remove(L, -2); /* remove global table (below error msg.) */ + status = docall(L, 1, 1); /* call 'require(name)' */ + if (status == LUA_OK) + lua_setglobal(L, name); /* global[name] = require return */ return report(L, status); } diff --git a/src/lua.h b/src/lua.h index 1fafa45e..a3a3a70c 100644 --- a/src/lua.h +++ b/src/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.282 2011/11/29 15:55:08 roberto Exp $ +** $Id: lua.h,v 1.283 2012/04/20 13:18:26 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -19,11 +19,11 @@ #define LUA_VERSION_MAJOR "5" #define LUA_VERSION_MINOR "2" #define LUA_VERSION_NUM 502 -#define LUA_VERSION_RELEASE "0" +#define LUA_VERSION_RELEASE "1" #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2011 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2012 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -413,7 +413,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2011 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2012 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/luaconf.h.in b/src/luaconf.h.in index 2bae837e..1ed89435 100644 --- a/src/luaconf.h.in +++ b/src/luaconf.h.in @@ -44,6 +44,41 @@ #cmakedefine LUA_USE_ULONGJMP +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionality listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#define LUA_USE_GMTIME_R +#endif + + + /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @* Lua libraries. @@ -53,20 +88,44 @@ ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ -#cmakedefine LUA_MODULE_SUFFIX "@LUA_MODULE_SUFFIX@" -#cmakedefine LUA_DIR "@LUA_DIR@" -#cmakedefine LUA_LDIR "@LUA_LDIR@" -#cmakedefine LUA_CDIR "@LUA_CDIR@" +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" + +#else /* }{ */ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif /* } */ -#define LUA_PATH_DEFAULT "@LUA_PATH_DEFAULT@" -#define LUA_CPATH_DEFAULT "@LUA_CPATH_DEFAULT@" /* @@ LUA_DIRSEP is the directory separator (for submodules). ** CHANGE it if your machine does not use "/" as the directory separator ** and is not Windows. (On Windows Lua automatically uses "\".) */ -#cmakedefine LUA_DIRSEP "@LUA_DIRSEP@" +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + /* @@ LUA_ENV is the name of the variable that holds the current @@ -182,7 +241,6 @@ ** You can define it to get all options, or change specific options ** to fit your specific needs. */ -#cmakedefine LUA_COMPAT_ALL #if defined(LUA_COMPAT_ALL) /* { */ /* diff --git a/src/lundump.c b/src/lundump.c index 80c7aa39..54de011a 100644 --- a/src/lundump.c +++ b/src/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.71 2011/12/07 10:39:12 lhf Exp $ +** $Id: lundump.c,v 2.22 2012/05/08 13:53:33 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -27,7 +27,7 @@ typedef struct { const char* name; } LoadState; -static void error(LoadState* S, const char* why) +static l_noret error(LoadState* S, const char* why) { luaO_pushfstring(S->L,"%s: %s precompiled chunk",S->name,why); luaD_throw(S->L,LUA_ERRSYNTAX); @@ -39,7 +39,7 @@ static void error(LoadState* S, const char* why) #define LoadVector(S,b,n,size) LoadMem(S,b,n,size) #if !defined(luai_verifycode) -#define luai_verifycode(L,b,f) (f) +#define luai_verifycode(L,b,f) /* empty */ #endif static void LoadBlock(LoadState* S, void* b, size_t size) @@ -91,7 +91,7 @@ static void LoadCode(LoadState* S, Proto* f) LoadVector(S,f->code,n,sizeof(Instruction)); } -static Proto* LoadFunction(LoadState* S); +static void LoadFunction(LoadState* S, Proto* f); static void LoadConstants(LoadState* S, Proto* f) { @@ -118,13 +118,18 @@ static void LoadConstants(LoadState* S, Proto* f) case LUA_TSTRING: setsvalue2n(S->L,o,LoadString(S)); break; + default: lua_assert(0); } } n=LoadInt(S); f->p=luaM_newvector(S->L,n,Proto*); f->sizep=n; for (i=0; ip[i]=NULL; - for (i=0; ip[i]=LoadFunction(S); + for (i=0; ip[i]=luaF_newproto(S->L); + LoadFunction(S,f->p[i]); + } } static void LoadUpvalues(LoadState* S, Proto* f) @@ -163,10 +168,8 @@ static void LoadDebug(LoadState* S, Proto* f) for (i=0; iupvalues[i].name=LoadString(S); } -static Proto* LoadFunction(LoadState* S) +static void LoadFunction(LoadState* S, Proto* f) { - Proto* f=luaF_newproto(S->L); - setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->linedefined=LoadInt(S); f->lastlinedefined=LoadInt(S); f->numparams=LoadByte(S); @@ -176,8 +179,6 @@ static Proto* LoadFunction(LoadState* S) LoadConstants(S,f); LoadUpvalues(S,f); LoadDebug(S,f); - S->L->top--; - return f; } /* the code below must be consistent with the code in luaU_header */ @@ -202,9 +203,10 @@ static void LoadHeader(LoadState* S) /* ** load precompiled chunk */ -Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) { LoadState S; + Closure* cl; if (*name=='@' || *name=='=') S.name=name+1; else if (*name==LUA_SIGNATURE[0]) @@ -215,7 +217,19 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) S.Z=Z; S.b=buff; LoadHeader(&S); - return luai_verifycode(L,buff,LoadFunction(&S)); + cl=luaF_newLclosure(L,1); + setclLvalue(L,L->top,cl); incr_top(L); + cl->l.p=luaF_newproto(L); + LoadFunction(&S,cl->l.p); + if (cl->l.p->sizeupvalues != 1) + { + Proto* p=cl->l.p; + cl=luaF_newLclosure(L,cl->l.p->sizeupvalues); + cl->l.p=p; + setclLvalue(L,L->top-1,cl); + } + luai_verifycode(L,buff,cl->l.p); + return cl; } #define MYINT(s) (s[0]-'0') diff --git a/src/lundump.h b/src/lundump.h index b63993ff..2b8accec 100644 --- a/src/lundump.h +++ b/src/lundump.h @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.44 2011/05/06 13:35:17 lhf Exp $ +** $Id: lundump.h,v 1.39 2012/05/08 13:53:33 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -11,7 +11,7 @@ #include "lzio.h" /* load one chunk; from lundump.c */ -LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); +LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); /* make header; from lundump.c */ LUAI_FUNC void luaU_header (lu_byte* h); diff --git a/src/lvm.c b/src/lvm.c index 694971b1..b77eac26 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.147 2011/12/07 14:43:55 roberto Exp $ +** $Id: lvm.c,v 2.152 2012/06/08 15:14:04 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -60,10 +60,15 @@ int luaV_tostring (lua_State *L, StkId obj) { static void traceexec (lua_State *L) { CallInfo *ci = L->ci; lu_byte mask = L->hookmask; - if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { - resethookcount(L); - luaD_hook(L, LUA_HOOKCOUNT, -1); + int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); + if (counthook) + resethookcount(L); /* reset count */ + if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ + return; /* do not call hook again (VM yielded, so it did not move) */ } + if (counthook) + luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ if (mask & LUA_MASKLINE) { Proto *p = ci_func(ci)->p; int npc = pcRel(ci->u.l.savedpc, p); @@ -71,11 +76,15 @@ static void traceexec (lua_State *L) { if (npc == 0 || /* call linehook when enter a new function, */ ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ - luaD_hook(L, LUA_HOOKLINE, newline); + luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ } L->oldpc = ci->u.l.savedpc; if (L->status == LUA_YIELD) { /* did hook yield? */ + if (counthook) + L->hookcount = 1; /* undo decrement to zero */ ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yieled */ + ci->func = L->top - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } } @@ -258,7 +267,8 @@ int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) { case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); case LUA_TLCF: return fvalue(t1) == fvalue(t2); - case LUA_TSTRING: return eqstr(rawtsvalue(t1), rawtsvalue(t2)); + case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2)); + case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2)); case LUA_TUSERDATA: { if (uvalue(t1) == uvalue(t2)) return 1; else if (L == NULL) return 0; @@ -293,7 +303,7 @@ void luaV_concat (lua_State *L, int total) { else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ (void)tostring(L, top - 2); /* result is first operand */ else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { - setsvalue2s(L, top-2, rawtsvalue(top-1)); /* result is second op. */ + setobjs2s(L, top - 2, top - 1); /* result is second op. */ } else { /* at least two non-empty string values; get as many as possible */ @@ -394,7 +404,8 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, int nup = p->sizeupvalues; Upvaldesc *uv = p->upvalues; int i; - Closure *ncl = luaF_newLclosure(L, p); + Closure *ncl = luaF_newLclosure(L, nup); + ncl->l.p = p; setclLvalue(L, ra, ncl); /* anchor new closure in stack */ for (i = 0; i < nup; i++) { /* fill in its upvalues */ if (uv[i].instack) /* upvalue refers to local variable? */ @@ -500,7 +511,11 @@ void luaV_finishOp (lua_State *L) { #define Protect(x) { {x;}; base = ci->u.l.base; } -#define checkGC(L,c) Protect(luaC_condGC(L, c); luai_threadyield(L);) +#define checkGC(L,c) \ + Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \ + luaC_step(L); \ + L->top = ci->top;}) /* restore top */ \ + luai_threadyield(L); ) #define arith_op(op,tm) { \ @@ -593,11 +608,7 @@ void luaV_execute (lua_State *L) { sethvalue(L, ra, t); if (b != 0 || c != 0) luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); - checkGC(L, - L->top = ra + 1; /* limit of live values */ - luaC_step(L); - L->top = ci->top; /* restore top */ - ) + checkGC(L, ra + 1); ) vmcase(OP_SELF, StkId rb = RB(i); @@ -649,10 +660,7 @@ void luaV_execute (lua_State *L) { ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ rb = b + base; setobjs2s(L, ra, rb); - checkGC(L, - L->top = (ra >= rb ? ra + 1 : rb); /* limit of live values */ - luaC_step(L); - ) + checkGC(L, (ra >= rb ? ra + 1 : rb)); L->top = ci->top; /* restore top */ ) vmcase(OP_JMP, @@ -830,11 +838,7 @@ void luaV_execute (lua_State *L) { pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ else setclLvalue(L, ra, ncl); /* push cashed closure */ - checkGC(L, - L->top = ra + 1; /* limit of live values */ - luaC_step(L); - L->top = ci->top; /* restore top */ - ) + checkGC(L, ra + 1); ) vmcase(OP_VARARG, int b = GETARG_B(i) - 1; diff --git a/src/lzio.c b/src/lzio.c index 354f94e7..8b77054e 100644 --- a/src/lzio.c +++ b/src/lzio.c @@ -1,6 +1,6 @@ /* -** $Id: lzio.c,v 1.34 2011/07/15 12:35:32 roberto Exp $ -** a generic input stream interface +** $Id: lzio.c,v 1.35 2012/05/14 13:34:18 roberto Exp $ +** Buffered streams ** See Copyright Notice in lua.h */ From b0dbd1ddd47f72bdf6c1c9b298a8d419b9f9470b Mon Sep 17 00:00:00 2001 From: yamad Date: Sun, 1 Jul 2012 14:07:58 -0400 Subject: [PATCH 14/48] add newline between commands, fixes cmake 2.8.8 error --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e445082b..fef40e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,8 @@ if ( WIN32 AND NOT CYGWIN ) option ( LUA_WIN "Windows specific build." ON ) option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON ) # Paths (Double escapes needed) - set ( LUA_DIRSEP "\\\\" ) string ( REPLACE " /" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) + set ( LUA_DIRSEP "\\\\" ) + string ( REPLACE " /" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_LDIR "${LUA_LDIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_CDIR "${LUA_CDIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_PATH_DEFAULT "${LUA_PATH_DEFAULT}" ) From 3ae893df4a506a21d1aa296d0ed6d2d6e04b3819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 2 Jul 2012 17:20:41 +0200 Subject: [PATCH 15/48] Updated luaconf.h.in, failed to merge changes correctly before. --- src/luaconf.h.in | 103 +++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/src/luaconf.h.in b/src/luaconf.h.in index 1ed89435..fba7e09f 100644 --- a/src/luaconf.h.in +++ b/src/luaconf.h.in @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.170 2011/12/06 16:58:36 roberto Exp $ +** $Id: luaconf.h,v 1.172 2012/05/11 14:14:42 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -227,6 +227,13 @@ (fprintf(stderr, (s), (p)), fflush(stderr)) +/* +@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, +** strings that are internalized. (Cannot be smaller than reserved words +** or tags for metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#define LUAI_MAXSHORTLEN 40 @@ -457,66 +464,76 @@ #define LUA_UNSIGNED unsigned LUA_INT32 -#if defined(LUA_CORE) /* { */ -#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** Some tricks with doubles +*/ -/* On a Microsoft compiler on a Pentium, use assembler to avoid clashes - with a DirectX idiosyncrasy */ +#if defined(LUA_CORE) && \ + defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** The next definitions activate some tricks to speed up the +** conversion from doubles to integer types, mainly to LUA_UNSIGNED. +** +@@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a +** DirectX idiosyncrasy. +** +@@ LUA_IEEE754TRICK uses a trick that should work on any machine +** using IEEE754 with a 32-bit integer type. +** +@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be +** defined when LUA_INTEGER is a 32-bit integer. +** +@@ LUA_IEEEENDIAN is the endianness of doubles in your machine +** (0 for little endian, 1 for big endian); if not defined, Lua will +** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). +** +@@ LUA_NANTRICK controls the use of a trick to pack all types into +** a single double value, using NaN values to represent non-number +** values. The trick only works on 32-bit machines (ints and pointers +** are 32-bit values) with numbers represented as IEEE 754-2008 doubles +** with conventional endianess (12345678 or 87654321), in CPUs that do +** not produce signaling NaN values (all NaNs are quiet). +*/ + +/* Microsoft compiler on a Pentium (32 bit) ? */ #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ #define MS_ASMTRICK +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK -#else /* }{ */ -/* the next definition uses a trick that should work on any machine - using IEEE754 with a 32-bit integer type */ - -#define LUA_IEEE754TRICK - -/* -@@ LUA_IEEEENDIAN is the endianness of doubles in your machine -** (0 for little endian, 1 for big endian); if not defined, Lua will -** check it dynamically. -*/ -/* check for known architectures */ -#if defined(__i386__) || defined(__i386) || defined(__X86__) || \ - defined (__x86_64) -#define LUA_IEEEENDIAN 0 -#elif defined(__POWERPC__) || defined(__ppc__) -#define LUA_IEEEENDIAN 1 -#endif -#endif /* } */ +/* pentium 32 bits? */ +#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ -#endif /* } */ +#define LUA_IEEE754TRICK +#define LUA_IEEELL +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK -#endif /* } */ +/* pentium 64 bits? */ +#elif defined(__x86_64) /* }{ */ -/* }================================================================== */ +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 0 +#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ -/* -@@ LUA_NANTRICK_LE/LUA_NANTRICK_BE controls the use of a trick to -** pack all types into a single double value, using NaN values to -** represent non-number values. The trick only works on 32-bit machines -** (ints and pointers are 32-bit values) with numbers represented as -** IEEE 754-2008 doubles with conventional endianess (12345678 or -** 87654321), in CPUs that do not produce signaling NaN values (all NaNs -** are quiet). -*/ -#if defined(LUA_CORE) && \ - defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 1 -/* little-endian architectures that satisfy those conditions */ -#if defined(__i386__) || defined(__i386) || defined(__X86__) || \ - defined(_M_IX86) +#else /* }{ */ -#define LUA_NANTRICK_LE +/* assume IEEE754 and a 32-bit integer type */ +#define LUA_IEEE754TRICK -#endif +#endif /* } */ #endif /* } */ +/* }================================================================== */ + From 6c66e02a58dcea78dde4a4ad5ddb08247f28efc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 2 Jul 2012 17:54:34 +0200 Subject: [PATCH 16/48] Finalized configuration. --- src/luaconf.h.in | 74 ++++++------------------------------------------ 1 file changed, 8 insertions(+), 66 deletions(-) diff --git a/src/luaconf.h.in b/src/luaconf.h.in index fba7e09f..5f5c76cb 100644 --- a/src/luaconf.h.in +++ b/src/luaconf.h.in @@ -44,41 +44,6 @@ #cmakedefine LUA_USE_ULONGJMP -#if defined(LUA_USE_LINUX) -#define LUA_USE_POSIX -#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ -#define LUA_USE_READLINE /* needs some extra libraries */ -#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ -#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ -#define LUA_USE_LONGLONG /* assume support for long long */ -#endif - -#if defined(LUA_USE_MACOSX) -#define LUA_USE_POSIX -#define LUA_USE_DLOPEN /* does not need -ldl */ -#define LUA_USE_READLINE /* needs an extra library: -lreadline */ -#define LUA_USE_STRTODHEX /* assume 'strtod' handles hexa formats */ -#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ -#define LUA_USE_LONGLONG /* assume support for long long */ -#endif - - - -/* -@@ LUA_USE_POSIX includes all functionality listed as X/Open System -@* Interfaces Extension (XSI). -** CHANGE it (define it) if your system is XSI compatible. -*/ -#if defined(LUA_USE_POSIX) -#define LUA_USE_MKSTEMP -#define LUA_USE_ISATTY -#define LUA_USE_POPEN -#define LUA_USE_ULONGJMP -#define LUA_USE_GMTIME_R -#endif - - - /* @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for @* Lua libraries. @@ -88,44 +53,20 @@ ** hierarchy or if you want to install your libraries in ** non-conventional directories. */ -#if defined(_WIN32) /* { */ -/* -** In Windows, any exclamation mark ('!') in the path is replaced by the -** path of the directory of the executable file of the current process. -*/ -#define LUA_LDIR "!\\lua\\" -#define LUA_CDIR "!\\" -#define LUA_PATH_DEFAULT \ - LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" -#define LUA_CPATH_DEFAULT \ - LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" - -#else /* }{ */ - -#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" -#define LUA_ROOT "/usr/local/" -#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR -#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR -#define LUA_PATH_DEFAULT \ - LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ - LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" -#define LUA_CPATH_DEFAULT \ - LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" -#endif /* } */ +#cmakedefine LUA_MODULE_SUFFIX "@LUA_MODULE_SUFFIX@" +#cmakedefine LUA_DIR "@LUA_DIR@" +#cmakedefine LUA_LDIR "@LUA_LDIR@" +#cmakedefine LUA_CDIR "@LUA_CDIR@" +#define LUA_PATH_DEFAULT "@LUA_PATH_DEFAULT@" +#define LUA_CPATH_DEFAULT "@LUA_CPATH_DEFAULT@" /* @@ LUA_DIRSEP is the directory separator (for submodules). ** CHANGE it if your machine does not use "/" as the directory separator ** and is not Windows. (On Windows Lua automatically uses "\".) */ -#if defined(_WIN32) -#define LUA_DIRSEP "\\" -#else -#define LUA_DIRSEP "/" -#endif - +#cmakedefine LUA_DIRSEP "@LUA_DIRSEP@" /* @@ LUA_ENV is the name of the variable that holds the current @@ -248,6 +189,7 @@ ** You can define it to get all options, or change specific options ** to fit your specific needs. */ +#cmakedefine LUA_COMPAT_ALL #if defined(LUA_COMPAT_ALL) /* { */ /* From 8cd5e176eb15fefe74a003b8f98999a172d94075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 20 Aug 2012 12:07:27 +0200 Subject: [PATCH 17/48] Updated travis hook --- .travis.yml | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7fd0f0b..049d304a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,27 +2,40 @@ # LuaDist Travis-CI Hook # -# Since CMake is not directly supported we use erlang VMs -language: erlang +# We assume C build environments +language: C + +# Try using multiple Lua Implementations +env: + - TOOL="" # Use native compiler (GCC usually) + - COMPILER="clang" # Use clang + - TOOL="i686-w64-mingw32" # 32bit MinGW + - TOOL="x86_64-w64-mingw32" # 64bit MinGW + - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux -# We need CMake and LuaDist +# Crosscompile builds may fail +matrix: + allow_failures: + - env: TOOL="i686-w64-mingw32" + - env: TOOL="x86_64-w64-mingw32" + - env: TOOL="arm-linux-gnueabihf" + +# Install dependencies install: - - export MODULE=`basename $PWD` - - sudo apt-get install cmake >/dev/null 2>&1 - - git clone git://github.com/LuaDist/bootstrap.git _luadist >/dev/null 2>&1 - - cd _luadist - - git submodule update --init >/dev/null 2>&1 - - ./bootstrap >/dev/null 2>&1 - - export LUADIST=$PWD/_install/bin/luadist - - cd $HOME + - git clone git://github.com/LuaDist/_util.git ~/_util + - ~/_util/travis install -# Use LuaDist to deploy the module +# Bootstap +before_script: + - ~/_util/travis bootstrap + +# Build the module script: - - $LUADIST _test install $LUA $MODULE-scm -verbose=true -test=true + - ~/_util/travis build # Execute additional tests or commands -after_script: - - ./_test/bin/lua -e "print (_VERSION)" +#after_script: +# - ~/_util/travis test # Only watch the master branch branches: From edd550e82d74184e239199479f913299862bd4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20J=2E=20Saraiva?= Date: Thu, 20 Sep 2012 18:56:43 +0100 Subject: [PATCH 18/48] Add missing LUA_BUILD_AS_DLL definition to the liblua target. Fixes lua.dll being generated without public symbols by the Visual Studio compiler; - when building a DLL you either need a DEF file listing the public symbols or use __declspec(export) in the public symbols. - when linking to a DLL you only need to use __declspec(import) when referencing data, since lua only exports functions it isn't needed for the other targets. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fef40e98..9e18e819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,9 @@ endif ( ) add_library ( liblua SHARED ${SRC_CORE} ${SRC_LIB} ${LUA_DLL_RC} ${LUA_DEF} ) target_link_libraries ( liblua ${LIBS} ) set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua CLEAN_DIRECT_OUTPUT 1 ) +if ( LUA_BUILD_AS_DLL ) + set_target_properties ( liblua PROPERTIES COMPILE_DEFINITIONS LUA_BUILD_AS_DLL ) +endif ( ) add_executable ( lua ${SRC_LUA} src/lua.rc ) target_link_libraries ( lua liblua ) From 99641870d948f42ccdcd6f0d8ecb13d0340b8614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Sun, 30 Sep 2012 16:52:19 +0200 Subject: [PATCH 19/48] Minor tweaks in window dll build --- .travis.yml | 2 +- CMakeLists.txt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 049d304a..067e4d96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ # We assume C build environments language: C - + # Try using multiple Lua Implementations env: - TOOL="" # Use native compiler (GCC usually) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e18e819..06267a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,12 @@ set ( LUA_CPATH_DEFAULT "./?${LUA_MODULE_SUFFIX};${LUA_DIR}${LUA_CDIR}/?${LUA_MO if ( WIN32 AND NOT CYGWIN ) # Windows systems option ( LUA_WIN "Windows specific build." ON ) - option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON ) - # Paths (Double escapes needed) + option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ${BUILD_SHARED_LIBS} ) + if ( LUA_BUILD_AS_DLL ) + add_definitions ( -DLUA_BUILD_AS_DLL ) + endif () + + # Paths (Double escapes ne option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON )eded) set ( LUA_DIRSEP "\\\\" ) string ( REPLACE " /" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_LDIR "${LUA_LDIR}" ) @@ -121,9 +125,6 @@ endif ( ) add_library ( liblua SHARED ${SRC_CORE} ${SRC_LIB} ${LUA_DLL_RC} ${LUA_DEF} ) target_link_libraries ( liblua ${LIBS} ) set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua CLEAN_DIRECT_OUTPUT 1 ) -if ( LUA_BUILD_AS_DLL ) - set_target_properties ( liblua PROPERTIES COMPILE_DEFINITIONS LUA_BUILD_AS_DLL ) -endif ( ) add_executable ( lua ${SRC_LUA} src/lua.rc ) target_link_libraries ( lua liblua ) From 59da638d4f1fe2a7c4fbef632d080536bc2a9b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Tue, 2 Oct 2012 17:49:02 +0200 Subject: [PATCH 20/48] LUA_BUILD_AS_DLL needs to affect only the liblua target --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06267a00..84d2d9a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,6 @@ if ( WIN32 AND NOT CYGWIN ) # Windows systems option ( LUA_WIN "Windows specific build." ON ) option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ${BUILD_SHARED_LIBS} ) - if ( LUA_BUILD_AS_DLL ) - add_definitions ( -DLUA_BUILD_AS_DLL ) - endif () # Paths (Double escapes ne option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON )eded) set ( LUA_DIRSEP "\\\\" ) @@ -125,6 +122,9 @@ endif ( ) add_library ( liblua SHARED ${SRC_CORE} ${SRC_LIB} ${LUA_DLL_RC} ${LUA_DEF} ) target_link_libraries ( liblua ${LIBS} ) set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua CLEAN_DIRECT_OUTPUT 1 ) +if ( LUA_BUILD_AS_DLL ) + set_target_properties ( liblua PROPERTIES COMPILE_DEFINITIONS LUA_BUILD_AS_DLL ) +endif () add_executable ( lua ${SRC_LUA} src/lua.rc ) target_link_libraries ( lua liblua ) From 910ebe9b272ba17395fbbea37cccc207566f7800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Wed, 19 Dec 2012 14:30:10 +0100 Subject: [PATCH 21/48] Updated travis hook --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 067e4d96..43f8453d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ language: C env: - TOOL="" # Use native compiler (GCC usually) - COMPILER="clang" # Use clang +# - COMPILER="fortran" # Use fortran, make sure to modify the matrix section - TOOL="i686-w64-mingw32" # 32bit MinGW - TOOL="x86_64-w64-mingw32" # 64bit MinGW - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux @@ -48,4 +49,4 @@ notifications: - luadist-dev@googlegroups.com email: on_success: change - on_failure: always \ No newline at end of file + on_failure: always From bc7574f25173dad4aa4f1c95a89aa7b069e3a778 Mon Sep 17 00:00:00 2001 From: Peter Drahos Date: Thu, 17 Jan 2013 19:52:35 +0100 Subject: [PATCH 22/48] Removed unintended paste in comment --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84d2d9a5..7a44c8f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if ( WIN32 AND NOT CYGWIN ) option ( LUA_WIN "Windows specific build." ON ) option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ${BUILD_SHARED_LIBS} ) - # Paths (Double escapes ne option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON )eded) + # Paths (Double escapes ne option needed) set ( LUA_DIRSEP "\\\\" ) string ( REPLACE " /" ${LUA_DIRSEP} LUA_DIR "${LUA_DIR}" ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_LDIR "${LUA_LDIR}" ) From c42ab1ab1cf1b06de82bb5eef14621465468e6b6 Mon Sep 17 00:00:00 2001 From: Peter Drahos Date: Sun, 17 Feb 2013 16:09:57 +0100 Subject: [PATCH 23/48] Updated travis hook --- .travis.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43f8453d..98e0f17b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,12 @@ # # We assume C build environments -language: C +language: c # Try using multiple Lua Implementations env: - TOOL="" # Use native compiler (GCC usually) - COMPILER="clang" # Use clang -# - COMPILER="fortran" # Use fortran, make sure to modify the matrix section - TOOL="i686-w64-mingw32" # 32bit MinGW - TOOL="x86_64-w64-mingw32" # 64bit MinGW - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux @@ -20,23 +19,23 @@ matrix: - env: TOOL="i686-w64-mingw32" - env: TOOL="x86_64-w64-mingw32" - env: TOOL="arm-linux-gnueabihf" - + # Install dependencies install: - - git clone git://github.com/LuaDist/_util.git ~/_util - - ~/_util/travis install + - git clone git://github.com/LuaDist/Tools.git ~/_tools + - ~/_tools/travis/travis install # Bootstap before_script: - - ~/_util/travis bootstrap + - ~/_tools/travis/travis bootstrap # Build the module script: - - ~/_util/travis build + - ~/_tools/travis/travis build # Execute additional tests or commands -#after_script: -# - ~/_util/travis test +after_script: + - ~/_tools/travis/travis test # Only watch the master branch branches: From 3b7eab46be417a5adbef0c53698e6bcea7ffd2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Sun, 17 Feb 2013 16:39:04 +0100 Subject: [PATCH 24/48] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98e0f17b..3303c41d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # # We assume C build environments -language: c +language: C # Try using multiple Lua Implementations env: From 705b7f0a0367b26b1e375026132d6220d5303246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 18 Feb 2013 16:09:51 +0100 Subject: [PATCH 25/48] Updated travis hook --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3303c41d..57493ebb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ language: C # Try using multiple Lua Implementations env: - - TOOL="" # Use native compiler (GCC usually) - - COMPILER="clang" # Use clang + - TOOL="gcc" # Use native compiler (GCC usually) + - TOOL="clang" # Use clang - TOOL="i686-w64-mingw32" # 32bit MinGW - TOOL="x86_64-w64-mingw32" # 64bit MinGW - TOOL="arm-linux-gnueabihf" # ARM hard-float (hf), linux From 4f5eb166560d62043e7a1c17cebf738008a64478 Mon Sep 17 00:00:00 2001 From: Peter Drahos Date: Sun, 3 Mar 2013 14:43:32 +0100 Subject: [PATCH 26/48] Added WinMain entry for wlua target. Fixed Visual Studio builds. --- CMakeLists.txt | 8 ++++++++ src/wmain.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/wmain.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a44c8f5..e54bb7b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ set ( LUA_CPATH_DEFAULT "./?${LUA_MODULE_SUFFIX};${LUA_DIR}${LUA_CDIR}/?${LUA_MO if ( WIN32 AND NOT CYGWIN ) # Windows systems option ( LUA_WIN "Windows specific build." ON ) + option ( LUA_BUILD_WLUA "Build wLua interpretter without console output." ON ) option ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ${BUILD_SHARED_LIBS} ) # Paths (Double escapes ne option needed) @@ -132,6 +133,13 @@ target_link_libraries ( lua liblua ) add_executable ( luac ${SRC_CORE} ${SRC_LIB} ${SRC_LUAC} src/luac.rc ) target_link_libraries ( luac ${LIBS} ) +# On windows a variant of the lua interpreter without console output needs to be built +if ( LUA_BUILD_WLUA ) + add_executable ( wlua WIN32 src/wmain.c ${SRC_LUA} ${LUA_RC} ) + target_link_libraries ( wlua liblua ) + install_executable ( wlua ) +endif ( ) + install_executable ( lua luac ) install_library ( liblua ) install_data ( README.md ) diff --git a/src/wmain.c b/src/wmain.c new file mode 100644 index 00000000..6cf3e579 --- /dev/null +++ b/src/wmain.c @@ -0,0 +1,16 @@ +#include +#include /* declaration of __argc and __argv */ + +extern int main(int, char **); + +int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int ncmdshow) +{ + int rc; + + extern int __argc; /* this seems to work for all the compilers we tested, except Watcom compilers */ + extern char** __argv; + + rc = main(__argc, __argv); + + return rc; +} From 59b3d7cabfe51c965a22bb6eb1c58c19613a27b3 Mon Sep 17 00:00:00 2001 From: Peter Drahos Date: Sun, 3 Mar 2013 14:48:41 +0100 Subject: [PATCH 27/48] Fixed reference to rc file for wlua --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e54bb7b7..9f8e72f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,7 +135,7 @@ target_link_libraries ( luac ${LIBS} ) # On windows a variant of the lua interpreter without console output needs to be built if ( LUA_BUILD_WLUA ) - add_executable ( wlua WIN32 src/wmain.c ${SRC_LUA} ${LUA_RC} ) + add_executable ( wlua WIN32 src/wmain.c ${SRC_LUA} src/lua.rc ) target_link_libraries ( wlua liblua ) install_executable ( wlua ) endif ( ) From 9672e2f04c54c5d422691a59f9f5104070f8cd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Wed, 27 Mar 2013 23:57:41 +0100 Subject: [PATCH 28/48] Updated to 5.2.2 --- README.md | 3 +- doc/contents.html | 18 +- doc/lua.css | 6 +- doc/manual.css | 6 +- doc/manual.html | 314 ++++++++++++++++---------- doc/readme.html | 10 +- src/Makefile | 2 +- src/lapi.c | 45 ++-- src/lauxlib.c | 13 +- src/lbaselib.c | 33 ++- src/lbitlib.c | 6 +- src/lcode.c | 11 +- src/lcorolib.c | 4 +- src/ldebug.c | 10 +- src/ldo.c | 15 +- src/lfunc.c | 4 +- src/lgc.c | 90 ++++---- src/lgc.h | 16 +- src/liolib.c | 26 ++- src/llex.c | 10 +- src/llimits.h | 8 +- src/lmathlib.c | 72 +++--- src/lmem.h | 15 +- src/loadlib_rel.c | 97 ++++---- src/lobject.c | 20 +- src/lobject.h | 7 +- src/loslib.c | 4 +- src/lparser.c | 11 +- src/lstate.c | 4 +- src/lstate.h | 4 +- src/lstring.c | 6 +- src/lstrlib.c | 207 ++++++++++------- src/ltable.c | 6 +- src/ltablib.c | 20 +- src/lua.c | 7 +- src/lua.h | 13 +- src/lua.rc | 10 +- src/luac.rc | 10 +- src/luaconf.h.in | 21 +- src/luaconf.h.orig | 551 +++++++++++++++++++++++++++++++++++++++++++++ src/lvm.c | 7 +- src/lvm.h | 5 +- 42 files changed, 1244 insertions(+), 503 deletions(-) create mode 100644 src/luaconf.h.orig diff --git a/README.md b/README.md index e07e097e..6e2aee6c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -This is Lua 5.2.1, released on 08 Jun 2012. -================ +This is Lua 5.2.2, released on 21 Mar 2013. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/doc/contents.html b/doc/contents.html index 9f506051..0ce297da 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -23,7 +23,7 @@

      The reference manual is the official definition of the Lua language. For a complete introduction to Lua programming, see the book -Programming in Lua. +Programming in Lua.

      start @@ -33,7 +33,7 @@

      index
      -Copyright © 2011–2012 Lua.org, PUC-Rio. +Copyright © 2011–2013 Lua.org, PUC-Rio. Freely available under the terms of the Lua license. @@ -149,8 +149,8 @@

      Lua functions

      error
      getmetatable
      ipairs
      -loadfile
      load
      +loadfile
      next
      pairs
      pcall
      @@ -385,6 +385,7 @@

      C API

      lua_pushcclosure
      lua_pushcfunction
      lua_pushfstring
      +lua_pushglobaltable
      lua_pushinteger
      lua_pushlightuserdata
      lua_pushliteral
      @@ -393,15 +394,16 @@

      C API

      lua_pushnumber
      lua_pushstring
      lua_pushthread
      +lua_pushunsigned
      lua_pushvalue
      lua_pushvfstring
      lua_rawequal
      lua_rawget
      lua_rawgeti
      +lua_rawgetp
      lua_rawlen
      lua_rawset
      lua_rawseti
      -lua_rawgetp
      lua_rawsetp
      lua_register
      lua_remove
      @@ -460,8 +462,8 @@

      auxiliary library

      luaL_buffinitsize
      luaL_callmeta
      luaL_checkany
      -luaL_checkinteger
      luaL_checkint
      +luaL_checkinteger
      luaL_checklong
      luaL_checklstring
      luaL_checknumber
      @@ -492,8 +494,8 @@

      auxiliary library

      luaL_newmetatable
      luaL_newstate
      luaL_openlibs
      -luaL_optinteger
      luaL_optint
      +luaL_optinteger
      luaL_optlong
      luaL_optlstring
      luaL_optnumber
      @@ -521,10 +523,10 @@

      auxiliary library


      Last update: -Sat May 26 08:52:25 BRT 2012 +Tue Mar 12 11:22:18 BRT 2013 diff --git a/doc/lua.css b/doc/lua.css index 7fafbb1b..240e85eb 100644 --- a/doc/lua.css +++ b/doc/lua.css @@ -16,10 +16,10 @@ h1, h2, h3, h4 { h2 { padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 30px ; - padding-right: 30px ; - margin-left: -30px ; + padding-left: 1em ; + padding-right: 1em ; background-color: #E0E0FF ; + border-radius: 8px ; } h3 { diff --git a/doc/manual.css b/doc/manual.css index b49b3629..269bd435 100644 --- a/doc/manual.css +++ b/doc/manual.css @@ -18,7 +18,9 @@ span.apii { p+h1, ul+h1 { padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 30px ; - margin-left: -30px ; + padding-left: 24px ; + margin-left: -24px ; background-color: #E0E0FF ; + border-radius: 8px ; } + diff --git a/doc/manual.html b/doc/manual.html index 4ba084df..85365363 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@

      by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes

      -Copyright © 2011–2012 Lua.org, PUC-Rio. +Copyright © 2011–2013 Lua.org, PUC-Rio. Freely available under the terms of the Lua license. @@ -33,7 +33,7 @@

      - + @@ -424,7 +424,6 @@

      2.4 – Metatables and Metamethods

            rawget(getmetatable(obj) or {}, event)
       

      - This means that the access to a metamethod does not invoke other metamethods, and access to objects with no metatables does not fail (it simply results in nil). @@ -915,7 +914,7 @@

      2.5.1 – Garbage-Collection Metamethods

      When you close a state (see lua_close), -Lua calls the finalizers of all objects marked for collection, +Lua calls the finalizers of all objects marked for finalization, following the reverse order that they were marked. If any finalizer marks new objects for collection during that phase, these new objects will not be finalized. @@ -1255,8 +1254,7 @@

      3.1 – Lexical Conventions

      -When parsing a from a string source, -any byte in a literal string not +Any byte in a literal string not explicitly affected by the previous rules represents itself. However, Lua opens files for parsing in text mode, and the system file functions may have problems with @@ -1409,6 +1407,35 @@

      3.3.1 – Blocks

      stat ::= ‘;’
    +

    +Function calls and assignments +can start with an open parenthesis. +This possibility leads to an ambiguity in Lua's grammar. +Consider the following fragment: + +

    +     a = b + c
    +     (print or io.write)('done')
    +

    +The grammar could see it in two ways: + +

    +     a = b + c(print or io.write)('done')
    +     
    +     a = b + c; (print or io.write)('done')
    +

    +The current parser always sees such constructions +in the first way, +interpreting the open parenthesis +as the start of the arguments to a call. +To avoid this ambiguity, +it is a good practice to always precede with a semicolon +statements that start with a parenthesis: + +

    +     ;(print or io.write)('done')
    +
    +

    A block can be explicitly delimited to produce a single statement: @@ -1428,7 +1455,7 @@

    3.3.1 – Blocks

    3.3.2 – Chunks

    -The unit of execution of Lua is called a chunk. +The unit of compilation of Lua is called a chunk. Syntactically, a chunk is simply a block: @@ -1859,7 +1886,8 @@

    3.4 – Expressions

    (unless the expression is enclosed in parentheses). In all other contexts, Lua adjusts the result list to one element, -discarding all values except the first one. +either discarding all values except the first one +or adding a single nil if there are no values.

    @@ -2559,32 +2587,35 @@

    4.3 – Valid and Acceptable Indices

    A valid index is an index that refers to a -valid position within the stack, that is, -it lies between 1 and the stack top +real position within the stack, that is, +its position lies between 1 and the stack top (1 ≤ abs(index) ≤ top). -Usually, functions that need a specific stack position -(e.g., lua_remove) require valid indices. +Usually, functions that can modify the value at an index +require valid indices. + + +

    +Unless otherwise noted, +any function that accepts valid indices also accepts pseudo-indices, +which represent some Lua values that are accessible to C code +but which are not in the stack. +Pseudo-indices are used to access the registry +and the upvalues of a C function (see §4.4).

    Functions that do not need a specific stack position, but only a value in the stack (e.g., query functions), can be called with acceptable indices. -An acceptable index refers to a position within -the space allocated for the stack, +An acceptable index can be any valid index, +including the pseudo-indices, +but it also can be any positive index after the stack top +within the space allocated for the stack, that is, indices up to the stack size. -More formally, we define an acceptable index -as follows: - -

    -     (index < 0 && abs(index) <= top) ||
    -     (index > 0 && index <= stack size)
    -

    (Note that 0 is never an acceptable index.) -When a function is called, -its stack size is top + LUA_MINSTACK. -You can change its stack size through function lua_checkstack. +Except when noted otherwise, +functions in the API work with acceptable indices.

    @@ -2598,16 +2629,8 @@

    4.3 – Valid and Acceptable Indices

    For functions that can be called with acceptable indices, any non-valid index is treated as if it -contains a value of a virtual type LUA_TNONE. - - -

    -Unless otherwise noted, -any function that accepts valid indices also accepts pseudo-indices, -which represent some Lua values that are accessible to C code -but which are not in the stack. -Pseudo-indices are used to access the registry -and the upvalues of a C function (see §4.4). +contains a value of a virtual type LUA_TNONE, +which behaves like a nil value. @@ -2628,13 +2651,13 @@

    4.4 – C Closures

    Whenever a C function is called, its upvalues are located at specific pseudo-indices. These pseudo-indices are produced by the macro -lua_upvalueindex. +lua_upvalueindex. The first value associated with a function is at position lua_upvalueindex(1), and so on. Any access to lua_upvalueindex(n), where n is greater than the number of upvalues of the current function (but not greater than 256), -produces an acceptable (but invalid) index. +produces an acceptable but invalid index. @@ -2647,7 +2670,8 @@

    4.5 – Registry

    a predefined table that can be used by any C code to store whatever Lua values it needs to store. The registry table is always located at pseudo-index -LUA_REGISTRYINDEX. +LUA_REGISTRYINDEX, +which is a valid index. Any C library can store data into this table, but it should take care to choose keys that are different from those used @@ -2692,8 +2716,8 @@

    4.6 – Error Handling in C

    Internally, Lua uses the C longjmp facility to handle errors. -(You can also choose to use exceptions if you use C++; -see file luaconf.h.) +(You can also choose to use exceptions if you compile Lua as C++; +search for LUAI_THROW in the source code.) When Lua faces any error (such as a memory allocation error, type errors, syntax errors, and runtime errors) @@ -3136,8 +3160,8 @@

    4.8 – Functions and Types

    Compares two Lua values. -Returns 1 if the value at acceptable index index1 satisfies op -when compared with the value at acceptable index index2, +Returns 1 if the value at index index1 satisfies op +when compared with the value at index index2, following the semantics of the corresponding Lua operator (that is, it may call metamethods). Otherwise returns 0. @@ -3180,7 +3204,7 @@

    4.8 – Functions and Types

    void lua_copy (lua_State *L, int fromidx, int toidx);

    -Moves the element at the valid index fromidx +Moves the element at index fromidx into the valid index toidx without shifting any element (therefore replacing the value at that position). @@ -3390,7 +3414,7 @@

    4.8 – Functions and Types

    Pushes onto the stack the value t[k], -where t is the value at the given valid index. +where t is the value at the given index. As in Lua, this function may trigger a metamethod for the "index" event (see §2.4). @@ -3414,8 +3438,7 @@

    4.8 – Functions and Types

    int lua_getmetatable (lua_State *L, int index);

    -Pushes onto the stack the metatable of the value at the given -acceptable index. +Pushes onto the stack the metatable of the value at the given index. If the value does not have a metatable, the function returns 0 and pushes nothing on the stack. @@ -3429,7 +3452,7 @@

    4.8 – Functions and Types

    Pushes onto the stack the value t[k], -where t is the value at the given valid index +where t is the value at the given index and k is the value at the top of the stack. @@ -3477,7 +3500,7 @@

    4.8 – Functions and Types

    Moves the top element into the given valid index, shifting up the elements above this index to open space. -Cannot be called with a pseudo-index, +This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position. @@ -3505,7 +3528,7 @@

    4.8 – Functions and Types

    int lua_isboolean (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a boolean, +Returns 1 if the value at the given index is a boolean, and 0 otherwise. @@ -3517,7 +3540,7 @@

    4.8 – Functions and Types

    int lua_iscfunction (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a C function, +Returns 1 if the value at the given index is a C function, and 0 otherwise. @@ -3529,7 +3552,7 @@

    4.8 – Functions and Types

    int lua_isfunction (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a function +Returns 1 if the value at the given index is a function (either C or Lua), and 0 otherwise. @@ -3541,7 +3564,7 @@

    4.8 – Functions and Types

    int lua_islightuserdata (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a light userdata, +Returns 1 if the value at the given index is a light userdata, and 0 otherwise. @@ -3553,7 +3576,7 @@

    4.8 – Functions and Types

    int lua_isnil (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is nil, +Returns 1 if the value at the given index is nil, and 0 otherwise. @@ -3565,8 +3588,7 @@

    4.8 – Functions and Types

    int lua_isnone (lua_State *L, int index);

    -Returns 1 if the given acceptable index is not valid -(that is, it refers to an element outside the current stack), +Returns 1 if the given index is not valid, and 0 otherwise. @@ -3578,8 +3600,7 @@

    4.8 – Functions and Types

    int lua_isnoneornil (lua_State *L, int index);

    -Returns 1 if the given acceptable index is not valid -(that is, it refers to an element outside the current stack) +Returns 1 if the given index is not valid or if the value at this index is nil, and 0 otherwise. @@ -3592,7 +3613,7 @@

    4.8 – Functions and Types

    int lua_isnumber (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a number +Returns 1 if the value at the given index is a number or a string convertible to a number, and 0 otherwise. @@ -3605,7 +3626,7 @@

    4.8 – Functions and Types

    int lua_isstring (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a string +Returns 1 if the value at the given index is a string or a number (which is always convertible to a string), and 0 otherwise. @@ -3618,7 +3639,7 @@

    4.8 – Functions and Types

    int lua_istable (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a table, +Returns 1 if the value at the given index is a table, and 0 otherwise. @@ -3630,7 +3651,7 @@

    4.8 – Functions and Types

    int lua_isthread (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a thread, +Returns 1 if the value at the given index is a thread, and 0 otherwise. @@ -3642,7 +3663,7 @@

    4.8 – Functions and Types

    int lua_isuserdata (lua_State *L, int index);

    -Returns 1 if the value at the given acceptable index is a userdata +Returns 1 if the value at the given index is a userdata (either full or light), and 0 otherwise. @@ -3654,7 +3675,7 @@

    4.8 – Functions and Types

    void lua_len (lua_State *L, int index);

    -Returns the "length" of the value at the given acceptable index; +Returns the "length" of the value at the given index; it is equivalent to the '#' operator in Lua (see §3.4.6). The result is pushed on the stack. @@ -3718,6 +3739,12 @@

    4.8 – Functions and Types

    a NULL value is equivalent to the string "bt". +

    +lua_load uses the stack internally, +so the reader function should always leave the stack +unmodified when returning. + +

    If the resulting function has one upvalue, this upvalue is set to the value of the global environment @@ -4038,7 +4065,7 @@

    4.8 – Functions and Types

    Pushes onto the stack a formatted string and returns a pointer to this string. -It is similar to the C function sprintf, +It is similar to the ANSI C function sprintf, but has some important differences:

      @@ -4066,6 +4093,17 @@

      4.8 – Functions and Types

      +

      lua_pushglobaltable

      +[-0, +1, –] +

      void lua_pushglobaltable (lua_State *L);
      + +

      +Pushes the global environment onto the stack. + + + + +


      lua_pushinteger

      [-0, +1, –]

      void lua_pushinteger (lua_State *L, lua_Integer n);
      @@ -4189,12 +4227,23 @@

      4.8 – Functions and Types

      +

      lua_pushunsigned

      +[-0, +1, –] +

      void lua_pushunsigned (lua_State *L, lua_Unsigned n);
      + +

      +Pushes a number with value n onto the stack. + + + + +


      lua_pushvalue

      [-0, +1, –]

      void lua_pushvalue (lua_State *L, int index);

      -Pushes a copy of the element at the given valid index +Pushes a copy of the element at the given index onto the stack. @@ -4220,7 +4269,7 @@

      4.8 – Functions and Types

      int lua_rawequal (lua_State *L, int index1, int index2);

      -Returns 1 if the two values in acceptable indices index1 and +Returns 1 if the two values in indices index1 and index2 are primitively equal (that is, without calling metamethods). Otherwise returns 0. @@ -4248,7 +4297,7 @@

      4.8 – Functions and Types

      Pushes onto the stack the value t[n], -where t is the table at the given valid index. +where t is the table at the given index. The access is raw; that is, it does not invoke metamethods. @@ -4262,7 +4311,7 @@

      4.8 – Functions and Types

      Pushes onto the stack the value t[k], -where t is the table at the given valid index and +where t is the table at the given index and k is the pointer p represented as a light userdata. The access is raw; that is, it does not invoke metamethods. @@ -4276,7 +4325,7 @@

      4.8 – Functions and Types

      size_t lua_rawlen (lua_State *L, int index);

      -Returns the raw "length" of the value at the given acceptable index: +Returns the raw "length" of the value at the given index: for strings, this is the string length; for tables, this is the result of the length operator ('#') with no metamethods; @@ -4306,7 +4355,7 @@

      4.8 – Functions and Types

      Does the equivalent of t[n] = v, -where t is the table at the given valid index +where t is the table at the given index and v is the value at the top of the stack. @@ -4325,7 +4374,7 @@

      4.8 – Functions and Types

      Does the equivalent of t[k] = v, -where t is the table at the given valid index, +where t is the table at the given index, k is the pointer p represented as a light userdata, and v is the value at the top of the stack. @@ -4384,7 +4433,7 @@

      4.8 – Functions and Types

      Removes the element at the given valid index, shifting down the elements above this index to fill the gap. -Cannot be called with a pseudo-index, +This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position. @@ -4396,9 +4445,9 @@

      4.8 – Functions and Types

      void lua_replace (lua_State *L, int index);

      -Moves the top element into the given position +Moves the top element into the given valid index without shifting any element -(therefore replacing the value at the given position), +(therefore replacing the value at the given index), and then pops the top element. @@ -4436,7 +4485,9 @@

      4.8 – Functions and Types

      -To resume a coroutine, you put on its stack only the values to +To resume a coroutine, +you remove any results from the last lua_yield, +put on its stack only the values to be passed as results from yield, and then call lua_resume. @@ -4468,7 +4519,7 @@

      4.8 – Functions and Types

      Does the equivalent to t[k] = v, -where t is the value at the given valid index +where t is the value at the given index and v is the value at the top of the stack. @@ -4499,8 +4550,7 @@

      4.8 – Functions and Types

      Pops a table from the stack and -sets it as the new metatable for the value at the given -acceptable index. +sets it as the new metatable for the value at the given index. @@ -4512,7 +4562,7 @@

      4.8 – Functions and Types

      Does the equivalent to t[k] = v, -where t is the value at the given valid index, +where t is the value at the given index, v is the value at the top of the stack, and k is the value just below the top. @@ -4531,7 +4581,7 @@

      4.8 – Functions and Types

      void lua_settop (lua_State *L, int index);

      -Accepts any acceptable index, or 0, +Accepts any index, or 0, and sets the stack top to this index. If the new top is larger than the old one, then the new elements are filled with nil. @@ -4603,13 +4653,12 @@

      4.8 – Functions and Types

      int lua_toboolean (lua_State *L, int index);

      -Converts the Lua value at the given acceptable index to a C boolean +Converts the Lua value at the given index to a C boolean value (0 or 1). Like all tests in Lua, lua_toboolean returns true for any Lua value different from false and nil; otherwise it returns false. -It also returns false when called with a non-valid index. (If you want to accept only actual boolean values, use lua_isboolean to test the value's type.) @@ -4622,7 +4671,7 @@

      4.8 – Functions and Types

      lua_CFunction lua_tocfunction (lua_State *L, int index);

      -Converts a value at the given acceptable index to a C function. +Converts a value at the given index to a C function. That value must be a C function; otherwise, returns NULL. @@ -4646,7 +4695,7 @@

      4.8 – Functions and Types

      lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);

      -Converts the Lua value at the given acceptable index +Converts the Lua value at the given index to the signed integral type lua_Integer. The Lua value must be a number or a string convertible to a number (see §3.4.2); @@ -4672,7 +4721,7 @@

      4.8 – Functions and Types

      const char *lua_tolstring (lua_State *L, int index, size_t *len);

      -Converts the Lua value at the given acceptable index to a C string. +Converts the Lua value at the given index to a C string. If len is not NULL, it also sets *len with the string length. The Lua value must be a string or a number; @@ -4714,7 +4763,7 @@

      4.8 – Functions and Types

      lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);

      -Converts the Lua value at the given acceptable index +Converts the Lua value at the given index to the C type lua_Number (see lua_Number). The Lua value must be a number or a string convertible to a number (see §3.4.2); @@ -4735,7 +4784,7 @@

      4.8 – Functions and Types

      const void *lua_topointer (lua_State *L, int index);

      -Converts the value at the given acceptable index to a generic +Converts the value at the given index to a generic C pointer (void*). The value can be a userdata, a table, a thread, or a function; otherwise, lua_topointer returns NULL. @@ -4766,7 +4815,7 @@

      4.8 – Functions and Types

      lua_State *lua_tothread (lua_State *L, int index);

      -Converts the value at the given acceptable index to a Lua thread +Converts the value at the given index to a Lua thread (represented as lua_State*). This value must be a thread; otherwise, the function returns NULL. @@ -4791,7 +4840,7 @@

      4.8 – Functions and Types

      lua_Unsigned lua_tounsignedx (lua_State *L, int index, int *isnum);

      -Converts the Lua value at the given acceptable index +Converts the Lua value at the given index to the unsigned integral type lua_Unsigned. The Lua value must be a number or a string convertible to a number (see §3.4.2); @@ -4820,7 +4869,7 @@

      4.8 – Functions and Types

      void *lua_touserdata (lua_State *L, int index);

      -If the value at the given acceptable index is a full userdata, +If the value at the given index is a full userdata, returns its block address. If the value is a light userdata, returns its pointer. @@ -4835,8 +4884,8 @@

      4.8 – Functions and Types

      int lua_type (lua_State *L, int index);

      -Returns the type of the value in the given acceptable index, -or LUA_TNONE for a non-valid index. +Returns the type of the value in the given valid index, +or LUA_TNONE for a non-valid (but acceptable) index. The types returned by lua_type are coded by the following constants defined in lua.h: LUA_TNIL, @@ -4882,6 +4931,18 @@

      4.8 – Functions and Types

      +

      lua_upvalueindex

      +[-0, +0, –] +

      int lua_upvalueindex (int i);
      + +

      +Returns the pseudo-index that represents the i-th upvalue of +the running function (see §4.4). + + + + +


      lua_version

      [-0, +0, v]

      const lua_Number *lua_version (lua_State *L);
      @@ -6095,7 +6156,7 @@

      5.1 – Functions and Types

      Ensures that the value t[fname], -where t is the value at the valid index idx, +where t is the value at index idx, is a table, and pushes that table onto the stack. Returns true if it finds a previous table there @@ -6127,7 +6188,7 @@

      5.1 – Functions and Types

      int luaL_len (lua_State *L, int index);

      -Returns the "length" of the value at the given acceptable index +Returns the "length" of the value at the given index as a number; it is equivalent to the '#' operator in Lua (see §3.4.6). Raises an error if the result of the operation is not a number. @@ -6242,7 +6303,7 @@

      5.1 – Functions and Types


      luaL_newlib

      [-0, +1, e] -

      int luaL_newlib (lua_State *L, const luaL_Reg *l);
      +
      void luaL_newlib (lua_State *L, const luaL_Reg *l);

      Creates a new table and registers there @@ -6258,7 +6319,7 @@

      5.1 – Functions and Types


      luaL_newlibtable

      [-0, +1, e] -

      int luaL_newlibtable (lua_State *L, const luaL_Reg l[]);
      +
      void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);

      Creates a new table with a size optimized @@ -6622,7 +6683,7 @@

      5.1 – Functions and Types

      const char *luaL_tolstring (lua_State *L, int idx, size_t *len);

      -Converts any Lua value at the given acceptable index to a C string +Converts any Lua value at the given index to a C string in a reasonable format. The resulting string is pushed onto the stack and also returned by the function. @@ -6986,11 +7047,14 @@

      6.1 – Basic Functions

      If the resulting function has upvalues, -the first upvalue is set to the value of the -global environment or to env, -if that parameter is given. -When loading main chunks, -the first upvalue will be the _ENV variable (see §2.2). +the first upvalue is set to the value of env, +if that parameter is given, +or to the value of the global environment. +(When you load a main chunk, +the resulting function will always have exactly one upvalue, +the _ENV variable (see §2.2). +When you load a binary chunk created from a function (see string.dump), +the resulting function can have arbitrary upvalues.)

      @@ -7510,7 +7574,6 @@

      6.3 – Modules

      -


      package.loaded

      @@ -7546,7 +7609,8 @@

      6.3 – Modules

      Otherwise, it looks for a function funcname inside the library and returns this function as a C function. -(So, funcname must follow the prototype lua_CFunction). +So, funcname must follow the lua_CFunction prototype +(see lua_CFunction).

      @@ -7842,7 +7906,7 @@

      6.4 – String Manipulation

      Returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). -The format string follows the same rules as the C function sprintf. +The format string follows the same rules as the ANSI C function sprintf. The only differences are that the options/modifiers *, h, L, l, n, and p are not supported @@ -8306,7 +8370,7 @@

      6.5 – Table Manipulation

      Given a list where all elements are strings or numbers, -returns list[i]..sep..list[i+1] ··· sep..list[j]. +returns the string list[i]..sep..list[i+1] ··· sep..list[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is #list. @@ -8348,10 +8412,17 @@

      6.5 – Table Manipulation

      Removes from list the element at position pos, -shifting down the elements +returning the value of the removed element. +When pos is an integer between 1 and #list, +it shifts down the elements list[pos+1], list[pos+2], ···, list[#list] -and erasing element list[#list]. -Returns the value of the removed element. +and erases element list[#list]; +The index pos can also be 0 when #list is 0, +or #list + 1; +in those cases, the function erases the element list[pos]. + + +

      The default value for pos is #list, so that a call table.remove(t) removes the last element of list t. @@ -8990,6 +9061,11 @@

      6.8 – Input and Output Facilities

      (plus an error message as a second result and a system-dependent error code as a third result) and some value different from nil on success. +On non-Posix systems, +the computation of the error message and error code +in case of errors +may be not thread safe, +because they rely on the global C variable errno.

      @@ -9410,7 +9486,7 @@

      6.9 – Operating System Facilities

      If format is not "*t", then date returns the date as a string, -formatted according to the same rules as the C function strftime. +formatted according to the same rules as the ANSI C function strftime.

      @@ -9421,8 +9497,9 @@

      6.9 – Operating System Facilities

      -On some systems, -this function may be not thread safe. +On non-Posix systems, +this function may be not thread safe +because of its reliance on C function gmtime and C function localtime. @@ -9444,7 +9521,7 @@

      6.9 – Operating System Facilities

      -This function is equivalent to the C function system. +This function is equivalent to the ANSI C function system. It passes command to be executed by an operating system shell. Its first result is true if the command terminated successfully, @@ -9479,7 +9556,7 @@

      6.9 – Operating System Facilities

      -Calls the C function exit to terminate the host program. +Calls the ANSI C function exit to terminate the host program. If code is true, the returned status is EXIT_SUCCESS; if code is false, @@ -9560,6 +9637,11 @@

      6.9 – Operating System Facilities

      for the given category. +

      +This function may be not thread safe +because of its reliance on C function setlocale. + +

      @@ -9746,7 +9828,7 @@

      6.10 – The Debug Library

      -Variable names starting with '(' (open parentheses) +Variable names starting with '(' (open parenthesis) represent internal variables (loop control variables, temporaries, varargs, and C function locals). @@ -10415,10 +10497,10 @@

      9 – The Complete Syntax of Lua


      Last update: -Fri Jun 8 16:13:40 BRT 2012 +Thu Mar 21 12:58:59 BRT 2013 diff --git a/doc/readme.html b/doc/readme.html index 2ff294ec..5b9e47ec 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -109,7 +109,7 @@

      Building Lua

      1. Open a terminal window and move to -the top-level directory, which is named lua-5.2.1. +the top-level directory, which is named lua-5.2.2. The Makefile there controls both the build process and the installation process.

      2. @@ -140,6 +140,8 @@

        Building Lua

        If you're running Linux and get compilation errors, make sure you have installed the readline development package. +If you get link errors after that, +then try "make linux MYLIBS=-ltermcap".

        Installing Lua

        @@ -372,7 +374,7 @@

        License

        this.
        -Copyright © 1994–2012 Lua.org, PUC-Rio. +Copyright © 1994–2013 Lua.org, PUC-Rio.

        Permission is hereby granted, free of charge, to any person obtaining a copy @@ -400,10 +402,10 @@

        License


        Last update: -Tue May 29 21:57:51 BRT 2012 +Fri Feb 22 09:24:20 BRT 2013 diff --git a/src/Makefile b/src/Makefile index 8c9ee677..fea895bc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -103,7 +103,7 @@ freebsd: generic: $(ALL) linux: - $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline -lncurses" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" macosx: $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" diff --git a/src/lapi.c b/src/lapi.c index 1854fe61..791d8545 100644 --- a/src/lapi.c +++ b/src/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.164 2012/06/08 15:14:04 roberto Exp $ +** $Id: lapi.c,v 2.171 2013/03/16 21:10:18 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -40,7 +40,16 @@ const char lua_ident[] = /* corresponding test */ #define isvalid(o) ((o) != luaO_nilobject) -#define api_checkvalidindex(L, i) api_check(L, isvalid(i), "invalid index") +/* test for pseudo index */ +#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) + +/* test for valid but not pseudo index */ +#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) + +#define api_checkvalidindex(L, o) api_check(L, isvalid(o), "invalid index") + +#define api_checkstackindex(L, i, o) \ + api_check(L, isstackindex(i, o), "index not in the stack") static TValue *index2addr (lua_State *L, int idx) { @@ -51,7 +60,7 @@ static TValue *index2addr (lua_State *L, int idx) { if (o >= L->top) return NONVALIDVALUE; else return o; } - else if (idx > LUA_REGISTRYINDEX) { + else if (!ispseudo(idx)) { /* negative index */ api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); return L->top + idx; } @@ -142,7 +151,7 @@ LUA_API const lua_Number *lua_version (lua_State *L) { ** convert an acceptable stack index into an absolute index */ LUA_API int lua_absindex (lua_State *L, int idx) { - return (idx > 0 || idx <= LUA_REGISTRYINDEX) + return (idx > 0 || ispseudo(idx)) ? idx : cast_int(L->top - L->ci->func + idx); } @@ -174,7 +183,7 @@ LUA_API void lua_remove (lua_State *L, int idx) { StkId p; lua_lock(L); p = index2addr(L, idx); - api_checkvalidindex(L, p); + api_checkstackindex(L, idx, p); while (++p < L->top) setobjs2s(L, p-1, p); L->top--; lua_unlock(L); @@ -186,8 +195,9 @@ LUA_API void lua_insert (lua_State *L, int idx) { StkId q; lua_lock(L); p = index2addr(L, idx); - api_checkvalidindex(L, p); - for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + api_checkstackindex(L, idx, p); + for (q = L->top; q > p; q--) /* use L->top as a temporary */ + setobjs2s(L, q, q - 1); setobjs2s(L, p, L->top); lua_unlock(L); } @@ -217,7 +227,6 @@ LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { TValue *fr; lua_lock(L); fr = index2addr(L, fromidx); - api_checkvalidindex(L, fr); moveto(L, fr, toidx); lua_unlock(L); } @@ -281,7 +290,7 @@ LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { } -LUA_API void lua_arith (lua_State *L, int op) { +LUA_API void lua_arith (lua_State *L, int op) { StkId o1; /* 1st operand */ StkId o2; /* 2nd operand */ lua_lock(L); @@ -295,7 +304,7 @@ LUA_API void lua_arith (lua_State *L, int op) { o1 = L->top - 2; o2 = L->top - 1; if (ttisnumber(o1) && ttisnumber(o2)) { - changenvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2))); + setnvalue(o1, luaO_arith(op, nvalue(o1), nvalue(o2))); } else luaV_arith(L, o1, o1, o2, cast(TMS, op - LUA_OPADD + TM_ADD)); @@ -611,7 +620,6 @@ LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; lua_lock(L); t = index2addr(L, idx); - api_checkvalidindex(L, t); luaV_gettable(L, t, L->top - 1, L->top - 1); lua_unlock(L); } @@ -621,7 +629,6 @@ LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { StkId t; lua_lock(L); t = index2addr(L, idx); - api_checkvalidindex(L, t); setsvalue2s(L, L->top, luaS_new(L, k)); api_incr_top(L); luaV_gettable(L, t, L->top - 1, L->top - 1); @@ -709,7 +716,6 @@ LUA_API void lua_getuservalue (lua_State *L, int idx) { StkId o; lua_lock(L); o = index2addr(L, idx); - api_checkvalidindex(L, o); api_check(L, ttisuserdata(o), "userdata expected"); if (uvalue(o)->env) { sethvalue(L, L->top, uvalue(o)->env); @@ -743,7 +749,6 @@ LUA_API void lua_settable (lua_State *L, int idx) { lua_lock(L); api_checknelems(L, 2); t = index2addr(L, idx); - api_checkvalidindex(L, t); luaV_settable(L, t, L->top - 2, L->top - 1); L->top -= 2; /* pop index and value */ lua_unlock(L); @@ -755,7 +760,6 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { lua_lock(L); api_checknelems(L, 1); t = index2addr(L, idx); - api_checkvalidindex(L, t); setsvalue2s(L, L->top++, luaS_new(L, k)); luaV_settable(L, t, L->top - 1, L->top - 2); L->top -= 2; /* pop value and key */ @@ -811,7 +815,6 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { lua_lock(L); api_checknelems(L, 1); obj = index2addr(L, objindex); - api_checkvalidindex(L, obj); if (ttisnil(L->top - 1)) mt = NULL; else { @@ -821,9 +824,10 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) { switch (ttypenv(obj)) { case LUA_TTABLE: { hvalue(obj)->metatable = mt; - if (mt) + if (mt) { luaC_objbarrierback(L, gcvalue(obj), mt); luaC_checkfinalizer(L, gcvalue(obj), mt); + } break; } case LUA_TUSERDATA: { @@ -850,7 +854,6 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) { lua_lock(L); api_checknelems(L, 1); o = index2addr(L, idx); - api_checkvalidindex(L, o); api_check(L, ttisuserdata(o), "userdata expected"); if (ttisnil(L->top - 1)) uvalue(o)->env = NULL; @@ -937,7 +940,7 @@ LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, func = 0; else { StkId o = index2addr(L, errfunc); - api_checkvalidindex(L, o); + api_checkstackindex(L, errfunc, o); func = savestack(L, o); } c.func = L->top - (nargs+1); /* function to be called */ @@ -1006,7 +1009,7 @@ LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { } -LUA_API int lua_status (lua_State *L) { +LUA_API int lua_status (lua_State *L) { return L->status; } @@ -1103,7 +1106,7 @@ LUA_API int lua_error (lua_State *L) { lua_lock(L); api_checknelems(L, 1); luaG_errormsg(L); - lua_unlock(L); + /* code unreachable; will unlock when control actually leaves the kernel */ return 0; /* to avoid warnings */ } diff --git a/src/lauxlib.c b/src/lauxlib.c index 36ae7e62..2e989d66 100644 --- a/src/lauxlib.c +++ b/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.244 2012/05/31 20:28:45 roberto Exp $ +** $Id: lauxlib.c,v 1.248 2013/03/21 13:54:57 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -84,7 +84,7 @@ static void pushfuncname (lua_State *L, lua_Debug *ar) { if (*ar->namewhat != '\0') /* is there a name? */ lua_pushfstring(L, "function " LUA_QS, ar->name); else if (*ar->what == 'm') /* main? */ - lua_pushfstring(L, "main chunk"); + lua_pushliteral(L, "main chunk"); else if (*ar->what == 'C') { if (pushglobalfuncname(L, ar)) { lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1)); @@ -158,7 +158,8 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { if (strcmp(ar.namewhat, "method") == 0) { narg--; /* do not count `self' */ if (narg == 0) /* error is in the self argument itself? */ - return luaL_error(L, "calling " LUA_QS " on bad self", ar.name); + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); } if (ar.name == NULL) ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; @@ -214,7 +215,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { if (fname) lua_pushfstring(L, "%s: %s", fname, strerror(en)); else - lua_pushfstring(L, "%s", strerror(en)); + lua_pushstring(L, strerror(en)); lua_pushinteger(L, en); return 3; } @@ -438,7 +439,7 @@ LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { if (B->size - B->n < sz) { /* not enough space? */ char *newbuff; size_t newsize = B->size * 2; /* double buffer size */ - if (newsize - B->n < sz) /* not bit enough? */ + if (newsize - B->n < sz) /* not big enough? */ newsize = B->n + sz; if (newsize < B->n || newsize - B->n < sz) luaL_error(L, "buffer too large"); @@ -598,7 +599,7 @@ static int skipBOM (LoadF *lf) { lf->n = 0; do { c = getc(lf->f); - if (c == EOF || c != *(unsigned char *)p++) return c; + if (c == EOF || c != *(const unsigned char *)p++) return c; lf->buff[lf->n++] = c; /* to be read by the parser */ } while (*p != '\0'); lf->n = 0; /* prefix matched; discard it */ diff --git a/src/lbaselib.c b/src/lbaselib.c index dbfcb02c..540e9a5c 100644 --- a/src/lbaselib.c +++ b/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.274 2012/04/27 14:13:19 roberto Exp $ +** $Id: lbaselib.c,v 1.276 2013/02/21 13:44:53 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -242,10 +242,16 @@ static int luaB_ipairs (lua_State *L) { } -static int load_aux (lua_State *L, int status) { - if (status == LUA_OK) +static int load_aux (lua_State *L, int status, int envidx) { + if (status == LUA_OK) { + if (envidx != 0) { /* 'env' parameter? */ + lua_pushvalue(L, envidx); /* environment for loaded function */ + if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ + lua_pop(L, 1); /* remove 'env' if not used by previous call */ + } return 1; - else { + } + else { /* error (message is on top of the stack) */ lua_pushnil(L); lua_insert(L, -2); /* put before error message */ return 2; /* return nil plus error message */ @@ -256,13 +262,9 @@ static int load_aux (lua_State *L, int status) { static int luaB_loadfile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); const char *mode = luaL_optstring(L, 2, NULL); - int env = !lua_isnone(L, 3); /* 'env' parameter? */ + int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ int status = luaL_loadfilex(L, fname, mode); - if (status == LUA_OK && env) { /* 'env' parameter? */ - lua_pushvalue(L, 3); - lua_setupvalue(L, -2, 1); /* set it as 1st upvalue of loaded chunk */ - } - return load_aux(L, status); + return load_aux(L, status, env); } @@ -307,9 +309,9 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { static int luaB_load (lua_State *L) { int status; size_t l; - int top = lua_gettop(L); const char *s = lua_tolstring(L, 1, &l); const char *mode = luaL_optstring(L, 3, "bt"); + int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ if (s != NULL) { /* loading a string? */ const char *chunkname = luaL_optstring(L, 2, s); status = luaL_loadbufferx(L, s, l, chunkname, mode); @@ -320,11 +322,7 @@ static int luaB_load (lua_State *L) { lua_settop(L, RESERVEDSLOT); /* create reserved slot */ status = lua_load(L, generic_reader, NULL, chunkname, mode); } - if (status == LUA_OK && top >= 4) { /* is there an 'env' argument */ - lua_pushvalue(L, 4); /* environment for loaded function */ - lua_setupvalue(L, -2, 1); /* set it as 1st upvalue */ - } - return load_aux(L, status); + return load_aux(L, status, env); } /* }====================================================== */ @@ -338,7 +336,8 @@ static int dofilecont (lua_State *L) { static int luaB_dofile (lua_State *L) { const char *fname = luaL_optstring(L, 1, NULL); lua_settop(L, 1); - if (luaL_loadfile(L, fname) != LUA_OK) lua_error(L); + if (luaL_loadfile(L, fname) != LUA_OK) + return lua_error(L); lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); return dofilecont(L); } diff --git a/src/lbitlib.c b/src/lbitlib.c index 7533b85c..9637532e 100644 --- a/src/lbitlib.c +++ b/src/lbitlib.c @@ -1,5 +1,5 @@ /* -** $Id: lbitlib.c,v 1.16 2011/06/20 16:35:23 roberto Exp $ +** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $ ** Standard library for bitwise operations ** See Copyright Notice in lua.h */ @@ -147,7 +147,9 @@ static int b_rrot (lua_State *L) { /* ** get field and width arguments for field-manipulation functions, -** checking whether they are valid +** checking whether they are valid. +** ('luaL_error' called without 'return' to avoid later warnings about +** 'width' being used uninitialized.) */ static int fieldargs (lua_State *L, int farg, int *width) { int f = luaL_checkint(L, farg); diff --git a/src/lcode.c b/src/lcode.c index 614e452f..56c26ac8 100644 --- a/src/lcode.c +++ b/src/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.60 2011/08/30 16:26:41 roberto Exp $ +** $Id: lcode.c,v 2.62 2012/08/16 17:34:28 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -330,10 +330,9 @@ int luaK_numberK (FuncState *fs, lua_Number r) { setnvalue(&o, r); if (r == 0 || luai_numisnan(NULL, r)) { /* handle -0 and NaN */ /* use raw representation as key to avoid numeric problems */ - setsvalue(L, L->top, luaS_newlstr(L, (char *)&r, sizeof(r))); - incr_top(L); - n = addk(fs, L->top - 1, &o); - L->top--; + setsvalue(L, L->top++, luaS_newlstr(L, (char *)&r, sizeof(r))); + n = addk(fs, L->top - 1, &o); + L->top--; } else n = addk(fs, &o, &o); /* regular case */ @@ -426,7 +425,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_nil(fs, reg, 1); break; } - case VFALSE: case VTRUE: { + case VFALSE: case VTRUE: { luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } diff --git a/src/lcorolib.c b/src/lcorolib.c index c7932d90..1326c814 100644 --- a/src/lcorolib.c +++ b/src/lcorolib.c @@ -1,5 +1,5 @@ /* -** $Id: lcorolib.c,v 1.4 2012/04/27 18:59:04 roberto Exp $ +** $Id: lcorolib.c,v 1.5 2013/02/21 13:44:53 roberto Exp $ ** Coroutine Library ** See Copyright Notice in lua.h */ @@ -73,7 +73,7 @@ static int luaB_auxwrap (lua_State *L) { lua_insert(L, -2); lua_concat(L, 2); } - lua_error(L); /* propagate error */ + return lua_error(L); /* propagate error */ } return r; } diff --git a/src/ldebug.c b/src/ldebug.c index 43f8f046..7e04f9d0 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.89 2012/01/20 22:05:50 roberto Exp $ +** $Id: ldebug.c,v 2.90 2012/08/16 17:34:28 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -196,7 +196,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) { static void collectvalidlines (lua_State *L, Closure *f) { if (noLuaClosure(f)) { setnilvalue(L->top); - incr_top(L); + api_incr_top(L); } else { int i; @@ -204,7 +204,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { int *lineinfo = f->l.p->lineinfo; Table *t = luaH_new(L); /* new table to store active lines */ sethvalue(L, L->top, t); /* push it on stack */ - incr_top(L); + api_incr_top(L); setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ @@ -285,7 +285,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { status = auxgetinfo(L, what, ar, cl, ci); if (strchr(what, 'f')) { setobjs2s(L, L->top, func); - incr_top(L); + api_incr_top(L); } if (strchr(what, 'L')) collectvalidlines(L, cl); @@ -563,7 +563,7 @@ l_noret luaG_errormsg (lua_State *L) { if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); setobjs2s(L, L->top, L->top - 1); /* move argument */ setobjs2s(L, L->top - 1, errfunc); /* push function */ - incr_top(L); + L->top++; luaD_call(L, L->top - 2, 1, 0); /* call it */ } luaD_throw(L, LUA_ERRRUN); diff --git a/src/ldo.c b/src/ldo.c index d18e33cd..aafa3dca 100644 --- a/src/ldo.c +++ b/src/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.105 2012/06/08 15:14:04 roberto Exp $ +** $Id: ldo.c,v 2.108 2012/10/01 14:05:04 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -311,6 +311,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { ci->top = L->top + LUA_MINSTACK; lua_assert(ci->top <= L->stack_last); ci->callstatus = 0; + luaC_checkGC(L); /* stack grow uses memory */ if (L->hookmask & LUA_MASKCALL) luaD_hook(L, LUA_HOOKCALL, -1); lua_unlock(L); @@ -338,6 +339,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { ci->u.l.savedpc = p->code; /* starting point */ ci->callstatus = CIST_LUA; L->top = ci->top; + luaC_checkGC(L); /* stack grow uses memory */ if (L->hookmask & LUA_MASKCALL) callhook(L, ci); return 0; @@ -393,7 +395,6 @@ void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { luaV_execute(L); /* call it */ if (!allowyield) L->nny--; L->nCcalls--; - luaC_checkGC(L); } @@ -402,7 +403,11 @@ static void finishCcall (lua_State *L) { int n; lua_assert(ci->u.c.k != NULL); /* must have a continuation */ lua_assert(L->nny == 0); - /* finish 'lua_callk' */ + if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ + ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */ + L->errfunc = ci->u.c.old_errfunc; + } + /* finish 'lua_callk'/'lua_pcall' */ adjustresults(L, ci->nresults); /* call continuation function */ if (!(ci->callstatus & CIST_STAT)) /* no call status? */ @@ -473,7 +478,7 @@ static int recover (lua_State *L, int status) { static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { L->top = firstArg; /* remove args from the stack */ setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ - incr_top(L); + api_incr_top(L); luaD_throw(L, -1); /* jump back to 'lua_resume' */ } @@ -558,7 +563,7 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { api_checknelems(L, nresults); if (L->nny > 0) { if (L != G(L)->mainthread) - luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + luaG_runerror(L, "attempt to yield across a C-call boundary"); else luaG_runerror(L, "attempt to yield from outside a coroutine"); } diff --git a/src/lfunc.c b/src/lfunc.c index 4fd27fe5..c2128405 100644 --- a/src/lfunc.c +++ b/src/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.29 2012/05/08 13:53:33 roberto Exp $ +** $Id: lfunc.c,v 2.30 2012/10/03 12:36:46 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -52,12 +52,12 @@ UpVal *luaF_findupval (lua_State *L, StkId level) { while (*pp != NULL && (p = gco2uv(*pp))->v >= level) { GCObject *o = obj2gco(p); lua_assert(p->v != &p->u.value); + lua_assert(!isold(o) || isold(obj2gco(L))); if (p->v == level) { /* found a corresponding upvalue? */ if (isdead(g, o)) /* is it dead? */ changewhite(o); /* resurrect it */ return p; } - resetoldbit(o); /* may create a newer upval after this one */ pp = &p->next; } /* not found: create a new one */ diff --git a/src/lgc.c b/src/lgc.c index 06f972a7..535e988a 100644 --- a/src/lgc.c +++ b/src/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.133 2012/05/31 21:28:59 roberto Exp $ +** $Id: lgc.c,v 2.140 2013/03/16 21:10:18 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -43,21 +43,12 @@ */ #define STEPMULADJ 200 + /* ** macro to adjust 'pause': 'pause' is actually used like ** 'pause / PAUSEADJ' (value chosen by tests) */ -#define PAUSEADJ 200 - - - - -/* -** standard negative debt for GC; a reasonable "time" to wait before -** starting a new cycle -*/ -#define stddebtest(g,e) (-cast(l_mem, (e)/PAUSEADJ) * g->gcpause) -#define stddebt(g) stddebtest(g, gettotalbytes(g)) +#define PAUSEADJ 100 /* @@ -144,9 +135,9 @@ static int iscleared (global_State *g, const TValue *o) { void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { global_State *g = G(L); lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - lua_assert(isgenerational(g) || g->gcstate != GCSpause); + lua_assert(g->gcstate != GCSpause); lua_assert(gch(o)->tt != LUA_TTABLE); - if (keepinvariant(g)) /* must keep invariant? */ + if (keepinvariantout(g)) /* must keep invariant? */ reallymarkobject(g, v); /* restore invariant */ else { /* sweep phase */ lua_assert(issweepphase(g)); @@ -343,7 +334,7 @@ static void remarkupvals (global_State *g) { ** mark root set and reset all gray lists, to start a new ** incremental (or full) collection */ -static void markroot (global_State *g) { +static void restartcollection (global_State *g) { g->gray = g->grayagain = NULL; g->weak = g->allweak = g->ephemeron = NULL; markobject(g, g->mainthread); @@ -459,7 +450,7 @@ static lu_mem traversetable (global_State *g, Table *h) { else /* not weak */ traversestrongtable(g, h); return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * sizenode(h); + sizeof(Node) * cast(size_t, sizenode(h)); } @@ -796,7 +787,7 @@ static GCObject *udata2finalize (global_State *g) { g->allgc = o; resetbit(gch(o)->marked, SEPARATED); /* mark that it is not in 'tobefnz' */ lua_assert(!isold(o)); /* see MOVE OLD rule */ - if (!keepinvariant(g)) /* not keeping invariant? */ + if (!keepinvariantout(g)) /* not keeping invariant? */ makewhite(g, o); /* "sweep" object */ return o; } @@ -855,7 +846,7 @@ static void separatetobefnz (lua_State *L, int all) { while ((curr = *p) != NULL) { /* traverse all finalizable objects */ lua_assert(!isfinalized(curr)); lua_assert(testbit(gch(curr)->marked, SEPARATED)); - if (!(all || iswhite(curr))) /* not being collected? */ + if (!(iswhite(curr) || all)) /* not being collected? */ p = &gch(curr)->next; /* don't bother with it */ else { l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ @@ -891,7 +882,7 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { ho->next = g->finobj; /* link it in list 'finobj' */ g->finobj = o; l_setbit(ho->marked, SEPARATED); /* mark it as such */ - if (!keepinvariant(g)) /* not keeping invariant? */ + if (!keepinvariantout(g)) /* not keeping invariant? */ makewhite(g, o); /* "sweep" object */ else resetoldbit(o); /* see MOVE OLD rule */ @@ -908,6 +899,21 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { */ +/* +** set a reasonable "time" to wait before starting a new GC cycle; +** cycle will start when memory use hits threshold +*/ +static void setpause (global_State *g, l_mem estimate) { + l_mem debt, threshold; + estimate = estimate / PAUSEADJ; /* adjust 'estimate' */ + threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ + ? estimate * g->gcpause /* no overflow */ + : MAX_LMEM; /* overflow; truncate to maximum */ + debt = -cast(l_mem, threshold - gettotalbytes(g)); + luaE_setdebt(g, debt); +} + + #define sweepphases \ (bitmask(GCSsweepstring) | bitmask(GCSsweepudata) | bitmask(GCSsweep)) @@ -918,7 +924,7 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { ** object inside the list (instead of to the header), so that the real ** sweep do not need to skip objects created between "now" and the start ** of the real sweep. -** Returns how many objects it sweeped. +** Returns how many objects it swept. */ static int entersweep (lua_State *L) { global_State *g = G(L); @@ -985,7 +991,7 @@ void luaC_freeallobjects (lua_State *L) { static l_mem atomic (lua_State *L) { global_State *g = G(L); - l_mem work = -g->GCmemtrav; /* start counting work */ + l_mem work = -cast(l_mem, g->GCmemtrav); /* start counting work */ GCObject *origweak, *origall; lua_assert(!iswhite(obj2gco(g->mainthread))); markobject(g, L); /* mark running thread */ @@ -1028,12 +1034,10 @@ static lu_mem singlestep (lua_State *L) { global_State *g = G(L); switch (g->gcstate) { case GCSpause: { - g->GCmemtrav = 0; /* start to count memory traversed */ - if (!isgenerational(g)) - markroot(g); /* start a new collection */ - /* in any case, root must be marked at this point */ - lua_assert(!iswhite(obj2gco(g->mainthread)) - && !iswhite(gcvalue(&g->l_registry))); + /* start to count memory traversed */ + g->GCmemtrav = g->strt.size * sizeof(GCObject*); + lua_assert(!isgenerational(g)); + restartcollection(g); g->gcstate = GCSpropagate; return g->GCmemtrav; } @@ -1105,18 +1109,23 @@ void luaC_runtilstate (lua_State *L, int statesmask) { static void generationalcollection (lua_State *L) { global_State *g = G(L); + lua_assert(g->gcstate == GCSpropagate); if (g->GCestimate == 0) { /* signal for another major collection? */ luaC_fullgc(L, 0); /* perform a full regular collection */ g->GCestimate = gettotalbytes(g); /* update control */ } else { lu_mem estimate = g->GCestimate; - luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ - luaC_runtilstate(L, bitmask(GCSpause)); + luaC_runtilstate(L, bitmask(GCSpause)); /* run complete (minor) cycle */ + g->gcstate = GCSpropagate; /* skip restart */ if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) g->GCestimate = 0; /* signal for a major collection */ + else + g->GCestimate = estimate; /* keep estimate from last major coll. */ + } - luaE_setdebt(g, stddebt(g)); + setpause(g, gettotalbytes(g)); + lua_assert(g->gcstate == GCSpropagate); } @@ -1124,7 +1133,7 @@ static void incstep (lua_State *L) { global_State *g = G(L); l_mem debt = g->GCdebt; int stepmul = g->gcstepmul; - if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values */ + if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values (and 0) */ /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */ debt = (debt / STEPMULADJ) + 1; debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; @@ -1133,10 +1142,11 @@ static void incstep (lua_State *L) { debt -= work; } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); if (g->gcstate == GCSpause) - debt = stddebtest(g, g->GCestimate); /* pause until next cycle */ - else + setpause(g, g->GCestimate); /* pause until next cycle */ + else { debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */ - luaE_setdebt(g, debt); + luaE_setdebt(g, debt); + } } @@ -1172,7 +1182,6 @@ void luaC_step (lua_State *L) { void luaC_fullgc (lua_State *L, int isemergency) { global_State *g = G(L); int origkind = g->gckind; - int someblack = keepinvariant(g); lua_assert(origkind != KGC_EMERGENCY); if (isemergency) /* do not run finalizers during emergency GC */ g->gckind = KGC_EMERGENCY; @@ -1180,22 +1189,21 @@ void luaC_fullgc (lua_State *L, int isemergency) { g->gckind = KGC_NORMAL; callallpendingfinalizers(L, 1); } - if (someblack) { /* may there be some black objects? */ + if (keepinvariant(g)) { /* may there be some black objects? */ /* must sweep all objects to turn them back to white (as white has not changed, nothing will be collected) */ entersweep(L); } /* finish any pending sweep phase to start a new cycle */ luaC_runtilstate(L, bitmask(GCSpause)); - /* run entire collector */ - luaC_runtilstate(L, ~bitmask(GCSpause)); - luaC_runtilstate(L, bitmask(GCSpause)); + luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */ + luaC_runtilstate(L, bitmask(GCSpause)); /* run entire collection */ if (origkind == KGC_GEN) { /* generational mode? */ - /* generational mode must always start in propagate phase */ + /* generational mode must be kept in propagate phase */ luaC_runtilstate(L, bitmask(GCSpropagate)); } g->gckind = origkind; - luaE_setdebt(g, stddebt(g)); + setpause(g, gettotalbytes(g)); if (!isemergency) /* do not run finalizers during emergency GC */ callallpendingfinalizers(L, 1); } diff --git a/src/lgc.h b/src/lgc.h index bdd5cce6..dee270b4 100644 --- a/src/lgc.h +++ b/src/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.56 2012/05/23 15:43:14 roberto Exp $ +** $Id: lgc.h,v 2.58 2012/09/11 12:53:08 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -50,14 +50,24 @@ #define isgenerational(g) ((g)->gckind == KGC_GEN) /* -** macro to tell when main invariant (white objects cannot point to black +** macros to tell when main invariant (white objects cannot point to black ** ones) must be kept. During a non-generational collection, the sweep ** phase may break the invariant, as objects turned white may point to ** still-black objects. The invariant is restored when sweep ends and ** all objects are white again. During a generational collection, the ** invariant must be kept all times. */ -#define keepinvariant(g) (isgenerational(g) || g->gcstate <= GCSatomic) + +#define keepinvariant(g) (isgenerational(g) || g->gcstate <= GCSatomic) + + +/* +** Outside the collector, the state in generational mode is kept in +** 'propagate', so 'keepinvariant' is always true. +*/ +#define keepinvariantout(g) \ + check_exp(g->gcstate == GCSpropagate || !isgenerational(g), \ + g->gcstate <= GCSatomic) /* diff --git a/src/liolib.c b/src/liolib.c index 4814aa2c..3f80db19 100644 --- a/src/liolib.c +++ b/src/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.108 2011/11/25 12:50:03 roberto Exp $ +** $Id: liolib.c,v 2.111 2013/03/21 13:57:27 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -29,6 +29,20 @@ #include "lualib.h" +#if !defined(lua_checkmode) + +/* +** Check whether 'mode' matches '[rwa]%+?b?'. +** Change this macro to accept other modes for 'fopen' besides +** the standard ones. +*/ +#define lua_checkmode(mode) \ + (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \ + (*mode != '+' || ++mode) && /* skip if char is '+' */ \ + (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \ + (*mode == '\0')) + +#endif /* ** {====================================================== @@ -212,14 +226,8 @@ static int io_open (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); LStream *p = newfile(L); - int i = 0; - /* check whether 'mode' matches '[rwa]%+?b?' */ - if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL && - (mode[i] != '+' || ++i) && /* skip if char is '+' */ - (mode[i] != 'b' || ++i) && /* skip if char is 'b' */ - (mode[i] == '\0'))) - return luaL_error(L, "invalid mode " LUA_QS - " (should match " LUA_QL("[rwa]%%+?b?") ")", mode); + const char *md = mode; /* to traverse/check mode */ + luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode"); p->f = fopen(filename, mode); return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; } diff --git a/src/llex.c b/src/llex.c index c4d8c65b..1a32e348 100644 --- a/src/llex.c +++ b/src/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.61 2012/01/23 23:05:51 roberto Exp $ +** $Id: llex.c,v 2.63 2013/03/16 21:10:18 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -73,16 +73,16 @@ void luaX_init (lua_State *L) { const char *luaX_token2str (LexState *ls, int token) { - if (token < FIRST_RESERVED) { + if (token < FIRST_RESERVED) { /* single-byte symbols? */ lua_assert(token == cast(unsigned char, token)); return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) : luaO_pushfstring(ls->L, "char(%d)", token); } else { const char *s = luaX_tokens[token - FIRST_RESERVED]; - if (token < TK_EOS) + if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ return luaO_pushfstring(ls->L, LUA_QS, s); - else + else /* names, strings, and numerals */ return s; } } @@ -313,7 +313,7 @@ static int readhexaesc (LexState *ls) { int c[3], i; /* keep input for error message */ int r = 0; /* result accumulator */ c[0] = 'x'; /* for error message */ - for (i = 1; i < 3; i++) { /* read two hexa digits */ + for (i = 1; i < 3; i++) { /* read two hexadecimal digits */ c[i] = next(ls); if (!lisxdigit(c[i])) escerror(ls, c, i + 1, "hexadecimal digit expected"); diff --git a/src/llimits.h b/src/llimits.h index fc9de1a1..1b8c79bd 100644 --- a/src/llimits.h +++ b/src/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.99 2012/05/28 20:32:28 roberto Exp $ +** $Id: llimits.h,v 1.103 2013/02/20 14:08:56 roberto Exp $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -200,7 +200,7 @@ typedef lu_int32 Instruction; ** both small and large values (outside the range of integers). */ -#if defined(MS_ASMTRICK) /* { */ +#if defined(MS_ASMTRICK) || defined(LUA_MSASMTRICK) /* { */ /* trick with Microsoft assembler for X86 */ #define lua_number2int(i,n) __asm {__asm fld n __asm fistp i} @@ -256,7 +256,7 @@ union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; #if !defined(lua_number2unsigned) /* { */ /* the following definition assures proper modulo behavior */ -#if defined(LUA_NUMBER_DOUBLE) +#if defined(LUA_NUMBER_DOUBLE) || defined(LUA_NUMBER_FLOAT) #include #define SUPUNSIGNED ((lua_Number)(~(lua_Unsigned)0) + 1) #define lua_number2unsigned(i,n) \ @@ -282,7 +282,7 @@ union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; #include #define luai_hashnum(i,n) { int e; \ - n = frexp(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ + n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ lua_number2int(i, n); i += e; } #endif diff --git a/src/lmathlib.c b/src/lmathlib.c index c3c605e8..a49f1fd2 100644 --- a/src/lmathlib.c +++ b/src/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.81 2012/05/18 17:47:53 roberto Exp $ +** $Id: lmathlib.c,v 1.83 2013/03/07 18:21:32 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -17,106 +17,101 @@ #include "lualib.h" -/* macro 'l_tg' allows the addition of an 'l' or 'f' to all math operations */ -#if !defined(l_tg) -#define l_tg(x) (x) -#endif - - #undef PI -#define PI (l_tg(3.1415926535897932384626433832795)) -#define RADIANS_PER_DEGREE (PI/180.0) +#define PI ((lua_Number)(3.1415926535897932384626433832795)) +#define RADIANS_PER_DEGREE ((lua_Number)(PI/180.0)) static int math_abs (lua_State *L) { - lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); return 1; } static int math_sin (lua_State *L) { - lua_pushnumber(L, l_tg(sin)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1))); return 1; } static int math_sinh (lua_State *L) { - lua_pushnumber(L, l_tg(sinh)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1))); return 1; } static int math_cos (lua_State *L) { - lua_pushnumber(L, l_tg(cos)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1))); return 1; } static int math_cosh (lua_State *L) { - lua_pushnumber(L, l_tg(cosh)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1))); return 1; } static int math_tan (lua_State *L) { - lua_pushnumber(L, l_tg(tan)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1))); return 1; } static int math_tanh (lua_State *L) { - lua_pushnumber(L, l_tg(tanh)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1))); return 1; } static int math_asin (lua_State *L) { - lua_pushnumber(L, l_tg(asin)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1))); return 1; } static int math_acos (lua_State *L) { - lua_pushnumber(L, l_tg(acos)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1))); return 1; } static int math_atan (lua_State *L) { - lua_pushnumber(L, l_tg(atan)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(atan)(luaL_checknumber(L, 1))); return 1; } static int math_atan2 (lua_State *L) { - lua_pushnumber(L, l_tg(atan2)(luaL_checknumber(L, 1), + lua_pushnumber(L, l_mathop(atan2)(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); return 1; } static int math_ceil (lua_State *L) { - lua_pushnumber(L, l_tg(ceil)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(ceil)(luaL_checknumber(L, 1))); return 1; } static int math_floor (lua_State *L) { - lua_pushnumber(L, l_tg(floor)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(floor)(luaL_checknumber(L, 1))); return 1; } static int math_fmod (lua_State *L) { - lua_pushnumber(L, l_tg(fmod)(luaL_checknumber(L, 1), + lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); return 1; } static int math_modf (lua_State *L) { lua_Number ip; - lua_Number fp = l_tg(modf)(luaL_checknumber(L, 1), &ip); + lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip); lua_pushnumber(L, ip); lua_pushnumber(L, fp); return 2; } static int math_sqrt (lua_State *L) { - lua_pushnumber(L, l_tg(sqrt)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1))); return 1; } static int math_pow (lua_State *L) { - lua_pushnumber(L, l_tg(pow)(luaL_checknumber(L, 1), - luaL_checknumber(L, 2))); + lua_Number x = luaL_checknumber(L, 1); + lua_Number y = luaL_checknumber(L, 2); + lua_pushnumber(L, l_mathop(pow)(x, y)); return 1; } @@ -124,11 +119,11 @@ static int math_log (lua_State *L) { lua_Number x = luaL_checknumber(L, 1); lua_Number res; if (lua_isnoneornil(L, 2)) - res = l_tg(log)(x); + res = l_mathop(log)(x); else { lua_Number base = luaL_checknumber(L, 2); - if (base == 10.0) res = l_tg(log10)(x); - else res = l_tg(log)(x)/l_tg(log)(base); + if (base == (lua_Number)10.0) res = l_mathop(log10)(x); + else res = l_mathop(log)(x)/l_mathop(log)(base); } lua_pushnumber(L, res); return 1; @@ -136,13 +131,13 @@ static int math_log (lua_State *L) { #if defined(LUA_COMPAT_LOG10) static int math_log10 (lua_State *L) { - lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1))); return 1; } #endif static int math_exp (lua_State *L) { - lua_pushnumber(L, l_tg(exp)(luaL_checknumber(L, 1))); + lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1))); return 1; } @@ -158,14 +153,15 @@ static int math_rad (lua_State *L) { static int math_frexp (lua_State *L) { int e; - lua_pushnumber(L, l_tg(frexp)(luaL_checknumber(L, 1), &e)); + lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e)); lua_pushinteger(L, e); return 2; } static int math_ldexp (lua_State *L) { - lua_pushnumber(L, l_tg(ldexp)(luaL_checknumber(L, 1), - luaL_checkint(L, 2))); + lua_Number x = luaL_checknumber(L, 1); + int ep = luaL_checkint(L, 2); + lua_pushnumber(L, l_mathop(ldexp)(x, ep)); return 1; } @@ -210,15 +206,15 @@ static int math_random (lua_State *L) { } case 1: { /* only upper limit */ lua_Number u = luaL_checknumber(L, 1); - luaL_argcheck(L, 1.0 <= u, 1, "interval is empty"); - lua_pushnumber(L, l_tg(floor)(r*u) + 1.0); /* int in [1, u] */ + luaL_argcheck(L, (lua_Number)1.0 <= u, 1, "interval is empty"); + lua_pushnumber(L, l_mathop(floor)(r*u) + (lua_Number)(1.0)); /* [1, u] */ break; } case 2: { /* lower and upper limits */ lua_Number l = luaL_checknumber(L, 1); lua_Number u = luaL_checknumber(L, 2); luaL_argcheck(L, l <= u, 2, "interval is empty"); - lua_pushnumber(L, l_tg(floor)(r*(u-l+1)) + l); /* int in [l, u] */ + lua_pushnumber(L, l_mathop(floor)(r*(u-l+1)) + l); /* [l, u] */ break; } default: return luaL_error(L, "wrong number of arguments"); diff --git a/src/lmem.h b/src/lmem.h index 535dfe07..5f850999 100644 --- a/src/lmem.h +++ b/src/lmem.h @@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $ +** $Id: lmem.h,v 1.40 2013/02/20 14:08:21 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -14,10 +14,17 @@ #include "lua.h" +/* +** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is +** always constant. +** The macro is somewhat complex to avoid warnings: +** +1 avoids warnings of "comparison has constant result"; +** cast to 'void' avoids warnings of "value unused". +*/ #define luaM_reallocv(L,b,on,n,e) \ - ((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ - (luaM_toobig(L), (void *)0) : \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e))) + (cast(void, \ + (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e))) #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 13fce898..81bf220b 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.108 2011/12/12 16:34:03 roberto Exp $ +** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -92,9 +92,9 @@ #define LUA_OFSEP "_" -#define LIBPREFIX "LOADLIB: " +/* table (in the registry) that keeps handles for all loaded C libraries */ +#define CLIBS "_CLIBS" -#define POF LUA_POF #define LIB_FAIL "open" @@ -300,48 +300,54 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { #endif - -static void **ll_register (lua_State *L, const char *path) { - void **plib; - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ - if (!lua_isnil(L, -1)) /* is there an entry? */ - plib = (void **)lua_touserdata(L, -1); - else { /* no entry yet; create one */ - lua_pop(L, 1); /* remove result from gettable */ - plib = (void **)lua_newuserdata(L, sizeof(const void *)); - *plib = NULL; - luaL_setmetatable(L, "_LOADLIB"); - lua_pushfstring(L, "%s%s", LIBPREFIX, path); - lua_pushvalue(L, -2); - lua_settable(L, LUA_REGISTRYINDEX); - } +static void *ll_checkclib (lua_State *L, const char *path) { + void *plib; + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_getfield(L, -1, path); + plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ + lua_pop(L, 2); /* pop CLIBS table and 'plib' */ return plib; } +static void ll_addtoclib (lua_State *L, const char *path, void *plib) { + lua_getfield(L, LUA_REGISTRYINDEX, CLIBS); + lua_pushlightuserdata(L, plib); + lua_pushvalue(L, -1); + lua_setfield(L, -3, path); /* CLIBS[path] = plib */ + lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ + lua_pop(L, 1); /* pop CLIBS table */ +} + + /* -** __gc tag method: calls library's `ll_unloadlib' function with the lib -** handle +** __gc tag method for CLIBS table: calls 'll_unloadlib' for all lib +** handles in list CLIBS */ static int gctm (lua_State *L) { - void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); - if (*lib) ll_unloadlib(*lib); - *lib = NULL; /* mark library as closed */ + int n = luaL_len(L, 1); + for (; n >= 1; n--) { /* for each handle, in reverse order */ + lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ + ll_unloadlib(lua_touserdata(L, -1)); + lua_pop(L, 1); /* pop handle */ + } return 0; } static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { - void **reg = ll_register(L, path); - if (*reg == NULL) *reg = ll_load(L, path, *sym == '*'); - if (*reg == NULL) return ERRLIB; /* unable to load library */ + void *reg = ll_checkclib(L, path); /* check loaded C libraries */ + if (reg == NULL) { /* must load library? */ + reg = ll_load(L, path, *sym == '*'); + if (reg == NULL) return ERRLIB; /* unable to load library */ + ll_addtoclib(L, path, reg); + } if (*sym == '*') { /* loading only library (no function)? */ lua_pushboolean(L, 1); /* return 'true' */ return 0; /* no errors */ } else { - lua_CFunction f = ll_sym(L, *reg, sym); + lua_CFunction f = ll_sym(L, reg, sym); if (f == NULL) return ERRFUNC; /* unable to find function */ lua_pushcfunction(L, f); /* else create new function */ @@ -470,12 +476,12 @@ static int loadfunc (lua_State *L, const char *filename, const char *modname) { if (mark) { int stat; funcname = lua_pushlstring(L, modname, mark - modname); - funcname = lua_pushfstring(L, POF"%s", funcname); + funcname = lua_pushfstring(L, LUA_POF"%s", funcname); stat = ll_loadfunc(L, filename, funcname); if (stat != ERRFUNC) return stat; modname = mark + 1; /* else go ahead and try old-style name */ } - funcname = lua_pushfstring(L, POF"%s", modname); + funcname = lua_pushfstring(L, LUA_POF"%s", modname); return ll_loadfunc(L, filename, funcname); } @@ -528,9 +534,9 @@ static void findloader (lua_State *L, const char *name) { lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ if (!lua_istable(L, 3)) luaL_error(L, LUA_QL("package.searchers") " must be a table"); - /* iterate over available seachers to find a loader */ + /* iterate over available searchers to find a loader */ for (i = 1; ; i++) { - lua_rawgeti(L, 3, i); /* get a seacher */ + lua_rawgeti(L, 3, i); /* get a searcher */ if (lua_isnil(L, -1)) { /* no more searchers? */ lua_pop(L, 1); /* remove nil */ luaL_pushresult(&msg); /* create error message */ @@ -718,18 +724,10 @@ static const luaL_Reg ll_funcs[] = { }; -static const lua_CFunction searchers[] = - {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; - - -LUAMOD_API int luaopen_package (lua_State *L) { +static void createsearcherstable (lua_State *L) { + static const lua_CFunction searchers[] = + {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; int i; - /* create new type _LOADLIB */ - luaL_newmetatable(L, "_LOADLIB"); - lua_pushcfunction(L, gctm); - lua_setfield(L, -2, "__gc"); - /* create `package' table */ - luaL_newlib(L, pk_funcs); /* create 'searchers' table */ lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); /* fill it with pre-defined searchers */ @@ -738,6 +736,19 @@ LUAMOD_API int luaopen_package (lua_State *L) { lua_pushcclosure(L, searchers[i], 1); lua_rawseti(L, -2, i+1); } +} + + +LUAMOD_API int luaopen_package (lua_State *L) { + /* create table CLIBS to keep track of loaded C libraries */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); + lua_createtable(L, 0, 1); /* metatable for CLIBS */ + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ + lua_setmetatable(L, -2); + /* create `package' table */ + luaL_newlib(L, pk_funcs); + createsearcherstable(L); #if defined(LUA_COMPAT_LOADERS) lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ lua_setfield(L, -3, "loaders"); /* put it in field `loaders' */ diff --git a/src/lobject.c b/src/lobject.c index cf0f7544..c152785a 100644 --- a/src/lobject.c +++ b/src/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.55 2011/11/30 19:30:16 roberto Exp $ +** $Id: lobject.c,v 2.58 2013/02/20 14:08:56 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -104,7 +104,7 @@ static int isneg (const char **s) { static lua_Number readhexa (const char **s, lua_Number r, int *count) { for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */ - r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s))); + r = (r * cast_num(16.0)) + cast_num(luaO_hexavalue(cast_uchar(**s))); (*count)++; } return r; @@ -149,7 +149,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { *endptr = cast(char *, s); /* valid up to here */ ret: if (neg) r = -r; - return ldexp(r, e); + return l_mathop(ldexp)(r, e); } #endif @@ -171,8 +171,7 @@ int luaO_str2d (const char *s, size_t len, lua_Number *result) { static void pushstr (lua_State *L, const char *str, size_t l) { - setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); - incr_top(L); + setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); } @@ -182,8 +181,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { for (;;) { const char *e = strchr(fmt, '%'); if (e == NULL) break; - setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); - incr_top(L); + luaD_checkstack(L, 2); /* fmt + item */ + pushstr(L, fmt, e - fmt); switch (*(e+1)) { case 's': { const char *s = va_arg(argp, char *); @@ -198,13 +197,11 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { break; } case 'd': { - setnvalue(L->top, cast_num(va_arg(argp, int))); - incr_top(L); + setnvalue(L->top++, cast_num(va_arg(argp, int))); break; } case 'f': { - setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); - incr_top(L); + setnvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); break; } case 'p': { @@ -226,6 +223,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { n += 2; fmt = e+2; } + luaD_checkstack(L, 1); pushstr(L, fmt, strlen(fmt)); if (n > 0) luaV_concat(L, n + 1); return svalue(L->top - 1); diff --git a/src/lobject.h b/src/lobject.h index ca75a028..dd23b914 100644 --- a/src/lobject.h +++ b/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.70 2012/05/11 14:10:50 roberto Exp $ +** $Id: lobject.h,v 2.71 2012/09/11 18:21:44 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -52,8 +52,7 @@ #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ -/* -** LUA_TSTRING variants */ +/* Variant tags for strings */ #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ @@ -188,8 +187,6 @@ typedef struct lua_TValue TValue; #define setnvalue(obj,x) \ { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); } -#define changenvalue(o,x) check_exp(ttisnumber(o), num_(o)=(x)) - #define setnilvalue(obj) settt_(obj, LUA_TNIL) #define setfvalue(obj,x) \ diff --git a/src/loslib.c b/src/loslib.c index 489755b6..5170fd0d 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.39 2012/05/23 15:37:09 roberto Exp $ +** $Id: loslib.c,v 1.40 2012/10/19 15:54:02 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -98,7 +98,7 @@ static int os_remove (lua_State *L) { static int os_rename (lua_State *L) { const char *fromname = luaL_checkstring(L, 1); const char *toname = luaL_checkstring(L, 2); - return luaL_fileresult(L, rename(fromname, toname) == 0, fromname); + return luaL_fileresult(L, rename(fromname, toname) == 0, NULL); } diff --git a/src/lparser.c b/src/lparser.c index b3eb3ca9..d8f5b4ff 100644 --- a/src/lparser.c +++ b/src/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.128 2012/05/20 14:51:23 roberto Exp $ +** $Id: lparser.c,v 2.130 2013/02/06 13:37:39 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -245,7 +245,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { static int searchvar (FuncState *fs, TString *n) { int i; - for (i=fs->nactvar-1; i >= 0; i--) { + for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) { if (luaS_eqstr(n, getlocvar(fs, i)->varname)) return i; } @@ -512,12 +512,15 @@ static Proto *addprototype (LexState *ls) { /* -** codes instruction to create new closure in parent function +** codes instruction to create new closure in parent function. +** The OP_CLOSURE instruction must use the last available register, +** so that, if it invokes the GC, the GC knows which registers +** are in use at that time. */ static void codeclosure (LexState *ls, expdesc *v) { FuncState *fs = ls->fs->prev; init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); - luaK_exp2nextreg(fs, v); /* fix it at stack top (for GC) */ + luaK_exp2nextreg(fs, v); /* fix it at the last register */ } diff --git a/src/lstate.c b/src/lstate.c index 3c00c285..207a106d 100644 --- a/src/lstate.c +++ b/src/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.98 2012/05/30 12:33:44 roberto Exp $ +** $Id: lstate.c,v 2.99 2012/10/02 17:40:53 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -48,7 +48,7 @@ */ #if !defined(luai_makeseed) #include -#define luai_makeseed() cast(size_t, time(NULL)) +#define luai_makeseed() cast(unsigned int, time(NULL)) #endif diff --git a/src/lstate.h b/src/lstate.h index 29f810ba..c8a31f5c 100644 --- a/src/lstate.h +++ b/src/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.81 2012/06/08 15:14:04 roberto Exp $ +** $Id: lstate.h,v 2.82 2012/07/02 13:37:04 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -137,7 +137,7 @@ typedef struct global_State { UpVal uvhead; /* head of double-linked list of all open upvalues */ Mbuffer buff; /* temporary buffer for string concatenation */ int gcpause; /* size of pause between successive GCs */ - int gcmajorinc; /* how much to wait for a major GC (only in gen. mode) */ + int gcmajorinc; /* pause between major collections (only in gen. mode) */ int gcstepmul; /* GC `granularity' */ lua_CFunction panic; /* to be called in unprotected errors */ struct lua_State *mainthread; diff --git a/src/lstring.c b/src/lstring.c index 8b959f19..8b5af0b2 100644 --- a/src/lstring.c +++ b/src/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.24 2012/05/11 14:14:42 roberto Exp $ +** $Id: lstring.c,v 2.26 2013/01/08 13:50:10 roberto Exp $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -49,7 +49,7 @@ int luaS_eqstr (TString *a, TString *b) { unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { - unsigned int h = seed ^ l; + unsigned int h = seed ^ cast(unsigned int, l); size_t l1; size_t step = (l >> LUAI_HASHLIMIT) + 1; for (l1 = l; l1 >= step; l1 -= step) @@ -139,7 +139,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) { o = gch(o)->next) { TString *ts = rawgco2ts(o); if (h == ts->tsv.hash && - ts->tsv.len == l && + l == ts->tsv.len && (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */ changewhite(o); /* resurrect it */ diff --git a/src/lstrlib.c b/src/lstrlib.c index e13098bb..fcc61c9a 100644 --- a/src/lstrlib.c +++ b/src/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.176 2012/05/23 15:37:09 roberto Exp $ +** $Id: lstrlib.c,v 1.178 2012/08/14 18:12:34 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -194,7 +194,9 @@ static int str_dump (lua_State *L) { #define CAP_UNFINISHED (-1) #define CAP_POSITION (-2) + typedef struct MatchState { + int matchdepth; /* control for recursive depth (to avoid C stack overflow) */ const char *src_init; /* init of source string */ const char *src_end; /* end ('\0') of source string */ const char *p_end; /* end ('\0') of pattern */ @@ -207,6 +209,16 @@ typedef struct MatchState { } MatchState; +/* recursive function */ +static const char *match (MatchState *ms, const char *s, const char *p); + + +/* maximum recursion depth for 'match' */ +#if !defined(MAXCCALLS) +#define MAXCCALLS 200 +#endif + + #define L_ESC '%' #define SPECIALS "^$*+?.([%-" @@ -294,19 +306,22 @@ static int matchbracketclass (int c, const char *p, const char *ec) { } -static int singlematch (int c, const char *p, const char *ep) { - switch (*p) { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class(c, uchar(*(p+1))); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); +static int singlematch (MatchState *ms, const char *s, const char *p, + const char *ep) { + if (s >= ms->src_end) + return 0; + else { + int c = uchar(*s); + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } } } -static const char *match (MatchState *ms, const char *s, const char *p); - - static const char *matchbalance (MatchState *ms, const char *s, const char *p) { if (p >= ms->p_end - 1) @@ -331,7 +346,7 @@ static const char *matchbalance (MatchState *ms, const char *s, static const char *max_expand (MatchState *ms, const char *s, const char *p, const char *ep) { ptrdiff_t i = 0; /* counts maximum expand for item */ - while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + while (singlematch(ms, s + i, p, ep)) i++; /* keeps trying to match with the maximum repetitions */ while (i>=0) { @@ -349,7 +364,7 @@ static const char *min_expand (MatchState *ms, const char *s, const char *res = match(ms, s, ep+1); if (res != NULL) return res; - else if (ssrc_end && singlematch(uchar(*s), p, ep)) + else if (singlematch(ms, s, p, ep)) s++; /* try with one more repetition */ else return NULL; } @@ -393,79 +408,105 @@ static const char *match_capture (MatchState *ms, const char *s, int l) { static const char *match (MatchState *ms, const char *s, const char *p) { + if (ms->matchdepth-- == 0) + luaL_error(ms->L, "pattern too complex"); init: /* using goto's to optimize tail recursion */ - if (p == ms->p_end) /* end of pattern? */ - return s; /* match succeeded */ - switch (*p) { - case '(': { /* start capture */ - if (*(p+1) == ')') /* position capture? */ - return start_capture(ms, s, p+2, CAP_POSITION); - else - return start_capture(ms, s, p+1, CAP_UNFINISHED); - } - case ')': { /* end capture */ - return end_capture(ms, s, p+1); - } - case '$': { - if ((p+1) == ms->p_end) /* is the `$' the last char in pattern? */ - return (s == ms->src_end) ? s : NULL; /* check end of string */ - else goto dflt; - } - case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ - switch (*(p+1)) { - case 'b': { /* balanced string? */ - s = matchbalance(ms, s, p+2); - if (s == NULL) return NULL; - p+=4; goto init; /* else return match(ms, s, p+4); */ - } - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - luaL_error(ms->L, "missing " LUA_QL("[") " after " - LUA_QL("%%f") " in pattern"); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s-1); - if (matchbracketclass(uchar(previous), p, ep-1) || - !matchbracketclass(uchar(*s), p, ep-1)) return NULL; - p=ep; goto init; /* else return match(ms, s, ep); */ - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': { /* capture results (%0-%9)? */ - s = match_capture(ms, s, uchar(*(p+1))); - if (s == NULL) return NULL; - p+=2; goto init; /* else return match(ms, s, p+2) */ - } - default: goto dflt; + if (p != ms->p_end) { /* end of pattern? */ + switch (*p) { + case '(': { /* start capture */ + if (*(p + 1) == ')') /* position capture? */ + s = start_capture(ms, s, p + 2, CAP_POSITION); + else + s = start_capture(ms, s, p + 1, CAP_UNFINISHED); + break; } - } - default: dflt: { /* pattern class plus optional suffix */ - const char *ep = classend(ms, p); /* points to what is next */ - int m = s < ms->src_end && singlematch(uchar(*s), p, ep); - switch (*ep) { - case '?': { /* optional */ - const char *res; - if (m && ((res=match(ms, s+1, ep+1)) != NULL)) - return res; - p=ep+1; goto init; /* else return match(ms, s, ep+1); */ - } - case '*': { /* 0 or more repetitions */ - return max_expand(ms, s, p, ep); - } - case '+': { /* 1 or more repetitions */ - return (m ? max_expand(ms, s+1, p, ep) : NULL); + case ')': { /* end capture */ + s = end_capture(ms, s, p + 1); + break; + } + case '$': { + if ((p + 1) != ms->p_end) /* is the `$' the last char in pattern? */ + goto dflt; /* no; go to default */ + s = (s == ms->src_end) ? s : NULL; /* check end of string */ + break; + } + case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ + switch (*(p + 1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p + 2); + if (s != NULL) { + p += 4; goto init; /* return match(ms, s, p + 4); */ + } /* else fail (s == NULL) */ + break; + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s - 1); + if (!matchbracketclass(uchar(previous), p, ep - 1) && + matchbracketclass(uchar(*s), p, ep - 1)) { + p = ep; goto init; /* return match(ms, s, ep); */ + } + s = NULL; /* match failed */ + break; + } + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p + 1))); + if (s != NULL) { + p += 2; goto init; /* return match(ms, s, p + 2) */ + } + break; + } + default: goto dflt; } - case '-': { /* 0 or more repetitions (minimum) */ - return min_expand(ms, s, p, ep); + break; + } + default: dflt: { /* pattern class plus optional suffix */ + const char *ep = classend(ms, p); /* points to optional suffix */ + /* does not match at least once? */ + if (!singlematch(ms, s, p, ep)) { + if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */ + p = ep + 1; goto init; /* return match(ms, s, ep + 1); */ + } + else /* '+' or no suffix */ + s = NULL; /* fail */ } - default: { - if (!m) return NULL; - s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + else { /* matched once */ + switch (*ep) { /* handle optional suffix */ + case '?': { /* optional */ + const char *res; + if ((res = match(ms, s + 1, ep + 1)) != NULL) + s = res; + else { + p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */ + } + break; + } + case '+': /* 1 or more repetitions */ + s++; /* 1 match already done */ + /* go through */ + case '*': /* 0 or more repetitions */ + s = max_expand(ms, s, p, ep); + break; + case '-': /* 0 or more repetitions (minimum) */ + s = min_expand(ms, s, p, ep); + break; + default: /* no suffix */ + s++; p = ep; goto init; /* return match(ms, s + 1, ep); */ + } } + break; } } } + ms->matchdepth++; + return s; } @@ -561,12 +602,14 @@ static int str_find_aux (lua_State *L, int find) { p++; lp--; /* skip anchor character */ } ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = s; ms.src_end = s + ls; ms.p_end = p + lp; do { const char *res; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); if ((res=match(&ms, s1, p)) != NULL) { if (find) { lua_pushinteger(L, s1 - s + 1); /* start */ @@ -600,6 +643,7 @@ static int gmatch_aux (lua_State *L) { const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp); const char *src; ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = s; ms.src_end = s+ls; ms.p_end = p + lp; @@ -608,6 +652,7 @@ static int gmatch_aux (lua_State *L) { src++) { const char *e; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); if ((e = match(&ms, src, p)) != NULL) { lua_Integer newstart = e-s; if (e == src) newstart++; /* empty match? go at least one position */ @@ -705,12 +750,14 @@ static int str_gsub (lua_State *L) { p++; lp--; /* skip anchor character */ } ms.L = L; + ms.matchdepth = MAXCCALLS; ms.src_init = src; ms.src_end = src+srcl; ms.p_end = p + lp; while (n < max_s) { const char *e; ms.level = 0; + lua_assert(ms.matchdepth == MAXCCALLS); e = match(&ms, src, p); if (e) { n++; @@ -867,7 +914,7 @@ static int str_format (lua_State *L) { nb = sprintf(buff, form, luaL_checkint(L, arg)); break; } - case 'd': case 'i': { + case 'd': case 'i': { lua_Number n = luaL_checknumber(L, arg); LUA_INTFRM_T ni = (LUA_INTFRM_T)n; lua_Number diff = n - (lua_Number)ni; @@ -877,7 +924,7 @@ static int str_format (lua_State *L) { nb = sprintf(buff, form, ni); break; } - case 'o': case 'u': case 'x': case 'X': { + case 'o': case 'u': case 'x': case 'X': { lua_Number n = luaL_checknumber(L, arg); unsigned LUA_INTFRM_T ni = (unsigned LUA_INTFRM_T)n; lua_Number diff = n - (lua_Number)ni; @@ -887,7 +934,7 @@ static int str_format (lua_State *L) { nb = sprintf(buff, form, ni); break; } - case 'e': case 'E': case 'f': + case 'e': case 'E': case 'f': #if defined(LUA_USE_AFORMAT) case 'a': case 'A': #endif diff --git a/src/ltable.c b/src/ltable.c index ffa5ecb3..420391fc 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.71 2012/05/23 15:37:09 roberto Exp $ +** $Id: ltable.c,v 2.72 2012/09/11 19:37:16 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -480,13 +480,13 @@ const TValue *luaH_getstr (Table *t, TString *key) { */ const TValue *luaH_get (Table *t, const TValue *key) { switch (ttype(key)) { - case LUA_TNIL: return luaO_nilobject; case LUA_TSHRSTR: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNIL: return luaO_nilobject; case LUA_TNUMBER: { int k; lua_Number n = nvalue(key); lua_number2int(k, n); - if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + if (luai_numeq(cast_num(k), n)) /* index is int? */ return luaH_getint(t, k); /* use specialized version */ /* else go through */ } diff --git a/src/ltablib.c b/src/ltablib.c index a52add03..ad798b4e 100644 --- a/src/ltablib.c +++ b/src/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.63 2011/11/28 17:26:30 roberto Exp $ +** $Id: ltablib.c,v 1.65 2013/03/07 18:17:24 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -16,8 +16,8 @@ #include "lualib.h" -#define aux_getn(L,n) \ - (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n)) +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n)) + #if defined(LUA_COMPAT_MAXN) @@ -49,7 +49,7 @@ static int tinsert (lua_State *L) { case 3: { int i; pos = luaL_checkint(L, 2); /* 2nd argument is the position */ - if (pos > e) e = pos; /* `grow' array if necessary */ + luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); for (i = e; i > pos; i--) { /* move up elements */ lua_rawgeti(L, 1, i-1); lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ @@ -66,17 +66,17 @@ static int tinsert (lua_State *L) { static int tremove (lua_State *L) { - int e = aux_getn(L, 1); - int pos = luaL_optint(L, 2, e); - if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ - return 0; /* nothing to remove */ + int size = aux_getn(L, 1); + int pos = luaL_optint(L, 2, size); + if (pos != size) /* validate 'pos' if given */ + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); lua_rawgeti(L, 1, pos); /* result = t[pos] */ - for ( ;pos 0 && b[l-1] == '\n') /* line ends with newline? */ diff --git a/src/lua.h b/src/lua.h index a3a3a70c..eb0482b8 100644 --- a/src/lua.h +++ b/src/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.283 2012/04/20 13:18:26 roberto Exp $ +** $Id: lua.h,v 1.285 2013/03/15 13:04:22 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -19,11 +19,11 @@ #define LUA_VERSION_MAJOR "5" #define LUA_VERSION_MINOR "2" #define LUA_VERSION_NUM 502 -#define LUA_VERSION_RELEASE "1" +#define LUA_VERSION_RELEASE "2" #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2012 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2013 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -119,6 +119,11 @@ typedef LUA_UNSIGNED lua_Unsigned; #endif +/* +** RCS ident string +*/ +extern const char lua_ident[]; + /* ** state manipulation @@ -413,7 +418,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2012 Lua.org, PUC-Rio. +* Copyright (C) 1994-2013 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/lua.rc b/src/lua.rc index 38b72d45..1886009d 100644 --- a/src/lua.rc +++ b/src/lua.rc @@ -1,8 +1,8 @@ 0 ICON "../etc/lua_lang.ico" 1 VERSIONINFO - FILEVERSION 5,2,0,0 - PRODUCTVERSION 5,2,0,0 + FILEVERSION 5,2,2,0 + PRODUCTVERSION 5,2,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -11,11 +11,11 @@ BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" VALUE "FileDescription", "Lua Standalone Interpreter\0" - VALUE "FileVersion", "5.2.0\0" - VALUE "LegalCopyright", "Copyright © 1994-2012 Lua.org, PUC-Rio.\0" + VALUE "FileVersion", "5.2.2\0" + VALUE "LegalCopyright", "Copyright © 1994-2013 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "lua.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.0\0" + VALUE "ProductVersion", "5.2.2\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END diff --git a/src/luac.rc b/src/luac.rc index ce2346ab..2fcd5c11 100644 --- a/src/luac.rc +++ b/src/luac.rc @@ -1,8 +1,8 @@ 0 ICON "../etc/lua.ico" 1 VERSIONINFO - FILEVERSION 5,2,0,0 - PRODUCTVERSION 5,2,0,0 + FILEVERSION 5,2,2,0 + PRODUCTVERSION 5,2,2,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -11,11 +11,11 @@ BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" VALUE "FileDescription", "Lua Compiler\0" - VALUE "FileVersion", "5.2.0\0" - VALUE "LegalCopyright", "Copyright © 1994-2012 Lua.org, PUC-Rio.\0" + VALUE "FileVersion", "5.2.2\0" + VALUE "LegalCopyright", "Copyright © 1994-2013 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "luac.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.0\0" + VALUE "ProductVersion", "5.2.2\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END diff --git a/src/luaconf.h.in b/src/luaconf.h.in index 5f5c76cb..659dfccd 100644 --- a/src/luaconf.h.in +++ b/src/luaconf.h.in @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.172 2012/05/11 14:14:42 roberto Exp $ +** $Id: luaconf.h,v 1.176 2013/03/16 21:10:18 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -351,10 +351,16 @@ #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +/* +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations +*/ +#define l_mathop(x) (x) + + /* @@ lua_str2number converts a decimal numeric string to a number. @@ lua_strx2number converts an hexadecimal numeric string to a number. -** In C99, 'strtod' do both conversions. C89, however, has no function +** In C99, 'strtod' does both conversions. C89, however, has no function ** to convert floating hexadecimal strings to numbers. For these ** systems, you can leave 'lua_strx2number' undefined and Lua will ** provide its own implementation. @@ -373,8 +379,8 @@ /* the following operations need the math library */ #if defined(lobject_c) || defined(lvm_c) #include -#define luai_nummod(L,a,b) ((a) - floor((a)/(b))*(b)) -#define luai_numpow(L,a,b) (pow(a,b)) +#define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b)) +#define luai_numpow(L,a,b) (l_mathop(pow)(a,b)) #endif /* these are quite standard operations */ @@ -411,13 +417,12 @@ ** Some tricks with doubles */ -#if defined(LUA_CORE) && \ - defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ /* ** The next definitions activate some tricks to speed up the ** conversion from doubles to integer types, mainly to LUA_UNSIGNED. ** -@@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a +@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a ** DirectX idiosyncrasy. ** @@ LUA_IEEE754TRICK uses a trick that should work on any machine @@ -441,7 +446,7 @@ /* Microsoft compiler on a Pentium (32 bit) ? */ #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ -#define MS_ASMTRICK +#define LUA_MSASMTRICK #define LUA_IEEEENDIAN 0 #define LUA_NANTRICK diff --git a/src/luaconf.h.orig b/src/luaconf.h.orig new file mode 100644 index 00000000..df802c95 --- /dev/null +++ b/src/luaconf.h.orig @@ -0,0 +1,551 @@ +/* +** $Id: luaconf.h,v 1.176 2013/03/16 21:10:18 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_WIN /* enable goodies for regular Windows platforms */ +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#endif + + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionality listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#define LUA_USE_GMTIME_R +#endif + + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" + +#else /* }{ */ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_ENV is the name of the variable that holds the current +@@ environment, used to access global names. +** CHANGE it if you do not like this name. +*/ +#define LUA_ENV "_ENV" + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +@* that are not to be exported to outside modules (LUAI_DDEF for +@* definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ + +#else /* }{ */ +#define LUAI_FUNC extern +#define LUAI_DDEC extern +#define LUAI_DDEF /* empty */ +#endif /* } */ + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ luai_writestring/luai_writeline define how 'print' prints its results. +** They are only used in libraries and the stand-alone program. (The #if +** avoids including 'stdio.h' everywhere.) +*/ +#if defined(LUA_LIB) || defined(lua_c) +#include +#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout)) +#endif + +/* +@@ luai_writestringerror defines how to print error messages. +** (A format string with one argument is enough for Lua...) +*/ +#define luai_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) + + +/* +@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, +** strings that are internalized. (Cannot be smaller than reserved words +** or tags for metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#define LUAI_MAXSHORTLEN 40 + + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_ALL controls all compatibility options. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_ALL) /* { */ + +/* +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. +*/ +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_pcall(L,1,0,0)) + + +/* +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. +*/ +#define LUA_COMPAT_LOG10 + +/* +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. +*/ +#define LUA_COMPAT_LOADSTRING + +/* +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. +*/ +#define LUA_COMPAT_MAXN + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ + +/* }================================================================== */ + + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 /* { */ +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L /* }{ */ +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else /* }{ */ +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif /* } */ + + +/* +@@ LUA_INT32 is an signed integer with exactly 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. Probably you do not need to change +** this. +*/ +#if LUAI_BITSINT >= 32 /* { */ +#define LUA_INT32 int +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else /* }{ */ +/* 16-bit ints */ +#define LUA_INT32 long +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif /* } */ + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua to consume unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + +/* reserve some space for error handling */ +#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) + + + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ + + +/* +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations +*/ +#define l_mathop(x) (x) + + +/* +@@ lua_str2number converts a decimal numeric string to a number. +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' does both conversions. C89, however, has no function +** to convert floating hexadecimal strings to numbers. For these +** systems, you can leave 'lua_strx2number' undefined and Lua will +** provide its own implementation. +*/ +#define lua_str2number(s,p) strtod((s), (p)) + +#if defined(LUA_USE_STRTODHEX) +#define lua_strx2number(s,p) strtod((s), (p)) +#endif + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ + +/* the following operations need the math library */ +#if defined(lobject_c) || defined(lvm_c) +#include +#define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b)) +#define luai_numpow(L,a,b) (l_mathop(pow)(a,b)) +#endif + +/* these are quite standard operations */ +#if defined(LUA_CORE) +#define luai_numadd(L,a,b) ((a)+(b)) +#define luai_numsub(L,a,b) ((a)-(b)) +#define luai_nummul(L,a,b) ((a)*(b)) +#define luai_numdiv(L,a,b) ((a)/(b)) +#define luai_numunm(L,a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(L,a,b) ((a)<(b)) +#define luai_numle(L,a,b) ((a)<=(b)) +#define luai_numisnan(L,a) (!luai_numeq((a), (a))) +#endif + + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + +/* +@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned. +** It must have at least 32 bits. +*/ +#define LUA_UNSIGNED unsigned LUA_INT32 + + + +/* +** Some tricks with doubles +*/ + +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** The next definitions activate some tricks to speed up the +** conversion from doubles to integer types, mainly to LUA_UNSIGNED. +** +@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a +** DirectX idiosyncrasy. +** +@@ LUA_IEEE754TRICK uses a trick that should work on any machine +** using IEEE754 with a 32-bit integer type. +** +@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be +** defined when LUA_INTEGER is a 32-bit integer. +** +@@ LUA_IEEEENDIAN is the endianness of doubles in your machine +** (0 for little endian, 1 for big endian); if not defined, Lua will +** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). +** +@@ LUA_NANTRICK controls the use of a trick to pack all types into +** a single double value, using NaN values to represent non-number +** values. The trick only works on 32-bit machines (ints and pointers +** are 32-bit values) with numbers represented as IEEE 754-2008 doubles +** with conventional endianess (12345678 or 87654321), in CPUs that do +** not produce signaling NaN values (all NaNs are quiet). +*/ + +/* Microsoft compiler on a Pentium (32 bit) ? */ +#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ + +#define LUA_MSASMTRICK +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + + +/* pentium 32 bits? */ +#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEELL +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + +/* pentium 64 bits? */ +#elif defined(__x86_64) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 0 + +#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 1 + +#else /* }{ */ + +/* assume IEEE754 and a 32-bit integer type */ +#define LUA_IEEE754TRICK + +#endif /* } */ + +#endif /* } */ + +/* }================================================================== */ + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/src/lvm.c b/src/lvm.c index b77eac26..657d5c45 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.152 2012/06/08 15:14:04 roberto Exp $ +** $Id: lvm.c,v 2.155 2013/03/16 21:10:18 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -83,7 +83,7 @@ static void traceexec (lua_State *L) { if (counthook) L->hookcount = 1; /* undo decrement to zero */ ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ - ci->callstatus |= CIST_HOOKYIELD; /* mark that it yieled */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ ci->func = L->top - 1; /* protect stack below results */ luaD_throw(L, LUA_YIELD); } @@ -98,7 +98,6 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, setobj2s(L, L->top++, p2); /* 2nd argument */ if (!hasres) /* no result? 'p3' is third argument */ setobj2s(L, L->top++, p3); /* 3rd argument */ - luaD_checkstack(L, 0); /* metamethod may yield only when called from Lua code */ luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); if (hasres) { /* if has result, move it to its place */ @@ -470,7 +469,7 @@ void luaV_finishOp (lua_State *L) { L->top = ci->top; /* adjust results */ break; } - case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: + case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: break; default: lua_assert(0); } diff --git a/src/lvm.h b/src/lvm.h index ec358224..07e25f9c 100644 --- a/src/lvm.h +++ b/src/lvm.h @@ -1,5 +1,5 @@ /* -** $Id: lvm.h,v 2.17 2011/05/31 18:27:56 roberto Exp $ +** $Id: lvm.h,v 2.18 2013/01/08 14:06:55 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -19,8 +19,7 @@ #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) -#define luaV_rawequalobj(t1,t2) \ - (ttisequal(t1,t2) && luaV_equalobj_(NULL,t1,t2)) +#define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) /* not to called directly */ From eccb1aec0386293903219aa73130bab480d8e181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Sun, 31 Mar 2013 11:08:25 +0200 Subject: [PATCH 29/48] Updated dist.info --- dist.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist.info b/dist.info index c239db34..ced1a727 100644 --- a/dist.info +++ b/dist.info @@ -1,7 +1,7 @@ --- This file is part of LuaDist project name = "lua" -version = "5.2.1" +version = "5.2.2" desc = "Lua is a powerful, fast, light-weight, embeddable scripting language." author = "Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo" From eb0e9be8bd00ffd814da0fba9786df5d844d3e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 1 Apr 2013 14:40:24 +0200 Subject: [PATCH 30/48] Relative path fix for FreeBSD and Solaris --- CMakeLists.txt | 7 +++++-- src/loadlib_rel.c | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f8e72f1..d96b4bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2012 LuaDist. +# Copyright (C) 2007-2013 LuaDist. # Created by Peter DrahoÅ¡, Peter Kapec # Redistribution and use of this file is allowed according to the terms of the MIT license. # For details see the COPYRIGHT file distributed with LuaDist. @@ -82,7 +82,10 @@ endif ( ) if ( LUA_USE_DLOPEN ) # Link to dynamic linker library "dl" - list ( APPEND LIBS dl ) + find_library ( DL_LIBRARY NAMES dl ) + if ( DL_LIBRARY ) + list ( APPEND LIBS ${DL_LIBRARY} ) + endif ( ) endif ( ) if ( LUA_USE_READLINE ) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 81bf220b..b503740e 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -132,7 +132,12 @@ static void setprogdir (lua_State *L); #include #endif -static void setprogdir (lua_State *L) { +#if defined(__FreeBSD__) + #include + #include +#endif + +static char* setprogdir () { char progdir[_PATH_MAX + 1]; char *lb; int nsize = sizeof(progdir)/sizeof(char); @@ -147,7 +152,22 @@ static void setprogdir (lua_State *L) { #elif defined(__linux__) n = readlink("/proc/self/exe", progdir, nsize); if (n > 0) progdir[n] = 0; +#elif defined(__sun) + pid_t pid = getpid(); + char linkname[256] + sprintf(linkname, "/proc/%d/path/a.out", pid); + n = readlink(linkname, progdir, nsize); + if (n > 0) progdir[n] = 0; #elif defined(__FreeBSD__) + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + size_t cb = sizeof(progdir); + sysctl(mib, 4, progdir, &cb, NULL, 0); + n = cb; +#elif defined(__BSD__) n = readlink("/proc/curproc/file", progdir, nsize); if (n > 0) progdir[n] = 0; #elif defined(__APPLE__) @@ -174,9 +194,6 @@ static void setprogdir (lua_State *L) { luaL_error(L, "unable to get process executable path"); else { *lb = '\0'; - // Set progdir global - lua_pushstring(L, progdir); - lua_setglobal(L, "_PROGDIR"); // Replace the relative path placeholder luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, progdir); From ea6bcae8119c8c4a42003baeaadf3c14c00aadd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 1 Apr 2013 14:42:54 +0200 Subject: [PATCH 31/48] Fix declaration --- src/loadlib_rel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index b503740e..878bdb40 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -137,7 +137,7 @@ static void setprogdir (lua_State *L); #include #endif -static char* setprogdir () { +static void setprogdir() { char progdir[_PATH_MAX + 1]; char *lb; int nsize = sizeof(progdir)/sizeof(char); From 8a4ca5178da6a90173fd0858a64e4ae3218473c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 1 Apr 2013 14:44:29 +0200 Subject: [PATCH 32/48] Fix declaration again --- src/loadlib_rel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 878bdb40..25525a90 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -137,7 +137,7 @@ static void setprogdir (lua_State *L); #include #endif -static void setprogdir() { +static void setprogdir(lua_State *L) { char progdir[_PATH_MAX + 1]; char *lb; int nsize = sizeof(progdir)/sizeof(char); From 96243d79e5509534fa9fc002a209270469cf940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Mon, 1 Apr 2013 14:51:35 +0200 Subject: [PATCH 33/48] Tested on solaris --- src/loadlib_rel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 25525a90..3182e682 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -123,7 +123,7 @@ static void setprogdir (lua_State *L); #define _PATH_MAX PATH_MAX #endif -#if defined(__linux__) +#if defined(__linux__) || defined(__sun) #include /* readlink */ #endif @@ -154,7 +154,7 @@ static void setprogdir(lua_State *L) { if (n > 0) progdir[n] = 0; #elif defined(__sun) pid_t pid = getpid(); - char linkname[256] + char linkname[256]; sprintf(linkname, "/proc/%d/path/a.out", pid); n = readlink(linkname, progdir, nsize); if (n > 0) progdir[n] = 0; From fc076a71577b53f7f35c30efd66203a8446a1036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 5 Apr 2013 14:41:40 +0200 Subject: [PATCH 34/48] Fix for FreeBSD path length --- src/loadlib_rel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 3182e682..4c8186d9 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -164,7 +164,7 @@ static void setprogdir(lua_State *L) { mib[1] = KERN_PROC; mib[2] = KERN_PROC_PATHNAME; mib[3] = -1; - size_t cb = sizeof(progdir); + size_t cb = nsize; sysctl(mib, 4, progdir, &cb, NULL, 0); n = cb; #elif defined(__BSD__) From a1d727dbf9bedd795825639c657260e3ee8f25d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 14 Jun 2013 10:42:29 +0200 Subject: [PATCH 35/48] Minor configuration adjustments for seamless Solaris support --- CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d96b4bdc..aa0c893a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,15 +51,18 @@ if ( WIN32 AND NOT CYGWIN ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_CPATH_DEFAULT "${LUA_CPATH_DEFAULT}" ) else ( ) # Posix systems (incl. Cygwin) - option ( LUA_USE_POSIX "Use POSIX functionality." ON ) option ( LUA_USE_DLOPEN "Use dynamic linker to load modules." ON ) option ( LUA_USE_MKSTEMP "Use mkstep." ON ) option ( LUA_USE_ISATTY "Use tty." ON ) option ( LUA_USE_POPEN "Use popen." ON ) option ( LUA_USE_ULONGJMP "Use ulongjmp" ON ) - option ( LUA_USE_STRTODHEX "assume 'strtod' handles hexa formats" ON ) - option ( LUA_USE_AFORMAT "assume 'printf' handles 'aA' specifiers" ON ) - option ( LUA_USE_LONGLONG "assume support for long long" ON ) + option ( LUA_USE_GMTIME_R "Use GTIME_R" ON ) + # Apple and Linux specific + if ( LINUX OR APPLE ) + option ( LUA_USE_STRTODHEX "Assume 'strtod' handles hexa formats" ON ) + option ( LUA_USE_AFORMAT "Assume 'printf' handles 'aA' specifiers" ON ) + option ( LUA_USE_LONGLONG "Assume support for long long" ON ) + endif ( ) endif ( ) ## SETUP From ceb92f3d955faa317ce0703e788dcbdaeef81407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Drahos=CC=8C?= Date: Fri, 14 Jun 2013 16:04:06 +0200 Subject: [PATCH 36/48] Added mission POSIX option --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa0c893a..b025a53e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ if ( WIN32 AND NOT CYGWIN ) string ( REPLACE "/" ${LUA_DIRSEP} LUA_CPATH_DEFAULT "${LUA_CPATH_DEFAULT}" ) else ( ) # Posix systems (incl. Cygwin) + option ( LUA_USE_POSIX "Use POSIX features." ON ) option ( LUA_USE_DLOPEN "Use dynamic linker to load modules." ON ) option ( LUA_USE_MKSTEMP "Use mkstep." ON ) option ( LUA_USE_ISATTY "Use tty." ON ) From 64407b14d95bf9a1f93aa00c3b3df5c1b0b417eb Mon Sep 17 00:00:00 2001 From: dekimsey Date: Wed, 28 Aug 2013 16:39:56 -0400 Subject: [PATCH 37/48] add lua.hpp to install_header It looks as though 5.2 accidentally dropped the included lua.hpp file from install_header. 5.1.5 still has it. This file is required for C++ projects using Lua. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b025a53e..bc9aed87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,7 @@ install_executable ( lua luac ) install_library ( liblua ) install_data ( README.md ) #install_lua_module ( strict etc/strict.lua ) -install_header ( src/lua.h src/lualib.h src/lauxlib.h ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) +install_header ( src/lua.h src/lualib.h src/lauxlib.h src/lua.hpp ${CMAKE_CURRENT_BINARY_DIR}/luaconf.h ) install_doc ( doc/ ) install_foo ( etc/ ) #install_test ( test/ ) From b70b777f37b85a6d4ef72b8e08f2469b4777266d Mon Sep 17 00:00:00 2001 From: greg-a Date: Thu, 28 Nov 2013 21:42:08 +0100 Subject: [PATCH 38/48] fix error and mem leak found by cppcheck --- src/loadlib_rel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index 4c8186d9..b3f537ba 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -141,7 +141,7 @@ static void setprogdir(lua_State *L) { char progdir[_PATH_MAX + 1]; char *lb; int nsize = sizeof(progdir)/sizeof(char); - int n; + int n = 0; #if defined(__CYGWIN__) char win_buff[_PATH_MAX + 1]; GetModuleFileNameA(NULL, win_buff, nsize); @@ -186,6 +186,7 @@ static void setprogdir(lua_State *L) { sprintf(cmd, "lsof -p %d | awk '{if ($5==\"REG\") { print $9 ; exit}}' 2> /dev/null", pid); fd = popen(cmd, "r"); n = fread(progdir, 1, nsize, fd); + pclose(fd); // remove newline if (n > 1) progdir[--n] = '\0'; From 9922a580fbcb405e8ad8285a52abd7843167a1a5 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Fri, 29 Nov 2013 17:04:49 -0500 Subject: [PATCH 39/48] allow for optional static compilation by overriding BUILD_SHARED_LIBS to OFF --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b025a53e..c0a83ece 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ endif ( ) ## BUILD # Create lua library -add_library ( liblua SHARED ${SRC_CORE} ${SRC_LIB} ${LUA_DLL_RC} ${LUA_DEF} ) +add_library ( liblua ${SRC_CORE} ${SRC_LIB} ${LUA_DLL_RC} ${LUA_DEF} ) target_link_libraries ( liblua ${LIBS} ) set_target_properties ( liblua PROPERTIES OUTPUT_NAME lua CLEAN_DIRECT_OUTPUT 1 ) if ( LUA_BUILD_AS_DLL ) From 467d3837ccc57dd301c279d52801ba80cfa94405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Sun, 8 Dec 2013 23:36:17 +0100 Subject: [PATCH 40/48] Update to version 5.2.3 --- Makefile | 2 +- README.md | 2 +- dist.info | 2 +- doc/lua.css | 31 ++++++++++++++++++++++--------- doc/manual.css | 9 +++++---- doc/readme.html | 7 ++++--- src/Makefile | 2 +- src/lapi.c | 2 +- src/lapi.h | 2 +- src/lauxlib.c | 2 +- src/lauxlib.h | 2 +- src/lbaselib.c | 2 +- src/lbitlib.c | 5 +++-- src/lcode.c | 2 +- src/lcode.h | 2 +- src/lcorolib.c | 2 +- src/lctype.c | 2 +- src/lctype.h | 2 +- src/ldblib.c | 2 +- src/ldebug.c | 31 ++++++++++++++++++++++--------- src/ldebug.h | 2 +- src/ldo.c | 18 +++++++++++++----- src/ldo.h | 2 +- src/ldump.c | 2 +- src/lfunc.c | 2 +- src/lfunc.h | 2 +- src/lgc.c | 13 ++++++++++--- src/lgc.h | 2 +- src/linit.c | 2 +- src/liolib.c | 23 ++++++++++++----------- src/llex.c | 5 ++++- src/llex.h | 2 +- src/llimits.h | 2 +- src/lmathlib.c | 2 +- src/lmem.c | 2 +- src/lmem.h | 2 +- src/loadlib.c | 2 +- src/lobject.c | 2 +- src/lobject.h | 2 +- src/lopcodes.c | 2 +- src/lopcodes.h | 2 +- src/loslib.c | 2 +- src/lparser.c | 2 +- src/lparser.h | 2 +- src/lstate.c | 11 ++++++----- src/lstate.h | 2 +- src/lstring.c | 2 +- src/lstring.h | 2 +- src/lstrlib.c | 2 +- src/ltable.c | 2 +- src/ltable.h | 6 +++++- src/ltablib.c | 2 +- src/ltm.c | 2 +- src/ltm.h | 2 +- src/lua.c | 2 +- src/lua.h | 4 ++-- src/lua.rc | 8 ++++---- src/luac.c | 4 ++-- src/luac.rc | 8 ++++---- src/luaconf.h.in | 2 +- src/luaconf.h.orig | 2 +- src/lualib.h | 2 +- src/lundump.c | 2 +- src/lundump.h | 2 +- src/lvm.c | 2 +- src/lvm.h | 2 +- src/lzio.c | 2 +- src/lzio.h | 2 +- 68 files changed, 171 insertions(+), 118 deletions(-) diff --git a/Makefile b/Makefile index bd9515fd..d2c7db4a 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ TO_MAN= lua.1 luac.1 # Lua version and release. V= 5.2 -R= $V.1 +R= $V.3 # Targets start here. all: $(PLAT) diff --git a/README.md b/README.md index 6e2aee6c..49033adb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -This is Lua 5.2.2, released on 21 Mar 2013. +This is Lua 5.2.3, released on 11 Nov 2013. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/dist.info b/dist.info index ced1a727..57416d98 100644 --- a/dist.info +++ b/dist.info @@ -1,7 +1,7 @@ --- This file is part of LuaDist project name = "lua" -version = "5.2.2" +version = "5.2.3" desc = "Lua is a powerful, fast, light-weight, embeddable scripting language." author = "Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo" diff --git a/doc/lua.css b/doc/lua.css index 240e85eb..3d2443ac 100644 --- a/doc/lua.css +++ b/doc/lua.css @@ -1,30 +1,37 @@ +html { + background-color: #F8F8F8 ; +} + body { + border: solid #a0a0a0 1px ; + border-radius: 20px ; + padding: 26px ; + margin: 16px ; color: #000000 ; background-color: #FFFFFF ; font-family: Helvetica, Arial, sans-serif ; text-align: justify ; - margin-right: 30px ; - margin-left: 30px ; } h1, h2, h3, h4 { font-family: Verdana, Geneva, sans-serif ; font-weight: normal ; - font-style: italic ; + font-style: normal ; } h2 { padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 1em ; - padding-right: 1em ; - background-color: #E0E0FF ; + padding-left: 0.8em ; + padding-right: 0.8em ; + background-color: #D0D0FF ; border-radius: 8px ; + border: solid #a0a0a0 1px ; } h3 { padding-left: 0.5em ; - border-left: solid #E0E0FF 1em ; + border-left: solid #D0D0FF 1em ; } table h3 { @@ -45,7 +52,7 @@ a:visited { a:link:hover, a:visited:hover { color: #000080 ; - background-color: #E0E0FF ; + background-color: #D0D0FF ; } a:link:active, a:visited:active { @@ -57,17 +64,23 @@ hr { height: 1px ; color: #a0a0a0 ; background-color: #a0a0a0 ; + display: none ; +} + +table hr { + display: block ; } :target { background-color: #F8F8F8 ; padding: 8px ; border: solid #a0a0a0 2px ; + border-radius: 8px ; } .footer { color: gray ; - font-size: small ; + font-size: x-small ; } input[type=text] { diff --git a/doc/manual.css b/doc/manual.css index 269bd435..ca613cd9 100644 --- a/doc/manual.css +++ b/doc/manual.css @@ -16,11 +16,12 @@ span.apii { } p+h1, ul+h1 { + font-style: normal ; padding-top: 0.4em ; padding-bottom: 0.4em ; - padding-left: 24px ; - margin-left: -24px ; - background-color: #E0E0FF ; + padding-left: 16px ; + margin-left: -16px ; + background-color: #D0D0FF ; border-radius: 8px ; + border: solid #000080 1px ; } - diff --git a/doc/readme.html b/doc/readme.html index 5b9e47ec..8acec874 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -7,6 +7,7 @@ @@ -33,7 +32,7 @@

        index
        -Copyright © 2011–2013 Lua.org, PUC-Rio. +Copyright © 2011–2015 Lua.org, PUC-Rio. Freely available under the terms of the Lua license. @@ -139,10 +138,10 @@

        Index

        Lua functions

        +basic
        _G
        _VERSION
        -

        assert
        collectgarbage
        dofile
        @@ -168,6 +167,7 @@

        Lua functions

        xpcall

        +bit32
        bit32.arshift
        bit32.band
        bit32.bnot
        @@ -182,6 +182,7 @@

        Lua functions

        bit32.rshift

        +coroutine
        coroutine.create
        coroutine.resume
        coroutine.running
        @@ -190,6 +191,7 @@

        Lua functions

        coroutine.yield

        +debug
        debug.debug
        debug.getuservalue
        debug.gethook
        @@ -208,15 +210,7 @@

        Lua functions

        debug.upvaluejoin

        -file:close
        -file:flush
        -file:lines
        -file:read
        -file:seek
        -file:setvbuf
        -file:write
        - -

        +io
        io.close
        io.flush
        io.input
        @@ -231,11 +225,19 @@

        Lua functions

        io.tmpfile
        io.type
        io.write
        +file:close
        +file:flush
        +file:lines
        +file:read
        +file:seek
        +file:setvbuf
        +file:write

         

        +math
        math.abs
        math.acos
        math.asin
        @@ -267,6 +269,7 @@

         

        math.tanh

        +os
        os.clock
        os.date
        os.difftime
        @@ -280,6 +283,7 @@

         

        os.tmpname

        +package
        package.config
        package.cpath
        package.loaded
        @@ -290,6 +294,7 @@

         

        package.searchpath

        +string
        string.byte
        string.char
        string.dump
        @@ -306,6 +311,7 @@

         

        string.upper

        +table
        table.concat
        table.insert
        table.pack
        @@ -313,6 +319,14 @@

         

        table.sort
        table.unpack
        +

        environment
        variables

        +LUA_CPATH
        +LUA_CPATH_5_2
        +LUA_INIT
        +LUA_INIT_5_2
        +LUA_PATH
        +LUA_PATH_5_2
        +

        C API

        @@ -516,6 +530,67 @@

        auxiliary library

        luaL_unref
        luaL_where
        +

        standard library

        +

        +luaopen_base
        +luaopen_bit32
        +luaopen_coroutine
        +luaopen_debug
        +luaopen_io
        +luaopen_math
        +luaopen_os
        +luaopen_package
        +luaopen_string
        +luaopen_table
        + +

        constants

        +LUA_ERRERR
        +LUA_ERRFILE
        +LUA_ERRGCMM
        +LUA_ERRMEM
        +LUA_ERRRUN
        +LUA_ERRSYNTAX
        +LUA_HOOKCALL
        +LUA_HOOKCOUNT
        +LUA_HOOKLINE
        +LUA_HOOKRET
        +LUA_HOOKTAILCALL
        +LUA_MASKCALL
        +LUA_MASKCOUNT
        +LUA_MASKLINE
        +LUA_MASKRET
        +LUA_MINSTACK
        +LUA_MULTRET
        +LUA_NOREF
        +LUA_OK
        +LUA_OPADD
        +LUA_OPDIV
        +LUA_OPEQ
        +LUA_OPLE
        +LUA_OPLT
        +LUA_OPMOD
        +LUA_OPMUL
        +LUA_OPPOW
        +LUA_OPSUB
        +LUA_OPUNM
        +LUA_REFNIL
        +LUA_REGISTRYINDEX
        +LUA_RIDX_GLOBALS
        +LUA_RIDX_MAINTHREAD
        +LUA_TBOOLEAN
        +LUA_TFUNCTION
        +LUA_TLIGHTUSERDATA
        +LUA_TNIL
        +LUA_TNONE
        +LUA_TNUMBER
        +LUA_TSTRING
        +LUA_TTABLE
        +LUA_TTHREAD
        +LUA_TUSERDATA
        +LUA_USE_APICHECK
        +LUA_YIELD
        +LUAL_BUFFERSIZE
        + @@ -523,10 +598,10 @@

        auxiliary library


        Last update: -Tue Mar 12 11:22:18 BRT 2013 +Mon Feb 23 22:24:36 BRT 2015 diff --git a/doc/lua.css b/doc/lua.css index 3d2443ac..5dc9a8b9 100644 --- a/doc/lua.css +++ b/doc/lua.css @@ -11,6 +11,7 @@ body { background-color: #FFFFFF ; font-family: Helvetica, Arial, sans-serif ; text-align: justify ; + line-height: 1.25 ; } h1, h2, h3, h4 { @@ -53,12 +54,17 @@ a:visited { a:link:hover, a:visited:hover { color: #000080 ; background-color: #D0D0FF ; + border-radius: 4px ; } a:link:active, a:visited:active { color: #FF0000 ; } +h1 a img { + vertical-align: text-bottom ; +} + hr { border: 0 ; height: 1px ; @@ -86,11 +92,15 @@ table hr { input[type=text] { border: solid #a0a0a0 2px ; border-radius: 2em ; - -moz-border-radius: 2em ; background-image: url('images/search.png') ; - background-repeat: no-repeat; + background-repeat: no-repeat ; background-position: 4px center ; padding-left: 20px ; height: 2em ; } +pre.session { + background-color: #F8F8F8 ; + padding: 1em ; + border-radius: 8px ; +} diff --git a/doc/manual.html b/doc/manual.html index 85365363..0a95e9e0 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@

        by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes

        -Copyright © 2011–2013 Lua.org, PUC-Rio. +Copyright © 2011–2015 Lua.org, PUC-Rio. Freely available under the terms of the Lua license. @@ -33,7 +33,7 @@

        - + @@ -2088,7 +2088,7 @@

        3.4.6 – The Length Operator

        table is a sequence, that is, the set of its positive numeric keys is equal to {1..n} -for some integer n. +for some non-negative integer n. In that case, n is its length. Note that a table like @@ -4065,7 +4065,7 @@

        4.8 – Functions and Types

        Pushes onto the stack a formatted string and returns a pointer to this string. -It is similar to the ANSI C function sprintf, +It is similar to the ISO C function sprintf, but has some important differences:

          @@ -7906,7 +7906,7 @@

          6.4 – String Manipulation

          Returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). -The format string follows the same rules as the ANSI C function sprintf. +The format string follows the same rules as the ISO C function sprintf. The only differences are that the options/modifiers *, h, L, l, n, and p are not supported @@ -9486,7 +9486,7 @@

          6.9 – Operating System Facilities

          If format is not "*t", then date returns the date as a string, -formatted according to the same rules as the ANSI C function strftime. +formatted according to the same rules as the ISO C function strftime.

          @@ -9521,7 +9521,7 @@

          6.9 – Operating System Facilities

          -This function is equivalent to the ANSI C function system. +This function is equivalent to the ISO C function system. It passes command to be executed by an operating system shell. Its first result is true if the command terminated successfully, @@ -9556,7 +9556,7 @@

          6.9 – Operating System Facilities

          -Calls the ANSI C function exit to terminate the host program. +Calls the ISO C function exit to terminate the host program. If code is true, the returned status is EXIT_SUCCESS; if code is false, @@ -9893,7 +9893,7 @@

          6.10 – The Debug Library

          Sets the given function as a hook. The string mask and the number count describe when the hook will be called. -The string mask may have the following characters, +The string mask may have any combination of the following characters, with the given meaning:
            @@ -9901,8 +9901,9 @@

            6.10 – The Debug Library

          • 'r': the hook is called every time Lua returns from a function;
          • 'l': the hook is called every time Lua enters a new line of code.

          -With a count different from zero, -the hook is called after every count instructions. +Moreover, +with a count different from zero, +the hook is called also after every count instructions.

          @@ -10497,10 +10498,10 @@

          9 – The Complete Syntax of Lua


          Last update: -Thu Mar 21 12:58:59 BRT 2013 +Mon Feb 23 22:24:44 BRT 2015 diff --git a/doc/readme.html b/doc/readme.html index 8acec874..a4ee9919 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -98,8 +98,8 @@

          Installing Lua

          get a binary from LuaBinaries. Try also -Lua for Windows, -an easy-to-use distribution of Lua that includes many useful libraries. +LuaDist, +a multi-platform distribution of Lua that includes batteries.

          Building Lua

          @@ -110,8 +110,8 @@

          Building Lua

          1. Open a terminal window and move to -the top-level directory, which is named lua-5.2.3. -The Makefile there controls both the build process and the installation process. +the top-level directory, which is named lua-5.2.x. +The Makefile there controls both the build process and the installation process.

          2. Do "make" and see if your platform is listed. @@ -136,11 +136,12 @@

            Building Lua

          3. To check that Lua has been built correctly, do "make test" - after building Lua. This will run the interpreter and print its version string. + after building Lua. This will run the interpreter and print its version.

          If you're running Linux and get compilation errors, -make sure you have installed the readline development package. +make sure you have installed the readline development package +(which is probably named libreadline-dev or readline-devel). If you get link errors after that, then try "make linux MYLIBS=-ltermcap". @@ -148,7 +149,7 @@

          Installing Lua

          Once you have built Lua, you may want to install it in an official place in your system. In this case, do "make install". The official - place and the way to install files are defined in the Makefile. You'll + place and the way to install files are defined in the Makefile. You'll probably need the right permissions to install files.

          @@ -158,11 +159,13 @@

          Installing Lua

          To install Lua locally, do "make local". This will create a directory install with subdirectories - bin, include, lib, man, + bin, include, lib, man, share, and install Lua as listed below. To install Lua locally, but in some other directory, do "make install INSTALL_TOP=xxx", where xxx is your chosen directory. + The installation starts in the src and doc directories, + so take care if INSTALL_TOP is not an absolute path.

          @@ -186,8 +189,8 @@

          Installing Lua

          These are the only directories you need for development. If you only want to run Lua programs, - you only need the files in bin and man. - The files in include and lib are needed for + you only need the files in bin and man. + The files in include and lib are needed for embedding Lua in C or C++ programs.

          Customization

          @@ -203,7 +206,7 @@

          Customization

          You don't actually need to edit the Makefiles because you may set the relevant variables in the command line when invoking make. Nevertheless, it's probably best to edit and save the Makefiles to - record the changes you need. + record the changes you've made.

          On the other hand, if you need to customize some Lua features, you'll need @@ -254,6 +257,7 @@

          Building Lua on other systems

          be linked statically into the host program and its symbols exported for dynamic linking; src/Makefile does this for the Lua interpreter. For Windows, we recommend that the Lua library be a DLL. + In all cases, the compiler luac should be linked statically.

          As mentioned above, you may edit src/luaconf.h to customize @@ -375,7 +379,7 @@

          License

          this.
          -Copyright © 1994–2013 Lua.org, PUC-Rio. +Copyright © 1994–2015 Lua.org, PUC-Rio.

          Permission is hereby granted, free of charge, to any person obtaining a copy @@ -403,10 +407,10 @@

          License


          Last update: -Sat Nov 9 22:39:16 BRST 2013 +Mon Feb 23 22:25:08 BRT 2015 diff --git a/src/ldblib.c b/src/ldblib.c index 84fe3c7d..bd8df9da 100644 --- a/src/ldblib.c +++ b/src/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.132.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: ldblib.c,v 1.132.1.2 2015/02/19 17:16:55 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -21,6 +21,11 @@ #define HOOKKEY "_HKEY" +static void checkstack (lua_State *L, lua_State *L1, int n) { + if (L != L1 && !lua_checkstack(L1, n)) + luaL_error(L, "stack overflow"); +} + static int db_getregistry (lua_State *L) { lua_pushvalue(L, LUA_REGISTRYINDEX); @@ -114,6 +119,7 @@ static int db_getinfo (lua_State *L) { int arg; lua_State *L1 = getthread(L, &arg); const char *options = luaL_optstring(L, arg+2, "flnStu"); + checkstack(L, L1, 3); if (lua_isnumber(L, arg+1)) { if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { lua_pushnil(L); /* level out of range */ @@ -173,6 +179,7 @@ static int db_getlocal (lua_State *L) { else { /* stack-level argument */ if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); + checkstack(L, L1, 1); name = lua_getlocal(L1, &ar, nvar); if (name) { lua_xmove(L1, L, 1); /* push local value */ @@ -196,6 +203,7 @@ static int db_setlocal (lua_State *L) { return luaL_argerror(L, arg+1, "level out of range"); luaL_checkany(L, arg+3); lua_settop(L, arg+3); + checkstack(L, L1, 1); lua_xmove(L, L1, 1); lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); return 1; @@ -313,6 +321,7 @@ static int db_sethook (lua_State *L) { lua_pushvalue(L, -1); lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ } + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_pushvalue(L, arg+1); lua_rawset(L, -3); /* set new hook */ @@ -331,6 +340,7 @@ static int db_gethook (lua_State *L) { lua_pushliteral(L, "external hook"); else { gethooktable(L); + checkstack(L, L1, 1); lua_pushthread(L1); lua_xmove(L1, L, 1); lua_rawget(L, -2); /* get hook */ lua_remove(L, -2); /* remove hook table */ diff --git a/src/ldebug.c b/src/ldebug.c index 20d663ef..96118461 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.90.1.3 2013/05/16 16:04:15 roberto Exp $ +** $Id: ldebug.c,v 2.90.1.4 2015/02/19 17:05:13 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -47,6 +47,16 @@ static int currentline (CallInfo *ci) { } +static void swapextra (lua_State *L) { + if (L->status == LUA_YIELD) { + CallInfo *ci = L->ci; /* get function that yielded */ + StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ + ci->func = restorestack(L, ci->extra); + ci->extra = savestack(L, temp); + } +} + + /* ** this function can be called asynchronous (e.g. during a signal) */ @@ -144,6 +154,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { const char *name; lua_lock(L); + swapextra(L); if (ar == NULL) { /* information about non-active function? */ if (!isLfunction(L->top - 1)) /* not a Lua function? */ name = NULL; @@ -158,6 +169,7 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { api_incr_top(L); } } + swapextra(L); lua_unlock(L); return name; } @@ -165,11 +177,14 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { StkId pos = 0; /* to avoid warnings */ - const char *name = findlocal(L, ar->i_ci, n, &pos); + const char *name; lua_lock(L); + swapextra(L); + name = findlocal(L, ar->i_ci, n, &pos); if (name) setobjs2s(L, pos, L->top - 1); L->top--; /* pop value */ + swapextra(L); lua_unlock(L); return name; } @@ -269,6 +284,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { CallInfo *ci; StkId func; lua_lock(L); + swapextra(L); if (*what == '>') { ci = NULL; func = L->top - 1; @@ -287,6 +303,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { setobjs2s(L, L->top, func); api_incr_top(L); } + swapextra(L); if (strchr(what, 'L')) collectvalidlines(L, cl); lua_unlock(L); diff --git a/src/lgc.c b/src/lgc.c index 52460dcd..553fd177 100644 --- a/src/lgc.c +++ b/src/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $ +** $Id: lgc.c,v 2.140.1.3 2014/09/01 16:55:08 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -403,7 +403,7 @@ static int traverseephemeron (global_State *g, Table *h) { reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ } } - if (prop) + if (g->gcstate != GCSatomic || prop) linktable(h, &g->ephemeron); /* have to propagate again */ else if (hasclears) /* does table have white keys? */ linktable(h, &g->allweak); /* may have to clean white keys */ diff --git a/src/llex.c b/src/llex.c index c4b820e8..32cdcf1c 100644 --- a/src/llex.c +++ b/src/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.63.1.2 2013/08/30 15:49:41 roberto Exp $ +** $Id: llex.c,v 2.63.1.3 2015/02/09 17:56:34 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -152,7 +152,7 @@ static void inclinenumber (LexState *ls) { if (currIsNewline(ls) && ls->current != old) next(ls); /* skip `\n\r' or `\r\n' */ if (++ls->linenumber >= MAX_INT) - luaX_syntaxerror(ls, "chunk has too many lines"); + lexerror(ls, "chunk has too many lines", 0); } diff --git a/src/lobject.h b/src/lobject.h index 3a630b94..bc0bb69f 100644 --- a/src/lobject.h +++ b/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.71.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: lobject.h,v 2.71.1.2 2014/05/07 14:14:58 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -561,12 +561,12 @@ typedef struct Table { CommonHeader; lu_byte flags; /* 1<

          = R(A) + 1 */ +OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */ OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ diff --git a/src/ltablib.c b/src/ltablib.c index 6001224e..99764d26 100644 --- a/src/ltablib.c +++ b/src/ltablib.c @@ -1,10 +1,11 @@ /* -** $Id: ltablib.c,v 1.65.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: ltablib.c,v 1.65.1.2 2014/05/07 16:32:55 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ +#include #include #define ltablib_c @@ -134,13 +135,14 @@ static int pack (lua_State *L) { static int unpack (lua_State *L) { - int i, e, n; + int i, e; + unsigned int n; luaL_checktype(L, 1, LUA_TTABLE); i = luaL_optint(L, 2, 1); e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1)); if (i > e) return 0; /* empty range */ - n = e - i + 1; /* number of elements */ - if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + n = (unsigned int)e - (unsigned int)i; /* number of elements minus 1 */ + if (n > (INT_MAX - 10) || !lua_checkstack(L, ++n)) return luaL_error(L, "too many results to unpack"); lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ while (i++ < e) /* push arg[i + 1...e] */ diff --git a/src/lua.h b/src/lua.h index 149a2c37..ff4a1086 100644 --- a/src/lua.h +++ b/src/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.285.1.2 2013/11/11 12:09:16 roberto Exp $ +** $Id: lua.h,v 1.285.1.4 2015/02/21 14:04:50 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -19,11 +19,11 @@ #define LUA_VERSION_MAJOR "5" #define LUA_VERSION_MINOR "2" #define LUA_VERSION_NUM 502 -#define LUA_VERSION_RELEASE "3" +#define LUA_VERSION_RELEASE "4" #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2013 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -418,7 +418,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2013 Lua.org, PUC-Rio. +* Copyright (C) 1994-2015 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/luaconf.h.in b/src/luaconf.h.in index a3f46b35..afc64e22 100644 --- a/src/luaconf.h.in +++ b/src/luaconf.h.in @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.176.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -42,6 +42,7 @@ #cmakedefine LUA_USE_ISATTY #cmakedefine LUA_USE_POPEN #cmakedefine LUA_USE_ULONGJMP +#cmakedefine LUA_USE_GMTIME_R /* @@ -272,7 +273,7 @@ /* -@@ LUA_INT32 is an signed integer with exactly 32 bits. +@@ LUA_INT32 is a signed integer with exactly 32 bits. @@ LUAI_UMEM is an unsigned integer big enough to count the total @* memory used by Lua. @@ LUAI_MEM is a signed integer big enough to count the total memory @@ -296,7 +297,7 @@ /* @@ LUAI_MAXSTACK limits the size of the Lua stack. ** CHANGE it if you need a different limit. This limit is arbitrary; -** its only purpose is to stop Lua to consume unlimited stack +** its only purpose is to stop Lua from consuming unlimited stack ** space (and to reserve some numbers for pseudo-indices). */ #if LUAI_BITSINT >= 32 diff --git a/src/luaconf.h.orig b/src/luaconf.h.orig index 18be9a9e..1b0ff59f 100644 --- a/src/luaconf.h.orig +++ b/src/luaconf.h.orig @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.176.1.1 2013/04/12 18:48:47 roberto Exp $ +** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -326,7 +326,7 @@ /* -@@ LUA_INT32 is an signed integer with exactly 32 bits. +@@ LUA_INT32 is a signed integer with exactly 32 bits. @@ LUAI_UMEM is an unsigned integer big enough to count the total @* memory used by Lua. @@ LUAI_MEM is a signed integer big enough to count the total memory @@ -350,7 +350,7 @@ /* @@ LUAI_MAXSTACK limits the size of the Lua stack. ** CHANGE it if you need a different limit. This limit is arbitrary; -** its only purpose is to stop Lua to consume unlimited stack +** its only purpose is to stop Lua from consuming unlimited stack ** space (and to reserve some numbers for pseudo-indices). */ #if LUAI_BITSINT >= 32 From 034cf56f1240999d7bfec26d2a02dc2af978ef1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Wed, 2 Dec 2015 15:45:41 +0100 Subject: [PATCH 45/48] Updated to lua-5.2.4 --- dist.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist.info b/dist.info index 5614ecad..50f91867 100644 --- a/dist.info +++ b/dist.info @@ -1,7 +1,7 @@ --- This file is part of LuaDist project name = "lua" -version = "5.2.3" +version = "5.2.4" desc = "Lua is a powerful, fast, light-weight, embeddable scripting language." author = "Roberto Ierusalimschy, Waldemar Celes, Luiz Henrique de Figueiredo" From 373ce2b8ee6d4339b9d53b57a14ea9071c15b355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Wed, 2 Dec 2015 16:28:09 +0100 Subject: [PATCH 46/48] Updated rc files --- src/lua.rc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lua.rc b/src/lua.rc index 8e392cc4..935cbd18 100644 --- a/src/lua.rc +++ b/src/lua.rc @@ -1,8 +1,8 @@ 0 ICON "../etc/lua_lang.ico" 1 VERSIONINFO - FILEVERSION 5,2,3,0 - PRODUCTVERSION 5,2,3,0 + FILEVERSION 5,2,4,0 + PRODUCTVERSION 5,2,4,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -11,11 +11,11 @@ BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" VALUE "FileDescription", "Lua Standalone Interpreter\0" - VALUE "FileVersion", "5.2.3\0" - VALUE "LegalCopyright", "Copyright © 1994-2013 Lua.org, PUC-Rio.\0" + VALUE "FileVersion", "5.2.4\0" + VALUE "LegalCopyright", "Copyright © 1994-2015 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "lua.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.3\0" + VALUE "ProductVersion", "5.2.4\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END From 291ece1caa76b779b52886e3ebc93397775e4dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Wed, 2 Dec 2015 16:29:12 +0100 Subject: [PATCH 47/48] Updated rc files --- src/luac.rc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/luac.rc b/src/luac.rc index c21630e1..acc06b5c 100644 --- a/src/luac.rc +++ b/src/luac.rc @@ -1,8 +1,8 @@ 0 ICON "../etc/lua.ico" 1 VERSIONINFO - FILEVERSION 5,2,3,0 - PRODUCTVERSION 5,2,3,0 + FILEVERSION 5,2,4,0 + PRODUCTVERSION 5,2,4,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -11,11 +11,11 @@ BEGIN VALUE "Comments", "www.lua.org\0" VALUE "CompanyName", "Lua.org\0" VALUE "FileDescription", "Lua Compiler\0" - VALUE "FileVersion", "5.2.3\0" - VALUE "LegalCopyright", "Copyright © 1994-2013 Lua.org, PUC-Rio.\0" + VALUE "FileVersion", "5.2.4\0" + VALUE "LegalCopyright", "Copyright © 1994-2015 Lua.org, PUC-Rio.\0" VALUE "OriginalFilename", "luac.exe\0" VALUE "ProductName", "Lua - The Programming Language\0" - VALUE "ProductVersion", "5.2.3\0" + VALUE "ProductVersion", "5.2.4\0" VALUE "PrivateBuild", "Built using LuaDist\0" END END From 98648514bf7c15d12ccb56222a85e06bfcf9317f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Draho=C5=A1?= Date: Wed, 2 Dec 2015 16:30:26 +0100 Subject: [PATCH 48/48] Minor merge of loadlib.c into loadlib_rel.c --- src/loadlib_rel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c index c2e9b950..1031fb35 100644 --- a/src/loadlib_rel.c +++ b/src/loadlib_rel.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.111 2012/05/30 12:33:44 roberto Exp $ +** $Id: loadlib.c,v 1.111.1.1 2013/04/12 18:48:47 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h **