wht@n4hgf.uucp (Warren Tucker) (04/11/90)
Submitted-by: wht%n4hgf@gatech.edu Archive-name: shar311/patch02 A problem pointed out by pat@rwing is that unshar failed when reading from stdin. The problem is that it was trying to seek on a pipe, which of course, fails. *** orig/unshar.c Tue Apr 3 21:09:00 1990 --- unshar.c Tue Apr 10 22:18:19 1990 *************** *** 19,24 * 29-Jan-85 Michael Mauldin (mlm) at Carnegie-Mellon University * Created. ****************************************************************/ #include <stdio.h> #define EOL '\n' --- 19,26 ----- * 29-Jan-85 Michael Mauldin (mlm) at Carnegie-Mellon University * Created. ****************************************************************/ + /*+:EDITS:*/ + /*:04-10-1990-22:02-wht@n4hgf-stdin failed sometimes-can not seek on pipe */ #include <stdio.h> #define EOL '\n' *************** *** 39,44 { int i,ch; FILE *in; setbuf(stdout,NULL); setbuf(stderr,NULL); --- 41,47 ----- { int i,ch; FILE *in; + char s1024[1024]; setbuf(stdout,NULL); setbuf(stderr,NULL); *************** *** 75,81 } } else ! process("standard input",stdin); exit(0); } --- 78,98 ----- } } else ! { ! sprintf(s1024,"/tmp/unsh.%05d",getpid()); ! unlink(s1024); ! if(!(in = fopen(s1024,"w+"))) ! { ! fprintf(stderr,"cannot open temp file '%s'\n",s1024); ! exit(1); ! } ! unlink(s1024); /* don't try this with MSDOS, sports fans */ ! while(i = fread(s1024,1,sizeof(s1024),stdin)) ! fwrite(s1024,i,1,in); ! rewind(in); ! process("standard input",in); ! fclose(in); ! } exit(0); } *************** *** 147,153 /* Does this line start with a shell command or comment */ if(stlmatch(buf,"#") || stlmatch(buf,":") || stlmatch(buf,"echo ") || stlmatch(buf,"sed ") || ! stlmatch(buf,"cat ")) { fseek(fil,pos,0); return(1); --- 164,170 ----- /* Does this line start with a shell command or comment */ if(stlmatch(buf,"#") || stlmatch(buf,":") || stlmatch(buf,"echo ") || stlmatch(buf,"sed ") || ! stlmatch(buf,"cat ") || stlmatch(buf,"touch ")) { fseek(fil,pos,0); return(1); ------------------------------------------------------------------- Warren Tucker, TuckerWare gatech!n4hgf!wht or wht%n4hgf@gatech.edu Sforzando (It., sfohr-tsahn'-doh). A direction to perform the tone or chord with special stress, or marked and sudden emphasis.