mirror of https://github.com/rusefi/lua.git
new option 'q' in function "format".
This commit is contained in:
parent
281db390e8
commit
2fee7e42c9
17
strlib.c
17
strlib.c
|
@ -3,7 +3,7 @@
|
|||
** String library to LUA
|
||||
*/
|
||||
|
||||
char *rcs_strlib="$Id: strlib.c,v 1.18 1996/02/12 18:32:40 roberto Exp $";
|
||||
char *rcs_strlib="$Id: strlib.c,v 1.18 1996/02/12 18:34:44 roberto Exp roberto $";
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
@ -175,6 +175,17 @@ static void str_ascii (void)
|
|||
lua_pushnumber(s[pos]);
|
||||
}
|
||||
|
||||
void luaI_addquoted (char *s)
|
||||
{
|
||||
luaI_addchar('"');
|
||||
for (; *s; s++)
|
||||
{
|
||||
if (*s == '"' || *s == '\\' || *s == '\n')
|
||||
luaI_addchar('\\');
|
||||
luaI_addchar(*s);
|
||||
}
|
||||
luaI_addchar('"');
|
||||
}
|
||||
|
||||
#define MAX_CONVERTION 2000
|
||||
#define MAX_FORMAT 50
|
||||
|
@ -215,6 +226,10 @@ static void str_format (void)
|
|||
form[i+1] = 0; /* ends string */
|
||||
switch (form[i])
|
||||
{
|
||||
case 'q':
|
||||
luaI_addquoted(lua_check_string(arg++, "format"));
|
||||
buff[0] = '\0'; /* addchar already done */
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
char *s = lua_check_string(arg++, "format");
|
||||
|
|
Loading…
Reference in New Issue