1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
--- classes/fpbase.cc Tue Oct 9 19:05:52 2001
+++ tvision/classes/fpbase.cc Thu Jun 6 21:30:20 2002
@@ -22,7 +22,7 @@
fpbase::fpbase()
{
- buf=new filebuf();
+ buf=new CLY_filebuf();
pstream::init(buf);
}
@@ -34,7 +34,7 @@
fpbase::fpbase( const char *name, CLY_OpenModeT omode, int prot )
{
- buf=new filebuf();
+ buf=new CLY_filebuf();
open(name,omode,prot);
pstream::init(buf);
}
@@ -94,3 +94,50 @@
return buf;
}
+#ifdef CLY_DefineSpecialFileBuf
+// gcc 3.1 specific
+CLY_filebuf *CLY_filebuf::open(FILE *f, ios_base::openmode mode)
+{
+ CLY_filebuf *ret=NULL;
+ if (!this->is_open())
+ {
+ _M_file.sys_open(f,mode);
+ if (this->is_open())
+ {
+ _M_allocate_internal_buffer();
+ _M_mode=mode;
+
+ // For time being, set both (in/out) sets of pointers.
+ _M_set_indeterminate();
+ if ((mode & ios_base::ate) &&
+ this->seekoff(0,ios_base::end,mode)<0)
+ this->close();
+ ret=this;
+ }
+ }
+ return ret;
+}
+
+CLY_filebuf *CLY_filebuf::open(int h, ios_base::openmode mode)
+{
+ CLY_filebuf *ret=NULL;
+ if (!this->is_open())
+ {
+ _M_file.sys_open(h,mode,false);
+ if (this->is_open())
+ {
+ _M_allocate_internal_buffer();
+ _M_mode=mode;
+
+ // For time being, set both (in/out) sets of pointers.
+ _M_set_indeterminate();
+ if ((mode & ios_base::ate) &&
+ this->seekoff(0,ios_base::end,mode)<0)
+ this->close();
+ ret=this;
+ }
+ }
+ return ret;
+}
+#endif // CLY_DefineSpecialFileBuf
+
--- include/tv/fpbase.h Tue Oct 9 19:06:00 2001
+++ tvision/include/tv/fpbase.h Thu Jun 6 21:30:20 2002
@@ -13,6 +13,11 @@
and not a filebuf. This is much more convenient to make the code
compilable with gcc 3.x without breaking compatibility.
+SET: Added a filebuf wrapper to get access to protected members needed
+to open associate a filebuf with a C stream/file handle. Andris proposed
+this idea. This is needed for gcc 3.1 and we don't know how long this
+trick will be used.
+
*
*
*/
@@ -28,6 +33,23 @@
#if defined( Uses_fpbase ) && !defined( __fpbase )
#define __fpbase
+#ifdef CLY_DefineSpecialFileBuf
+class CLY_filebuf: public std::filebuf
+{
+public:
+ CLY_filebuf() : std::filebuf() {};
+ CLY_filebuf(FILE *f, std::ios_base::openmode mode)
+ { open(f,mode); };
+ CLY_filebuf(int h, std::ios_base::openmode mode)
+ { open(h,mode); };
+
+ CLY_filebuf *open(FILE *f, std::ios_base::openmode);
+ CLY_filebuf *open(int h, std::ios_base::openmode);
+ std::filebuf *open(const char *file, std::ios_base::openmode mode)
+ { return std::filebuf::open(file,mode); };
+};
+#endif
+
class fpbase : virtual public pstream
{
@@ -49,7 +71,7 @@
private:
- CLY_std(filebuf) *buf;
+ CLY_filebuf *buf;
};
--- include/compatlayer.h Wed Feb 6 15:35:38 2002
+++ tvision/include/compatlayer.h Mon Jun 24 16:54:15 2002
@@ -117,6 +117,7 @@
#undef DIRSEPARATOR
#undef DIRSEPARATOR_
#undef CLY_ISOCpp98
+#undef CLY_filebuf
#undef CLY_OpenModeT
#undef CLY_StreamPosT
#undef CLY_StreamOffT
@@ -133,6 +134,7 @@
#undef CreateStrStream
#undef GetStrStream
#undef UsingNamespaceStd
+#undef CLY_HiddenDifferent
#ifdef TVComp_GCC
/* GNU C is supported for various OSs: */
@@ -225,6 +231,15 @@
library. GCC implemented it in version 3.0. BC++ implemented some
stuff in versions like BC++ 5.5. So that's a real mess. */
#if __GNUC__>=3
+ // gcc 3.1 needs a special filebuf
+ #if __GNUC_MINOR__<1
+ #define CLY_filebuf std::filebuf
+ #define CLY_NewFBFromFD(f) new CLY_filebuf(fdopen(f,"rb+"),ios::in|ios::out|ios::binary)
+ #else
+ #undef CLY_DefineSpecialFileBuf
+ #define CLY_DefineSpecialFileBuf 1
+ #define CLY_NewFBFromFD(f) new CLY_filebuf(f,ios::in|ios::out|ios::binary)
+ #endif
#define CLY_ISOCpp98 1
#define CLY_OpenModeT std::ios::openmode
#define CLY_StreamPosT std::streampos
@@ -246,7 +242,9 @@
#define CLY_StreamOffT std::streamoff
#define CLY_IOSSeekDir std::ios::seekdir
#define CLY_FBOpenProtDef 0
- #define CLY_NewFBFromFD(f) new filebuf(fdopen(f,"rb+"),ios::in|ios::out|ios::binary)
+ #ifndef CLY_NewFBFromFD
+ #define CLY_NewFBFromFD(f) new filebuf(fdopen(f,"rb+"),ios::in|ios::out|ios::binary)
+ #endif
#define CLY_PubSetBuf(a,b) pubsetbuf(a,b)
#define CLY_FBOpen(a,b,c) open(a,b)
#define CLY_IOSBin std::ios::binary
@@ -252,6 +266,7 @@
#undef IOSTREAM_HEADER
#define IOSTREAM_HEADER <iostream>
#else
+ #define CLY_filebuf filebuf
#define CLY_OpenModeT int
#define CLY_StreamPosT streampos
#define CLY_StreamOffT streamoff
@@ -272,7 +271,9 @@
#define CLY_StreamOffT streamoff
#define CLY_IOSSeekDir ios::seek_dir
#define CLY_FBOpenProtDef filebuf::openprot
- #define CLY_NewFBFromFD(f) new filebuf(f)
+ #ifndef CLY_NewFBFromFD
+ #define CLY_NewFBFromFD(f) new filebuf(f)
+ #endif
#define CLY_PubSetBuf(a,b) setbuf(a,b)
#define CLY_HaveFBAttach 1
# CLY_FBOpen(a,b,c) open(a,b,c)
@@ -373,6 +388,7 @@
/* Win32/Cygwin -- OH! */
#ifdef TVCompf_Cygwin
+ #define CLY_HiddenDifferent 1
#define CLY_Have_UGID 1
#undef FA_ARCH
#undef FA_DIREC
@@ -525,6 +543,7 @@
/* Common to all UNIX systems */
#ifdef TVOS_UNIX
/* Filesystem */
+ #define CLY_HiddenDifferent 1
#define CLY_Have_UGID 1
#undef FA_ARCH
#undef FA_DIREC
@@ -830,6 +849,7 @@
#define Uses_CLY_IfStreamGetLine 1
#endif
+ #define CLY_filebuf filebuf
#define CLY_OpenModeT int
#define CLY_StreamPosT streampos
#define CLY_StreamOffT streamoff
@@ -1040,6 +1076,7 @@
#define IfStreamGetLine(istream,buffer,size) \
istream.getline(buffer,size)
+ #define CLY_filebuf filebuf
#define CLY_OpenModeT int
#define CLY_StreamPosT streampos
#define CLY_StreamOffT streamoff
|