Blob Blame History Raw
--- AGReader/Sources/Text.h.gcc41	2001-12-05 21:42:45.000000000 +0100
+++ AGReader/Sources/Text.h	2006-05-27 10:48:23.000000000 +0200
@@ -21,4 +21,6 @@
 /** Create a AGFile directly from a char stream **/
 AGFile CreateTextFromStream(char *stream, char *title);
 
+void AdjustColors(AGNode node);
+
 #endif
--- AGReader/Sources/Text.c.gcc41	2001-12-05 22:10:33.000000000 +0100
+++ AGReader/Sources/Text.c	2006-05-27 10:53:25.000000000 +0200
@@ -8,6 +8,7 @@
 #include "AGNodes.h"
 #include "AGObj.h"
 #include "Text.h"
+#include "Input.h"
 
 /** Redefines only functions that differs from AG_lib.c **/
 
@@ -15,11 +16,11 @@
 AGFile CreateTextNodes(char *filename)
 {
 	AGFile new;
-	if( new = CreateFile( filename ) )
+	if( (new = CreateFile( filename )) )
 	{
 		AGNode node;
 		/* Only one node is defined for text file */
-		if( (AGNode) new->Content = node = (AGNode) malloc(sizeof(*node)) )
+		if( (new->Content = (AGList)(node = (AGNode) malloc(sizeof(*node)))) )
 		{
 			memset(node, 0, sizeof(*node));
 			node->name  = "MAIN";
@@ -45,7 +46,7 @@
 {
 	AGFile new;
 
-	if( new = CreateTextNodes( NULL ) )
+	if( (new = CreateTextNodes( NULL )) )
 	{
 		AGNode node = (AGNode) new->Content;
 		node->start = new->Buffer = stream;
@@ -102,7 +103,6 @@
 	static AGPara par;
 	static AGWord new;
 	char  *buf, *p;
-	long   nb;
 
 	InitContext(&AGC, JM_NORMAL);
 	/* Alloc a first paragraph */
--- /dev/null	2006-05-27 07:46:48.810857750 +0200
+++ AGReader/Sources/Input.h	2006-05-27 10:48:23.000000000 +0200
@@ -0,0 +1,11 @@
+#ifndef	INPUT_H
+#define	INPUT_H
+
+#include "AGNodes.h"
+
+void Prompt( char *str );
+void SetTopLine( AGNode node );
+void ThrowError(char *msg, char *param);
+void ProcessKeys( void );
+
+#endif
--- AGReader/Sources/AGNodes.h.gcc41	2001-12-05 21:48:46.000000000 +0100
+++ AGReader/Sources/AGNodes.h	2006-05-27 10:48:23.000000000 +0200
@@ -124,8 +124,10 @@
 char   tabstop(short pos);				/* Amount of spaces to add to reach tabstop  */
 
 void   RenderAGNode(AGPara, short nbl, short left, short wid, char mode);
+void   RenderLine(AGPara para, short start, short max, char ins_mode);
 void   ScrollDisplay(struct scrpos *, short pos);
 void   AGFileInfo(AGFile, char *obj, char *objs);
+char  *FindAGLinkInfo(AGLink link, char *format);
 
 /*** Special character may trashed the display ***/
 AGWord DisableSpecialChar(AGPara par,AGWord old, unsigned char);
--- AGReader/Sources/Input.c.gcc41	2001-07-14 15:13:34.000000000 +0200
+++ AGReader/Sources/Input.c	2006-05-27 10:48:23.000000000 +0200
@@ -3,11 +3,13 @@
 **          by T.Pierron, 11/9/2000, free software **
 ****************************************************/
 
+#include <string.h>
 #include "AGReader.h"
 #include "AGNodes.h"
 #include "Navig.h"
 #include "IO_tty.h"
 #include "Help.h"
+#include "Text.h"
 
 static char InfDisp = 0;			/* 1 if information screen is displayed */
 static char TmpBuf[80];				/* Buffer used for various output */
@@ -32,7 +34,7 @@
 
 		printf("[%d;H%4d%%%*s[%d;6H",
 				terminfo.height,(node && node->maxlines > terminfo.height ?
-				(100 * node->line) / (node->maxlines-terminfo.height+1) : 100),
+				(100 * node->line) / ((int)node->maxlines-terminfo.height+1) : 100),
 				terminfo.width-5,str,terminfo.height
 		);
 		if( svg[0] ) memcpy(str + plen, svg, 2);
@@ -81,6 +83,7 @@
 void ThrowError(char *msg, char *param)
 {
 	char *d, *s;
+	int i; /* silence warnings */
 
 	/* Frequently error message encountered */
 	if(msg == ERROR_NO_FREE_STORE) msg = "Not enough memory!";
@@ -95,7 +98,7 @@
 	/* If GUI isn't already set, display on stderr */
 	if( is_rawmode() ) *d='\0',Prompt(TmpBuf);
 	else /* fputs doesn't write any \n */
-		*d++='\n',write(2,TmpBuf,d-TmpBuf);
+		*d++='\n',i=write(2,TmpBuf,d-TmpBuf);
 }
 
 /*** Toggle display between node and information ***/
@@ -106,7 +109,7 @@
 	if( InfDisp ) inf->node = old;
 	else
 		/* The node may not yet exists */
-		if(strinfo = (AGList) FindAGNode(inf->file, STR_INFONAME))
+		if( (strinfo = (AGList) FindAGNode(inf->file, STR_INFONAME)) )
 			old = inf->node, inf->node = strinfo;
 		else return;
 
@@ -266,7 +269,7 @@
 				case '=':
 					/* Display line statistics */
 					sprintf(TmpBuf,"line %d of %d ",AGNODE(&terminfo)->line+1,
-					        AGNODE(&terminfo)->maxlines);
+					        (int)AGNODE(&terminfo)->maxlines);
 					Prompt(TmpBuf);
 					break;
 				case 'b': case 'B':
--- AGReader/Sources/Navig.h.gcc41	2001-10-15 12:47:01.000000000 +0200
+++ AGReader/Sources/Navig.h	2006-05-27 10:48:23.000000000 +0200
@@ -30,6 +30,8 @@
 /** Search for node/file pointed by link and display it **/
 int  Navigate( char *GuideName, AGLink );
 
+void SetActiveLine( AGNode node );
+
 /** Function use to create file / node **/
 typedef AGFile (*pfnCreateNodes)( char *path );
 typedef char   (*pfnCreateWords)( AGNode node );
--- AGReader/Sources/AGReader.h.gcc41	2001-03-21 11:28:39.000000000 +0100
+++ AGReader/Sources/AGReader.h	2006-05-27 10:48:23.000000000 +0200
@@ -60,5 +60,7 @@
 #define	QUIT_OK				0
 #define	QUIT_ERROR			1
 
+void quit(char *msg, int status);
+
 #endif
 
--- AGReader/Sources/main.c.gcc41	2001-12-05 21:03:14.000000000 +0100
+++ AGReader/Sources/main.c	2006-05-27 10:48:23.000000000 +0200
@@ -10,6 +10,7 @@
 #include "AGNodes.h"
 #include "IO_tty.h"
 #include "Navig.h"
+#include "Input.h"
 
 struct scrpos terminfo;			/* Information about visited node & screen */
 
@@ -96,5 +97,7 @@
 	} else
 		/* Errors will be displayed in Navigate() */
 		quit(NULL,QUIT_ERROR);
+	
+	return 0;
 }
 
--- AGReader/Sources/Navigate.c.gcc41	2001-10-16 15:24:18.000000000 +0200
+++ AGReader/Sources/Navigate.c	2006-05-27 10:56:17.000000000 +0200
@@ -12,6 +12,8 @@
 #include "AGObj.h"
 #include "Navig.h"
 #include "Text.h"
+#include "Input.h"
+#include "IO_tty.h"
 
 extern char buffer[ 512 ];
 extern short *tabs;
@@ -25,15 +27,15 @@
 /*** System-specific execute command ***/
 int myExecute( char *fmt, char *arg )
 {
-	char *space, *drive, *dest;
+	char *space, *drive, *dest = NULL;
 	int   pid;
 
 	/* Command comes from AmigaOS, try to convert to Unix */
 	if( strncasecmp(fmt, "Run ", 4) == 0 ) fmt += 4;
 	/* Get command name */
-	if( space = strchr(fmt, ' ') ) *space = 0;
+	if( (space = strchr(fmt, ' ')) ) *space = 0;
 	/* Get device specifier */
-	if( drive = strchr(fmt, ':') ) {
+	if( (drive = strchr(fmt, ':')) ) {
 		*drive = 0;
 		if(NULL != (dest = getenv( fmt )) ||
 		   NULL != (dest = getenv( AGR_PATH_ENV_NAME )))
@@ -229,7 +231,7 @@
 /*** Try to locate a file, depending where program runs ***/
 char *LocateFile( char *guidename, char *filename )
 {
-	char *p, *path, isdev=0;
+	char *p = NULL, *path, isdev=0;
 	int  fd;
 
 	/* Retrieve directory where remains the document */
@@ -289,7 +291,7 @@
 	if( (*path = LocateFile( GuideName, link->file )) != NULL )
 	{
 		extern char AGHeader[];
-		unsigned char *p;
+		char *p;
 
 		/* Read a few bytes from this file */
 		if( (fd = open(*path,O_RDONLY)) == -1 )
@@ -317,9 +319,10 @@
 		/* Check for a few bytes, whether it's ASCII text */
 		for(p=buffer+len-1; (char *)p>=buffer; p--)
 		{
+			unsigned char u = *p;
 			/* Non-ISO-8859-1 characters */
-			if( *p>126 && *p<160 ) break;
-			if( *p<32  && *p!='\r' && *p!='\n' && *p!='\t' && *p!=27) break;
+			if( u>126 && u<160 ) break;
+			if( u<32  && u!='\r' && u!='\n' && u!='\t' && u!=27) break;
 		}
 		if((char *)p<buffer) return TEXT_FILE;
 
@@ -369,7 +372,6 @@
 /*** Go back to the previous visited page ***/
 void HistoryBack( struct scrpos *scr )
 {
-	extern long nballoc, nbfree;
 	/* It should have at least one node */
 	if( stack && stack->prev )
 	{
@@ -417,8 +419,11 @@
 							SetActiveLine(node);
 						/* Set the first displayed line */
 						FindNth(node, link->line, &terminfo);
-						if(node != AGNODE(&terminfo));
-							PushAGNode(terminfo.file, AGNODE(&terminfo) = node, 0);
+						if(node != (AGNode)terminfo.node) {
+							terminfo.node = node;
+							PushAGNode(terminfo.file,
+								terminfo.node, 0);
+						}
 						if( is_rawmode() ) ReRenderAGNode();
 					} else ThrowError("Can't find node `%s'.", link->node);
 					return 1;
--- AGReader/Sources/IO_tty.c.gcc41	2001-12-05 20:59:30.000000000 +0100
+++ AGReader/Sources/IO_tty.c	2006-05-27 10:48:23.000000000 +0200
@@ -4,6 +4,7 @@
 *****           but greatly simplified by T.Pierron          ****
 ****************************************************************/
 
+#include <strings.h>
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
@@ -44,6 +45,7 @@
 {
 	static struct termios save_term;
 	struct termios s;
+	int i; /* silence warnings */
 
 	/* Do not set twice the same mode!! */
 	if (old_st == on) return; old_st = on;
@@ -121,12 +123,12 @@
 		s.c_cc[VTIME] = 0;
 
 		/* let's enter in private mode */
-		write(1,SET_PRIV,sizeof(SET_PRIV)-1);
+		i = write(1,SET_PRIV,sizeof(SET_PRIV)-1);
 	} else {
 		/* Restore saved modes */
 		s = save_term;
 		/* and old display mode */
-		write(1,SET_PUB,sizeof(SET_PUB)-1);
+		i = write(1,SET_PUB,sizeof(SET_PUB)-1);
 	}
 	tcsetattr(2, TCSADRAIN, &s);
 }
@@ -185,7 +187,8 @@
 char getchr(void)
 {
 	char c;
-	read(tty, &c, sizeof(c));
+	if (read(tty, &c, sizeof(c)) != sizeof(c))
+		return 0;
 
 	return c;
 }
--- AGReader/Sources/Makefile.gcc41	2001-07-10 12:41:17.000000000 +0200
+++ AGReader/Sources/Makefile	2006-05-27 10:48:23.000000000 +0200
@@ -21,7 +21,7 @@
 	$(CC) $(OBJECTS) -o $(EXE) $(LIBS) -g
 
 final: $(OBJECTS)
-	$(CC) $(OBJECTS) -o $(EXE) $(LIBS) -s
+	$(CC) $(OBJECTS) -o $(EXE) $(LIBS)
 
 install:
 	cp $(EXE) $(HOME)/bin -f
--- AGReader/Sources/AGObj.c.gcc41	2001-05-10 23:01:03.000000000 +0200
+++ AGReader/Sources/AGObj.c	2006-05-27 10:48:23.000000000 +0200
@@ -5,6 +5,8 @@
 ** Started on 13/2/2001, free software under GNU PL    **
 ********************************************************/
 
+#include <ctype.h>
+#include <string.h>
 #include "AGReader.h"
 #include "AGNodes.h"
 #include "AGObj.h"
@@ -51,7 +53,7 @@
 
 		/* Makes them appear like web-page anchor */
 		new->style = DEF_LINKSTYLE;
-		new->fgpen = LinkColor[ new->link->type ];
+		new->fgpen = LinkColor[ (int)new->link->type ];
 		/* Search content of command/node */
 		if( new->link->type != UNKNOWN_TYPE )
 			FindAGLinkInfo(new->link, p+strlen(LinkTokens[new->link->type-1]));
--- AGReader/Sources/AGObj.h.gcc41	2001-05-10 22:43:29.000000000 +0200
+++ AGReader/Sources/AGObj.h	2006-05-27 10:48:23.000000000 +0200
@@ -69,6 +69,8 @@
 /*** Object containing series of tab stops in spaces ***/
 AGWord NewTabs(AGPara par, AGWord old, char *fmt);
 
+void InsertAGWord(AGPara par, AGWord new, AGWord ins);
+
 /** pfnInit parameter for NewObject ***/
 void WrapOFF(AGObj, ObjPara *);
 void ClearTabs(AGObj, ObjPara *);
--- AGReader/Sources/AG_lib.c.gcc41	2001-12-05 22:00:24.000000000 +0100
+++ AGReader/Sources/AG_lib.c	2006-05-27 10:51:25.000000000 +0200
@@ -7,11 +7,13 @@
 
 #include <sys/stat.h>
 #include <string.h>
+#include <ctype.h>
 #include "AGReader.h"
 #include "AGNodes.h"
 #include "AGObj.h"
 #include "IO_tty.h"
 #include "Version.h"
+#include "Input.h"
 
 /** Global buffer used to render one line of text **/
 char   buffer[512], ts, bgpen;
@@ -350,7 +352,7 @@
 			*buf = '\0';  if(p < buf) new = NewWord(par,new,p,&AGC);
 			p    = ++buf;
 
-		} else if(*buf == '@')     /* Start of an AmigaGuide style modifier */
+		} else if(*buf == '@') {  /* Start of an AmigaGuide style modifier */
 		if( buf[1] == '{' )
 		{
 			char **token; *buf='\0';
@@ -426,9 +428,8 @@
 			** already processed in CreateAGNodes(), so just skip them.  */
 			while(*buf != '\n') buf++;
 			*buf='\0'; p = buf+1;
-		}
+		} }
 	}
-	eof:
 	for(; PREV(par); par = PREV(par));
 	node->AGContent = node->Shown = par;
 	node->column    = node->line  = 0;
@@ -441,7 +442,7 @@
 	if(len > width) len = width;
 	switch( (unsigned char)par->align & ~JMF_PREVIOUS )
 	{
-		case JMF_CENTER: par->spaces = (width - len + indent >> 1); break;
+		case JMF_CENTER: par->spaces = (width - len + indent) >> 1; break;
 		case JMF_RIGHT:  par->spaces = width - len; break;
 		default:         par->spaces = indent + par->alinea;
 	}
@@ -453,7 +454,7 @@
 {
 	AGPara new, next = NEXT(par);
 	AGWord wrd;
-	if( new = NewPara(par, NULL) )
+	if( (new = NewPara(par, NULL)) )
 	{
 		if(next) PREV(next) = new, NEXT(new) = next;
 		/* Paragraph's indenting properties equal previous */
@@ -469,7 +470,7 @@
 		}
 		else /* Split the whole word */
 		{
-			if(wrd = PREV(cut)) NEXT(wrd) = NULL;
+			if( (wrd = PREV(cut)) ) NEXT(wrd) = NULL;
 			new->line = cut; PREV(cut) = NULL;
 		}
 	}
@@ -485,8 +486,8 @@
 	if( wrd->style & FSF_SPLITTED ) wrd = FreeSplit(wrd);
 	else if(isspace( wrd->data[-1] )) wrd->data--;
 	for(ins=((AGPara)PREV(par))->line; NEXT(ins); ins=NEXT(ins));
-	if( NEXT(ins) = wrd ) PREV(wrd) = ins;
-	if( NEXT((AGPara)PREV(par)) = next )
+	if( (NEXT(ins) = wrd) ) PREV(wrd) = ins;
+	if( (NEXT((AGPara)PREV(par)) = next) )
 		PREV(next) = PREV(par);
 	free(par);
 	return ins;
@@ -496,14 +497,14 @@
 char FormatPara( AGNode node, short width )
 {
 	AGPara par; AGWord word; ObjPara op;
-	short  len, lg, spc, indent;
+	short  len, lg, spc = 0, indent;
 
 	ts = node->tabsize; tabs = NULL;
 	node->width = ((op.limit = node->wordwrap) ? width : 0x7fff);
 	op.nidt = indent = 0;
 	for(par=node->AGContent; par; indent=op.nidt, par=NEXT(par))
 	{
-		char *p, *q, nbwrd;
+		char *p = NULL, *q, nbwrd;
 
 		redo:for(len=indent+par->alinea, nbwrd=1, word=par->line; word; word=NEXT(word))
 		{
@@ -536,7 +537,7 @@
 			if( tmp && (tmp->align & JMF_PREVIOUS) && p)
 			{
 				/* This reduce a lot of computing with opaque resizing */
-				if(word = tmp->line)
+				if( (word = tmp->line) )
 					for(t=word->data,spc=0; *t && !isspace(*t); t++, spc++);
 				
 				if(len+spc <= width) {