Minor cleanups.
This commit is contained in:
parent
4feb8d6a9a
commit
5f4fd49867
|
@ -42,7 +42,7 @@ Loggable::open ( const char *filename )
|
||||||
|
|
||||||
if ( ! ( fp = fopen( filename, "a+" ) ) )
|
if ( ! ( fp = fopen( filename, "a+" ) ) )
|
||||||
{
|
{
|
||||||
printf( "Could not open log file for writing!" );
|
WARNING( "Could not open log file for writing!" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ Loggable::open ( const char *filename )
|
||||||
/** sigh. parse a string of ":name value :name value" pairs into an
|
/** sigh. parse a string of ":name value :name value" pairs into an
|
||||||
* array of strings, one per pair */
|
* array of strings, one per pair */
|
||||||
// FIXME: doesn't handle the case of :name ":foo bar", nested quotes
|
// FIXME: doesn't handle the case of :name ":foo bar", nested quotes
|
||||||
// or other things it should. Also, quotes should be removed here, not
|
// or other things it should.
|
||||||
// in client code.
|
|
||||||
static
|
static
|
||||||
char **
|
char **
|
||||||
parse_alist( const char *s )
|
parse_alist( const char *s )
|
||||||
|
@ -84,7 +83,7 @@ parse_alist( const char *s )
|
||||||
int tl = strlen( s );
|
int tl = strlen( s );
|
||||||
char **r = (char**)malloc( sizeof( char* ) * tl );
|
char **r = (char**)malloc( sizeof( char* ) * tl );
|
||||||
|
|
||||||
const char *e = s + tl;
|
// const char *e = s + tl;
|
||||||
|
|
||||||
const char *c = NULL;
|
const char *c = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -124,7 +123,7 @@ parse_alist( const char *s )
|
||||||
{
|
{
|
||||||
// v++;
|
// v++;
|
||||||
if ( v[ strlen( v ) - 1 ] != '"' )
|
if ( v[ strlen( v ) - 1 ] != '"' )
|
||||||
printf( "error: invalid quoting in log entry!\n" );
|
WARNING( "invalid quoting in log entry!" );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v[ strlen( v ) - 1 ] = '\0';
|
v[ strlen( v ) - 1 ] = '\0';
|
||||||
|
@ -288,7 +287,7 @@ Loggable::undo ( void )
|
||||||
|
|
||||||
if ( ! strlen( s ) )
|
if ( ! strlen( s ) )
|
||||||
{
|
{
|
||||||
printf( "corrupt undo file or no undo entries.\n" );
|
WARNING( "corrupt undo file or no undo entries." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,10 +296,7 @@ Loggable::undo ( void )
|
||||||
s += strlen( s ) - 1;
|
s += strlen( s ) - 1;
|
||||||
|
|
||||||
if ( strtok( b, "\n" ) == NULL )
|
if ( strtok( b, "\n" ) == NULL )
|
||||||
{
|
FATAL( "empty undo transaction!\n" );
|
||||||
printf( "error, empty undo transaction!\n" );
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
int n = 1;
|
int n = 1;
|
||||||
while ( strtok( NULL, "\n" ) )
|
while ( strtok( NULL, "\n" ) )
|
||||||
|
@ -332,7 +328,7 @@ Loggable::undo ( void )
|
||||||
if ( *s == '\t' )
|
if ( *s == '\t' )
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
printf( "undoing \"%s\"\n", s );
|
DMESSAGE( "undoing \"%s\"\n", s );
|
||||||
|
|
||||||
do_this( s, true );
|
do_this( s, true );
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ using namespace std;
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
class Log_Entry;
|
class Log_Entry;
|
||||||
class Loggable;
|
class Loggable;
|
||||||
typedef Loggable *(create_func)(Log_Entry &);
|
typedef Loggable *(create_func)(Log_Entry &);
|
||||||
|
@ -155,7 +157,9 @@ public:
|
||||||
/* make sure it'll fit */
|
/* make sure it'll fit */
|
||||||
_loggables.reserve( _id );
|
_loggables.reserve( _id );
|
||||||
|
|
||||||
assert( ! _loggables[ _id - 1 ] );
|
// assert( ! _loggables[ _id - 1 ] );
|
||||||
|
|
||||||
|
ASSERT( ! _loggables[ _id - 1 ], "Attempt to create object with an ID (0x%X) that already exists. The existing object is of type \"%s\", the new one is \"%s\". Corrupt journal?", _id, _loggables[ _id -1 ]->class_name(), class_name() );
|
||||||
|
|
||||||
_loggables[ _id - 1 ] = this;
|
_loggables[ _id - 1 ] = this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue