Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-lcc!lll-winken!uunet!munnari!gwydir!gara!wtoomey From: wtoomey@gara.une.oz (Warren Toomey) Newsgroups: comp.os.minix Subject: Official Patch #1 to Clam (1 of 5) Message-ID: <611@gara.une.oz> Date: 27 Mar 89 04:27:04 GMT Organization: University of New England, Armidale, Australia Lines: 705 # 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