[comp.os.minix] Official Patch #1 to Clam

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

Here is the first official set of patches to Clam, the shell I posted
recently. The patches allow Clam to run under ST Minix, using the Gnu
C compiler, and mainly tidied up some of the loose ends in the code.
Thanks go to Jwahar Bammi, who sent me the patches!
(However, your ST makefile didn't get here, Jwahar; could you post it
to the net?!)

Every time something is patched, new bugs crop up, so if you do notice
Clam behaving strangely, please send me a bug report (plus bug fixes if
possible). I think the way Clam exec Bourne shell scripts is still a bit
dodgy, so try some out for me.

Finally, please apply these patches to Clam, as I will assume that this
has been done from now on.

				Cheers everyone,

					Warren Toomey
					(wtoomey@gara.une.oz)

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# alias.cdif builtin.cdif clex.cdif

echo x - alias.cdif
cat > "alias.cdif" << '//E*O*F alias.cdif//'
*** org/alias.c	Fri Mar 10 21:34:29 1989
--- st-gcc/alias.c	Fri Mar 10 22:17:01 1989
***************
*** 79,96 ****
    if (lex<0)
      if (i)		/* normal insertion between old and aptr */
      {
!       new=(struct alias *) malloc (sizeof(struct alias));
        old->next=new;			/* insert the new alias node */
        new->next=aptr;
        new->defin=stdefn;		/* point at new definition */
!       new->a_name=(char *) malloc (strlen(aname)+1);
        strcpy(new->a_name,aname);
      }
      else		/* insertion before atop. old=aptr=atop still */
      {
!       old=(struct alias *) malloc (sizeof(struct alias));
        old->next=atop;
!       old->a_name=(char *) malloc (strlen(aname)+1);
        strcpy(old->a_name,aname);
        old->defin=stdefn;
        atop=old;
--- 79,96 ----
    if (lex<0)
      if (i)		/* normal insertion between old and aptr */
      {
!       new=(struct alias *) malloc ((unsigned)(sizeof(struct alias)));
        old->next=new;			/* insert the new alias node */
        new->next=aptr;
        new->defin=stdefn;		/* point at new definition */
!       new->a_name=(char *) malloc ((unsigned)(strlen(aname)+1));
        strcpy(new->a_name,aname);
      }
      else		/* insertion before atop. old=aptr=atop still */
      {
!       old=(struct alias *) malloc ((unsigned)(sizeof(struct alias)));
        old->next=atop;
!       old->a_name=(char *) malloc ((unsigned)(strlen(aname)+1));
        strcpy(old->a_name,aname);
        old->defin=stdefn;
        atop=old;
***************
*** 107,116 ****
      }
      else		/* alias doesn't exist, append to list. */
      {
!       new=(struct alias *) malloc (sizeof(struct alias));
        new->next=0;
        old->next=new;
!       new->a_name=(char *) malloc (strlen(aname)+1);
        strcpy(new->a_name,aname);
        new->defin=stdefn;
      }
--- 107,116 ----
      }
      else		/* alias doesn't exist, append to list. */
      {
!       new=(struct alias *) malloc ((unsigned)(sizeof(struct alias)));
        new->next=0;
        old->next=new;
!       new->a_name=(char *) malloc ((unsigned)(strlen(aname)+1));
        strcpy(new->a_name,aname);
        new->defin=stdefn;
      }
***************
*** 121,128 ****
  {
    struct adefn *ptr;
  
!   ptr=(struct adefn *) malloc (sizeof(struct adefn));
!   ptr->a_line=(char *) malloc (strlen(aline)+1);
    strcpy(ptr->a_line,aline);
    ptr->nextln=0;
    addalias(aname,ptr);
--- 121,128 ----
  {
    struct adefn *ptr;
  
!   ptr=(struct adefn *) malloc ((unsigned)(sizeof(struct adefn)));
!   ptr->a_line=(char *) malloc ((unsigned)(strlen(aline)+1));
    strcpy(ptr->a_line,aline);
    ptr->nextln=0;
    addalias(aname,ptr);
***************
*** 147,161 ****
  #endif
        if (defn_top)
        {
! 	dptr->nextln=(struct adefn *) malloc (sizeof(struct adefn));
  	dptr=dptr->nextln;
        }
        else
        {
! 	defn_top=(struct adefn *) malloc (sizeof(struct adefn));
  	dptr=defn_top;
        }
!       dptr->a_line=(char *) malloc (strlen(line)+1);
        strcpy(dptr->a_line,line);
      }
    }
--- 147,161 ----
  #endif
        if (defn_top)
        {
! 	dptr->nextln=(struct adefn *) malloc ((unsigned)(sizeof(struct adefn)));
  	dptr=dptr->nextln;
        }
        else
        {
! 	defn_top=(struct adefn *) malloc ((unsigned)(sizeof(struct adefn)));
  	dptr=defn_top;
        }
!       dptr->a_line=(char *) malloc ((unsigned)(strlen(line)+1));
        strcpy(dptr->a_line,line);
      }
    }
//E*O*F alias.cdif//

echo x - builtin.cdif
cat > "builtin.cdif" << '//E*O*F builtin.cdif//'
*** org/builtin.c	Fri Mar 10 21:34:31 1989
--- st-gcc/builtin.c	Sat Mar 11 01:36:03 1989
***************
*** 6,11 ****
--- 6,16 ----
  ******************************************************************************/
  
  #include "header.h"
+ 
+ #ifdef ATARI_ST
+ #define lock _LOCK	/* conflicts with libc lock prototype */
+ #endif
+ 
  #define FOUND 0
  #define NONEXIST 2
  #define NOTEXEC 13
***************
*** 39,46 ****
      perror("cd");
  #ifndef MINIX
    else if (hashed==TRUE) hashpath();
!   if (argc==2) argv[1]=(char *) realloc (argv[1],MAXPL);
!   else argv[1]=(char *) malloc (MAXPL);
  #endif
  #ifdef ATT
    if (getcwd(argv[1]),MAXPL) vset("cwd",argv[1]);
--- 44,51 ----
      perror("cd");
  #ifndef MINIX
    else if (hashed==TRUE) hashpath();
!   if (argc==2) argv[1]=(char *) realloc (argv[1],(unsigned)(MAXPL));
!   else argv[1]=(char *) malloc ((unsigned)(MAXPL));
  #endif
  #ifdef ATT
    if (getcwd(argv[1]),MAXPL) vset("cwd",argv[1]);
***************
*** 157,163 ****
      redirect(infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd);
      if (alias_defn!=0)
      {
!       runalias(alias_defn,argc-1,startarg,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd);
        if (!fromfile) setdown();
        exit(0);
      }
--- 162,170 ----
      redirect(infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd);
      if (alias_defn!=0)
      {
!       runalias(alias_defn,argc-1,startarg,infd,outfd,errfd,ifil,ofil,efil,
! 	       appnd,bckgnd, FALSE); /* is FALSE ok for piped ?? was */
! 				     /* missing in origonal code */
        if (!fromfile) setdown();
        exit(0);
      }
***************
*** 322,331 ****
--- 329,343 ----
    else write(1,"\nKeys are different!\n",21);
  }
  
+ #ifdef __STDC__
+ void alias(int argc, char **argv, int infd, int outfd, int errfd,
+ 	   char *ifil, char *ofil, char *efil, bool appnd, bool bckgnd)
+ #else
  void alias(argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd)
    int argc,infd,outfd,errfd;
    char *argv[],*ifil,*ofil,*efil;
    bool appnd,bckgnd;
+ #endif
  {
    extern struct adefn *checkalias();
    extern void makealias(),makelinealias(),aliaslist(),savealias(),checkjobs();
***************
*** 338,344 ****
    FILE *fp;
    char line[MAXLL],editor[MAXPL],file[MAXFNL],temp[MAXLL];
    int i,pid;
! 
    if (argc==1)
    {
      aliaslist();
--- 350,359 ----
    FILE *fp;
    char line[MAXLL],editor[MAXPL],file[MAXFNL],temp[MAXLL];
    int i,pid;
! #ifdef DEBUG
!   extern int errno;
! #endif
!   
    if (argc==1)
    {
      aliaslist();
***************
*** 575,584 ****
--- 590,604 ----
  }
  #endif
  
+ #ifdef __STDC__
+ void logout(int argc, char **argv, int infd, int outfd, int errfd,
+ 	    char *ifil, char *ofil, char *efil, bool appnd, bool bckgnd)
+ #else
  void logout(argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd)
    int argc,infd,outfd,errfd;
    char *argv[],*ifil,*ofil,*efil;
    bool appnd,bckgnd;
+ #endif
  {
    extern void resetsh(),setdown(),file();
    extern bool loginsh;
***************
*** 1175,1179 ****
    if (!strcmp(name,"read"))
      return(Read);
  #endif
!   return(0);
  }
--- 1195,1199 ----
    if (!strcmp(name,"read"))
      return(Read);
  #endif
!   return(NULL);
  }
//E*O*F builtin.cdif//

echo x - clex.cdif
cat > "clex.cdif" << '//E*O*F clex.cdif//'
*** org/clex.c	Fri Mar 10 21:34:33 1989
--- st-gcc/clex.c	Sat Mar 11 01:00:01 1989
***************
*** 24,30 ****
    stopflag=1;
  }
  
! void colprint(csa,number,longest)
    struct candidates_2 csa[];
    int number,longest;
  {
--- 24,30 ----
    stopflag=1;
  }
  
! static void colprint(csa,number,longest)
    struct candidates_2 csa[];
    int number,longest;
  {
***************
*** 129,135 ****
    int i=0,max,looping=1,bltin;
    char c;
  
!   buf=(struct stat *) malloc (sizeof(struct stat));
    yankprev(line,*pos,word);	/* first get the thing we're trying to expand */
  
  /* Look for a slash to see if its a relative path name or current directory.
--- 129,135 ----
    int i=0,max,looping=1,bltin;
    char c;
  
!   buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat)));
    yankprev(line,*pos,word);	/* first get the thing we're trying to expand */
  
  /* Look for a slash to see if its a relative path name or current directory.
***************
*** 155,166 ****
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=start;
  	  }
  	  ptr->next=0;		/* to make sure */
--- 155,166 ----
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=start;
  	  }
  	  ptr->next=0;		/* to make sure */
***************
*** 172,183 ****
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=start;
  	  }
  	  ptr->next=0;		/* to make sure */
--- 172,183 ----
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=start;
  	  }
  	  ptr->next=0;		/* to make sure */
***************
*** 211,222 ****
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=start;
  	  }
  	  ptr->next=0;			/* make sure it's null */
--- 211,222 ----
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=start;
  	  }
  	  ptr->next=0;			/* make sure it's null */
***************
*** 251,262 ****
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc (sizeof(struct candidates));
  	    ptr=start;
  	  }
  	  ptr->next=0;
--- 251,262 ----
  	{
  	  if (start)
  	  {
! 	    ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=ptr->next;
  	  }
  	  else
  	  {
! 	    start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	    ptr=start;
  	  }
  	  ptr->next=0;
***************
*** 266,272 ****
  	  ptr->c_isdir=TRUE;
  	}
        }
!       close(pswdp);
      }
      else	/* not ~, search whole path */
      {
--- 266,273 ----
  	  ptr->c_isdir=TRUE;
  	}
        }
! /*      close(pswdp); */
!       fclose(pswdp);
      }
      else	/* not ~, search whole path */
      {
***************
*** 284,295 ****
  	    {
  	      if (start)
  	      {
! 		ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  		ptr=ptr->next;
  	      }
  	      else
  	      {
! 		start=(struct candidates *) malloc (sizeof(struct candidates));
  		ptr=start;
  	      }
  	      ptr->next=0;		/* to make sure */
--- 285,296 ----
  	    {
  	      if (start)
  	      {
! 		ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  		ptr=ptr->next;
  	      }
  	      else
  	      {
! 		start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  		ptr=start;
  	      }
  	      ptr->next=0;		/* to make sure */
***************
*** 301,312 ****
  	    {
  	      if (start)
  	      {
! 		ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  		ptr=ptr->next;
  	      }
  	      else
  	      {
! 		start=(struct candidates *) malloc (sizeof(struct candidates));
  		ptr=start;
  	      }
  	      ptr->next=0;		/* to make sure */
--- 302,313 ----
  	    {
  	      if (start)
  	      {
! 		ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  		ptr=ptr->next;
  	      }
  	      else
  	      {
! 		start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  		ptr=start;
  	      }
  	      ptr->next=0;		/* to make sure */
***************
*** 323,334 ****
  	  {
  	    if (start)
  	    {
! 	      ptr->next=(struct candidates *) malloc (sizeof(struct candidates));
  	      ptr=ptr->next;
  	    }
  	    else
  	    {
! 	      start=(struct candidates *) malloc (sizeof(struct candidates));
  	      ptr=start;
  	    }
  	    ptr->next=0;		/* make sure it's null */
--- 324,335 ----
  	  {
  	    if (start)
  	    {
! 	      ptr->next=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	      ptr=ptr->next;
  	    }
  	    else
  	    {
! 	      start=(struct candidates *) malloc ((unsigned)(sizeof(struct candidates)));
  	      ptr=start;
  	    }
  	    ptr->next=0;		/* make sure it's null */
***************
*** 375,380 ****
--- 376,387 ----
      write(1,beep,beeplength);
  }
  
+ static int compare(a,b)
+   struct candidates_2 *a,*b;
+ {
+   return(strcmp(a->c_name,b->c_name));
+ }
+ 
  /* The following function is essentially the same as the previous one except
     that the candidate list is printed out rather than used to expand the
     existing word. It would be possible to put the common code in a separate
***************
*** 407,414 ****
    struct stat *buf;
    struct alias *aptr;
    int i,bltin,max,index=0,maxlength=0,temp,compare();
! 
!   buf=(struct stat *) malloc (sizeof(struct stat));
    if ((pos==0) || (line[pos-1]==' '))
      strcpy(word,"");		/* nothing there to get */
    else
--- 414,422 ----
    struct stat *buf;
    struct alias *aptr;
    int i,bltin,max,index=0,maxlength=0,temp,compare();
!   extern int beeplength;
!   
!   buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat)));
    if ((pos==0) || (line[pos-1]==' '))
      strcpy(word,"");		/* nothing there to get */
    else
***************
*** 433,439 ****
        for (aptr=atop;aptr;aptr=aptr->next)
  	if (!strncmp(&word[i+1],aptr->a_name,max))
  	{
! 	  carray[index].c_name=(char *) malloc (temp=strlen(aptr->a_name)+2);
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,aptr->a_name);
  	  else
--- 441,447 ----
        for (aptr=atop;aptr;aptr=aptr->next)
  	if (!strncmp(&word[i+1],aptr->a_name,max))
  	{
! 	  carray[index].c_name=(char *) malloc ((unsigned)(temp=strlen(aptr->a_name)+2));
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,aptr->a_name);
  	  else
***************
*** 448,454 ****
        for (bltin=0;builtin_name[bltin];bltin++)
  	if (!strncmp(&word[i+1],builtin_name[bltin],max))
  	{
! 	  carray[index].c_name=(char *) malloc (temp=strlen(builtin_name[bltin])+2);
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,builtin_name[bltin]);
  	  else
--- 456,462 ----
        for (bltin=0;builtin_name[bltin];bltin++)
  	if (!strncmp(&word[i+1],builtin_name[bltin],max))
  	{
! 	  carray[index].c_name=(char *) malloc ((unsigned)(temp=strlen(builtin_name[bltin])+2));
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,builtin_name[bltin]);
  	  else
***************
*** 487,493 ****
  /* Check to see if the chars we typed match so far */
  	if (!strncmp(&word[i+1],entry->d_name,max))
  	{
! 	  carray[index].c_name=(char *) malloc (temp=strlen(entry->d_name)+2);
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,entry->d_name);
  	  else
--- 495,501 ----
  /* Check to see if the chars we typed match so far */
  	if (!strncmp(&word[i+1],entry->d_name,max))
  	{
! 	  carray[index].c_name=(char *) malloc ((unsigned)(temp=strlen(entry->d_name)+2));
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,entry->d_name);
  	  else
***************
*** 536,542 ****
  	  for (temp=0;dir[temp]!=':' && dir[temp]!=EOS;temp++)
  	    path[temp]=dir[temp];
  	  path[temp]=EOS;
! 	  carray[index].c_name=(char *) malloc (temp+1);
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,path);
  	  else
--- 544,550 ----
  	  for (temp=0;dir[temp]!=':' && dir[temp]!=EOS;temp++)
  	    path[temp]=dir[temp];
  	  path[temp]=EOS;
! 	  carray[index].c_name=(char *) malloc ((unsigned)(temp+1));
  	  if (carray[index].c_name!=NULL)
  	    strcpy(carray[index].c_name,path);
  	  else
***************
*** 550,556 ****
  	  carray[index++].c_mode=0;
  	}
        }
!       close(pswdp);
      }
      else	/* not ~, search whole path */
      {
--- 558,565 ----
  	  carray[index++].c_mode=0;
  	}
        }
! /*      close(pswdp); */
!       fclose(pswdp);
      }
      else	/* not ~, search whole path */
      {
***************
*** 566,572 ****
  	  for (aptr=atop;aptr;aptr=aptr->next)
  	    if (!strncmp(word,aptr->a_name,max))
  	    {
! 	      carray[index].c_name=(char *) malloc (temp=strlen(aptr->a_name)+2);
  	      if (carray[index].c_name!=NULL)
  		strcpy(carray[index].c_name,aptr->a_name);
  	      else
--- 575,581 ----
  	  for (aptr=atop;aptr;aptr=aptr->next)
  	    if (!strncmp(word,aptr->a_name,max))
  	    {
! 	      carray[index].c_name=(char *) malloc ((unsigned)(temp=strlen(aptr->a_name)+2));
  	      if (carray[index].c_name!=NULL)
  		strcpy(carray[index].c_name,aptr->a_name);
  	      else
***************
*** 581,587 ****
  	  for (bltin=0;builtin_name[bltin];bltin++)
  	    if (!strncmp(word,builtin_name[bltin],max))
  	    {
! 	      carray[index].c_name=(char *) malloc (temp=strlen(builtin_name[bltin])+2);
  	      if (carray[index].c_name!=NULL)
  		strcpy(carray[index].c_name,builtin_name[bltin]);
  	      else
--- 590,596 ----
  	  for (bltin=0;builtin_name[bltin];bltin++)
  	    if (!strncmp(word,builtin_name[bltin],max))
  	    {
! 	      carray[index].c_name=(char *) malloc ((unsigned)(temp=strlen(builtin_name[bltin])+2));
  	      if (carray[index].c_name!=NULL)
  		strcpy(carray[index].c_name,builtin_name[bltin]);
  	      else
***************
*** 610,616 ****
  	      break;
  	    }
  	    temp=strlen(entry->d_name);
! 	    carray[index].c_name=(char *) malloc (temp+1);
  	    if (carray[index].c_name!=NULL)
  	      strcpy(carray[index].c_name,entry->d_name);
  	    else
--- 619,625 ----
  	      break;
  	    }
  	    temp=strlen(entry->d_name);
! 	    carray[index].c_name=(char *) malloc ((unsigned)temp+1);
  	    if (carray[index].c_name!=NULL)
  	      strcpy(carray[index].c_name,entry->d_name);
  	    else
***************
*** 631,637 ****
    }
    if (index)			/* have we found any ?? */
    {
!     qsort((char *)carray,index,sizeof(struct candidates_2),compare);
      colprint(carray,index,maxlength);
  /* free up the space */
      for (index--;index>=0;index--)
--- 640,646 ----
    }
    if (index)			/* have we found any ?? */
    {
!     qsort((char *)carray,index,(int)(sizeof(struct candidates_2)),compare);
      colprint(carray,index,maxlength);
  /* free up the space */
      for (index--;index>=0;index--)
***************
*** 643,651 ****
      write(1,beep,beeplength);
  }
  
- int compare(a,b)
-   struct candidates_2 *a,*b;
- {
-   return(strcmp(a->c_name,b->c_name));
- }
  
--- 652,655 ----
//E*O*F clex.cdif//

exit 0

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# comlined.cdif cx.cdif exec.cdif hash.cdif header.hdif hist.cdif

echo x - comlined.cdif
cat > "comlined.cdif" << '//E*O*F comlined.cdif//'
*** org/comlined.c	Fri Mar 10 21:34:35 1989
--- st-gcc/comlined.c	Sat Mar 11 03:33:21 1989
***************
*** 16,22 ****
  extern char termcapbuf[];
  extern FILE *zin,*zout,*fopen();
  
! 
  void mputc(c,f,curs)
    char c;
    FILE *f;
--- 16,22 ----
  extern char termcapbuf[];
  extern FILE *zin,*zout,*fopen();
  
! #ifndef ATARI_ST
  void mputc(c,f,curs)
    char c;
    FILE *f;
***************
*** 33,44 ****
--- 33,72 ----
      curs[1]++;
    }
  }
+ #else
+ void mputc(c,f,curs)
+   int c;
+   FILE *f;
+   int curs[];
+ {
+   extern int wid;
+   char cc = c;
+   
+   write(f->_file,&cc,1);
+   curs[0]++;
+   if (curs[0]>=wid)
+   {
+     write(f->_file,"\n",1);			/* goto start of next line */
+     curs[0]=curs[0]%wid;			/* hopefully gives zero */
+     curs[1]++;
+   }
+ }
+ #endif
  
+ #ifndef ATARI_ST
  void oputc(c)
    char c;
  {
    write(zout->_file,&c,1);
  }
+ #else
+ int oputc(c)
+   int c;
+ {
+     char cc = c;
+     return write(zout->_file,&cc,1);
+ }
+ #endif
  
  void go(curs,hor,vert)
    int curs[],hor,vert;
***************
*** 144,153 ****
--- 172,185 ----
    go(curs,horig,vorig);
  }
  
+ #ifdef __STDC__
+ void show(char *line, int *curs, bool clearing)
+ #else
  void show(line,curs,clearing)
    char *line;
    int curs[];
    bool clearing;
+ #endif
  {
    extern int lenprompt;
    int pos=0,horig,vorig;
//E*O*F comlined.cdif//

echo x - cx.cdif
cat > "cx.cdif" << '//E*O*F cx.cdif//'
*** org/cx.c	Fri Mar 10 21:34:36 1989
--- st-gcc/cx.c	Sat Mar 11 05:40:06 1989
***************
*** 16,21 ****
--- 16,22 ----
    FILE *pswdp,*fopen();
    char pwent[256],username[USERNL],restpath[MAXWL];
    int i,j,colon=0;
+   extern  char *getlogin();
  
  #ifdef DEBUG
  fprintf(stderr,"user_path is %s\n",user_path);
***************
*** 68,80 ****
        else
        {
  	fprintf(stderr,"\n%sBad password entry in %s for %s.\n",beep,PASSWD,username);
! 	close(pswdp);
  	return(FALSE);
        }
        break;
      }
    }
!   close(pswdp);
  /* this test is a repeat of the one above but will give a different error
     message if we can't find a matching username */
    if (colon!=5)
--- 69,83 ----
        else
        {
  	fprintf(stderr,"\n%sBad password entry in %s for %s.\n",beep,PASSWD,username);
! /*	close(pswdp); */
! 	fclose(pswdp);
  	return(FALSE);
        }
        break;
      }
    }
! /*  close(pswdp); */
!   fclose(pswdp);
  /* this test is a repeat of the one above but will give a different error
     message if we can't find a matching username */
    if (colon!=5)
//E*O*F cx.cdif//

echo x - exec.cdif
cat > "exec.cdif" << '//E*O*F exec.cdif//'
*** org/exec.c	Fri Mar 10 21:34:38 1989
--- st-gcc/exec.c	Sat Mar 11 03:03:02 1989
***************
*** 14,20 ****
  #ifdef MINIX
  extern int errno;
  #endif
! extern **environ;
  void (*builtin_func)();
  struct adefn *alias_defn;
  int stopflg,NoIoctl=0;
--- 14,20 ----
  #ifdef MINIX
  extern int errno;
  #endif
! extern char **environ;
  void (*builtin_func)();
  struct adefn *alias_defn;
  int stopflg,NoIoctl=0;
***************
*** 46,57 ****
  fprintf(stderr,"set exec\n");
  #endif
  
!   termod=(struct sgttyb *) malloc (sizeof(struct sgttyb));
    if (ioctl(0,TIOCGETP,termod)) perror("ioctl in setexec");
    termod->sg_flags &= (~CBREAK);		/* cooked mode */
    termod->sg_flags |= ECHO;			/* with echo */
    if (ioctl(0,TIOCSETN,termod)) perror("ioctl");
!   setsigc=(struct tchars *) malloc (sizeof(struct tchars));
    if (ioctl(0,TIOCGETC,setsigc)) perror("ioctl");
    setsigc->t_intrc=03;				/* interrupt ctrl c */
    setsigc->t_quitc=034;				/* quit ctrl \ */
--- 46,57 ----
  fprintf(stderr,"set exec\n");
  #endif
  
!   termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb)));
    if (ioctl(0,TIOCGETP,termod)) perror("ioctl in setexec");
    termod->sg_flags &= (~CBREAK);		/* cooked mode */
    termod->sg_flags |= ECHO;			/* with echo */
    if (ioctl(0,TIOCSETN,termod)) perror("ioctl");
!   setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars)));
    if (ioctl(0,TIOCGETC,setsigc)) perror("ioctl");
    setsigc->t_intrc=03;				/* interrupt ctrl c */
    setsigc->t_quitc=034;				/* quit ctrl \ */
***************
*** 86,92 ****
  {
    int sig;
  
!   for(sig=1;sig<21;sig++)
      signal(sig,SIG_DFL);
  }
  
--- 86,92 ----
  {
    int sig;
  
!   for(sig=1;sig<NSIG;sig++)
      signal(sig,SIG_DFL);
  }
  
***************
*** 111,121 ****
--- 111,127 ----
    stopflg=1;
  }
  
+ #ifdef __STDC__
+ void runalias(struct adefn *start, int argc, char **argv, int infd,
+ 	      int outfd, int errfd, char *ifil, char *ofil, char *efil,
+ 	      bool appnd, bool bckgnd, bool piped)
+ #else
  void runalias(start,argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd,piped)
    struct adefn *start;
    int argc,infd,outfd,errfd;
    char *argv[],*ifil,*ofil,*efil;
    bool appnd,bckgnd,piped;
+ #endif
  {
    extern SYM_T intercom();
    extern FILE *zin;
***************
*** 170,181 ****
--- 176,197 ----
      {
        if (stopflg) break;
        retval=0;
+ #if 0
+       /* WAS: same problem here as in main.c:fopen() */
        act=intercom(line,&pos,&pid,FALSE,NULL,fromfile);
+ #else
+       act=intercom(line,&pos,&pid, &i, FALSE,fromfile);
+ #endif
+ 
  #ifdef DEBUG
  fprintf(stderr,"pid returned from intercom is %d for line %s\n",pid,line);
  fprintf(stderr,"fileno(zin) is %d\n",fileno(zin));
  #endif
+ #if 0
        for (i=3;i<=20;i++) if (i!=fileno(zin)) close(i);
+ #else
+       for (i=3;i<=NFILES;i++) if (i!=fileno(zin)) close(i);
+ #endif
        if (pid && act!=BCKGND)
  	retval=waitfor(pid);
  #ifndef MINIX
***************
*** 415,424 ****
--- 431,445 ----
    umask(cmask);
  }
  
+ #ifdef __STDC__
+ void redirect(int infd, int outfd, int errfd, char *ifil, char *ofil,
+ 	      char *efil, bool appnd, bool bckgnd)
+ #else
  void redirect(infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd)
    int infd,outfd,errfd;
    char *ifil,*ofil,*efil;
    bool appnd,bckgnd;
+ #endif
  {
    extern char *vget();
    int fd,mode,flags;
***************
*** 437,443 ****
--- 458,468 ----
  	panic("exec.c: dup: stdin");
      }
      else
+ #ifndef ATARI_ST
        if (open(ifil,O_RDONLY,0) == -1)
+ #else
+       if (open(ifil,O_RDONLY) == -1)
+ #endif
        {
  	fprintf(stderr,"Can't open %s\n",ifil);
  	exit(0);
***************
*** 505,517 ****
        mode= 0777;
        if (creat(efil,mode)==-1)
        {
! 	write(2,"Can't open ");
  	write(2,efil,strlen(efil));
  	exit(0);
        }
        if (open(efil,flags)==-1)
        {
! 	write(2,"Can't open ");
  	write(2,efil,strlen(efil));
  	exit(0);
        }
--- 530,542 ----
        mode= 0777;
        if (creat(efil,mode)==-1)
        {
! 	write(2,"Can't open ", 11);
  	write(2,efil,strlen(efil));
  	exit(0);
        }
        if (open(efil,flags)==-1)
        {
! 	write(2,"Can't open ", 11);
  	write(2,efil,strlen(efil));
  	exit(0);
        }
***************
*** 527,541 ****
--- 552,576 ----
  #endif
      }
    }
+ #if 0
    for (fd=3;fd<20;fd++)
+ #else
+   for (fd=3;fd<NFILES;fd++)
+ #endif
      (void) close(fd);
  }
  	
+ #ifdef __STDC__
+ int execute(int argc, char **argv, int infd, int outfd, int errfd,
+ 	    char *ifil, char *ofil, char *efil, bool appnd,
+ 	    bool bckgnd, bool piped, int fromfile)
+ #else
  int execute(argc,argv,infd,outfd,errfd,ifil,ofil,efil,appnd,bckgnd,piped,fromfile)
    int argc,infd,outfd,errfd;
    char *argv[],*ifil,*ofil,*efil;
    bool appnd,bckgnd,piped;
    int fromfile;
+ #endif
  {
    extern void makenv();
    extern char *invokename,*current_alias;
***************
*** 617,625 ****
  #endif
  
  	       for (i=argc;i;i--) argv[i]=argv[i-1];
! 	       argv[1]=(char *) realloc (argv[1],strlen(path)+1);
  	       strcpy(argv[1],path);		/* full path for source file */
! 	       argv[0]=(char *) malloc (strlen(DFLTSH)+1);
  	       strcpy(argv[0],DFLTSH);
  	       strcpy(path,DFLTSH);
  	       argc++;			/* one more arg for mankind... */
--- 652,660 ----
  #endif
  
  	       for (i=argc;i;i--) argv[i]=argv[i-1];
! 	       argv[1]=(char *) realloc (argv[1],(unsigned)(strlen(path)+1));
  	       strcpy(argv[1],path);		/* full path for source file */
! 	       argv[0]=(char *) malloc ((unsigned)(strlen(DFLTSH)+1));
  	       strcpy(argv[0],DFLTSH);
  	       strcpy(path,DFLTSH);
  	       argc++;			/* one more arg for mankind... */
//E*O*F exec.cdif//

echo x - hash.cdif
cat > "hash.cdif" << '//E*O*F hash.cdif//'
*** org/hash.c	Fri Mar 10 21:34:40 1989
--- st-gcc/hash.c	Fri Mar 10 22:04:31 1989
***************
*** 34,40 ****
    struct stat *buf;
    char fpn[MAXWL];
  
!   buf=(struct stat *) malloc (sizeof(struct stat));
    if (nojoin)
      stat(dir,buf);
    else
--- 34,40 ----
    struct stat *buf;
    char fpn[MAXWL];
  
!   buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat)));
    if (nojoin)
      stat(dir,buf);
    else
***************
*** 92,98 ****
        }
      }
  /* Having found a blank position we now malloc some space and copy the values */
!     hasharray[hashval].name=(char *) malloc (strlen(aptr->a_name)+1);
      strcpy(hasharray[hashval].name,aptr->a_name);
      hasharray[hashval].exec_ptr.alias_defn=checkalias(aptr->a_name);
      hasharray[hashval].type=1;
--- 92,98 ----
        }
      }
  /* Having found a blank position we now malloc some space and copy the values */
!     hasharray[hashval].name=(char *) malloc ((unsigned)(strlen(aptr->a_name)+1));
      strcpy(hasharray[hashval].name,aptr->a_name);
      hasharray[hashval].exec_ptr.alias_defn=checkalias(aptr->a_name);
      hasharray[hashval].type=1;
***************
*** 128,134 ****
        }
      }
  /* Having found a blank position we now malloc some space and copy the values */
!     hasharray[hashval].name=(char *) malloc (strlen(builtin_name[i])+1);
      strcpy(hasharray[hashval].name,builtin_name[i]);
      hasharray[hashval].exec_ptr.builtin_fn=checkbuiltins(builtin_name[i]);
      hasharray[hashval].type=2;
--- 128,134 ----
        }
      }
  /* Having found a blank position we now malloc some space and copy the values */
!     hasharray[hashval].name=(char *) malloc ((unsigned)strlen(builtin_name[i])+1);
      strcpy(hasharray[hashval].name,builtin_name[i]);
      hasharray[hashval].exec_ptr.builtin_fn=checkbuiltins(builtin_name[i]);
      hasharray[hashval].type=2;
***************
*** 248,256 ****
  	}
  
  /* Having found a blank position we now malloc some space and copy the values */
! 	hasharray[hashval].name=(char *) malloc (strlen(entry->d_name)+1);
  	strcpy(hasharray[hashval].name,entry->d_name);
! 	hasharray[hashval].exec_ptr.dir=(char *) malloc (strlen(dir)+1);
  	strcpy(hasharray[hashval].exec_ptr.dir,dir);
  	hasharray[hashval].type=0;
        }
--- 248,256 ----
  	}
  
  /* Having found a blank position we now malloc some space and copy the values */
! 	hasharray[hashval].name=(char *) malloc ((unsigned)(strlen(entry->d_name)+1));
  	strcpy(hasharray[hashval].name,entry->d_name);
! 	hasharray[hashval].exec_ptr.dir=(char *) malloc ((unsigned)(strlen(dir)+1));
  	strcpy(hasharray[hashval].exec_ptr.dir,dir);
  	hasharray[hashval].type=0;
        }
//E*O*F hash.cdif//

echo x - header.hdif
cat > "header.hdif" << '//E*O*F header.hdif//'
*** org/header.h	Fri Mar 10 21:34:41 1989
--- st-gcc/header.h	Sat Mar 11 03:27:07 1989
***************
*** 10,16 ****
  #else
  #  include <sgtty.h>
  #  include <sys/dir.h>
! #  include <sys/time.h>
  #  ifdef SUN
  #    include <sys/wait.h>
  #    include <sys/resource.h>
--- 10,20 ----
  #else
  #  include <sgtty.h>
  #  include <sys/dir.h>
! #  ifndef ATARI_ST
! #    include <sys/time.h>
! #else
! #    include <time.h>
! #endif
  #  ifdef SUN
  #    include <sys/wait.h>
  #    include <sys/resource.h>
***************
*** 60,66 ****
  #define DFLTSH "/bin/sh"
  
  /* name of default editor to use for alias creation. */
! #define DFLTED "/usr/local/bin/vi"
  
  /* Sizes of some data structures */
  #ifdef MINIX
--- 64,70 ----
  #define DFLTSH "/bin/sh"
  
  /* name of default editor to use for alias creation. */
! #define DFLTED "/usr/local/bin/mg"
  
  /* Sizes of some data structures */
  #ifdef MINIX
***************
*** 93,99 ****
  #  ifndef MINIX
  #    define NUMSIG 27
  #  else
! #    define NUMSIG 19
  #  endif
  #endif
  
--- 97,107 ----
  #  ifndef MINIX
  #    define NUMSIG 27
  #  else
! #    ifdef ATARI_ST
! #      define NUMSIG NSIG		/* defined in <signal.h> */
! #    else
! #      define NUMSIG 19
! #    endif
  #  endif
  #endif
  
***************
*** 102,107 ****
--- 110,118 ----
  #define UNDEF -1
  
  /* Identification for error codes for metacharacter expansion function */
+ #ifdef OK	/* defined somewhere on minixST */
+ #undef OK
+ #endif
  #define OK 0
  #define SH_ERR -1
  #define ST_ERR -2
***************
*** 115,120 ****
--- 126,141 ----
  #define DL_ERR -10
  
  typedef enum TS {RDRIN,RDROUT,RDRERR,APPND,PIPE,WORD,ENDLN,SEMI,EQ,ADD,BCKGND,DBLPIPE,DBLAMP,ERRER} SYM_T;
+ 
+ /* some brain damaged people put these in stdio */
+ #ifdef FALSE
+ #undef FALSE
+ #endif
+ 
+ #ifdef TRUE
+ #undef TRUE
+ #endif
+ 
  typedef enum bb {FALSE,TRUE} bool;
  
  /* These structures are used to store the alias definitions. */
***************
*** 166,168 ****
--- 187,310 ----
    long lastmod;
    struct job *next;
  };
+ 
+ #ifdef __STDC__
+ #ifndef __NO_PROTO__
+ void aliaslist(void);
+ void savealias(char *, FILE *);
+ struct adefn *checkalias(char *);
+ void addalias(char *, struct adefn *);
+ void makelinealias(char *, char *);
+ void makealias(char *, FILE *);
+ void delalias(char *);
+ 
+ void alias(int, char **, int, int, int, char *, char *, char *, bool, bool);
+ void logout(int, char **, int, int, int, char *, char *, char *, bool, bool);
+ void (*checkbuiltins())(char *);
+ 
+ bool firstword(char *, int);
+ void complete(char *, int *, int *);
+ void nameopt(char *, int, int *);
+ 
+ void mputc(int, FILE *, int *);
+ int oputc(int);
+ void go(int *, int, int);
+ void backward(int *);
+ void forward(int *);
+ void clrscrn(void);
+ void insert(char *, int, int, int *);
+ void show(char *, int *, bool);
+ void goend(char *, int *, int *);
+ void copyback(char *, int, int *);
+ void delword(char *, int, int *);
+ void backword(char *, int *, int *);
+ void forword(char *, int *, int *);
+ void yanknext(char *, int, char *);
+ void yankprev(char *, int, char *);
+ void clrline(char *, int, int *);
+ void transpose(char *, int, int *);
+ int strip(char *);
+ void tardis(char *, int *, int *);
+ bool getlin(char *, int *, int);
+ 
+ bool expand_tilde(char *, int *);
+ void help(char *, int, int *);
+ 
+ void setexec(void);
+ void setbgexec(void);
+ void resetsigdefaults(void);
+ bool findslash(char *);
+ void runalias(struct adefn *, int, char **, int, int, int, char *,
+ 	      char *, char *, bool, bool, bool);
+ int getpath(char *, char *);
+ void panic(char *);
+ int atoo(char *);
+ void setmask(char *);
+ void redirect(int, int, int, char *, char *, char *, bool, bool);
+ int execute(int, char **, int, int, int, char *, char *, char *, bool,
+ 	    bool, bool, int);
+ 
+ bool getfileline(char *, FILE *, int);
+ 
+ bool executable(char *, char *, int);
+ 
+ void savehist(char *, int, int);
+ void loadhist(char *, int *, int, int *);
+ void mprint(char *);
+ void history(char **);
+ bool gethist(char *);
+ char *getnumhist(int);
+ int matchhist(int);
+ 
+ void joblist(void);
+ struct job *findjob(int);
+ int pidfromjob(int);
+ void addreport(struct job *);
+ int addjob(int, char *, int, bool);
+ void newcurr(void);
+ void rmjob(int);
+ int update(int, int);
+ void checkjobs(void);
+ int waitfor(int);
+ void reportjobs(void);
+ int lengthint(int);
+ void printime(void);
+ void prprompt(int);
+ bool tflagexist(char *, char *);
+ void terminal(void);
+ void graceful(int);
+ void setup(void);
+ void resetsh(void);
+ void setdown(void);
+ void leave_shell(void);
+ int process(int, char **, char *);
+ void file(FILE *, int);
+ void shinit(void);
+ void interact(void);
+ void execstring(int, char **, int);
+ 
+ void getdir(FILE *, char *);
+ int isanum(char *);
+ int meta(char *, int);
+ 
+ bool getword(char *, int *, char *, bool );
+ SYM_T retsym(char *, char *, int *, bool );
+ SYM_T intercom(char *, int *, int *, int *, bool , int);
+ 
+ char *vget(char *);
+ char *vwget(char *, int);
+ bool export(char *, char *);
+ void makenvpath(void);
+ void makenventry(char *);
+ void makenv(void);
+ void vset(char *, char *);
+ void vadd(char *, char *);
+ void vdel(char *);
+ void venvdel(char *);
+ void vprint(void);
+ void venvprint(void);
+ void copyenv(char **, char **);
+ void loadenv(void);
+ 
+ #endif /* __NO_PROTO__ */
+ #endif /* __STDC__ */
//E*O*F header.hdif//

echo x - hist.cdif
cat > "hist.cdif" << '//E*O*F hist.cdif//'
*** org/hist.c	Fri Mar 10 21:34:42 1989
--- st-gcc/hist.c	Fri Mar 10 22:02:30 1989
***************
*** 27,40 ****
    for (old=ptr=htop;ptr && ptr->hnum!=histnum;old=ptr,ptr=ptr->next);
    if (ptr)				/* change existing history */
    {
!     ptr->hline=(char *) realloc (ptr->hline,strlen(line)+1);
      strcpy(ptr->hline,line);
    }
    else
      if (htop)				/* there is a history, isn't there? */
      {
!       old->next=ptr=(struct histlist *) malloc (sizeof(struct histlist));
!       ptr->hline=(char *) malloc (strlen(line)+1);
        strcpy(ptr->hline,line);
        ptr->hnum=histnum;
        ptr->next=0;
--- 27,40 ----
    for (old=ptr=htop;ptr && ptr->hnum!=histnum;old=ptr,ptr=ptr->next);
    if (ptr)				/* change existing history */
    {
!     ptr->hline=(char *) realloc (ptr->hline,(unsigned)(strlen(line)+1));
      strcpy(ptr->hline,line);
    }
    else
      if (htop)				/* there is a history, isn't there? */
      {
!       old->next=ptr=(struct histlist *) malloc((unsigned)(sizeof(struct histlist))); 
!       ptr->hline=(char *) malloc ((unsigned)(strlen(line)+1));
        strcpy(ptr->hline,line);
        ptr->hnum=histnum;
        ptr->next=0;
***************
*** 47,54 ****
      }
      else				/* no? well, let's make one then. */
      {
!       htop=(struct histlist *) malloc (sizeof(struct histlist));
!       htop->hline=(char *) malloc (strlen(line)+1);
        strcpy(htop->hline,line);
        htop->hnum=histnum;
        htop->next=0;
--- 47,54 ----
      }
      else				/* no? well, let's make one then. */
      {
!       htop=(struct histlist *) malloc ((unsigned)(sizeof(struct histlist)));
!       htop->hline=(char *) malloc ((unsigned)(strlen(line)+1));
        strcpy(htop->hline,line);
        htop->hnum=histnum;
        htop->next=0;
//E*O*F hist.cdif//

exit 0

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# idoprint.c iscanf.c

echo x - idoprint.c
cat > "idoprint.c" << '//E*O*F idoprint.c//'
#ifdef __RCS_ID__
static char rcsid[] = "$Header: /u5/mnx/gnu/lib/RCS/doprintf.c,v 1.6 89/03/04 04:16:09 bammi Exp $";
#endif /* __RCS_ID__ */

/*
 * Log and Header added (03/03/89)
 *
 * $Log:	doprintf.c,v $
 * Revision 1.6  89/03/04  04:16:09  bammi
 * Fourth release of Gcc Gnulib for MinixST (03/03/89)
 * 
 */

#include <stdio.h>

/*
 * three compile time options:
 *	STACKUP		fetch arguments using *p-- instead of *p++
 *	NO_LONGD	%d and %ld/%D are equal
 *	NO_FLOAT	abort on %e, %f and %g
 */
#ifndef __GNUC__	/* __GNUC__ handles doubles all right */
#define	NO_FLOAT
#else
#ifdef __INT_PRINTF__  /* we want an integer only doprintf() in gnu */
#define NO_FLOAT
#endif
#endif

#ifdef NO_FLOAT
#define	MAXDIG		11	/* 32 bits in radix 8 */
#else
#define	MAXDIG		128	/* this must be enough */
#endif

static char *
_itoa(p, num, radix)
register char *p;
register unsigned num;
register radix;
{
	register	i;
	register char	*q;

	q = p + MAXDIG;
	do {
		i = (int)(num % radix);
		i += '0';
		if (i > '9')
			i += 'A' - '0' - 10;
		*--q = i;
	} while (num = num / radix);
	/* bug bug buggy code	i = p + MAXDIG - q; */
	i = (int)(p - q) + MAXDIG;
	do
		*p++ = *q++;
	while (--i);
	return(p);
}

#ifndef NO_LONGD
static char *
_ltoa(p, num, radix)
register char *p;
register unsigned long num;
register radix;
{
	register	i;
	register char	*q;

	q = p + MAXDIG;
	do {
		i = (int)(num % radix);
		i += '0';
		if (i > '9')
			i += 'A' - '0' - 10;
		*--q = i;
	} while (num = num / radix);
	i = (int)(p - q) + MAXDIG;
	do
		*p++ = *q++;
	while (--i);
	return(p);
}
#endif

#ifndef NO_FLOAT
#ifndef __GNUC__
extern char	*_ecvt();
extern char	*_fcvt();
extern char	*_gcvt();
#else
/*
 * deal with floating point formatting
 *	++jrb bammi@dsrgsun.ces.cwru.edu
 *
 * code below does not deal with rounding off digit at precision
 * and is probably not as precise as some would want, but its
 * good enough for rock & roll.
 *
 * 12/10/88 added rounding ++jrb
 * 02/01/89 corrected buggy rounding code  ++jrb
 *
 */
#define MAXWIDTH 30	/* chosen arb. */

typedef enum { EFORMAT, FFORMAT, GFORMAT  } FORMAT_TYPE;

#ifdef __STDC__
static void  _flofmt(char *, double, double, int);
char *itoa(int);
#else
static void _flofmt();
extern char *itoa();
#endif

/* return 5.0E-p */

static double _fleast(p)
register int p;
{
    double least = 5.0;
    while(--p >= 0) least /= 10.0;
    return least;    
}

/*  #define KLUDGEDIV	no longer needed */
static char *_cvt(buf, val, precision, fmt)
char *buf;
double val;
int precision;
FORMAT_TYPE fmt;
{
    char mybuf[MAXWIDTH+1];
    int  pow;
    int  sign;
    double least;
#ifdef KLUDGEDIV
    long l;
    int i;
#endif
#ifndef __STDC__
    extern double _fleast();
#else
    double _fleast(int);
#endif
    
#ifdef DDD
    printf("_cvt called\n");
#endif
    /* make val +ve record sign */
    if(val < 0)
    {
	sign = 1;
	val = -val;
    }
    else sign = 0;

    /* round it off at precision -- add 5.0E-(precision+1) */
    least =  _fleast(precision+1);
    if(least > val)
    {
	least = 0.0;
	precision = MAXWIDTH;
    }
    else
	val += least;

#ifdef DDD
    printf("sign %d\n", sign);
#endif
    
    /* convert val to 0.nnn form -- record pow */
    pow = 0;
    while(val >= 1.0)
    {
	val /= 10.0;
	pow++;
    }

#ifdef DDD
    puts("pow determined\n");
    printf("pow %d  precision+pow %d\n", pow, precision+pow);
#endif

    if((precision + pow) > MAXWIDTH)
	precision -= ((precision + pow) - MAXWIDTH);
    
    _flofmt(mybuf, val, least, precision+pow);

#ifdef DDD
    printf("back from flofmt mybuf :%s:\n", mybuf);
#endif

    switch(fmt)
    {
      case EFORMAT:
      efmt:
        {
	    register char *p = mybuf, *q = buf;
	    if(sign) *q++ = '-';
	    while((*p != '\0') && (*p == '0'))
	    {
		pow -= 1;
		p++;
	    }
	    if(*p == '\0')
	    {
		while(precision-- > 0)
		    *q++ = '0';
		*q = '\0';
		return q;
	    }
	    pow -= 1;
	    *q++ = *p++;
	    *q++ = '.';
	    if(*p == '\0')
		*q++ = '0';
	    while(*p != '\0')
		*q++ = *p++;
	    *q++ = 'e';
	    if(pow >= 0)
		*q++ = '+';
	    else
	    {
		*q++ = '-';
		pow = -pow;
	    }
	    if(pow < 10)
		*q++ = '0';
	    p = itoa(pow);
	    while(*p != '\0') *q++ = *p++;
	    *q = '\0';
	    return q;
	}
	
      case FFORMAT:
          ffmt:
            {
		register char *p = mybuf, *q = buf;
		if(sign)
		    *q++ = '-';
		while(pow-- > 0)
		    *q++ = *p++;
		if(*p != '\0')
		{
		    *q++ = '.';
		    while(*p != '\0')
			*q++ = *p++;
		}
		*q = '\0';
		return q;
	    }
	
		
      case GFORMAT:
    	{
	    register int leading = 0;
	    register char *p = mybuf;
	    while(*p != '\0')
		if (*p++ == '0') leading++;
	    
	    /* anyone have a good heuristic to decide between F and E */
	    /* formats ??? */
	    if((leading > 6) || (precision > 6) || ((pow+precision) > 10))
		goto efmt; 
	    goto ffmt;
	}
    }
}    
	
	
    
/* the formatter for flona -- basic body from pfgutc.c Tos Gcc lib */
static void  _flofmt(buf, val, least, precision)
char * buf;
double val, least;
int precision;
{
    long int_part;
    int i, ndigits;
    char digit[MAXWIDTH+2];

#ifdef DDD
    printf("\t_flofmt\n");
#endif
    
    for (i = 0 ; i < MAXWIDTH ; i++)
	digit[i] = 0;
    for (i = 0, ndigits = 0 ;
	 ((val > least) && (ndigits < precision) && (i < MAXWIDTH)); i++) 
    {
	val = val * 10.0;
	int_part = val;
	val = val - int_part;
	digit[i] = int_part;
	/* kludge till we get doubles accurate... */
	/*  -- probably not  needed now */
	if ((digit[i] > 9) || (digit[i] < 0))
	    digit[i] = 0;
	if (int_part > 0) ndigits = i + 1;
    }
#ifdef DDD
    printf("\t_loop done ndigits %d  precision %d\n", ndigits, precision);
#endif
    if(ndigits < precision)
	ndigits = precision;	/* we have already zero'ed the rest */
    
    if (ndigits > 0)		/* were there any? */
    {
	for (i = 0 ; i < ndigits ; i++)
	{
	    *buf++ = digit[i] + '0';
	}
    }
    *buf = '\0';
}

#endif /* __GNUC__ */
#endif /* NO_FLOAT */

#ifdef STACKUP
#define	GETARG(typ)	*((typ *)args)--
#else
#define	GETARG(typ)	*((typ *)args)++
#endif STACKUP

#ifndef TEST
int _doprintf(iop, fmt, args)
#else
int __Ddoprintf(iop, fmt, args)
#endif
FILE *iop;
register char *fmt;
register int *args;
{
	char		buf[MAXDIG+1];	/* +1 for sign */
	register char	*p;
	register char	*s;
	register	c;
	register	i;
	register short	width;
	register short	ndigit;
	register	ndfnd;
	register	ljust;
	register	zfill;
#ifndef NO_LONGD
	register	lflag;
	register long	l;
#endif
	register int	n_written = 0;
	
	for (;;) {
		c = *fmt++;
		if (c == 0)
			return n_written;
		if (c != '%') {
			if(putc(c, iop) == EOF)
			    return EOF;
			else
			    n_written++;
			continue;
		}
		p = buf;
		s = buf;
		ljust = 0;
		if (*fmt == '-') {
			fmt++;
			ljust++;
		}
		zfill = ' ';
		if (*fmt == '0') {
			fmt++;
			zfill = '0';
		}
		for (width = 0;;) {
			c = *fmt++;
			if (c >= '0' && c <= '9')
				c -= '0';
			else if (c == '*')
				c = GETARG(int);
			else
				break;
			width *= 10;
			width += c;
		}
		ndfnd = 0;
		ndigit = 0;
		if (c == '.') {
			for (;;) {
				c = *fmt++;
				if (c >= '0' && c <= '9')
					c -= '0';
				else if (c == '*')
					c = GETARG(int);
				else
					break;
				ndigit *= 10;
				ndigit += c;
				ndfnd++;
			}
		}
#ifndef NO_LONGD
		lflag = 0;
#endif
		if (c == 'l' || c == 'L') {
#ifndef NO_LONGD
			lflag++;
#endif
			if (*fmt)
				c = *fmt++;
		}
		switch (c) {
		case 'X':
#ifndef NO_LONGD
			lflag++;
#endif
		case 'x':
			c = 16;
			goto oxu;
		case 'U':
#ifndef NO_LONGD
			lflag++;
#endif
		case 'u':
			c = 10;
			goto oxu;
		case 'O':
#ifndef NO_LONGD
			lflag++;
#endif
		case 'o':
			c = 8;
		oxu:
#ifndef NO_LONGD
			if (lflag) {
				p = _ltoa(p, GETARG(long), c);
				break;
			}
#endif
			p = _itoa(p, GETARG(int), c);
			break;
		case 'D':
#ifndef NO_LONGD
			lflag++;
#endif
		case 'd':
#ifndef NO_LONGD
			if (lflag) {
				if ((l = GETARG(long)) < 0) {
					*p++ = '-';
					l = -l;
				}
				p = _ltoa(p, l, 10);
				break;
			}
#endif
			if ((i = GETARG(int)) < 0) {
				*p++ = '-';
				i = -i;
			}

			p = _itoa(p, i, 10);
			break;
#ifdef NO_FLOAT
		case 'e':
		case 'f':
		case 'g':
			zfill = ' ';
			*p++ = '?';
			break;
#else
#ifdef __GNUC__
#ifndef __INT_PRINTF__
		case 'e':
			if (ndfnd == 0)
				ndigit = 6;
			ndigit++;
			p = _cvt(p, (double)GETARG(double), ndigit, EFORMAT);
			break;
		case 'f':
			if (ndfnd == 0)
				ndigit = 6;
			p = _cvt(p, (double)GETARG(double), ndigit, FFORMAT);
			break;
		case 'g':
			if (ndfnd == 0)
				ndigit = 6;
			p = _cvt(p, (double)GETARG(double), ndigit, GFORMAT);
			break;
#endif /* __INT_PRINTF__ */
#else
		case 'e':
			if (ndfnd == 0)
				ndigit = 6;
			ndigit++;
			p = _ecvt(p, GETARG(double), ndigit);
			break;
		case 'f':
			if (ndfnd == 0)
				ndigit = 6;
			p = _fcvt(p, GETARG(double), ndigit);
			break;
		case 'g':
			if (ndfnd == 0)
				ndigit = 6;
			p = _gcvt(p, GETARG(double), ndigit);
			break;
#endif /* __GNUC__ */
#endif /* NO_FLOAT */

		case 'c':
			zfill = ' ';
			*p++ = GETARG(int);
			break;
		case 's':
			zfill = ' ';
			if ((s = GETARG(char *)) == 0)
				s = "(null)";
			if (ndigit == 0)
				ndigit = 32767;
			for (p = s; *p && --ndigit >= 0; p++)
				;
			break;
		default:
			*p++ = c;
			break;
		}
		i = p - s;
		if ((width -= i) < 0)
			width = 0;
		if (ljust == 0)
			width = -width;
		if (width < 0) {
			if (*s == '-' && zfill == '0') {
				if(putc(*s++, iop) == EOF)
				    return EOF;
				else
				    n_written++;
				i--;
			}
			do
				if(putc(zfill, iop) == EOF)
				    return EOF;
				else
				    n_written++;
			while (++width != 0);
		}
		while (--i >= 0)
			if(putc(*s++, iop) == EOF)
			    return EOF;
			else
			    n_written++;
		while (width) {
			if(putc(zfill, iop) == EOF)
			    return EOF;
			else
			    n_written++;
			width--;
		}
	}
	return n_written;
}

#ifdef TEST
char b[128];
main()
{
	extern long rand();
	int i, prec;
	double val = 10.624624624624;

	for(i = 1; i < 11; i++)
	{
		_cvt(b, val, i, FFORMAT);
		printf("%f %2d %s (%.*f)\n", val, i, b, i, val);
	}
}
#ifndef ATARI_ST
char *itoa(i)
int i;
{
	static char x[32];
	sprintf(x, "%d", i);
	return x;
}
#endif
#endif
//E*O*F idoprint.c//

echo x - iscanf.c
cat > "iscanf.c" << '//E*O*F iscanf.c//'
#ifdef __RCS_ID__
static char rcsid[] = "$Header: /u5/mnx/gnu/lib/RCS/scanf.c,v 1.5 89/03/04 04:19:25 bammi Exp $";
#endif /* __RCS_ID__ */

/*
 * Log and Header added (03/03/89)
 *
 * $Log:	scanf.c,v $
 * Revision 1.5  89/03/04  04:19:25  bammi
 * Fourth release of Gcc Gnulib for MinixST (03/03/89)
 * 
 */

/* scanf - formatted input conversion	Author: Patrick van Kleef */

#define __SRC__

/*
 * - added %f,%e,%g
 * - [scanset] implementation wrote into format string, which is 
 *   obviously a no-no. Changed that real quick.
 * - added [0-9] style scansets
 *	++jrb bammi@dsrgsun.ces.cwru.edu
 *
 * 12/10/88 minor bugfix to accept floating #'s of the for .nnnn
 *	++jrb
 */


#include <stdio.h>


int scanf (format, args)
CONST char           *format;
#ifdef __GNUC__
unsigned long  args;
#else
unsigned        args;
#endif
{
    return _doscanf (0, stdin, format, &args);
}



int fscanf (fp, format, args)
FILE           *fp;
CONST char           *format;
#ifdef __GNUC__
unsigned long  args;
#else
unsigned        args;
#endif
{
    return _doscanf (0, fp, format, &args);
}


int sscanf (string, format, args)
CONST char           *string;		/* source of data */
CONST char           *format;		/* control string */
#ifdef __GNUC__
unsigned long  args;
#else
unsigned        args;
#endif
{
    return _doscanf (1, string, format, &args);
}


union ptr_union {
    char           *chr_p;
    unsigned int   *uint_p;
    unsigned long  *ulong_p;
#ifndef __INT_SCANF__
    float	       *float_p;
    double	       *double_p;
#endif
};

static int      ic;		/* the current character */
static char    *rnc_arg;	/* the string or the filepointer */
static          rnc_code;	/* 1 = read from string, else from FILE */




/* get the next character */

static void rnc ()
{
    if (rnc_code) {
	if (!(ic = *rnc_arg++))
	    ic = EOF;
    } else
	ic = getc ((FILE *) rnc_arg);
}



/*
 * unget the current character 
 */

static void ugc ()
{
    
    if (rnc_code)
	--rnc_arg;
    else
	ungetc (ic, (FILE *)rnc_arg);
}



/* [01234] style scanset */
static int scn1index(ch, string, endmarker)
char ch;
char *string, *endmarker;
{
    while (*string++ != ch) 
	if (string >= endmarker)
	    return 0;
    return 1;
}

static int scnindex(ch, string, endmarker)
char ch;
char *string, *endmarker;
{
    if(((endmarker - string) == 3) && (string[1] == '-'))
	/* [0-9] style scanset */
	return ((string[0] <= ch) &&  (ch <= string[2]));
    else
	return scn1index(ch, string, endmarker);
}



/*
 * this is cheaper than iswhite from <ctype.h> 
 */

static int iswhite (ch)
int             ch;
{
    
    return (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
}





static int isdigit (ch)
int             ch;
{
    return (ch >= '0' && ch <= '9');
}




static int __tolower (ch)
int             ch;
{
    if (ch >= 'A' && ch <= 'Z')
	ch = ch + 'a' - 'A';
    
    return ch;
}

#ifndef __INT_SCANF__
#ifdef __GNUC__
/* eval f * 10**p */
static double _fraise(f, p)
double f;
int p;
{
    if(p > 0)
	while(p--)
	    f *= 10.0;
    else
	while(p++)
	    f /= 10.0;
    return f;
}
#endif
#endif

/*
 * the routine that does the job 
 */

int _doscanf (code, funcarg, format, argp)
int             code;		/* function to get a character */
char           *funcarg;	/* an argument for the function */
char           *format;		/* the format control string */
union ptr_union *argp;		/* our argument list */
{
    int             done = 0;	/* number of items done */
    int             base;		/* conversion base */
    long            val;		/* an integer value */
    int             sign;		/* sign flag */
    int             do_assign;	/* assignment suppression flag */
    unsigned        width;		/* width of field */
    int             widflag;	/* width was specified */
    int             longflag;	/* true if long */
    int             done_some;	/* true if we have seen some data */
    int		reverse;	/* reverse the checking in [...] */
    char	       *endbracket;     /* position of the ] in format string */
#ifndef __INT_SCANF__
#ifdef __GNUC__
    double		fval;		/* a double value  */
#endif
#endif
    
    
    rnc_arg = funcarg;
    rnc_code = code;
    
    rnc ();			/* read the next character */
    
    if (ic == EOF) {
	done = EOF;
	goto quit;
    }
    
    while (1) {
	while (iswhite (*format))
	    ++format;	/* skip whitespace */
	if (!*format)
	    goto all_done;	/* end of format */
	if (ic < 0)
	    goto quit;	/* seen an error */
	if (*format != '%') {
	    while (iswhite (ic))
		rnc ();
	    if (ic != *format)
		goto all_done;
	    ++format;
	    rnc ();
	    ++done;
	    continue;
	}
	++format;
	do_assign = 1;
	if (*format == '*') {
	    ++format;
	    do_assign = 0;
	}
	if (isdigit (*format)) {
	    widflag = 1;
	    for (width = 0; isdigit (*format);)
		width = width * 10 + *format++ - '0';
	} else
	    widflag = 0;	/* no width spec */
	if (longflag = (__tolower (*format) == 'l'))
	    ++format;
	if (*format != 'c')
	    while (iswhite (ic))
		rnc ();
	done_some = 0;	/* nothing yet */
	switch (*format) {
	  case 'o':
	    base = 8;
	    goto decimal;
	  case 'u':
	  case 'd':
	    base = 10;
	    goto decimal;
	  case 'x':
	    base = 16;
	    if (((!widflag) || width >= 2) && ic == '0') {
		rnc ();
		if (__tolower (ic) == 'x') {
		    width -= 2;
		    done_some = 1;
		    rnc ();
		} else {
		    ugc ();
		    ic = '0';
		}
	    }
	  decimal:
	    val = 0L;	/* our result value */
	    sign = 0;	/* assume positive */
	    if (!widflag)
		width = 0xffff;	/* very wide */
	    if (width && ic == '+')
		rnc ();
	    else if (width && ic == '-') {
		sign = 1;
		rnc ();
	    }
	    while (width--) {
		if (isdigit (ic) && ic - '0' < base)
		    ic -= '0';
		else if (base == 16 && __tolower (ic) >= 'a' && __tolower (ic) <= 'f')
		    ic = 10 + __tolower (ic) - 'a';
		else
		    break;
		val = val * base + ic;
		rnc ();
		done_some = 1;
	    }
	    if (do_assign) {
		if (sign)
		    val = -val;
		if (longflag)
		    *(argp++)->ulong_p = (unsigned long) val;
		else
		    *(argp++)->uint_p = (unsigned) val;
	    }
	    if (done_some)
		++done;
	    else
		goto all_done;
	    break;
	  case 'c':
	    if (!widflag)
		width = 1;
	    while (width-- && ic >= 0) {
		if (do_assign)
		    *(argp)->chr_p++ = (char) ic;
		rnc ();
		done_some = 1;
	    }
	    if (do_assign)
		argp++;	/* done with this one */
	    if (done_some)
		++done;
	    break;
	  case 's':
	    if (!widflag)
		width = 0xffff;
	    while (width-- && !iswhite (ic) && ic > 0) {
		if (do_assign)
		    *(argp)->chr_p++ = (char) ic;
		rnc ();
		done_some = 1;
	    }
	    if (do_assign)		/* terminate the string */
		*(argp++)->chr_p = '\0';	
	    if (done_some)
		++done;
	    else
		goto all_done;
	    break;
	    
#ifndef __INT_SCANF__
#ifdef __GNUC__
	  case 'e':
	  case 'f':
	  case 'g':
	    fval = 0.0;	/* our result value */
	    sign = 0;	/* assume positive */
	    if (!widflag)
		width = 0xffff;	/* very wide */
	    if (width && ic == '+')
		rnc ();
	    else if (width && ic == '-') {
		sign = 1;
		rnc ();
	    }
	    while (width && isdigit(ic)) {
		width--;
		fval = fval * 10.0 + (ic - '0');
		rnc ();
		done_some = 1;
	    }
	    if(ic == '.')
	    {
		double factor = 1.0/10.0;
		rnc ();
		while (--width && isdigit(ic))
		{
		    fval = fval + ((ic - '0') * factor);
		    factor = factor/10.0;
		    done_some = 1;
		    rnc();
		}
	    }
	    if(sign)
		fval = -fval;
	    sign = 0;
	    if(((ic == 'E') || (ic == 'e')) && done_some)
	    {
		int pow = 0;
		rnc ();
		if((ic == '+') || (ic == '-'))
		{
		    if(ic == '-') sign = 1;
		    width--;
		    rnc();
		} 
		
		while(--width && isdigit(ic))
		{
		    pow = pow * 10 + (ic -'0');
		    rnc();
		}
		fval = _fraise(fval, (sign == 1)? -pow : pow);
	    }
	    if (do_assign) {
		if (longflag)
		    *(argp++)->double_p = fval;
		else
		    *(argp++)->float_p = (float) fval;
	    }
	    if (done_some)
		++done;
	    else
		goto all_done;
	    break;
#endif /* __GNUC__ */
#endif /* __INT_SCANF__ */

	  case '[':
	    if (!widflag)
		width = 0xffff;
	    
	    if ( *(++format) == '^' ) {
		reverse = 1;
		format++;
	    } else
		reverse = 0;
	    
	    endbracket = format;
	    while ( *endbracket != ']'  && *endbracket != '\0')
		endbracket++;
	    
	    if (!*endbracket)
		goto quit;
	    
	    while (width-- && !iswhite (ic) && ic > 0 && 
		   (scnindex(ic, format, endbracket) ^ reverse)) {
		if (do_assign)
		    *(argp)->chr_p++ = (char) ic;
		rnc ();
		done_some = 1;
	    }
	    
	    if (do_assign)		/* terminate the string */
		*(argp++)->chr_p = '\0';	
	    if (done_some)
		++done;
	    else
		goto all_done;
	    break;
	}		/* end switch */
	++format;
    }
  all_done:
    if (ic >= 0)
	ugc ();		/* restore the character */
  quit:
    return done;
}

#if 0
/* TEST ONLY */
main()
{
    int i, n;
    float x;
    char name[50];

    n = scanf("%d%f%s", &i, &x, name);
    printf("n = %d i = %d x = %f name = :%s:\n", n, i, x, name);
    /* input:  54.32E-1 thompson */
    /* output: n = 3 i = 25 x = 5.432000 name = :thompson: */
    
    n = scanf("%2d%f%*d %[0-9]", &i, &x, name);
    printf("n = %d i = %d x = %f name = :%s:\n", n, i, x, name);
    /* input:  56789 0123 56a72 */
    /* output: n = 4 i = 56 x = 789.000000 name = :56: */

    n = scanf("%s", name);
    printf("n = %d name = :%s:\n", n, name);
    /* output: n = 1 name = :a72: */

    n = scanf("%2d%f%*d %[0123456789]", &i, &x, name);
    printf("n = %d i = %d x = %f name = :%s:\n", n, i, x, name);
    /* input:  56789 0123 56a72 */
    /* output: n = 4 i = 56 x = 789.000000 name = :56: */
    /* 'a72' left over */

    n = scanf("%s", name);
    printf("n = %d name = :%s:\n", n, name);
    /* output: n = 1 name = :a72: */
}
#endif /* test only */
//E*O*F iscanf.c//

exit 0

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# job.cdif login.cdif main.cdif

echo x - job.cdif
cat > "job.cdif" << '//E*O*F job.cdif//'
*** org/job.c	Fri Mar 10 21:34:43 1989
--- st-gcc/job.c	Sat Mar 11 01:22:03 1989
***************
*** 94,100 ****
  #endif
    if (i)
    {
!     old->next=ptr=(struct job *) malloc (sizeof(struct job));
      if (ptr==0)
      {
        write(2,"Malloc failed. Cannot add report.\n",34);
--- 94,100 ----
  #endif
    if (i)
    {
!     old->next=ptr=(struct job *) malloc ((unsigned)(sizeof(struct job)));
      if (ptr==0)
      {
        write(2,"Malloc failed. Cannot add report.\n",34);
***************
*** 104,110 ****
    }
    else
    {
!     exitop=(struct job *) malloc (sizeof(struct job));
      if (exitop==0)
      {
        write(2,"Malloc failed. Cannot add report.\n",34);
--- 104,110 ----
    }
    else
    {
!     exitop=(struct job *) malloc ((unsigned)(sizeof(struct job)));
      if (exitop==0)
      {
        write(2,"Malloc failed. Cannot add report.\n",34);
***************
*** 116,127 ****
    ptr->jobnumber=newone->jobnumber;
    ptr->pid=newone->pid;
    ptr->status.w_status=newone->status.w_status;
!   ptr->name=(char *) malloc (strlen(newone->name)+1);
    if (ptr->name)
      (void) strcpy(ptr->name,newone->name);
    else
      write(2,"Malloc failed in addreport.\n",28);
!   ptr->dir=(char *) malloc (strlen(newone->dir)+1);
    if (ptr->dir)
      (void) strcpy(ptr->dir,newone->dir);
    else
--- 116,127 ----
    ptr->jobnumber=newone->jobnumber;
    ptr->pid=newone->pid;
    ptr->status.w_status=newone->status.w_status;
!   ptr->name=(char *) malloc ((unsigned)(strlen(newone->name)+1));
    if (ptr->name)
      (void) strcpy(ptr->name,newone->name);
    else
      write(2,"Malloc failed in addreport.\n",28);
!   ptr->dir=(char *) malloc ((unsigned)(strlen(newone->dir)+1));
    if (ptr->dir)
      (void) strcpy(ptr->dir,newone->dir);
    else
***************
*** 132,141 ****
--- 132,145 ----
  #endif
  }
  
+ #ifdef __STDC__
+ int addjob(int pid, char *name, int outfd, bool bckgnd)
+ #else
  int addjob(pid,name,outfd,bckgnd)
    int pid,outfd;
    char *name;
    bool bckgnd;/* this isn't used yet */
+ #endif
  {
    int jobno,diff=(-1);
  #ifdef UCB
***************
*** 148,154 ****
    if (diff<0)
      if (jobno!=1)			/* insertion between old and ptr */
      {
!       new=(struct job *) malloc (sizeof(struct job));
        if (new==0)
        {
  	write(2,"Malloc failed. Cannot add job.\n",31);
--- 152,158 ----
    if (diff<0)
      if (jobno!=1)			/* insertion between old and ptr */
      {
!       new=(struct job *) malloc ((unsigned)(sizeof(struct job)));
        if (new==0)
        {
  	write(2,"Malloc failed. Cannot add job.\n",31);
***************
*** 160,166 ****
      }
      else			/* insertion before jtop */
      {
!       old=(struct job *) malloc (sizeof(struct job));
        if (old==0)
        {
  	write(2,"Malloc failed. Cannot add job.\n",31);
--- 164,170 ----
      }
      else			/* insertion before jtop */
      {
!       old=(struct job *) malloc ((unsigned)(sizeof(struct job)));
        if (old==0)
        {
  	write(2,"Malloc failed. Cannot add job.\n",31);
***************
*** 171,177 ****
      }
    else					/* append at end */
    {
!     ptr=(struct job *) malloc (sizeof(struct job));
      if (ptr==0)
      {
        write(2,"Malloc failed. Cannot add job.\n",31);
--- 175,181 ----
      }
    else					/* append at end */
    {
!     ptr=(struct job *) malloc ((unsigned)(sizeof(struct job)));
      if (ptr==0)
      {
        write(2,"Malloc failed. Cannot add job.\n",31);
***************
*** 182,188 ****
    }
    ptr->jobnumber=jobno;
    ptr->pid=pid;
!   ptr->name=(char *) malloc (strlen(name)+1);
    if (ptr->name)
      (void) strcpy(ptr->name,name);
    else
--- 186,192 ----
    }
    ptr->jobnumber=jobno;
    ptr->pid=pid;
!   ptr->name=(char *) malloc ((unsigned)(strlen(name)+1));
    if (ptr->name)
      (void) strcpy(ptr->name,name);
    else
***************
*** 190,196 ****
    ptr->status.w_status=0;
    if (getwd(execdir))
    {
!     ptr->dir=(char *) malloc (strlen(execdir)+1);
      if (ptr->dir)
        (void) strcpy(ptr->dir,execdir);
      else
--- 194,200 ----
    ptr->status.w_status=0;
    if (getwd(execdir))
    {
!     ptr->dir=(char *) malloc ((unsigned)(strlen(execdir)+1));
      if (ptr->dir)
        (void) strcpy(ptr->dir,execdir);
      else
//E*O*F job.cdif//

echo x - login.cdif
cat > "login.cdif" << '//E*O*F login.cdif//'
*** login.c.B	Thu Oct 19 03:30:24 1988
--- login.c	Thu Mar 11 06:06:49 1989
***************
*** 55,61 ****
  		setgid (pwd->pw_gid);
  		setuid (pwd->pw_uid);
  		chdir (pwd->pw_dir);
! 		strcpy(pwd->pw_dir, home+5);
  		if (pwd->pw_shell) {
  			execle(pwd->pw_shell, "-", (char *) 0, env);
  		}
--- 55,62 ----
  		setgid (pwd->pw_gid);
  		setuid (pwd->pw_uid);
  		chdir (pwd->pw_dir);
! /*		strcpy(pwd->pw_dir, home+5); --bug */
! 		strcpy(home+5, pwd->pw_dir);	/* and fix ++jrb */
  		if (pwd->pw_shell) {
  			execle(pwd->pw_shell, "-", (char *) 0, env);
  		}
//E*O*F login.cdif//

echo x - main.cdif
cat > "main.cdif" << '//E*O*F main.cdif//'
*** org/main.c	Fri Mar 10 21:34:44 1989
--- st-gcc/main.c	Sat Mar 11 03:13:30 1989
***************
*** 21,27 ****
  
  void printime()
  {
!   long clock, *time();
    struct tm *t, *localtime();
  
    time(&clock);
--- 21,27 ----
  
  void printime()
  {
!   long clock, time();
    struct tm *t, *localtime();
  
    time(&clock);
***************
*** 270,276 ****
  
  /* setup terminal with ioctl calls */
  
!   termod=(struct sgttyb *) malloc (sizeof(struct sgttyb));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in setup");
    termod->sg_flags |= CBREAK;		/* cbreak mode to get each char */
--- 270,276 ----
  
  /* setup terminal with ioctl calls */
  
!   termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb)));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in setup");
    termod->sg_flags |= CBREAK;		/* cbreak mode to get each char */
***************
*** 277,283 ****
    termod->sg_flags &= (~ECHO);		/* do not echo chars to screen */
    if (ioctl(0,TIOCSETP,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc (sizeof(struct tchars));
    if (ioctl(0,TIOCGETC,setsigc))		/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=(UNDEF);		/* no interrupt or quitting */
--- 277,283 ----
    termod->sg_flags &= (~ECHO);		/* do not echo chars to screen */
    if (ioctl(0,TIOCSETP,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars)));
    if (ioctl(0,TIOCGETC,setsigc))		/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=(UNDEF);		/* no interrupt or quitting */
***************
*** 300,306 ****
  /* now set up signals */
  
    for (i=1;i<=NUMSIG;i++)
!     signal(i,SIG_IGN);
    signal(SIGQUIT,SIG_DFL); /* allow while debugging */
  /*signal(SIGQUIT,SIG_IGN);*/
    signal(SIGHUP,SIG_DFL);
--- 300,309 ----
  /* now set up signals */
  
    for (i=1;i<=NUMSIG;i++)
!   {
!       if ( i != SIGKILL )  /* SIGKILL cannot be caught or ignored */
! 	  signal(i,SIG_IGN);
!   }
    signal(SIGQUIT,SIG_DFL); /* allow while debugging */
  /*signal(SIGQUIT,SIG_IGN);*/
    signal(SIGHUP,SIG_DFL);
***************
*** 312,319 ****
  /* This catches all the serious errors from within the shell, ILL -> SYS */
  /* If any program uses these, then the programmer should be shot. */
    for (i=4;i<=12;i++)
!     signal(i,graceful);
! 
  #ifndef MINIX
    signal(SIGCHLD,checkjobs);
  #endif
--- 315,324 ----
  /* This catches all the serious errors from within the shell, ILL -> SYS */
  /* If any program uses these, then the programmer should be shot. */
    for (i=4;i<=12;i++)
!   {
!       if (i != SIGKILL) /* SIGKILL cannot be caught or ignored */
! 	  signal(i,graceful);
!   }
  #ifndef MINIX
    signal(SIGCHLD,checkjobs);
  #endif
***************
*** 345,351 ****
  write(2,"Resetting shell\n",16);
  #endif
  
!   termod=(struct sgttyb *) malloc (sizeof(struct sgttyb));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in resetsh");
    termod->sg_flags |= CBREAK;		/* cbreak mode to get each char */
--- 350,356 ----
  write(2,"Resetting shell\n",16);
  #endif
  
!   termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb)));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in resetsh");
    termod->sg_flags |= CBREAK;		/* cbreak mode to get each char */
***************
*** 352,358 ****
    termod->sg_flags &= (~ECHO);		/* do not echo chars to screen */
    if (ioctl(0,TIOCSETN,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc (sizeof(struct tchars));
    if (ioctl(0,TIOCGETC,setsigc))	/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=(UNDEF);		/* no interrupt or quitting */
--- 357,363 ----
    termod->sg_flags &= (~ECHO);		/* do not echo chars to screen */
    if (ioctl(0,TIOCSETN,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars)));
    if (ioctl(0,TIOCGETC,setsigc))	/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=(UNDEF);		/* no interrupt or quitting */
***************
*** 401,407 ****
  fprintf(stderr,"Setdown terminal\n");
  #endif
  
!   termod=(struct sgttyb *) malloc (sizeof(struct sgttyb));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in setdown");
    termod->sg_flags &= (~CBREAK);	/* reset cooked mode */
--- 406,412 ----
  fprintf(stderr,"Setdown terminal\n");
  #endif
  
!   termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb)));
    if (ioctl(0,TIOCGETP,termod))		/* get the sgttyb struct */
      perror("ioctl in setdown");
    termod->sg_flags &= (~CBREAK);	/* reset cooked mode */
***************
*** 408,414 ****
    termod->sg_flags |= ECHO;		/* echo chars to screen */
    if (ioctl(0,TIOCSETP,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc (sizeof(struct tchars));
    if (ioctl(0,TIOCGETC,setsigc))	/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=3;		/* set interrupt and quitting */
--- 413,419 ----
    termod->sg_flags |= ECHO;		/* echo chars to screen */
    if (ioctl(0,TIOCSETP,termod))		/* put it back, modified */
      perror("ioctl");
!   setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars)));
    if (ioctl(0,TIOCGETC,setsigc))	/* get the tchars struct */
      perror("ioctl");
    setsigc->t_intrc=3;		/* set interrupt and quitting */
***************
*** 560,567 ****
        while (act!=ENDLN && act!=ERRER)
        {
  	retval=0;
! 	act=intercom(line,&pos,&pid,FALSE,NULL,1);	/* call intercom with fromfile set */
  	for (i=3;i<=20;i++) if (i!=fileno(finp)) close(i);
  	if (pid && act!=BCKGND)
  	  retval=waitfor(pid);
  	if (!disable_auto && act==ERRER) exit(1);	/* exit on shell syntax error */
--- 565,585 ----
        while (act!=ENDLN && act!=ERRER)
        {
  	retval=0;
! #if 0
! 	/* Was this: appears to be totally wrong */
! 	act=intercom(line,&pos,&pid,FALSE,NULL,1);
! #else
! 	act=intercom(line,&pos,&pid,&i ,FALSE,1);
!  /* call intercom with fromfile  set -- ?? the big question is do we */
!  /* really ignore the value of outpfd - i dunno., could'nt make out, */
!  /* so i just put in &i, otherwise obviusly this call causes bombs in */
!  /* intercom() */
! #endif
! #if 0
  	for (i=3;i<=20;i++) if (i!=fileno(finp)) close(i);
+ #else
+ 	for (i=3;i<=NFILES;i++) if (i!=fileno(finp)) close(i);
+ #endif
  	if (pid && act!=BCKGND)
  	  retval=waitfor(pid);
  	if (!disable_auto && act==ERRER) exit(1);	/* exit on shell syntax error */
***************
*** 585,590 ****
--- 603,610 ----
  void shinit()
  {
    extern void loadenv(),vset(),venvprint();
+   extern int O_faststart;
+ 
  #ifndef MINIX
    extern void hashpath();
    extern bool hashed;
***************
*** 733,740 ****
        while (act!=ENDLN && act!=ERRER)
        {
  	retval=0;
! 	act=intercom(line,&pos,&pid,FALSE,NULL,0);	/* call intercom with fromfile not set */
  	for (i=3;i<=20;i++) close(i);
  	if (pid && act!=BCKGND)
  	  retval=waitfor(pid);
  #ifndef MINIX
--- 753,769 ----
        while (act!=ENDLN && act!=ERRER)
        {
  	retval=0;
! #if 0
! 	/* WAS: same intercom problem as in file() here */
! 	act=intercom(line,&pos,&pid,FALSE,NULL,0);
! #else
! 	act=intercom(line,&pos,&pid, &i, FALSE,0);	/* call intercom with fromfile not set */
! #endif
! #if 0
  	for (i=3;i<=20;i++) close(i);
+ #else
+ 	for (i=3;i<=NFILES;i++) close(i);
+ #endif
  	if (pid && act!=BCKGND)
  	  retval=waitfor(pid);
  #ifndef MINIX
***************
*** 765,771 ****
    char *argv[];
  {
    extern SYM_T intercom();
!   extern int O_echoexp,meta();
    SYM_T act;
    char line[MAXLL];
    int i,pos,retval,pid;
--- 794,800 ----
    char *argv[];
  {
    extern SYM_T intercom();
!   extern int O_echoexp,O_exiterror,meta();
    SYM_T act;
    char line[MAXLL];
    int i,pos,retval,pid;
***************
*** 790,797 ****
--- 819,835 ----
    while (act!=ENDLN && act!=ERRER)
    {
      retval=0;
+ #if 0
+     /* WAS: sample problem */
      act=intercom(line,&pos,&pid,FALSE,NULL,0);	/* call intercom with fromfile not set */
+ #else
+     act=intercom(line,&pos,&pid, &i,FALSE,0);	/* call intercom with fromfile not set */
+ #endif
+ #if 0
      for (i=3;i<=20;i++) close(i);
+ #else
+     for (i=3;i<=NFILES;i++) close(i);
+ #endif
      if (pid && act!=BCKGND)
        retval=waitfor(pid);
  #ifndef MINIX
***************
*** 816,822 ****
    extern void copyenv();
    extern char *invokename,**arguments,**environ,*newenv[];
    extern FILE *zin,*zout;
!   extern int fromfile,numargs;
    char filename[MAXFNL];
    int argp;
  
--- 854,860 ----
    extern void copyenv();
    extern char *invokename,**arguments,**environ,*newenv[];
    extern FILE *zin,*zout;
!   extern int fromfile,numargs, O_execstring;
    char filename[MAXFNL];
    int argp;
//E*O*F main.cdif//

exit 0

wtoomey@gara.une.oz (Warren Toomey) (03/27/89)

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# meta.cdif parse.cdif readme.st var.cdif

echo x - meta.cdif
cat > "meta.cdif" << '//E*O*F meta.cdif//'
*** org/meta.c	Fri Mar 10 21:34:46 1989
--- st-gcc/meta.c	Sat Mar 11 05:52:44 1989
***************
*** 16,21 ****
--- 16,27 ----
  bool Curly,Pattern,Shriek,Bquote,Tilde,Caret,Dollar;
  char *matchers[MAXARG];
  int mindex;
+ /* forward decl */
+ #ifndef __STDC__
+ static int matchdir();
+ #else
+ static int matchdir(char *directory, char *pattern);
+ #endif
  
  static
  void prefilter(line)
***************
*** 610,616 ****
        strcat(where,"/");
      }
      strcat(where,string);
!     matchers[mindex]=(char *) malloc (strlen(where)+1);
      strcpy(matchers[mindex++],where);
      return(OK);
    }
--- 616,622 ----
        strcat(where,"/");
      }
      strcat(where,string);
!     matchers[mindex]=(char *) malloc ((unsigned)(strlen(where)+1));
      strcpy(matchers[mindex++],where);
      return(OK);
    }
***************
*** 703,709 ****
      mindex=0;nopat=0;
      if (!(err=matchdir(dir,word))) m_err=OK;
      else lasterr=err;		/* keep record of last error */
!     qsort((char *)matchers,mindex,sizeof(char *),cmp);
      for (k=0;k<mindex;k++)
      {
        strcat(newline," ");
--- 709,715 ----
      mindex=0;nopat=0;
      if (!(err=matchdir(dir,word))) m_err=OK;
      else lasterr=err;		/* keep record of last error */
!     qsort((char *)matchers,mindex,(int)sizeof(char *),cmp);
      for (k=0;k<mindex;k++)
      {
        strcat(newline," ");
***************
*** 794,800 ****
      }
  }
  
! isanum(string)
    char *string;
  {
    int i;
--- 800,806 ----
      }
  }
  
! int isanum(string)
    char *string;
  {
    int i;
***************
*** 934,940 ****
  			      break;
  			    }
  			    if (getname(line,&i,username)==FALSE)
! 			      strncpy(username,getenv("USER"),USERNL);
  			    i--;	/* put back the pointer */
  			    if ((passwdp=fopen(PASSWD,"r"))==NULL)
  			    {
--- 940,962 ----
  			      break;
  			    }
  			    if (getname(line,&i,username)==FALSE)
! #if 0
! /* WAS:			      strncpy(username,getenv("USER"),USERNL); */
! #else
! 			    { /* on the ST $USER is not set! so i */
! 			      /* discov'ed this little bug */
! 				extern char *getlogin(), *getenv();
! 				register char *p;
! 				if((p = getenv("USER")) == (char *)NULL)
! 				    if((p = getlogin()) == (char *)NULL)
! 				    {
! 					fprintf(stderr, "Cannot determine USER\n");
! 					return(TL_ERR);
! 				    }
! 				strncpy(username,p ,USERNL);
! 			    }
! #endif
! 				
  			    i--;	/* put back the pointer */
  			    if ((passwdp=fopen(PASSWD,"r"))==NULL)
  			    {
***************
*** 958,970 ****
  				else
  				{
  				  fprintf(stderr,"Bad passwd entry for %s.\n",username);
! 				  close(passwdp);
  				  return(TL_ERR);
  				}
  				break;
  			      }
  			    }
! 			    close(passwdp);
  /* This test is a repeat of the one above but will give a different error
     message if we can't find a matching username */
  			    if (colon!=5)
--- 980,994 ----
  				else
  				{
  				  fprintf(stderr,"Bad passwd entry for %s.\n",username);
! /*				  close(passwdp); */
! 				  fclose(passwdp);
  				  return(TL_ERR);
  				}
  				break;
  			      }
  			    }
! /*			    close(passwdp); */
! 			    fclose(passwdp);
  /* This test is a repeat of the one above but will give a different error
     message if we can't find a matching username */
  			    if (colon!=5)
//E*O*F meta.cdif//

echo x - parse.cdif
cat > "parse.cdif" << '//E*O*F parse.cdif//'
*** org/parse.c	Fri Mar 10 21:34:48 1989
--- st-gcc/parse.c	Sat Mar 11 00:06:52 1989
***************
*** 11,21 ****
--- 11,25 ----
  extern FILE *zin,*zout,*fopen();
  extern int lenprompt,curr_hist,wid;
  
+ #ifdef __STDC__
+ bool getword(char *line, int *pos, char *word, bool allow_slash_or_bracket)
+ #else
  bool getword(line,pos,word,allow_slash_or_bracket)
    char *line,*word;
    int *pos;
    bool allow_slash_or_bracket;
  /* if true then / and [ are not word delimiters */
+ #endif
  {
    int inword=0,l=1,i=0;
  
***************
*** 52,61 ****
--- 56,69 ----
    return(TRUE);
  }
  
+ #ifdef __STDC__
+ SYM_T retsym(char *line, char *word, int *pos, bool allow_colon)
+ #else
  SYM_T retsym(line,word,pos,allow_colon)
    char *line,*word;
    int *pos;
    bool allow_colon;
+ #endif
  {
    /*extern char *vget(),*vwget();*/
    char c,vname[VARNL];
***************
*** 190,200 ****
--- 198,213 ----
    }
  }
  
+ #ifdef __STDC__
+ SYM_T intercom(char *line, int *pos, int *wpid, int *outpfd,
+ 	       bool pipedin, int fromfile) 
+ #else
  SYM_T intercom(line,pos,wpid,outpfd,pipedin,fromfile)
    char *line;
    int *pos,*wpid,*outpfd;	/* pointers so we can change the value */
    bool pipedin;
    int fromfile;
+ #endif
  {
    char word[MAXWL],				/* max word length */
        ifile[MAXFNL],ofile[MAXFNL],efile[MAXFNL],	/* max filename length */
***************
*** 257,263 ****
  		     write(2,"Too many arguments.\n",20);
  		     return(ERRER);
  		   }
! 		   if ((argv[argc]=(char *) malloc (strlen(word)+1))==NULL)
  		   {
  		     write(2,"Cannot allocate any memory for arguments.\n",42);
  		     return(ERRER);
--- 270,277 ----
  		     write(2,"Too many arguments.\n",20);
  		     return(ERRER);
  		   }
! 		   if ((argv[argc]=(char *) malloc
! 			((unsigned)(strlen(word)+1)))==NULL)
  		   {
  		     write(2,"Cannot allocate any memory for arguments.\n",42);
  		     return(ERRER);
//E*O*F parse.cdif//

echo x - readme.st
cat > "readme.st" << '//E*O*F readme.st//'
Thanks to Warren Toomey	(wtoomey@gara.une.oz) && Callum Gibson
for posting Clam (a much needed shell, sh drives me up the wall).

Here are diffs and additional files to build clam for atariST minix
I only compiled with Gnu gcc, others may want to try  ACK cc, but I
believe that I caught most of the stuff required (see second note below)

NOTES:
	- gcc users *must* ensure that they have <std.h> installed
		(distributed with gcc V1.34)
	  if <std.h> is not included (<stdio.h> does this for you)
	  then the code is missing many essential extern declarations
	  that will lead to pointer/integer problems. If you are
	  adventurous enough to use ACK, then you will probably have
	  to determine all the extern declarations required.

	- if you want to make Clam your login shell, then the diff
	  enclosed below in login.cdif must be applied to
	  /usr/src/commands/login.c, and login recompiled and
	  installed in /bin/login. This diff fixes the bug where
	  login was not setting the environment var HOME properly.
	  If you do not do this, you'll end up witha signal 6, so
	  you know what you did wrong.

Contents:
	readme.st	this file
	makefile.gcc	makefile for minixST gcc

	alias.cdif
	builtin.cdif
	clex.cdif
	comlined.cdif
	cx.cdif
	exec.cdif
	hash.cdif	Diffs to original Clam
	header.hdif
	hist.cdif
	job.cdif
	main.cdif
	meta.cdif
	parse.cdif
	var.cdif
	
	idoprintf.c	additional files required for gcc only
	iscanf.c

	login.cdif	diffs to minixST /usr/src/commands/login.c

							enjoy,
--
usenet: {decvax,sun}!cwjcc!dsrgsun!bammi	jwahar r. bammi
csnet:       bammi@dsrgsun.ces.CWRU.edu
arpa:        bammi@dsrgsun.ces.CWRU.edu
compuServe:  71515,155
//E*O*F readme.st//

echo x - var.cdif
cat > "var.cdif" << '//E*O*F var.cdif//'
*** org/var.c	Fri Mar 10 21:34:49 1989
--- st-gcc/var.c	Fri Mar 10 21:44:47 1989
***************
*** 111,122 ****
      for (i=0;environ[i];i++)
        if (!strncmp(environ[i],"PATH=",5))
        {
! 	environ[i]=(char *) realloc (environ[i],strlen(env)+1);
  	break;
        }
      if (!environ[i])			/* if we didn't find an existing one */
      {
!       environ[i]=(char *) malloc (strlen(env)+1);
        environ[i+1]=0;
      }
      strcpy(environ[i],env);
--- 111,122 ----
      for (i=0;environ[i];i++)
        if (!strncmp(environ[i],"PATH=",5))
        {
! 	environ[i]=(char *) realloc (environ[i],(unsigned)(strlen(env)+1));
  	break;
        }
      if (!environ[i])			/* if we didn't find an existing one */
      {
!       environ[i]=(char *) malloc ((unsigned)(strlen(env)+1));
        environ[i+1]=0;
      }
      strcpy(environ[i],env);
***************
*** 158,164 ****
  #ifdef DEBUG
  fprintf(stderr,"strncmp matched\n");
  #endif
! 	environ[i]=(char *) realloc (environ[i],strlen(env)+1);
  	if (environ[i]==NULL)
  	{
  	  fprintf(stderr,"vname %s env %s i %d\n",vname,env,i);
--- 158,164 ----
  #ifdef DEBUG
  fprintf(stderr,"strncmp matched\n");
  #endif
! 	environ[i]=(char *) realloc (environ[i],(unsigned)(strlen(env)+1));
  	if (environ[i]==NULL)
  	{
  	  fprintf(stderr,"vname %s env %s i %d\n",vname,env,i);
***************
*** 174,180 ****
  #ifdef DEBUG
  fprintf(stderr,"Making new environ for %s environ[%d]\n",env,i);
  #endif
!       environ[i]=(char *) malloc (strlen(env)+1);
        environ[i+1]=0;
      }
      strcpy(environ[i],env);
--- 174,180 ----
  #ifdef DEBUG
  fprintf(stderr,"Making new environ for %s environ[%d]\n",env,i);
  #endif
!       environ[i]=(char *) malloc ((unsigned)(strlen(env)+1));
        environ[i+1]=0;
      }
      strcpy(environ[i],env);
***************
*** 232,253 ****
    if (lex<0)		/* value doesn't exist, make new variable and insert */
      if (i)		/* normal insertion between old and ptr */
      {
!       new=(struct vlist *) malloc (sizeof(struct vlist));
        old->next=new;
        new->next=ptr;
!       new->var=(char *) malloc (strlen(vname)+1);
        strcpy(new->var,vname);
!       new->val=(char *) malloc (strlen(vval)+1);
        strcpy(new->val,vval);
        new->exported=FALSE;
      }
      else		/* insertion before top, old=ptr=top still. */
      {
!       old=(struct vlist *) malloc (sizeof(struct vlist));
        old->next=top;
!       old->var=(char *) malloc (strlen(vname)+1);
        strcpy(old->var,vname);
!       old->val=(char *) malloc (strlen(vval)+1);
        strcpy(old->val,vval);
        old->exported=FALSE;
        top=old;		/* and finally assign new top */
--- 232,253 ----
    if (lex<0)		/* value doesn't exist, make new variable and insert */
      if (i)		/* normal insertion between old and ptr */
      {
!       new=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist)));
        old->next=new;
        new->next=ptr;
!       new->var=(char *) malloc ((unsigned)(strlen(vname)+1));
        strcpy(new->var,vname);
!       new->val=(char *) malloc ((unsigned)(strlen(vval)+1));
        strcpy(new->val,vval);
        new->exported=FALSE;
      }
      else		/* insertion before top, old=ptr=top still. */
      {
!       old=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist)));
        old->next=top;
!       old->var=(char *) malloc ((unsigned)(strlen(vname)+1));
        strcpy(old->var,vname);
!       old->val=(char *) malloc ((unsigned)(strlen(vval)+1));
        strcpy(old->val,vval);
        old->exported=FALSE;
        top=old;		/* and finally assign new top */
***************
*** 255,271 ****
    else
      if (lex==0)		/* variable already exists, just change value */
      {
!       ptr->val=(char *) realloc (ptr->val,strlen(vval)+1);
        strcpy(ptr->val,vval);
      }
      else		/* value doesn't exist, make new variable and append */
      {
!       new=(struct vlist *) malloc (sizeof(struct vlist));
        new->next=0;
        old->next=new;
!       new->var=(char *) malloc (strlen(vname)+1);
        strcpy(new->var,vname);
!       new->val=(char *) malloc (strlen(vval)+1);
        strcpy(new->val,vval);
      }
  
--- 255,271 ----
    else
      if (lex==0)		/* variable already exists, just change value */
      {
!       ptr->val=(char *) realloc (ptr->val,(unsigned)(strlen(vval)+1));
        strcpy(ptr->val,vval);
      }
      else		/* value doesn't exist, make new variable and append */
      {
!       new=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist)));
        new->next=0;
        old->next=new;
!       new->var=(char *) malloc ((unsigned)(strlen(vname)+1));
        strcpy(new->var,vname);
!       new->val=(char *) malloc ((unsigned)(strlen(vval)+1));
        strcpy(new->val,vval);
      }
  
***************
*** 347,353 ****
    if (vget(vname)!=(char *)UNDEF)
    {
      l=strlen(vget(vname));
!     newval=(char *) malloc (l+strlen(vval)+1);
      sprintf(newval,"%s%s",vget(vname),vval);
      vset(vname,newval);
      free(newval);
--- 347,353 ----
    if (vget(vname)!=(char *)UNDEF)
    {
      l=strlen(vget(vname));
!     newval=(char *) malloc ((unsigned)(l+strlen(vval)+1));
      sprintf(newval,"%s%s",vget(vname),vval);
      vset(vname,newval);
      free(newval);
***************
*** 434,440 ****
  
    for (i=0;envp[i];i++)
    {
!     newenv[i]=(char *) malloc (strlen(envp[i])+1);
      (void) strcpy(newenv[i],envp[i]);
    }
    newenv[i]=0;
--- 434,440 ----
  
    for (i=0;envp[i];i++)
    {
!     newenv[i]=(char *) malloc ((unsigned)(strlen(envp[i])+1));
      (void) strcpy(newenv[i],envp[i]);
    }
    newenv[i]=0;
//E*O*F var.cdif//

exit 0