From: Tim W. <tw...@re...> - 2002-01-22 12:13:51
|
I have been trying to compile Omni using the GCC 3.1 RPM packages from Red Hat Rawhide, and have made a patch that makes it go. I have tried to keep the changes minimal. They are largely to do with explicitly declaring that we want to use the 'std' namespace by default, although there are some other issues as well: o cerr can't be the LHS of an assignment o filebuf(int&) constructor no longer exists o some missing includes o unsigned char* vs char* Is this list the right place to send a patch to? Tim. */ |
From: Tim W. <tw...@re...> - 2002-01-22 15:37:18
|
..and here is the patch. BinaryData.hpp | 2 ++ DeviceConnection.hpp | 2 ++ DeviceGamma.hpp | 2 ++ Foomatic/omni2foo.cpp | 2 +- Foomatic/omni2foo.hpp | 2 ++ GhostscriptInterface.cpp | 39 ++++++++++++++++++++------------------- Makefile | 9 +++++---- OmniProxy.cpp | 1 + PrintDevice.cpp | 25 +++++++++++++++++++++++-- PrintDevice.hpp | 1 + PrinterCommand.cpp | 3 +++ XMLParser/DeviceInfo.hpp | 2 ++ hppcl3/CMYKbitmap.cpp | 2 ++ hppcl3/bitmap.cpp | 5 ++++- 14 files changed, 70 insertions(+), 27 deletions(-) The two larger changes are: - GhostscriptInterface.cpp: Due to the ISO resolution of defect report 50, you can no longer do things like 'cerr = fcerr;'. This work-around is probably a bit of a sledge-hammer and there is sure to be an easier way around it. - PrintDevice.cpp: a) there is no filebuf(int fd) constructor any more, but you can now construct a filebuf from a FILE* and ios modes (this is still non-standard). So, do that. NOTE: unfortunately, this won't work on older versions of libstdc++. Long-term fix would be not to start from a file descriptor.. b) char* vs unsigned char*: I just put a cast in for now. Still unresolved: Lots of the DeviceTester files have similar sorts of problems as GhostscriptInterface.cpp did: assignments to cerr and the like. --- Omni/XMLParser/DeviceInfo.hpp.gcc31 Fri Nov 16 21:23:46 2001 +++ Omni/XMLParser/DeviceInfo.hpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,8 @@ #include <map> #include <list> +using namespace std; + typedef list <string> OrientationList; typedef list <string> ResolutionList; typedef list <string> PrintModeList; --- Omni/hppcl3/bitmap.cpp.gcc31 Thu Mar 1 22:55:00 2001 +++ Omni/hppcl3/bitmap.cpp Tue Jan 22 14:16:30 2002 @@ -22,6 +22,9 @@ #include <unistd.h> #include <memory.h> #include <iostream.h> +#include <algorithm> + +using std::min; const static bool fDebugOutput = false; @@ -395,7 +398,7 @@ while (iPos < iSize) { - rc = write (fileno, abData, min ((iSize - iPos), (int)sizeof (abData))); + rc = write (fileno, abData, min ((iSize - iPos), (long int)sizeof (abData))); if (-1 == rc) return rc; --- Omni/hppcl3/CMYKbitmap.cpp.gcc31 Thu Mar 1 22:55:00 2001 +++ Omni/hppcl3/CMYKbitmap.cpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,8 @@ #include <memory.h> #include <iostream.h> +using std::dec; + const static bool fDebugOutput = false; extern int chsize (int fileno, long int iSize); --- Omni/Foomatic/omni2foo.hpp.gcc31 Thu Sep 20 18:53:36 2001 +++ Omni/Foomatic/omni2foo.hpp Tue Jan 22 14:16:30 2002 @@ -41,6 +41,8 @@ #include <algorithm> // used for the to lower transform #include <cctype> +using namespace std; + typedef map<string,string> printerMap; class omni2foo { --- Omni/Foomatic/omni2foo.cpp.gcc31 Fri Nov 16 21:23:40 2001 +++ Omni/Foomatic/omni2foo.cpp Tue Jan 22 14:16:30 2002 @@ -66,7 +66,7 @@ // lowercase all characters transform (printerName.begin(), printerName.end(), // source printerName.begin(), // destination - tolower); // operation + ::tolower); // operation return _mPrinterMap[printerName]; } --- Omni/BinaryData.hpp.gcc31 Thu Mar 1 22:54:45 2001 +++ Omni/BinaryData.hpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,8 @@ #include "defines.hpp" +using namespace std; + class BinaryData { public: --- Omni/DeviceConnection.hpp.gcc31 Thu Mar 1 22:54:45 2001 +++ Omni/DeviceConnection.hpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,8 @@ #include <strstream> #include <string> +using namespace std; + class DeviceConnection { public: --- Omni/DeviceGamma.hpp.gcc31 Thu Mar 1 22:54:45 2001 +++ Omni/DeviceGamma.hpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,8 @@ #include <strstream> #include <string> +using namespace std; + class DeviceGamma { public: DeviceGamma (int iCGamma, --- Omni/OmniProxy.cpp.gcc31 Fri Nov 16 21:23:44 2001 +++ Omni/OmniProxy.cpp Tue Jan 22 14:16:30 2002 @@ -23,6 +23,7 @@ #include <unistd.h> #include <sys/mman.h> #include <errno.h> +#include <stdarg.h> #include "hppcl3/bitmap.hpp" --- Omni/PrinterCommand.cpp.gcc31 Thu Sep 20 19:08:58 2001 +++ Omni/PrinterCommand.cpp Tue Jan 22 14:16:30 2002 @@ -20,10 +20,13 @@ #include <string.h> #include <fstream.h> #include <unistd.h> +#include <iostream.h> #include "PrinterCommand.hpp" #include "DebugOutput.hpp" +using namespace std; + PrinterCommand:: PrinterCommand (char *pszProgram) { --- Omni/PrintDevice.cpp.gcc31 Fri Nov 16 21:23:43 2001 +++ Omni/PrintDevice.cpp Tue Jan 22 14:16:30 2002 @@ -21,6 +21,8 @@ #include <stdarg.h> #include <string.h> #include <stdio.h> +#include <unistd.h> +#include <fstream> #include "hppcl3/bitmap.hpp" @@ -59,6 +61,7 @@ outputStream_d = &cout; fShouldDeleteOutputStream_d = false; outputStreamBuf_d = 0; + outputStreamFILE_d = 0; pszDriverName_d = pszDriverName; pszDeviceName_d = pszDeviceName; pszShortName_d = pszShortName; @@ -121,6 +124,12 @@ delete outputStreamBuf_d; } + if (outputStreamFILE_d) + { + fclose (outputStreamFILE_d); + outputStreamFILE_d = 0; + } + if (pszLoadedLibrary_d) { free (pszLoadedLibrary_d); @@ -1073,13 +1082,25 @@ setOutputStream (ostream *osNew) { outputStream_d = osNew; + if (outputStreamFILE_d) + { + fclose (outputStreamFILE_d); + outputStreamFILE_d = NULL; + } } void PrintDevice:: setOutputStream (int iFileNo) { - streambuf *sb = new filebuf (iFileNo); + int fd = ::dup (iFileNo); + FILE *f = fdopen (fd, "w"); + streambuf *sb = new filebuf (f, ios::out); outputStream_d = new ostream (sb); + if (outputStreamFILE_d) + { + fclose (outputStreamFILE_d); + } + outputStreamFILE_d = f; fShouldDeleteOutputStream_d = true; } @@ -1133,7 +1154,7 @@ } else { - outputStream_d->write (pbData, iLength); + outputStream_d->write ((const char*) pbData, iLength); outputStream_d->flush (); } --- Omni/GhostscriptInterface.cpp.gcc31 Fri Nov 16 21:23:45 2001 +++ Omni/GhostscriptInterface.cpp Tue Jan 22 14:47:02 2002 @@ -306,12 +306,13 @@ bIJSDevice = false; // Added for debugging convienence + ostream *pcerr = &cerr; if ( pszCerr && pszCerr[0] ) { ofstream *fcerr = new ofstream (pszCerr); - cerr = *fcerr; + pcerr = fcerr; pOutputObject = (void *)fcerr; } @@ -322,7 +323,7 @@ #ifndef RETAIL if (DebugOutput::shouldOutputOmniInterface ()) - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": Trying to load " << cDeviceName << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": Trying to load " << cDeviceName << endl; #endif static char *apszLibraryPaths[] = { @@ -357,27 +358,27 @@ if (!*pvhDevice) { - cerr << endl << "<<<<<<<<<<<<<<<<<<<<<< ERROR >>>>>>>>>>>>>>>>>>>>>>>" << endl; - cerr << endl << endl; - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << g_module_error () << endl; - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": cDeviceName = " << cDeviceName << endl; - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": pszDeviceName = " << pszDeviceName << endl; - cerr << endl; - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": LD_LIBRARY_PATH = " << getenv ("LD_LIBRARY_PATH") << endl; - cerr << endl; - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": Omni device library not found in the following paths:" << endl; + (*pcerr) << endl << "<<<<<<<<<<<<<<<<<<<<<< ERROR >>>>>>>>>>>>>>>>>>>>>>>" << endl; + (*pcerr) << endl << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << g_module_error () << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": cDeviceName = " << cDeviceName << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": pszDeviceName = " << pszDeviceName << endl; + (*pcerr) << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": LD_LIBRARY_PATH = " << getenv ("LD_LIBRARY_PATH") << endl; + (*pcerr) << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": Omni device library not found in the following paths:" << endl; for (int i = 0; i < (int)dimof (apszLibraryPaths) - 1 && !*pvhDevice; i++) { - cerr << "\t" << apszLibraryPaths[i] << "." << endl; + (*pcerr) << "\t" << apszLibraryPaths[i] << "." << endl; } - cerr << "\t$LD_LIBRARY_PATH" << endl; + (*pcerr) << "\t$LD_LIBRARY_PATH" << endl; return 0; } #ifndef RETAIL if (DebugOutput::shouldOutputOmniInterface ()) - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": *pvhDevice = " << hex << *pvhDevice << dec << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": *pvhDevice = " << hex << *pvhDevice << dec << endl; #endif // nm libHP_Deskjet_1120Cxi.so @@ -388,12 +389,12 @@ #ifndef RETAIL if (DebugOutput::shouldOutputOmniInterface ()) - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": pfnNewDevice = 0x" << hex << (int)pfnNewDevice << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": pfnNewDevice = 0x" << hex << (int)pfnNewDevice << endl; #endif if (!pfnNewDevice) { - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << dec << g_module_error () << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << dec << g_module_error () << endl; return 0; } @@ -404,12 +405,12 @@ #ifndef RETAIL if (DebugOutput::shouldOutputOmniInterface ()) - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": pfnNewDeviceWArgs = 0x" << hex << (int)pfnNewDeviceWArgs << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": pfnNewDeviceWArgs = 0x" << hex << (int)pfnNewDeviceWArgs << endl; #endif if (!pfnNewDeviceWArgs) { - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << dec << g_module_error () << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": g_module_error returns " << dec << g_module_error () << endl; return 0; } @@ -421,7 +422,7 @@ #ifndef RETAIL if (DebugOutput::shouldOutputOmniInterface ()) - cerr << "GhostscriptInterface::" << __FUNCTION__ << ": pDevice = " << *pDevice_d << endl; + (*pcerr) << "GhostscriptInterface::" << __FUNCTION__ << ": pDevice = " << *pDevice_d << endl; #endif return pDevice_d; --- Omni/PrintDevice.hpp.gcc31 Fri Nov 16 21:23:43 2001 +++ Omni/PrintDevice.hpp Tue Jan 22 14:16:30 2002 @@ -140,6 +140,7 @@ ostream *outputStream_d; streambuf *outputStreamBuf_d; + FILE *outputStreamFILE_d; int fShouldDeleteOutputStream_d; char *pszDriverName_d; char *pszDeviceName_d; |