@ -473,45 +473,42 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
}
/* number of chars of a literal string without the ending \0 */
# define LL(x) (sizeof(x) / sizeof(char) - 1)
# define RETS "..."
# define PRE "[string \""
# define POS "\"]"
# define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
void luaO_chunkid ( char * out , const char * source , size_t buff len) {
size_t l = strlen ( source ) ;
void luaO_chunkid ( char * out , const char * source , size_t src len) {
size_t bufflen = LUA_IDSIZE ; /* free space in buffer */
if ( * source = = ' = ' ) { /* 'literal' source */
if ( l < = bufflen ) /* small enough? */
memcpy ( out , source + 1 , l * sizeof ( char ) ) ;
if ( src len < = bufflen ) /* small enough? */
memcpy ( out , source + 1 , src len * sizeof ( char ) ) ;
else { /* truncate it */
addstr ( out , source + 1 , bufflen - 1 ) ;
* out = ' \0 ' ;
}
}
else if ( * source = = ' @ ' ) { /* file name */
if ( l < = bufflen ) /* small enough? */
memcpy ( out , source + 1 , l * sizeof ( char ) ) ;
if ( src len < = bufflen ) /* small enough? */
memcpy ( out , source + 1 , src len * sizeof ( char ) ) ;
else { /* add '...' before rest of name */
addstr ( out , RETS , LL ( RETS ) ) ;
bufflen - = LL ( RETS ) ;
memcpy ( out , source + 1 + l - bufflen , bufflen * sizeof ( char ) ) ;
memcpy ( out , source + 1 + src len - bufflen , bufflen * sizeof ( char ) ) ;
}
}
else { /* string; format as [string "source"] */
const char * nl = strchr ( source , ' \n ' ) ; /* find first new line (if any) */
addstr ( out , PRE , LL ( PRE ) ) ; /* add prefix */
bufflen - = LL ( PRE RETS POS ) + 1 ; /* save space for prefix+suffix+'\0' */
if ( l < bufflen & & nl = = NULL ) { /* small one-line source? */
addstr ( out , source , l ) ; /* keep it */
if ( src len < bufflen & & nl = = NULL ) { /* small one-line source? */
addstr ( out , source , src len ) ; /* keep it */
}
else {
if ( nl ! = NULL ) l = nl - source ; /* stop at first newline */
if ( l > bufflen ) l = bufflen ;
addstr ( out , source , l ) ;
if ( nl ! = NULL ) src len = nl - source ; /* stop at first newline */
if ( src len > bufflen ) src len = bufflen ;
addstr ( out , source , src len ) ;
addstr ( out , RETS , LL ( RETS ) ) ;
}
memcpy ( out , POS , ( LL ( POS ) + 1 ) * sizeof ( char ) ) ;