[comp.sys.amiga] Matt Dillon's Shell and Aztec C II

walton@ametek.UUCP (Steve Walton) (11/29/86)

After consultation off the net with Matt Dillon, we have come
up with a revised set of changes which will allow Shell V2.01 to compile
easily under Aztec C using the latter's library only.  A reminder to
compile using the +L switch to cc and to link to c32.lib.  As for the
changes, add to the end of shell.h the following lines:

#ifdef MCH_AMIGA
#define check32()
#define xopen(a,b,c) fopen(a,b)
#define xgets(f,s,n) fgets(s,n,f)
#define xputs(f,s) fputs(s,f)    /* required for below change in do_cat */
#define xclose(a) fclose(a)
#define xseek(a,b,c) fseek(a,b,c-1)
#define bmov(a,b,c) movmem(a,b,c)
#endif

Also, the routine do_cat in comm.c has to be modified.  It contains a loop:

	while (xgets(f,s,n) != 0)
		puts(s);

The puts(s) should be changed to xputs(stdout, s), due to the fact that
puts(s) adds a newline to the end of s before output, which is fine with
xgets() since it strips the newline.  But fgets() leaves the newline in
place, giving double spacing.  This change plus the xputs() #define above
will allow the shell to still function with Matt's library and Lattice.
     Instead of the above change and xget/xputs definitions, Matt came
up with:

#define xgets(f,s,n) (fgets(s,n,f),(s[0]&&s[strlen(s)-1]='\0'),strlen(s)+1)

which is a little messy but works.
					Steve Walton

[Note to Info-Amiga: will this go to the USENET too?]

[Yes, things posted to info-amiga get sent out to Usenet as well.  The
 relationship between the two is somewhat messy in that we have two
 gateways (rutgers and ulowell), but we're working on that.  --Bob]