Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!purdue!ames!uhccux!munnari.oz.au!murtoa.cs.mu.oz.au!gwydir!gara!wtoomey From: wtoomey@gara.une.oz (Warren Toomey) Newsgroups: comp.os.minix Subject: Official Clam1.3 Patch#1 (1 of 3) Message-ID: <1101@gara.une.oz> Date: 24 Aug 89 02:16:43 GMT Organization: University of New England, Armidale, Australia Lines: 566 # 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: # Makefile.dif clex.cdif exec.cdif hash.cdif main.cdif meta.cdif var.cdif echo x - Makefile.dif cat > "Makefile.dif" << '//E*O*F Makefile.dif//' *** Makefile Thu Aug 24 11:29:53 1989 --- ../New/Makefile Thu Aug 24 11:39:22 1989 *************** *** 53,60 **** # compiler, try the previous section. I don't guarantee this will work # with Gnu C either, as I don't have Gnu to test it with. #DEFINES=-DMINIX -DATARI_ST ! #CLIB=-ltermcap -ldir ! clam : alias.$(O) builtin1.$(O) builtin2.$(O) clex.$(O) comlined.$(O) cx.$(O) exec.$(O) file.$(O) global.$(O) hash.$(O) hist.$(O) job.$(O) main.$(O) meta.$(O) parse.$(O) var.$(O) $(CC) $(CFLAGS) alias.$(O) builtin1.$(O) builtin2.$(O) clex.$(O) comlined.$(O) cx.$(O) exec.$(O) file.$(O) global.$(O) hash.$(O) hist.$(O) job.$(O) main.$(O) meta.$(O) parse.$(O) var.$(O) -o clam $(CLIB) --- 53,59 ---- # compiler, try the previous section. I don't guarantee this will work # with Gnu C either, as I don't have Gnu to test it with. #DEFINES=-DMINIX -DATARI_ST ! #CLIB= -ldir32 -liio32 -s -z clam : alias.$(O) builtin1.$(O) builtin2.$(O) clex.$(O) comlined.$(O) cx.$(O) exec.$(O) file.$(O) global.$(O) hash.$(O) hist.$(O) job.$(O) main.$(O) meta.$(O) parse.$(O) var.$(O) $(CC) $(CFLAGS) alias.$(O) builtin1.$(O) builtin2.$(O) clex.$(O) comlined.$(O) cx.$(O) exec.$(O) file.$(O) global.$(O) hash.$(O) hist.$(O) job.$(O) main.$(O) meta.$(O) parse.$(O) var.$(O) -o clam $(CLIB) //E*O*F Makefile.dif// echo x - clex.cdif cat > "clex.cdif" << '//E*O*F clex.cdif//' *** clex.c Thu Aug 24 11:30:10 1989 --- ../New/clex.c Thu Aug 24 11:26:48 1989 *************** *** 660,666 **** --- 660,671 ---- } if (index) /* have we found any ?? */ { + #ifdef __GNUC__ + qsort((char *)carray,(unsigned long)index, + (unsigned long)(sizeof(struct candidates_2)),compare); + #else qsort((char *)carray,index,(int)(sizeof(struct candidates_2)),compare); + #endif colprint(carray,index,maxlength); /* free up the space */ for (index--;index>=0;index--) //E*O*F clex.cdif// echo x - exec.cdif cat > "exec.cdif" << '//E*O*F exec.cdif//' *** exec.c Thu Aug 24 11:30:18 1989 --- ../New/exec.c Thu Aug 24 11:27:02 1989 *************** *** 380,400 **** fprintf(stderr,"call executable\n"); #endif errno=0; ! if (executable(name,NULL,1)==FALSE) { - if (errno!=ENOENT) - exist=TRUE; - hashval++; - hashval%=HSHSIZ; - continue; - } - else - { if (times==0) hits++; /* found it first go */ else misses++; /* had a collision */ strcpy(fullpathname,hasharray[hashval].name); return(FOUND); } } #ifdef DEBUG fprintf(stderr,"Not rejected by . checking for alias or builtin.\n"); --- 380,393 ---- fprintf(stderr,"call executable\n"); #endif errno=0; ! if (executable(name,NULL,1)==TRUE) { if (times==0) hits++; /* found it first go */ else misses++; /* had a collision */ strcpy(fullpathname,hasharray[hashval].name); return(FOUND); } + /* otherwise we just fall through and do the other testing */ } #ifdef DEBUG fprintf(stderr,"Not rejected by . checking for alias or builtin.\n"); *************** *** 401,406 **** --- 394,402 ---- #endif if (pos=(hasharray[hashval].flag&EXTYPE)) { + #ifdef DEBUG + fprintf(stderr,"pos is %d\n",pos); + #endif if (pos==ALIASEX) { for (i=0;i "hash.cdif" << '//E*O*F hash.cdif//' *** hash.c Thu Aug 24 11:30:15 1989 --- ../New/hash.c Thu Aug 24 11:26:49 1989 *************** *** 53,66 **** char fpn[MAXWL]; if (nojoin) ! stat(dir,&buf); else { sprintf(fpn,"%s/%s",dir,entname); ! stat(fpn,&buf); } if (((buf.st_mode & S_IFMT)==S_IFREG) && (buf.st_mode & 0111)) return(TRUE); return(FALSE); } --- 53,82 ---- char fpn[MAXWL]; if (nojoin) ! { ! #ifdef DEBUG ! fprintf(stderr,"ex f1\n"); ! #endif ! if (stat(dir,&buf)) return(FALSE); ! } else { + #ifdef DEBUG + fprintf(stderr,"ex f2\n"); + #endif sprintf(fpn,"%s/%s",dir,entname); ! if (stat(fpn,&buf)) return(FALSE); } if (((buf.st_mode & S_IFMT)==S_IFREG) && (buf.st_mode & 0111)) + { + #ifdef DEBUG + fprintf(stderr,"ex s\n"); + #endif return(TRUE); + } + #ifdef DEBUG + fprintf(stderr,"ex f3\n"); + #endif return(FALSE); } //E*O*F hash.cdif// echo x - main.cdif cat > "main.cdif" << '//E*O*F main.cdif//' *** main.c Thu Aug 24 11:30:33 1989 --- ../New/main.c Thu Aug 24 11:27:02 1989 *************** *** 730,736 **** { extern SYM_T intercom(); extern bool getline(),getpipeline(); ! extern void insert(),(*charfn)(),(*ptif)(); extern int loadline,O_echoexp,O_exiterror,meta_1(),meta_2(), waitfor(); extern char saveline[]; --- 730,736 ---- { extern SYM_T intercom(); extern bool getline(),getpipeline(); ! extern void reportjobs(),insert(),(*charfn)(),(*ptif)(); extern int loadline,O_echoexp,O_exiterror,meta_1(),meta_2(), waitfor(); extern char saveline[]; //E*O*F main.cdif// echo x - meta.cdif cat > "meta.cdif" << '//E*O*F meta.cdif//' *** meta.c Thu Aug 24 11:30:41 1989 --- ../New/meta.c Thu Aug 24 11:26:45 1989 *************** *** 549,554 **** --- 549,557 ---- } break; case ' ': + #ifdef DEBUG + fprintf(stderr,"inword %d insym %d\n",inword,insym); + #endif if (inword || insym) { l=0; *************** *** 561,568 **** fprintf(stderr,"copying to next \"\n"); #endif inword=1; ! word[i++]=line[(*pos)++]; ! while(line[*pos]!=EOS && line[*pos]!='"') word[i++]=line[(*pos)++]; break; case '\'': #ifdef DEBUG --- 564,579 ---- fprintf(stderr,"copying to next \"\n"); #endif inword=1; ! while(line[*pos]!=EOS) ! { ! word[i++]=line[*pos]; ! if (line[*pos]=='"') ! { ! (*pos)++; ! break; ! } ! (*pos)++; ! } break; case '\'': #ifdef DEBUG *************** *** 569,576 **** fprintf(stderr,"copying to next '\n"); #endif inword=1; ! word[i++]=line[(*pos)++]; ! while(line[*pos]!=EOS && line[*pos]!='\'') word[i++]=line[(*pos)++]; break; case '\\': inword=1; --- 580,595 ---- fprintf(stderr,"copying to next '\n"); #endif inword=1; ! while(line[*pos]!=EOS) ! { ! word[i++]=line[*pos]; ! if (line[*pos]=='\'') ! { ! (*pos)++; ! break; ! } ! (*pos)++; ! } break; case '\\': inword=1; *************** *** 607,612 **** --- 626,634 ---- *pattern=FALSE; if (loadword(line,pos,word,1)==FALSE) return(EOLN); /* end of line encountered */ + #ifdef DEBUG + fprintf(stderr,"word from loadword is %s<\n",word); + #endif /* this loop will detect if there's any * ? [] to match */ while(c=word[i++]) switch(quote) *************** *** 847,852 **** --- 869,876 ---- #endif /* if an absolute path name is given, then chop it off the front of word and put it in dir. Now word contains the patterned stuff onwards. */ + + dir[0] = EOS; /* finddir seems to assume this */ finddir(word,dir); /* Ok, here goes with the first call to the recursive functions. The parameters *************** *** 857,863 **** 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 "var.cdif" << '//E*O*F var.cdif//' *** var.c Thu Aug 24 11:30:45 1989 --- ../New/var.c Thu Aug 24 11:26:58 1989 *************** *** 52,59 **** { extern bool getword(); int i,pos; ! char word[MAXWL],*vval; pos=0; vval=vget(vname); for (i=0;i<=wnum;i++) --- 52,64 ---- { extern bool getword(); int i,pos; ! char *word,*vval; + if((word = (char *)malloc((unsigned)MAXWL)) == (char *)NULL) + { + perror("vwget: malloc"); + return(NULL); + } pos=0; vval=vget(vname); for (i=0;i<=wnum;i++) *************** *** 60,66 **** if (getword(vval,&pos,word,TRUE)==TRUE) continue; else break; ! return(word); } bool export(vname,opt) --- 65,72 ---- if (getword(vval,&pos,word,TRUE)==TRUE) continue; else break; ! return(word); /* caller frees mem alloc'ed for word */ ! /* found only one instance in meta.c */ } bool export(vname,opt) *************** *** 120,130 **** --- 126,146 ---- if (!strncmp(environ[i],"PATH=",5)) { environ[i]=(char *) realloc (environ[i],(unsigned)(strlen(env)+1)); + if (environ[i]==NULL) + { + perror("realloc"); + exit(1); + } break; } if (!environ[i]) /* if we didn't find an existing one */ { environ[i]=(char *) malloc ((unsigned)(strlen(env)+1)); + if (environ[i]==NULL) + { + perror("malloc1"); + exit(1); + } environ[i+1]=0; } strcpy(environ[i],env); *************** *** 168,173 **** --- 184,195 ---- if (!environ[i]) /* if we didn't find an existing one */ { environ[i]=(char *) malloc ((unsigned)(strlen(env)+1)); + if (environ[i]==NULL) + { + perror("malloc2"); + environ[i]="NULL"; + return; + } environ[i+1]=0; } strcpy(environ[i],env); *************** *** 232,242 **** --- 254,279 ---- if (i) /* normal insertion between old and ptr */ { new=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist))); + if (new==NULL) + { + perror("vset: malloc1"); + return; + } old->next=new; new->next=ptr; new->var=(char *) malloc ((unsigned)(strlen(vname)+1)); + if (new->var==NULL) + { + perror("vset: malloc2"); + return; + } strcpy(new->var,vname); new->val=(char *) malloc ((unsigned)(strlen(vval)+1)); + if (new->val==NULL) + { + perror("vset: malloc3"); + return; + } strcpy(new->val,vval); new->exported=FALSE; } *************** *** 243,252 **** --- 280,304 ---- else /* insertion before top, old=ptr=top still. */ { old=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist))); + if (old==NULL) + { + perror("vset: malloc4"); + return; + } old->next=top; old->var=(char *) malloc ((unsigned)(strlen(vname)+1)); + if (old->var==NULL) + { + perror("vset: malloc5"); + return; + } strcpy(old->var,vname); old->val=(char *) malloc ((unsigned)(strlen(vval)+1)); + if (old->val==NULL) + { + perror("vset: malloc6"); + return; + } strcpy(old->val,vval); old->exported=FALSE; top=old; /* and finally assign new top */ *************** *** 258,273 **** --- 310,345 ---- fprintf(stderr,"old val %s new val %s.\n",ptr->val,vval); #endif ptr->val=(char *) realloc (ptr->val,(unsigned)(strlen(vval)+1)); + if (ptr->val==NULL) + { + perror("vset: malloc7"); + return; + } strcpy(ptr->val,vval); } else /* value doesn't exist, make new variable and append */ { new=(struct vlist *) malloc ((unsigned)(sizeof(struct vlist))); + if (new==NULL) + { + perror("vset: malloc8"); + return; + } new->next=0; old->next=new; new->var=(char *) malloc ((unsigned)(strlen(vname)+1)); + if (new->var==NULL) + { + perror("vset: malloc9"); + return; + } strcpy(new->var,vname); new->val=(char *) malloc ((unsigned)(strlen(vval)+1)); + if (new->val==NULL) + { + perror("vset: malloc10"); + return; + } strcpy(new->val,vval); } *************** *** 358,363 **** --- 430,440 ---- { l=strlen(vget(vname)); newval=(char *) malloc ((unsigned)(l+strlen(vval)+1)); + if (newval==NULL) + { + perror("vadd: malloc"); + return; + } sprintf(newval,"%s%s",vget(vname),vval); vset(vname,newval); free(newval); *************** *** 445,450 **** --- 522,532 ---- for (i=0;envp[i];i++) { newenv[i]=(char *) malloc ((unsigned)(strlen(envp[i])+1)); + if (newenv[i]==NULL) + { + perror("copyenv: malloc"); + return; + } (void) strcpy(newenv[i],envp[i]); } newenv[i]=0; //E*O*F var.cdif// exit 0