home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1167 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  2.5 KB

  1. From: wht@n4hgf.uucp (Warren Tucker)
  2. Newsgroups: alt.sources
  3. Subject: shar311/patch02
  4. Message-ID: <659@n4hgf.uucp>
  5. Date: 11 Apr 90 02:27:12 GMT
  6.  
  7. Submitted-by: wht%n4hgf@gatech.edu
  8. Archive-name: shar311/patch02
  9.  
  10. A problem pointed out by pat@rwing is that unshar failed
  11. when reading from stdin.  The problem is that it was trying
  12. to seek on a pipe, which of course, fails.
  13.  
  14. *** orig/unshar.c    Tue Apr  3 21:09:00 1990
  15. --- unshar.c    Tue Apr 10 22:18:19 1990
  16. ***************
  17. *** 19,24
  18.    * 29-Jan-85  Michael Mauldin (mlm) at Carnegie-Mellon University
  19.    *    Created.
  20.    ****************************************************************/
  21.   
  22.   #include <stdio.h>
  23.   #define EOL '\n'
  24.  
  25. --- 19,26 -----
  26.    * 29-Jan-85  Michael Mauldin (mlm) at Carnegie-Mellon University
  27.    *    Created.
  28.    ****************************************************************/
  29. + /*+:EDITS:*/
  30. + /*:04-10-1990-22:02-wht@n4hgf-stdin failed sometimes-can not seek on pipe */
  31.   
  32.   #include <stdio.h>
  33.   #define EOL '\n'
  34. ***************
  35. *** 39,44
  36.   { 
  37.       int i,ch;
  38.       FILE *in;
  39.   
  40.       setbuf(stdout,NULL);
  41.       setbuf(stderr,NULL);
  42.  
  43. --- 41,47 -----
  44.   { 
  45.       int i,ch;
  46.       FILE *in;
  47. +     char s1024[1024];
  48.   
  49.       setbuf(stdout,NULL);
  50.       setbuf(stderr,NULL);
  51. ***************
  52. *** 75,81
  53.           }
  54.       }
  55.       else
  56. !         process("standard input",stdin);
  57.   
  58.       exit(0);
  59.   }
  60.  
  61. --- 78,98 -----
  62.           }
  63.       }
  64.       else
  65. !     {
  66. !         sprintf(s1024,"/tmp/unsh.%05d",getpid());
  67. !         unlink(s1024);
  68. !         if(!(in = fopen(s1024,"w+")))
  69. !         {
  70. !             fprintf(stderr,"cannot open temp file '%s'\n",s1024);
  71. !             exit(1);
  72. !         }
  73. !         unlink(s1024);    /* don't try this with MSDOS, sports fans */
  74. !         while(i = fread(s1024,1,sizeof(s1024),stdin))
  75. !             fwrite(s1024,i,1,in);
  76. !         rewind(in);
  77. !         process("standard input",in);
  78. !         fclose(in);
  79. !     }
  80.   
  81.       exit(0);
  82.   }
  83. ***************
  84. *** 147,153
  85.           /* Does this line start with a shell command or comment */
  86.           if(stlmatch(buf,"#")    || stlmatch(buf,":") ||
  87.               stlmatch(buf,"echo ")    || stlmatch(buf,"sed ") ||
  88. !             stlmatch(buf,"cat "))
  89.           { 
  90.               fseek(fil,pos,0); 
  91.               return(1); 
  92.  
  93. --- 164,170 -----
  94.           /* Does this line start with a shell command or comment */
  95.           if(stlmatch(buf,"#")    || stlmatch(buf,":") ||
  96.               stlmatch(buf,"echo ")    || stlmatch(buf,"sed ") ||
  97. !             stlmatch(buf,"cat ") || stlmatch(buf,"touch "))
  98.           { 
  99.               fseek(fil,pos,0); 
  100.               return(1); 
  101.  
  102. -------------------------------------------------------------------
  103. Warren Tucker, TuckerWare  gatech!n4hgf!wht or wht%n4hgf@gatech.edu
  104. Sforzando (It., sfohr-tsahn'-doh).  A direction to perform the tone
  105. or chord with special stress, or marked and sudden emphasis.
  106.