This commit is contained in:
Axel Kittenberger 2018-03-26 18:09:22 +02:00
parent 73daba0960
commit 590a7f7124
2 changed files with 18 additions and 54 deletions

3
.gitignore vendored
View File

@ -19,4 +19,5 @@ install_manifest.txt
# generated C code # generated C code
luacode.c default.c
mantle.c

View File

@ -770,10 +770,7 @@ l_exec( lua_State *L )
s[ i ] = cs[ i ] ? cs[ i ] : '\n'; s[ i ] = cs[ i ] ? cs[ i ] : '\n';
} }
logstring0( logstring0( LOG_DEBUG, "Exec", s );
LOG_DEBUG, "Exec",
s
);
free( s ); free( s );
@ -785,10 +782,7 @@ l_exec( lua_State *L )
// pipes something into stdin // pipes something into stdin
if( !lua_isstring( L, 3 ) ) if( !lua_isstring( L, 3 ) )
{ {
logstring( logstring( "Error", "in spawn(), expected a string after pipe '<'" );
"Error",
"in spawn(), expected a string after pipe '<'"
);
exit( -1 ); exit( -1 );
} }
@ -1053,8 +1047,7 @@ l_stackdump( lua_State * L )
case LUA_TBOOLEAN: case LUA_TBOOLEAN:
printlogf( printlogf( L, "Debug",
L, "Debug",
"%d boolean %s", i, lua_toboolean( L, i ) ? "true" : "false" "%d boolean %s", i, lua_toboolean( L, i ) ? "true" : "false"
); );
@ -1062,19 +1055,13 @@ l_stackdump( lua_State * L )
case LUA_TNUMBER: case LUA_TNUMBER:
printlogf( printlogf( L, "Debug", "%d number: %g", i, lua_tonumber( L, i ) );
L, "Debug",
"%d number: %g", i, lua_tonumber( L, i )
);
break; break;
default: default:
printlogf( printlogf( L, "Debug", "%d %s", i, lua_typename( L, t ) );
L, "Debug",
"%d %s", i, lua_typename( L, t )
);
break; break;
} }
@ -1105,10 +1092,7 @@ l_readdir( lua_State *L )
if( d == NULL ) if( d == NULL )
{ {
printlogf( printlogf( L, "Error", "cannot open dir [%s].", dirname );
L, "Error", "cannot open dir [%s].",
dirname
);
return 0; return 0;
} }
@ -1120,29 +1104,17 @@ l_readdir( lua_State *L )
struct dirent *de = readdir( d ); struct dirent *de = readdir( d );
bool isdir; bool isdir;
if( de == NULL ) // finished // finished?
{ if( de == NULL ) break;
break;
}
// ignores . and .. // ignores . and ..
if( if( !strcmp( de->d_name, "." ) || !strcmp( de->d_name, ".." ) ) continue;
!strcmp( de->d_name, "." )
|| !strcmp( de->d_name, ".." )
)
{
continue;
}
if( de->d_type == DT_UNKNOWN ) if( de->d_type == DT_UNKNOWN )
{ {
// must call stat on some systems :-/ // must call stat on some systems :-/
// ( e.g. ReiserFS ) // ( e.g. ReiserFS )
char *entry = s_malloc( char *entry = s_malloc( strlen( dirname ) + strlen( de->d_name ) + 2 );
strlen( dirname ) +
strlen( de->d_name ) +
2
);
struct stat st; struct stat st;
@ -1267,10 +1239,7 @@ l_configure( lua_State *L )
} }
else else
{ {
printlogf( printlogf( L, "Error", "Logging facility must be a number or string" );
L, "Error",
"Logging facility must be a number or string"
);
exit( -1 ); exit( -1 );
} }
@ -1279,10 +1248,7 @@ l_configure( lua_State *L )
{ {
const char * ident = luaL_checkstring( L, 2 ); const char * ident = luaL_checkstring( L, 2 );
if( settings.log_ident ) if( settings.log_ident ) free( settings.log_ident );
{
free( settings.log_ident );
}
settings.log_ident = s_strdup( ident ); settings.log_ident = s_strdup( ident );
} }
@ -1670,8 +1636,8 @@ masterloop(lua_State *L)
// of reading/writing from observances it jumps directly to // of reading/writing from observances it jumps directly to
// handling // handling
// TODO: Actually it might be smarter to handler observances // TODO: Actually it might be smarter to handle observances
// eitherway. since event queues might overflow. // anyway. since event queues might overflow.
logstring( "Masterloop", "immediately handling delays." ); logstring( "Masterloop", "immediately handling delays." );
} }
else else
@ -1684,7 +1650,7 @@ masterloop(lua_State *L)
if( have_alarm ) if( have_alarm )
{ {
// TODO use trunc instead of long converstions // TODO use trunc instead of long conversions
double d = ( (double )( alarm_time - now ) ) / clocks_per_sec; double d = ( (double )( alarm_time - now ) ) / clocks_per_sec;
tv.tv_sec = d; tv.tv_sec = d;
tv.tv_nsec = ( (d - ( long ) d) ) * 1000000000.0; tv.tv_nsec = ( (d - ( long ) d) ) * 1000000000.0;
@ -1770,10 +1736,7 @@ masterloop(lua_State *L)
} }
// Checks for signals, again, better safe than sorry // Checks for signals, again, better safe than sorry
if ( hup || term ) if ( hup || term ) break;
{
break;
}
// FIXME breaks on multiple nonobservances in one beat // FIXME breaks on multiple nonobservances in one beat
if( if(