page%swap@Sun.COM (Bob Page) (10/26/89)
Submitted-by: jap@syssun.cl.msu.edu (Joe A. Porkka)
Posting-number: Volume 89, Issue 187
Archive-name: applications/hyphelp.1
[Source code only. Help files in comp.binaries.amiga. ..bob]
# This is a shell archive.
# Remove anything above and including the cut line.
# Then run the rest of the file through 'sh'.
# Unpacked files will be owned by you and have default permissions.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: SHell ARchive
# Run the following text through 'sh' to create:
# cco
# debug.c
# displayline.c
# fileinit.c
# findwordinline.c
# format.c
# This is archive 1 of a 3-part kit.
# This archive created: Wed Oct 25 10:02:51 1989
echo "extracting cco"
sed 's/^X//' << \SHAR_EOF > cco
X.KEY file/a
Xfailat 1
Xlc1 -. -b -cscdmtuw -oram: <file>
Xlc2 -. -o<file>.o -r -v -sc=HelpCode ram:<file>
X
SHAR_EOF
echo "extracting debug.c"
sed 's/^X//' << \SHAR_EOF > debug.c
X/* HyperHelp -- Copyright 1989 Joe Porkka */
X
X/* debug.c -- Memory tracking routines + misc. other debug things */
X
X#include <exec/types.h>
X#include <exec/lists.h>
X
X#define TRACKFILE "t:trackmem"
X
Xextern long stdin, stdout;
Xextern long debug;
Xstatic char membuf[500]; /* for building strings with sprintf() */
Xstatic long mfile=0;
X
Xstatic struct List memlist;
X
Xstruct node {
X struct node *ln_Succ;
X struct node *ln_Pred;
X};
Xstruct memnode {
X struct node n;
X char *name;
X unsigned long size;
X};
X
Xvoid
Xpause(s)
X unsigned char *s;
X{
X static char *pausebuf[256];
X
X if(stdout==0) {
X return;
X }
X if(!debug) return;
X#ifdef DEBUG1
X if(s) dmsg(1,"`%s' ",s);
X#endif
X if(stdin && IsInteractive(stdin)) {
X#ifdef DEBUG1
X dmsg(1,"PRESS ENTER to continue ");
X#endif
X Read(stdin,pausebuf,10);
X } else {
X#ifdef DEBUG1
X dmsg(1,"PAUSE");
X#endif
X Delay(50);
X#ifdef DEBUG1
X dmsg(1,".\n");
X#endif
X }
X}
X
Xvoid
Xmeminit()
X{
X mfile=0;
X if(!debug) {
X return;
X }
X mfile=Open(TRACKFILE,1006);
X /* mfile=Open("*",1006); */
X if(mfile==0) {
X#ifdef DEBUG1
X if(stdout) dmsg(1,"fail to open memfile\n");
X#endif
X return;
X }
X
X memlist.lh_Head = (struct Node *)&memlist.lh_Tail;
X memlist.lh_TailPred = (struct Node *)&memlist.lh_Head;
X memlist.lh_Tail=0;
X memlist.lh_Type=0;
X}
X
Xvoid
Xmembye() {
X struct memnode *node;
X char *ptr;
X int count=0, amount=0;
X if(mfile==0) return;
X
X while (!(memlist.lh_TailPred == (struct Node *)&memlist)) {
X node=(struct memnode *)memlist.lh_Head;
X if(node->name) ptr=node->name; else ptr="<nil>";
X sprintf(membuf,"UNfreed mem at %6lx size=%4lx name=%s\n",((unsigned char *)node)+sizeof(struct memnode),node->size,ptr);
X Write(mfile,membuf,strlen(membuf));
X RemHead(&memlist);
X count++;
X amount+=node->size;
X FreeMem(node,node->size+sizeof(struct memnode));
X }
X Close(mfile);
X#ifdef DEBUG1
X dmsg(1,"There were %ld bytes not freed in %ld blocks.\nTake a look in file'%s'.\n",amount,count,TRACKFILE);
X#endif
X pause(0);
X mfile=0;
X}
X
X
Xunsigned char *
Xallocmem(size,type,name)
X unsigned long size,type;
X char *name;
X{
X unsigned char *t, *AllocMem();
X struct memnode *node;
X char *ptr=0;
X
X if(mfile==0) {
X return AllocMem(size,type & ~ 0x10000000);
X }
X sprintf(membuf,"AllocMem(%6lx,%4lx",size,type);
X /* Write(mfile,membuf,strlen(membuf)); */
X if(type & 0x10000000) {
X type &= ~0x10000000;
X sprintf(membuf,",'%s'",name);
X /* Write(mfile,membuf,strlen(membuf)); */
X ptr=name;
X }
X t=AllocMem(size+sizeof(struct memnode),type);
X sprintf(membuf,")==%6lx.\n",t+sizeof(struct memnode));
X /* Write(mfile,membuf,strlen(membuf)); */
X
X node=(struct memnode *)t;
X node->size=size;
X node->name=ptr;
X AddHead(&memlist,node);
X
X return t+sizeof(struct memnode);
X}
X
Xvoid
Xfreemem(ptr,size)
X unsigned char *ptr;
X unsigned long size;
X{
X struct memnode *node;
X
X if(mfile==0) {
X FreeMem(ptr,size);
X return;
X }
X sprintf(membuf,"FreeMem(%6lx,%4lx) ... ",ptr,size);
X /* Write(mfile,membuf,strlen(membuf)); */
X
X ptr -= sizeof(struct memnode);
X for(node=(struct memnode *)memlist.lh_Head; node->n.ln_Succ; node=(struct memnode *)node->n.ln_Succ) {
X if(node->size==size && node==(struct memnode *)ptr) {
X /* Write(mfile,"OK!\n",4); */
X Remove(node);
X FreeMem(ptr,size+sizeof(struct memnode));
X return;
X }
X }
X Write(mfile,membuf,strlen(membuf));
X Write(mfile,"FAILED!\n",8);
X
X return;
X}
X
SHAR_EOF
echo "extracting displayline.c"
sed 's/^X//' << \SHAR_EOF > displayline.c
X/* HyperHelp -- Copyright 1989 Joe Porkka */
X
X/* displayline.c -- Displays one line of text into a window */
X
X#include <exec/types.h>
X#include <graphics/text.h>
X#include <graphics/rastport.h>
X#include <intuition/intuition.h>
X#include "help.h"
X#include "helptext.h"
X#include "style.h"
X
Xextern PenColor;
Xextern int debug;
X
X#define PRINTTEXT if(pos-begin > 0) {\
X if(!buf) {\
X SetSoftStyle(rp,style,0x0f);\
X if( color!=-1 ) {\
X SetAPen(rp,color);\
X } else {\
X SetAPen(rp,PenColor);\
X }\
X Text(rp,begin,pos-begin);\
X }else{\
X copyintobuf(style,&buf,&buflen,begin,pos-begin);\
X }\
X begin=pos;\
X }\
X
X/* These help to optimize print output */
Xstatic u_char pstyle, pstyle_italic, pstyle_bold, pstyle_underline, pstyle_color;
X
Xvoid
Xindentbuf(buf,buflen,indent)
X u_char **buf;
X int *buflen,indent;
X{
X u_char *bp;
X int i,blen;
X
X bp=*buf;
X blen = *buflen;
X
X if(blen<indent) indent=blen;
X blen -= indent;
X for(i=0;i<indent;i++) *bp++ == ' ';
X
X *bp=0;
X *buf=bp;
X *buflen=blen;
X}
X
Xvoid
Xcopyintobuf(style,buf,buflen,pos,len)
X u_char style, **buf, *pos;
X int *buflen,len;
X{
X u_char *bp;
X int i,blen;
X
X bp=*buf;
X blen = *buflen;
X
X style &= 7;
X if(pstyle != style) { /* style change && enuff space to do it? */
X /* *bp++ = '\033'; *bp++ = '['; */
X if( (pstyle&1) != pstyle_underline && blen>4 ) {
X *bp++ = '\033'; *bp++ = '[';
X pstyle_underline=(pstyle & 1);
X if(pstyle_underline) {
X *bp++ = '4'; *bp++ = 'm';
X blen-=4;
X } else {
X *bp++ = '2'; *bp++ = '4'; *bp++ = 'm';
X blen-=5;
X }
X }
X if( (pstyle&2) != pstyle_bold && blen>4) {
X *bp++ = '\033'; *bp++ = '[';
X pstyle_bold=(pstyle & 2);
X if(pstyle_bold) {
X *bp++ = '1'; *bp++ = 'm';
X blen-=4;
X } else {
X *bp++ = '2'; *bp++ = '2'; *bp++ = 'm';
X blen-=5;
X }
X }
X if( (pstyle&4) != pstyle_italic && blen>4) {
X *bp++ = '\033'; *bp++ = '[';
X pstyle_italic=(pstyle & 4);
X if(pstyle_italic) {
X *bp++ = '3'; *bp++ = 'm';
X blen-=4;
X } else {
X *bp++ = '2'; *bp++ = '3'; *bp++ = 'm';
X blen-=5;
X }
X }
X }
X if(blen>0) {
X if(blen<len) len=blen;
X blen -= len;
X for(i=0;i<len;i++) {
X if (*pos==0) /* This should probly print a diagnostic */
X *pos=128; /* but I have not seen this ever output */
X *bp++ = *pos++;
X }
X }
X *bp=0;
X *buf=bp;
X *buflen=blen;
X}
X
Xvoid
Xdisplayline(rp,p,num,ow,buf,buflen)
X struct RastPort *rp;
X struct paragraph *p;
X u_short num;
X struct openwindows *ow;
X u_char *buf; /* these two are for printfiles */
X int buflen;
X{
X register u_char *pos, *end, *begin, style, color;
X int len, W, bl=ow->window->BorderLeft;
X /*NOTE: `spacing' below is just a flag, not a valid pointer to spacing info */
X int spacing;
X
X if(rp) {
X spacing=rp->TxFlags & FPF_PROPORTIONAL;
X W=rp->TxWidth;
X } else {
X spacing=0;
X W=1;
X }
X begin = pos = p->data+p->lines[num].offset;
X style=p->lines[num].style ;
X color=p->lines[num].color ;
X len=0;
X pstyle= pstyle_italic= pstyle_bold= pstyle_underline= pstyle_color=0;
X if(buf) buf[0]=0;
X if(num==0 && p->pindent>0) {
X if(rp) rp->cp_x+=p->pindent*W;
X len +=p->pindent;
X if(buf) indentbuf(&buf,&buflen,p->pindent);
X } else if(num>0 && p->indent>0) {
X if(rp) rp->cp_x+= p->indent*W;
X len +=p->indent;
X if(buf) indentbuf(&buf,&buflen,p->indent);
X }
X for(end=pos+p->lines[num].length;pos<end;pos++) {
X if( *pos=='\t') {
X PRINTTEXT;
X if(spacing) {
X if(*pos=='\t') {
X if(rp) rp->cp_x += (8 - ((rp->cp_x-bl) / W &7)) * W;
X begin++;
X pos++;
X }
X } else {
X if(*pos=='\t') {
X if(rp) rp->cp_x += (8-(len & 7))*W;
X len+= 8-(len & 7);
X begin++;
X pos++;
X }
X }
X } else if(*pos==0) {
X if(*(pos+1)==0 || end-pos<2) {
X pos--;
X break;
X }
X PRINTTEXT;
X switch(*(pos+2)) {
X case STYLE_REF:
X style |= 0x81;
X break;
X case STYLE_EXEC:
X style |= 0xC1;
X break;
X case STYLE_UNREF:
X style &= ~0xC1;
X break;
X case STYLE_NORMAL:
X style=0;
X color=PenColor;
X break;
X case STYLE_UNDERLINE:
X style ^= 1;
X break;
X case STYLE_BOLD:
X style ^= 2;
X break;
X case STYLE_ITALIC:
X style ^= 4;
X break;
X case STYLE_COLOR:
X if(pos[8]>='0' && pos[8]<='7') {
X color = (pos[8]-'0');
X } else color = PenColor;
X break;
X case STYLE_FONT:
X case STYLE_WINDOW:
X case STYLE_TITLE:
X break;
X case STYLE_LSPACE:
X case STYLE_INDENT:
X case STYLE_PINDENT:
X case STYLE_LABEL:
X break;
X default:
X#ifdef DEBUG9
X dmsg(9,"Unknown style=%lx\n",(long)(*(pos+2)));
X#endif
X }
X
X pos+=*(pos+1)-1;
X begin=pos+1;
X } else len++;
X }
X PRINTTEXT;
X}
X
X
X
SHAR_EOF
echo "extracting fileinit.c"
sed 's/^X//' << \SHAR_EOF > fileinit.c
X/* HyperHelp -- Copyright 1989 Joe Porkka */
X
X/* fileinit.c -- Initialize fileIO, and our task */
X
X
X#include <exec/types.h>
X#include <exec/tasks.h>
X
Xextern int debug;
Xstruct Task *mytask, *FindTask();
Xlong stdout, stdin, oserr, outwindow;
Xint
Xfileinit() {
X outwindow=0;
X stdout=0;
X if(debug) outwindow=stdout=Open("CON:300/100/339/99/HyperHelp DEBUG output window.",1005);
X if(stdout==0) stdout=Output();
X stdin=Input();
X mytask=(struct Task *)FindTask(0);
X mytask->tc_SigRecvd=0;
X oserr=0;
X return(-1);
X}
X
X
SHAR_EOF
echo "extracting findwordinline.c"
sed 's/^X//' << \SHAR_EOF > findwordinline.c
X /* HyperHelp -- Copyright 1989 Joe Porkka */
X
X/* findword.c -- Given a mouse-click, computes location in the file */
X
X#include <exec/types.h>
X#include <graphics/text.h>
X#include <intuition/intuition.h>
X#include "help.h"
X#include "helptext.h"
X#include "style.h"
X
Xextern int debug;
Xextern char *IndexFile;
X
Xvoid
Xfindword(ow,x,y,key)
X struct openwindows *ow;
X int x,y;
X struct key *key;
X{
X u_short wordx, wordy, lnum;
X u_short pnum;
X struct paragraph *p;
X struct RastPort *rp=ow->window->RPort;
X
X key->type=0;
X key->name=0;
X key->length=0;
X x-=ow->window->BorderLeft;
X y-=ow->window->BorderTop;
X
X if(ow->doc->propwidth)
X wordx=x;
X else
X wordx= x/rp->TxWidth;
X
X wordy= y/rp->TxHeight;
X
X if(x<0 || y<0 || wordx>=ow->wide || wordy>=ow->high) {
X return;
X }
X pnum=ow->doc->pnum;
X lnum=ow->doc->lnum;
X p = &ow->doc->p[pnum];
X while(wordy>0) {
X lnum++;
X if (lnum>=p->count) {
X lnum=0;
X pnum++;
X if(pnum>=ow->doc->p_count) return;
X p = &ow->doc->p[pnum];
X }
X wordy--;
X }
X if(findwordinline(p,lnum,wordx,key, ow->doc->propwidth,rp->TxWidth+1)==0) return;
X
X#ifdef DEBUG1
X dmsg(1,"Cheking the index, avail=%ld... ",AvailMem(0));
X#endif
X index(IndexFile,key);
X#ifdef DEBUG1
X dmsg(1,"%ld done\n",AvailMem(0));
X#endif
X return;
X}
X
Xint
Xfindwordinline(p,lnum,count,key, spacing,W)
X struct paragraph *p;
X u_short lnum;
X short count;
X struct key *key;
X u_short *spacing;
X int W;
X{
X register u_char *pos, *end, *begin, *lastref=0;
X u_short ref, lnum2, len=0;
X u_char *reffile=0;
X
X key->name=0;
X key->length=0;
X key->type=0;
X
X if(lnum==0 ) {
X count-=p->pindent;
X len +=p->pindent;
X } else {
X count-=p->indent;
X len +=p->indent;
X }
X
X begin = pos = p->data+p->lines[lnum].offset;
X#ifdef DEBUG1
X dmsg(1,"FINDWORD count=%ld '",count);
X#endif
X if (p->lines[lnum].style & 0x80) ref=1; else ref=0;
X for(end=pos+p->lines[lnum].length;pos<end && count>0;pos++) {
X if(*pos==0) {
X switch(*(pos+2)) {
X case STYLE_EXEC:
X key->type=1;
X lastref=pos;
X ref=1;
X break;
X case STYLE_REF:
X key->type=0;
X lastref=pos;
X ref=1;
X break;
X case STYLE_UNREF:
X key->type=0;
X lastref=0;
X ref=0;
X break;
X }
X pos+=*(pos+1)-1 ;
X begin=pos+1;
X } else {
X if(spacing) {
X if(*pos=='\t') {
X count -= (8-(len/W &7))*W;
X len += (8-(len/W &7))*W;
X } else {
X count -= 1+spacing[*pos];
X len += 1+spacing[*pos];
X }
X } else {
X if(*pos=='\t') {
X /* dmsg(1,"%ld += %ld\n",len,8-(len &7)); */
X count -= 8-(len & 7);
X len += 8-(len & 7);
X } else {
X count--;
X len++;
X }
X }
X
X dmsg(1,"%lc",(long)(*pos));
X }
X }
X dmsg(1,"'\n");
X if(pos<end) {
X if(ref) {
X#ifdef DEBUG1
X dmsg(1,"Reference point!\n");
X#endif
X if(lastref==0) {
X lnum2=lnum;
X while(lastref==0) {
X#ifdef DEBUG1
X dmsg(1,"REF");
X#endif
X if(lnum2==0) {
X#ifdef DEBUG9
X dmsg(9,"findwordinline: ** BUG ALERT!! Reference without a REF mark\n");
X#endif
X return(0);
X }
X lnum2--;
X begin = p->data+p->lines[lnum2].offset;
X lastref = begin + p->lines[lnum2].length - 2;
X while (lastref>=begin) {
X if(*lastref==0 && (*(lastref+2)==STYLE_REF || *(lastref+2)==STYLE_EXEC)) {
X ref=1;
X if( *(lastref+2)==STYLE_EXEC) ref=2;
X#ifdef DEBUG1
X dmsg(1,"FOUNDREF BACK ");
X#endif
X break;
X }
X lastref--;
X }
X if(lastref<begin) lastref=0;
X }
X }
X reffile=lastref+6;
X if(ref==2) {
X reffile++;
X key->type=1;
X }
X#ifdef DEBUG1
X dmsg(1,"REFERENCE FILE = '%s'\n",reffile);
X#endif
X key->name=reffile;
X return 0;
X } /* if ref */ else {
X while(pos>begin && pos[-1]>' ') pos--;
X key->name=pos;
X key->type=0;
X return 1;
X }
X }
X return(0);
X}
SHAR_EOF
echo "extracting format.c"
sed 's/^X//' << \SHAR_EOF > format.c
X/* HyperHelp -- Copyright 1989 Joe Porkka */
X
X/* format.c -- formats the text for a specified width widow */
X
X#include <exec/types.h>
X#include <exec/memory.h>
X#include <graphics/rastport.h>
X#include <graphics/text.h>
X#include "help.h"
X#include "helptext.h"
X#include "style.h"
X
Xextern int debug;
Xextern int PenColor;
X
X#define NDL 12
Xstruct displaylines dl[NDL];
X
Xint
Xformat(doc, width, rp)
X struct doc *doc;
X int width;
X struct RastPort *rp;
X{
X struct paragraph *thisp;
X struct displaylines *tmp;
X
X int DefaultColor, j, k, l;
X u_short *spacing=doc->propwidth;
X int i, W, charperline, lab_count;
X u_short charcount, len, countp=0, count, oldcount=0;
X u_char *pos, *end, *pspace, *lastpos, *tmppos;
X u_char style, pstyle, color, pcolor, indent, pindent;
X
X if(PenColor==-1) DefaultColor=1; else DefaultColor=PenColor;
X if( (spacing==0 && width>254) || (width>1024) ) return(0);
X if(rp)
X W=rp->TxWidth;
X else {
X W=1;
X spacing=0;
X#ifdef DEBUG2
X dmsg(2,"Spacing set to zero!\n");
X#endif
X }
X pcolor=color=DefaultColor;
X
X pindent=0;
X indent=0;
X doc->l_count=0;
X
X lab_count=0;
X if(doc->lab_count!=0 && doc->labs==0) {
X doc->labs=(struct labels *)AllocMem(sizeof(struct labels)*doc->lab_count,MEMF_CLEAR);
X }
X
X charperline=width/W;
X do {
X thisp=&doc->p[countp];
X countp++;
X if(thisp->count && thisp->lines) {
X FreeMem(thisp->lines, thisp->count * sizeof(struct displaylines));
X thisp->lines=0;
X }
X thisp->count=0;
X count=0;
X pos= thisp->data;
X pspace=0; pstyle=0;
X style=0;
X end= &thisp->data[thisp->length];
X
X len=pindent;
X thisp->indent=indent;
X thisp->pindent=pindent;
X /* dmsg(1,"FORMAT: pindent=%ld, indent=%ld.\n",pindent,indent); */
X
X if(spacing) len*=W;
X charcount=0;
X
X lastpos=pos;
X dl[0].offset=0;
X dl[0].style=style;
X dl[0].color=color;
X oldcount=0;
X while(pos<end) {
X if(*pos == 0 && *(pos+1) != 0) {
X switch (* (pos+2) ) {
X case STYLE_REF:
X style |= 0x81;
X break;
X case STYLE_EXEC:
X style |= 0xC1;
X break;
X case STYLE_UNREF:
X style &= ~0xC1;
X break;
X case STYLE_NORMAL:
X style=0;
X color=DefaultColor;
X break;
X case STYLE_UNDERLINE:
X style ^= 1;
X break;
X case STYLE_BOLD:
X style ^= 2;
X break;
X case STYLE_ITALIC:
X style ^= 4;
X break;
X case STYLE_COLOR:
X if(pos[8]>='0' && pos[8]<='7') {
X color = (pos[8]-'0');
X } else color = DefaultColor;
X break;
X case STYLE_LSPACE:
X if(pos[9]>='0' && pos[9]<='9') {
X doc->linespace = (pos[9]-'0');
X#ifdef DEBUG1
X dmsg(1,"linespace set to %ld.\n",doc->linespace);
X#endif
X }
X break;
X case STYLE_INDENT:
X l=9; j=0;
X while(pos[l]==32) l++;
X if(pos[l]=='-') {
X j=-1;
X l++;
X } else if(pos[l]=='+') {
X j= 1;
X l++;
X }
X if(pos[l]>='0' && pos[l]<='9') {
X k = (pos[l]-'0');
X if(pos[l+1]>='0' && pos[l+1]<='9') {
X k = k*10+(pos[l+1]-'0');
X }
X } else k=0;
X if(j) {
X if(j<0 && k>indent) k=indent;
X indent += j*k;
X } else indent=k;
X
X while(indent>charperline && indent!=0) indent/=2;
X if(len+indent*W <= width) {
X len+=indent*W;
X thisp->indent=indent;
X }
X break;
X case STYLE_PINDENT:
X l=10; j=0;
X while(pos[l]==32) l++;
X if(pos[l]=='-') {
X j=-1;
X l++;
X } else if(pos[l]=='+') {
X j= 1;
X l++;
X }
X if(pos[l]>='0' && pos[l]<='9') {
X k = (pos[l]-'0');
X if(pos[l+1]>='0' && pos[l+1]<='9') {
X k = k*10+(pos[l+1]-'0');
X }
X } else k=0;
X if(j) {
X if(j<0 && k>pindent) k=pindent;
X pindent += j*k;
X } else pindent=k;
X
X while(pindent>charperline && pindent!=0) pindent/=2;
X break;
X case STYLE_LABEL:
X if(doc->labs && lab_count<doc->lab_count) {
X doc->labs[lab_count].name=&pos[8];
X doc->labs[lab_count].paragraph=countp-1;
X doc->labs[lab_count].line=thisp->count;
X lab_count++;
X }
X break;
X }
X pos+=*(pos+1);
X } else {
X if(spacing) {
X if(*pos=='\t')
X len += (8-(len/W &7))*W;
X else
X len+=1+spacing[*pos];
X } else {
X if(*pos=='\t') {
X len+= 8-(len & 7);
X } else
X len++;
X }
X if(*pos == ' ' || *pos=='\t') {
X pspace=pos+1;
X pstyle=style;
X pcolor=color;
X }
X pos++;
X
X if(len>=width) {
X if(pspace) {
X pos=pspace;
X style=pstyle;
X color=pcolor;
X }
X tmppos=pos;
X if(count < NDL ) {
X while( (*(pos-1)==' ' || *(pos-1)=='\t') && pos>lastpos) {
X pos--;
X }
X dl[count].length=pos-lastpos;
X } else {
X#ifdef DEBUG1
X dmsg(1,"!");
X#endif
X }
X pos=tmppos;
X if(*pos==' ' || *pos=='\t') pos++;
X lastpos=pos;
X doc->l_count++;
X thisp->count++;
X count++;
X if(count >= NDL) {
X
X tmp =(struct displaylines *)AllocMem(thisp->count * sizeof(struct displaylines),0|MEMF_NAMED,"format0");
X if(tmp==0) {
X#ifdef DEBUG5
X dmsg(5,"WHOOPS! I ran out of memory! tried to get %ld bytes\n",thisp->count * sizeof(struct displaylines));
X#endif
X thisp->count=0;
X return(0 );
X }
X if(thisp->lines) {
X CopyMem(thisp->lines,tmp,oldcount*sizeof(struct displaylines));
X }
X CopyMem(&dl,&tmp[oldcount],NDL*sizeof(struct displaylines));
X count=0;
X if(thisp->lines) {
X FreeMem(thisp->lines,oldcount*sizeof(struct displaylines));
X }
X oldcount=thisp->count;
X thisp->lines=tmp;
X }
X dl[count].offset=pos-thisp->data;
X dl[count].style=style;
X dl[count].color=color;
X
X len=indent;
X if(spacing) len*=W;
X pspace=0;
X pstyle=0;
X }
X }
X }
X if(len>0 || thisp->count==0) {
X if(count < NDL) dl[count].length=pos-lastpos;
X thisp->count++;
X count++;
X doc->l_count++;
X }
X tmp=(struct displaylines *)AllocMem(thisp->count * sizeof(struct displaylines),0|MEMF_NAMED,"format1");
X if(tmp==0) {
X#ifdef DEBUG5
X dmsg(5,"WHOOPS! I ran out of memory! tried to get %ld bytes\n",thisp->count * sizeof(struct displaylines));
X#endif
X if(thisp->lines) {
X FreeMem(thisp->lines,oldcount * sizeof(struct displaylines));
X thisp->lines=0;
X }
X thisp->count=0;
X return(0 );
X }
X
X if(thisp->lines) {
X CopyMem(thisp->lines,tmp,oldcount*sizeof(struct displaylines));
X }
X for(i=oldcount;i<thisp->count;i++) {
X tmp[i]=dl[i-oldcount];
X }
X if(thisp->lines) {
X FreeMem(thisp->lines,oldcount * sizeof(struct displaylines));
X }
X thisp->lines=tmp;
X } while (countp<doc->p_count);
X return(-1);
X}
SHAR_EOF
echo "End of archive 1 (of 3)"
# if you want to concatenate archives, remove anything after this line
exit