Re: Fix portability issues in dwmainc.c
"Igor V. Melichev" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
What compilers did you test it with ? Igor. ----- Original Message ----- From: "Alex Cherepanov" <[email protected]> To: "gs-code-review" <[email protected]>; "Igor V. Melichev" <[email protected]> Sent: Wednesday, August 13, 2003 3:54 AM Subject: Fix portability issues in dwmainc.c > Use our portability layer instead of calling MS functions directly. > > ---------------------------------------------------------------------------- ---- > Index: gs/src/dwmainc.c > =================================================================== > RCS file: /cvs/ghostscript/gs/src/dwmainc.c,v > retrieving revision 1.14 > diff -b -u -r1.14 dwmainc.c > --- gs/src/dwmainc.c 22 Aug 2002 10:00:48 -0000 1.14 > +++ gs/src/dwmainc.c 12 Aug 2003 23:34:14 -0000 > @@ -19,9 +19,8 @@ > > #include <windows.h> > #include <stdio.h> > -#include <stdlib.h> > -#include <io.h> > -#include <fcntl.h> > +#include "fcntl_.h" > +#include "unistd_.h" > #include "errors.h" > #include "iapi.h" > #include "vdtrace.h" > @@ -30,14 +29,6 @@ > #include "dwimg.h" > #include "dwtrace.h" > > -/* Patch by Rod Webster (rodw) */ > -/* Added conditional below to allow Borland Compilation (Tested on 5.5) */ > -/* It would be better to place this code in an include file but no dwmainc.h exists */ > -#ifdef __BORLANDC__ > -#define _isatty isatty > -#define _setmode setmode > -#endif > - > GSDLL gsdll; > struct gs_main_instance_s *instance; > BOOL quitnow = FALSE; > @@ -54,7 +45,7 @@ > static int GSDLLCALL > gsdll_stdin(void *instance, char *buf, int len) > { > - return _read(fileno(stdin), buf, len); > + return read(fileno(stdin), buf, len); > } > > static int GSDLLCALL > @@ -313,10 +304,10 @@ > char buf[256]; > char dformat[64]; > > - if (!_isatty(fileno(stdin))) > - _setmode(fileno(stdin), _O_BINARY); > - _setmode(fileno(stdout), _O_BINARY); > - _setmode(fileno(stderr), _O_BINARY); > + if (!isatty(fileno(stdin))) > + setmode(fileno(stdin), O_BINARY); > + setmode(fileno(stdout), O_BINARY); > + setmode(fileno(stderr), O_BINARY); > > hwndforeground = GetForegroundWindow(); /* assume this is ours */ > memset(buf, 0, sizeof(buf)); > Index: gs/src/unistd_.h > =================================================================== > RCS file: /cvs/ghostscript/gs/src/unistd_.h,v > retrieving revision 1.8 > diff -b -u -r1.8 unistd_.h > --- gs/src/unistd_.h 10 Apr 2003 18:45:12 -0000 1.8 > +++ gs/src/unistd_.h 12 Aug 2003 23:34:14 -0000 > @@ -40,6 +40,8 @@ > # define fsync(handle) _commit(handle) > # define read(fd, buf, len) _read(fd, buf, len) > # define fstat(fd, buf) _fstat(fd, buf) > +# define isatty(fd) _isatty(fd) > +# define setmode(fd, mode) _setmode(fd, mode) > #else > # include <unistd.h> > #endif > Index: gs/src/winint.mak > =================================================================== > RCS file: /cvs/ghostscript/gs/src/winint.mak,v > retrieving revision 1.18 > diff -b -u -r1.18 winint.mak > --- gs/src/winint.mak 12 Apr 2003 13:28:31 -0000 1.18 > +++ gs/src/winint.mak 12 Aug 2003 23:34:14 -0000 > @@ -139,7 +139,7 @@ > > OBJCNO=$(PSOBJ)dwmainc.obj $(PSOBJ)dwnodllc.obj $(GLOBJ)dwimg.obj $(DWTRACE) $(GLOBJ)dwreg.obj > > -$(PSOBJ)dwmainc.obj: $(PSSRC)dwmainc.c $(AK) \ > +$(PSOBJ)dwmainc.obj: $(PSSRC)dwmainc.c $(AK) $(fcntl__h) $(unistd__h) \ > $(iapi_h) $(vdtrace_h) $(gdevdsp_h) $(dwdll_h) $(dwimg_h) $(dwtrace_h) > $(PSCCWIN) $(COMPILE_FOR_CONSOLE_EXE) $(PSO_)dwmainc.obj $(C_) $(PSSRC)dwmainc.c > >