Hello,
this is a bugfix release. simply apply both patches in order to the program and compile with gcc 3.x.
diff -Naur v0.11/atom.cc b/atom.cc
--- v0.11/atom.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/atom.cc 2012-04-20 03:36:09.000000000 -0700
@@ -26,6 +26,8 @@
#include <string.h> // strcat, strlen
#include <stdio.h> // snprintf
+extern FILE* _file;
+
char* atom::ptrtocx( atom* object )
{
switch( object -> id_mask )
@@ -50,13 +52,13 @@
int size;
if( it == 0 ) size = 1;
else size = ( int )log10( it ) + 1;
- _name = new char[ size + 1 + strlen( pname ) ];
+ _name = new char[ size + 1 + strlen( pname ) + 1 ];
snprintf( _name, size + 1, "%d", it );
}
else
{
int size = strlen( object -> cx -> name );
- _name = new char[ size + 1 + strlen( pname ) ];
+ _name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( _name, object -> cx -> name );
}
if( pname[ 0 ] != '\0' ) // root
@@ -81,6 +83,7 @@
char* name,* pname;
//if( object -> parent -> parent -> id_mask == ID_SCRIPT_DIR )
pname = ptrtocx( object -> parent -> parent );
+ //pname = ptrtocx( object -> parent );
int size;
/*
if( object -> cx == NULL )
@@ -96,14 +99,14 @@
int size;
if( it == 0 ) size = 1;
else size = ( int )log10( it ) + 1;
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
snprintf( name, size + 1, "%d", it );
}
*/
if( object -> cx == NULL )
{
int size = strlen( ( ( line* )( object -> parent ) ) -> text );
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( name, ( ( line_s* )( object -> parent ) ) -> text );
char* _c = strchr( name, '.' );
if( _c ) *_c = '\0';
@@ -111,7 +114,7 @@
else
{
int size = strlen( object -> cx -> name );
- name = new char[ size + 1 + strlen( pname ) ];
+ name = new char[ size + 1 + strlen( pname ) + 1 ];
strcpy( name, object -> cx -> name );
}
if( pname[ 0 ] != '\0' ) // root
diff -Naur v0.11/context.cc b/context.cc
--- v0.11/context.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/context.cc 2012-04-20 03:53:34.000000000 -0700
@@ -6,12 +6,63 @@
{
}
-context::context( context* _up, atom* _a , char* _name )
+context::context( context* _up, atom* _a , char* _name ) // please new[] _name
: a( _a ), name( _name ), up( _up )
, first( NULL ), last( NULL ), prev( NULL ), next( NULL )
{
}
+#include <stdlib.h> // strchr
+#include <string.h> // strlen, strcat, bzero, memcpy
+#include <stdio.h> // debug
+#include <unistd.h> // sync()
+
+char* context::rename( char* _name )
+{
+ char* __name = NULL;
+ if( name ) __name = name;
+ name = new char[ strlen( _name ) + 1 ];
+ memcpy( name, _name, strlen( _name ) + 1 );
+ if( __name ) delete[] __name;
+ return name;
+}
+
+char* context::path()
+{
+ char* cx = a -> ptrtocx( a );
+ char* _here = NULL;
+ char* _path = new char[ strlen( cx ) + 1 ];
+ char* _name = new char[ strlen( cx ) + 1 ];
+ strcpy( _name, cx );
+ bzero( _path, strlen( _name ) + 1 );
+ for(;;)
+ {
+ _here = strrchr( _name, '.' );
+ int bah;
+ if( _here == NULL )
+ {
+ strcat( _path, _name );
+ break;
+ }
+ *_here++ = '\0'; // shortening _name
+ bah = strlen( _here ) + 1;
+
+ char* _this = new char[ bah ]; // how to, int strchr - strchr
+
+ memcpy( _this, _here, bah );
+ strcat( _path, _this );
+ strcat( _path, "/" ); // for a total of bah added to _path
+
+ delete[] _this;
+ }
+ delete[] _name;
+
+ return _path;
+}
+ //char* _this = strchr( _here, '.' );
+ //if( _this != NULL )
+ // *_this = '\0';
+
/*
atom* context::findcx( char* );
int context::possess( int );
diff -Naur v0.11/context.h b/context.h
--- v0.11/context.h 2005-07-29 17:04:22.000000000 -0700
+++ b/context.h 2012-04-18 09:12:44.000000000 -0700
@@ -14,6 +14,9 @@
~context();
context( context*, atom*, char* );
+ char* rename( char* );
+ char* path();
+
// atom* findcx( char* );
// int possess( int );
// int colorize( int );
diff -Naur v0.11/main.cc b/main.cc
--- v0.11/main.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/main.cc 2012-04-20 03:50:53.000000000 -0700
@@ -169,6 +169,8 @@
signal( SIGTERM, term );
signal( SIGABRT, term );
+ sync();
+
if( argc < 2 )
{
printf( "usage: %s <id#>\r\n", argv[ 0 ] );
@@ -186,7 +188,7 @@
puck.que = q = new queue( &puck.pad, ms, to, id );
-// puck.pad.clear();
+ puck.pad.clear();
#if 0
puck.pad.debug();
#endif // debug
diff -Naur v0.11/program.cc b/program.cc
--- v0.11/program.cc 2005-07-29 17:04:22.000000000 -0700
+++ b/program.cc 2012-04-20 02:29:48.000000000 -0700
@@ -67,9 +67,17 @@
void term( int signal );
+//#include <stdio.h> // debug
+//#include <unistd.h> // sync()
+
void program::mcast( void* state )
{
// printf( "y" );
// fflush( stdout );
+//FILE* _file = fopen( "/home/mdasoh/atom.log", "a" );
+//fprintf( _file, ":for:\n" );
+//fflush( stdout );
+//fclose( _file );
+//sync();
que -> disperse();
}
diff -Naur v0.11/script.cc b/script.cc
--- v0.11/script.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/script.cc 2012-04-20 03:43:17.000000000 -0700
@@ -85,15 +85,15 @@
line* script::ins( line* here )
{
- line* brand = new line( this ),
+ line* brand = new line( this ), // parent
* there = here -> next;
brand -> last = here;
brand -> next = there;
if( there != NULL ) there -> last = brand;
here -> next = brand;
- // if( bot == here )
- // bot = brand;
+ if( bot == here )
+ bot = brand;
return brand;
}
@@ -141,37 +141,32 @@
}
#endif
-FILE* _file;
+#include "context.h" // debug
int script::load( char* path )
{
-fprintf( _file, "2\n" );
-fflush( _file );
-
close( top );
bot = top = new line( this ); line* current = top;
- if( 0 != chdir( path ) )
-fprintf( _file, "2.0\n" );
-fflush( _file );
+ if( 0 == chdir( path ) ); // solved
+ else if( 0 == chdir( "./" ) );
+ else if( 0 == chdir( "/" ) );
+ else
+{
+printf( "2.0.error\n" ); // reopen output
+fflush( stdout );
+}
struct dirent** dir; int entries;
sync();
-fprintf( _file, "2.1\n" );
-fflush( _file );
-
// entries = scandir( "./", &dir, nodots, alphasort );
// entries = scandir( "./", &dir, 0, alphasort );
entries = scandir( "./", &dir, 0, 0 );
if( entries == -1 )
-fprintf( _file, "2.2.0\n" );
-
-fprintf( _file, "2.2\n" );
-fflush( _file );
sync();
@@ -192,10 +187,7 @@
}
else return 1;
-fprintf( _file, "3\n" );
-fflush( _file );
-
- return entries;
+ return entries;
}
void script::save( char* file )
diff -Naur v0.11/term.cc b/term.cc
--- v0.11/term.cc 2012-04-20 03:17:29.000000000 -0700
+++ b/term.cc 2012-04-20 03:47:21.000000000 -0700
@@ -273,8 +273,7 @@
}
}
-extern FILE* _file;
-
+#include "context.h"
// update each here for cursors within this context
void term::expand( u_int cursor )
{
@@ -297,34 +296,26 @@
} // else
if( _row == 0 ) s -> top = lines;
-// if it has a name, loop through parent contexts
-// if( strlen( lines -> text ) == 0 )
+ if(0) // uncomment if you want to browse paths beginning with root
{
lines -> scr -> id_mask = ID_SCRIPT_DIR;
atom* _a = lines -> parent;
- if( _a == NULL )
+
+ char* cx = new char[ strlen( lines -> text ) + 1 ];
+ strcpy( cx, lines -> text );
+ if( lines -> parent -> parent )
{
+ lines -> scr -> cx = new
+ context( lines -> parent -> parent -> cx, lines -> scr, cx );
}
-_file = fopen( "atom.log", "a" );
-fprintf( _file, "1\n" );
-fflush( _file );
- lines -> scr -> load( "/root/hier" );
-fprintf( _file, "4\n" );
-fflush( _file );
- char* cx; // strange bug, do investigate further
-// if( lines == s -> top || strlen( lines -> last -> text ) != 23 )
-{
- cx = lines -> ptrtocx( lines -> scr );
-}
-// else { cx = new char[ 1 ]; cx[ 0 ] = '\0'; }
- lines -> clear();
-// lines -> ins( 0, "" );
-// cx[ 40 ] = '\0';
- lines -> ins( 0, cx );
- delete[] cx;
-fprintf( _file, "5\n" );
-fflush( _file );
-fclose( _file );
+ else
+ {
+ lines -> scr -> cx = new
+ context( NULL, lines -> scr, cx );
+ }
+ char* cx_path = lines -> scr -> cx -> path();
+ lines -> scr -> load( cx_path );
+ delete[] cx_path;
}
}
if( _row > 0 )
@@ -360,6 +351,7 @@
if( _row - _orig == note::rows ) _orig++;
if( _row > xorig + note::rows || _row + count <= xorig ) return;
+
redraw();
}
diff -Naur v0.11/thread.h b/thread.h
--- v0.11/thread.h 2005-07-29 17:04:22.000000000 -0700
+++ b/thread.h 2012-04-20 03:22:13.000000000 -0700
@@ -35,13 +35,13 @@
// printf( "%%" );
// fflush( stdout );
- thread* top = new thread;
+ register thread* top = new struct thread; // malloc failure centers on this
// printf( "%%" );
// fflush( stdout );
top -> next = next;
- top -> addr = v; // failure centers on this
+ top -> addr = v; // with allegro, malloc failure centers on this
top -> state = state;
( thread* )top_thread = top;