[net.sources] bug fix to cpmfloppy.c

wwb (04/30/83)

	I have submitted to net.sources the diff file for a
bug fix to cpmfloppy.c.  The bug causes the program to report
that a directory is badly formatted when the 0128 boundry on
the floppy is reached. Also included are certain changes to 
make it more portable.

			Bill Barker.
    			...decvax!genrad!wjh12!wwb




% diff cpmfloppy.c cpmfloppy.c.old


163c163
< 	      quit0(-1,"\n"); /* EOF error */
---
> 	      quit(-1,"\n",NULL); /* EOF error */
248c248
<         quit0(1,"\ncpmutl:user number out of range\n");
---
>         quit(1,"\ncpmutl:user number out of range\n",NULL);
265c265
<      quit_i(1,"\ncpmutl: bad option '%c'. use h for help\n", (int)*cp);
---
>       quit(1,"\ncpmutl: bad option '%c'. use h for help\n", *cp);
273c273
<     quit0(1,"\ncpmutl: mode t(ext) or b(inary) must be specified\n");
---
>     quit(1,"\ncpmutl: mode t(ext) or b(inary) must be specified\n",NULL);
314c314
< 	if(!argc) quit0(1,"no directory given?\n");
---
> 	if(!argc) quit(1,"no directory given?\n",NULL);
326c326
< 	char *getenv(),buff[100];
---
> 	char *getenv(),*shnm[4],buff[100];
328c328,332
< 	int iret;
---
> 	int i;
> 	shnm[0] = getenv("SHELL"); /* get favorite shell */
> 	shnm[1] = argc ? "-c" : "-i";
> 	shnm[2] = buff;
> 	shnm[3] = NULL;
335,336c339,342
< 	if(iret=system(argc ? buff : getenv("SHELL"))) 
< 	    quit_i(1,"Error exit status %d\n",iret);
---
> 	if((i = fork()) == 0) execv(shnm[0],shnm);
> 	else if(i == -1) quit(1,"Can't fork new process\n",NULL);
> 	wait(0);
> 	return;
426c432
<     quit0(1,"\ncpmutl:can't parse start.size address\n");
---
>     quit(1,"\ncpmutl:can't parse start.size address\n",NULL);
521,522c527,528
<       recsiz += (unsigned)cp_dir[curext].cp_rc;	/* this many records */
<       ksiz += (((unsigned)cp_dir[curext].cp_rc+CP_CLUSTER-1)/CP_CLUSTER); /* k size */
---
>       recsiz += cp_dir[curext].cp_rc;	/* this many records */
>       ksiz += ((cp_dir[curext].cp_rc+CP_CLUSTER-1)/CP_CLUSTER); /* k size */
552c558
<     for(cp = unix_prefix; cp[1]; cp++ );	/* find the end */
---
>     for(cp = unix_prefix; cp[1]; *cp++ );	/* find the end */
568c574
<     extsiz = (unsigned)cp_dir[index].cp_rc;	/* read all the records */
---
>     extsiz = cp_dir[index].cp_rc;	/* read all the records */
588c594
<     quit0(1,"\ncpmutl:can't parse start.size address\n");
---
>     quit(1,"\ncpmutl:can't parse start.size address\n",NULL);
625c631
<           quit0(1,"\ncpmutl:write error on unix file\n");
---
>           quit(1,"\ncpmutl:write error on unix file\n",NULL);
629c635
<     quit0(1,"\ncpmutl:write error on unix file\n");
---
>     quit(1,"\ncpmutl:write error on unix file\n",NULL);
693c699
<     quit0(1,"\ncpmutl:cpm file name to long\n");
---
>     quit(1,"\ncpmutl:cpm file name to long\n",NULL);
752c758
<   quit_i(1,"\ncpmutl:command aborted due to %d directory error(s)\n",dir_err);
---
>   quit(1,"\ncpmutl:command aborted due to %d directory error(s)\n",dir_err);
759c765
< { quit0(1,"\ncpmutl:too many arguments\n");
---
> { quit(1,"\ncpmutl:too many arguments\n",NULL);
764c770
< { quit0(1,"\ncpmutl:too few arguments");
---
> { quit(1,"\ncpmutl:too few arguments",NULL);
822c828
<   bit_aloc=((unsigned)cp_dir[index].cp_rc+CP_CLUSTER-1)/CP_CLUSTER;
---
>   bit_aloc=(cp_dir[index].cp_rc+CP_CLUSTER-1)/CP_CLUSTER;
855,857c861,862
< 	      /* wrong ext? */
<      if (((unsigned)cp_dir[j].cp_ex != (unsigned)cp_dir[index].cp_ex-1) 
< 	  || (cp_dir[j].cp_et != cp_dir[index].cp_et) || /* or wrong user */
---
>       if ((cp_dir[j].cp_ex != cp_dir[index].cp_ex-1) || /* wrong ext? */
> 	  (cp_dir[j].cp_et != cp_dir[index].cp_et) || /* or wrong user */
932,933c937
<         set_btb((int)cp_dir[index].cp_dm[j],index); 
< 					/* yes, owned by this extent */
---
>         set_btb((int)cp_dir[index].cp_dm[j],index); /* yes, owned by this extent */
1007c1011
<     cp_dir[new_ext].cp_ex = (unsigned)cp_dir[cur_ext].cp_ex + 1;
---
>     cp_dir[new_ext].cp_ex = cp_dir[cur_ext].cp_ex + 1;
1057c1061
<     quit0(1,"\ncpmutl:allocate extent failure, floppy directory full\n");
---
>     quit(1,"\ncpmutl:allocate extent failure, floppy directory full\n",NULL);
1074,1075c1078,1079
<   quit0(1,
<     "\ncpmutl:allocate disk cluster failure, floppy file system full\n");
---
>   quit(1,
>     "\ncpmutl:allocate disk cluster failure, floppy file system full\n", NULL);
1160,1173d1163
< quit0(status,fmt)
< int status;
< char *fmt;   {
< 		fprintf(stderr,fmt);
< 		quit_co(status);
< 		}
< 
< quit_i(status,fmt,iarg)
< int status,iarg;
< char *fmt;		{
< 		fprintf(stderr,fmt,iarg);
< 		quit_co(status);
< 		}
< 
1177,1182c1167
< {  fprintf(stderr,fmt,args);
<    quit_co(status);
<    }
< 
<    quit_co(status)
<    int status; {
---
> { _doprnt(fmt,&args,stderr);