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 (5 of 5) Message-ID: <615@gara.une.oz> Date: 27 Mar 89 04:29:36 GMT Organization: University of New England, Armidale, Australia Lines: 467 # 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 "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 installed (distributed with gcc V1.34) if is not included ( 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