summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-04-12 17:13:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-04-12 17:13:52 -0300
commit84879136970b76e5d1782f3b4664c7c8f9076821 (patch)
treed7cba2b3b7032c9bff3a01208c74b5d83a0209a6
parent672bb67ee6b3f1c705fca4537824e6190c4a8d57 (diff)
downloadlua-84879136970b76e5d1782f3b4664c7c8f9076821.tar.gz
lua-84879136970b76e5d1782f3b4664c7c8f9076821.tar.bz2
lua-84879136970b76e5d1782f3b4664c7c8f9076821.zip
BUG: option '%q' for string.format does not handle '\r' correctly
-rw-r--r--bugs48
-rw-r--r--lstrlib.c6
2 files changed, 52 insertions, 2 deletions
diff --git a/bugs b/bugs
index c2ebe2c1..5f8feb1b 100644
--- a/bugs
+++ b/bugs
@@ -806,7 +806,7 @@ Bug{
806what = [[In 16-bit machines, expressions and/or with numeric constants as the 806what = [[In 16-bit machines, expressions and/or with numeric constants as the
807right operand may result in weird values]], 807right operand may result in weird values]],
808 808
809report = [[Andreas Stenius, 15/03/2006]], 809report = [[Andreas Stenius/Kein-Hong Man, 15/03/2006]],
810 810
811example = [[ 811example = [[
812print(false or 0) -- on 16-bit machines 812print(false or 0) -- on 16-bit machines
@@ -877,3 +877,49 @@ patch = [[
877 877
878} 878}
879 879
880
881Bug{
882what = [[
883In Windows,
884when Lua is used in an application that also uses DirectX,
885it may present an erractic behavior.
886THIS IS NOT A LUA BUG!
887The problem is that DirectX violates an ABI that Lua depends on.]],
888
889patch = [[
890The simplest solution is to use DirectX with
891the D3DCREATE_FPU_PRESERVE flag.
892
893Otherwise, you can change the definition of lua_number2int,
894in luaconf.h, to this one:
895#define lua_number2int(i,d) __asm fld d __asm fistp i
896]],
897
898}
899
900
901Bug{
902what = [[option '%q' in string.format does not handle '\r' correctly.]],
903
904example = [[
905local s = "a string with \r and \n and \r\n and \n\r"
906local c = string.format("return %q", s)
907assert(assert(loadstring(c))() == s)
908]],
909
910patch = [[
911* lstrlib.c:
912@@ -703,6 +703,10 @@
913 luaL_addchar(b, *s);
914 break;
915 }
916+ case '\r': {
917+ luaL_addlstring(b, "\\r", 2);
918+ break;
919+ }
920 case '\0': {
921 luaL_addlstring(b, "\\000", 4);
922 break;
923]],
924
925}
diff --git a/lstrlib.c b/lstrlib.c
index 6020978d..82ae4ed7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.129 2005/12/21 12:59:43 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.130 2005/12/29 15:32:11 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -703,6 +703,10 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
703 luaL_addchar(b, *s); 703 luaL_addchar(b, *s);
704 break; 704 break;
705 } 705 }
706 case '\r': {
707 luaL_addlstring(b, "\\r", 2);
708 break;
709 }
706 case '\0': { 710 case '\0': {
707 luaL_addlstring(b, "\\000", 4); 711 luaL_addlstring(b, "\\000", 4);
708 break; 712 break;